rairo commited on
Commit
b0f1a60
·
verified ·
1 Parent(s): bfda5a8

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +51 -35
main.py CHANGED
@@ -434,13 +434,18 @@ def validate_odysseus_v6(t: dict) -> (bool, str):
434
  return True, "ok"
435
  except: return False, "Blueprint Error"
436
 
 
 
 
 
437
  @app.route('/api/trial/generate', methods=['POST'])
438
  def generate_trial():
439
  """
440
- Odysseus v6.1: The Layer-Specific Architect.
441
- Enforces unique gameplay for Genesis vs Core vs Edge vs Future.
 
442
  """
443
- logger.info(">>> ODYSSEUS V6.1: LAYER-SPECIFIC GENERATION")
444
  uid = verify_token(request.headers.get('Authorization'))
445
  if not uid: return jsonify({"error": "Unauthorized"}), 401
446
 
@@ -452,49 +457,53 @@ def generate_trial():
452
  if existing: return jsonify(existing), 200
453
 
454
  lock_ref = db_ref.child(f"epiphanies/{ep_id}/trialLocks/{layer_key}")
455
- if lock_ref.get(): return jsonify({"error": "Synthesizing Layer Logic..."}), 409
456
  lock_ref.set({"uid": uid, "at": datetime.utcnow().isoformat()})
457
 
458
  try:
459
  layer_data = db_ref.child(f"epiphanies/{ep_id}/layers/{layer_key}").get() or {}
460
  context = layer_data.get('text', '')
461
 
462
- # THE LAYER-PERSONALITY PROMPT
463
  trial_prompt = f"""
464
- Act as a Master Game Designer. Subject: {subject}. Layer: {layer_key}.
465
- Context: {context}.
466
-
467
- TASK: Invent a unique 2D physics experiment.
468
- CRITICAL: The gameplay MUST match the layer's personality:
469
- - If 'genesis': Focus on ASSEMBLY or ORIGIN.
470
- - If 'scientific_core': Focus on BASIC PHYSICS (Gravity/Friction/Heat).
471
- - If 'engineering_edge': Focus on STRESS, TOLERANCE, or SPEED.
472
- - If 'cross_pollination': Focus on HYBRIDIZATION or UNUSUAL FORCES.
473
-
474
- PHYSICS RULES:
475
- 1. The system must NOT win automatically.
476
- 2. Implement ENTROPY: If the user does nothing, the 'Stability' metric must decrease by 2% per second.
477
- 3. The user MUST use their 'Tool' (draggable or clicker) to counteract this decay.
478
 
479
  MANDATORY JSON SCHEMA:
480
  {{
481
- "engine": {{"name": "odysseus", "version": "v6.1"}},
482
- "scenario_name": "Unique Title",
483
- "mission_brief": "Active goal for the user.",
484
- "world_settings": {{ "gravity": [x, y], "entropy_decay": 0.02 }},
 
 
 
 
 
 
 
 
 
485
  "entities": [
486
  {{
487
- "id": "e1",
488
- "label": "Part Name",
489
- "physics": {{ "mass": float, "restitution": 0.7, "isDraggable": bool }},
490
- "visuals": {{ "color": "hex", "glow": bool }}
491
  }}
492
  ],
493
- "logic_rules": [
494
- {{ "trigger": "onHold | onCollision | onDrag", "action": "increase_stability | boost_score" }}
495
- ],
496
- "victory_logic": {{ "target_metric": "Stability", "threshold": 100, "hold_ms": 2000 }},
497
- "revelation": {{ "on_win": "Feynman Insight", "on_fail": "Socratic Hint" }}
 
 
 
 
498
  }}
499
  """
500
 
@@ -506,17 +515,24 @@ def generate_trial():
506
 
507
  trial_data = json.loads(_strip_json_fences(res.text))
508
 
509
- # Persistence & Deduction (4 Sparks)
510
  user_ref = db_ref.child(f'users/{uid}')
511
- user_ref.update({'credits': (user_ref.get().get('credits', 0) or 0) - 4})
 
 
 
512
 
513
  trial_data["createdAt"] = datetime.utcnow().isoformat()
514
  db_ref.child(trial_path).set(trial_data)
515
- lock_ref.delete()
516
 
 
 
517
  return jsonify(trial_data), 201
 
518
  except Exception as e:
519
  lock_ref.delete()
 
520
  return jsonify({"error": str(e)}), 500
521
 
522
  # -----------------------------------------------------------------------------
 
434
  return True, "ok"
435
  except: return False, "Blueprint Error"
436
 
437
+ # -----------------------------------------------------------------------------
438
+ # ODYSSEUS ENGINE V9: THE SOCRATIC SIMULATOR (ESSENTIAL VERB ENGINE)
439
+ # -----------------------------------------------------------------------------
440
+
441
  @app.route('/api/trial/generate', methods=['POST'])
442
  def generate_trial():
443
  """
444
+ Odysseus v9: The Socratic Simulator.
445
+ Synthesizes the physical laws and interaction verbs specific to the object.
446
+ Cost: 1 Spark.
447
  """
448
+ logger.info(">>> ODYSSEUS V9: GENERATING SOCRATIC SIMULATOR")
449
  uid = verify_token(request.headers.get('Authorization'))
450
  if not uid: return jsonify({"error": "Unauthorized"}), 401
451
 
 
457
  if existing: return jsonify(existing), 200
458
 
459
  lock_ref = db_ref.child(f"epiphanies/{ep_id}/trialLocks/{layer_key}")
460
+ if lock_ref.get(): return jsonify({"error": "Synthesizing First Principles..."}), 409
461
  lock_ref.set({"uid": uid, "at": datetime.utcnow().isoformat()})
462
 
463
  try:
464
  layer_data = db_ref.child(f"epiphanies/{ep_id}/layers/{layer_key}").get() or {}
465
  context = layer_data.get('text', '')
466
 
 
467
  trial_prompt = f"""
468
+ Act as Athena's Simulator Architect.
469
+ Subject: {subject}. Layer: {layer_key}. Context: {context}
470
+
471
+ TASK: Identify the "Essential Scientific Verb" for this object (e.g. Expand, Ionize, Dampen, Pivot).
472
+ Design a 30-second interaction where the user operates the system's core physics.
473
+ DO NOT use a puzzle/slider template. Invent the interaction logic from scratch.
 
 
 
 
 
 
 
 
474
 
475
  MANDATORY JSON SCHEMA:
476
  {{
477
+ "engine": {{"name": "odysseus", "version": "v9"}},
478
+ "verb": "The core scientific action (e.g. COMPRESS)",
479
+ "mission": "Feynman-style objective for the Seeker.",
480
+ "physics_world": {{
481
+ "gravity": [x, y],
482
+ "viscosity": float,
483
+ "entropy_decay_rate": float
484
+ }},
485
+ "user_tool": {{
486
+ "type": "emitter | attractor | manipulator",
487
+ "label": "Custom tool name",
488
+ "effect_on_system": "string"
489
+ }},
490
  "entities": [
491
  {{
492
+ "label": "string",
493
+ "role": "agent | target | hazard",
494
+ "physics": {{ "mass": float, "charge": float, "bounciness": float }},
495
+ "behavior": "How this entity reacts to the User Tool"
496
  }}
497
  ],
498
+ "win_state": {{
499
+ "metric": "string (e.g. 'Pressure_Stable')",
500
+ "target": 100,
501
+ "hold_seconds": 3
502
+ }},
503
+ "revelation": {{
504
+ "on_win": "Feynman truth about the verb.",
505
+ "on_fail": "Socratic hint about the physics."
506
+ }}
507
  }}
508
  """
509
 
 
515
 
516
  trial_data = json.loads(_strip_json_fences(res.text))
517
 
518
+ # 1-Spark Seeker Economy
519
  user_ref = db_ref.child(f'users/{uid}')
520
+ credits = (user_ref.get() or {}).get('credits', 0)
521
+ if credits < 1:
522
+ lock_ref.delete()
523
+ return jsonify({"error": "Insufficient Sparks"}), 402
524
 
525
  trial_data["createdAt"] = datetime.utcnow().isoformat()
526
  db_ref.child(trial_path).set(trial_data)
527
+ user_ref.update({'credits': credits - 1})
528
 
529
+ lock_ref.delete()
530
+ logger.info(f"Odysseus v9: Simulator manifested for {subject} with verb: {trial_data.get('verb')}")
531
  return jsonify(trial_data), 201
532
+
533
  except Exception as e:
534
  lock_ref.delete()
535
+ logger.error(f"v9 Architecture Failure: {e}")
536
  return jsonify({"error": str(e)}), 500
537
 
538
  # -----------------------------------------------------------------------------