Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
|
@@ -463,6 +463,7 @@ def deep_dive():
|
|
| 463 |
|
| 464 |
# -----------------------------------------------------------------------------
|
| 465 |
# ODYSSEUS ENGINE V10.1: HARDENED GAME CONSOLE (SYNTAX GUARD + VICTORY HOOKS)
|
|
|
|
| 466 |
# -----------------------------------------------------------------------------
|
| 467 |
|
| 468 |
# Enhanced Forbidden Patterns to prevent "Unexpected Token" errors in Babel
|
|
@@ -510,6 +511,8 @@ def generate_trial():
|
|
| 510 |
Odysseus v10.1: The Hardened Instrumentalist.
|
| 511 |
Architects bespoke, interactive React games with a 3-pass syntax repair loop.
|
| 512 |
Cost: 1 Spark.
|
|
|
|
|
|
|
| 513 |
"""
|
| 514 |
logger.info(">>> ODYSSEUS V10.1: FORGING HARDENED INSTRUMENT")
|
| 515 |
uid = verify_token(request.headers.get('Authorization'))
|
|
@@ -538,37 +541,59 @@ def generate_trial():
|
|
| 538 |
attempts, forged, last_raw, last_errs = 0, None, "", []
|
| 539 |
|
| 540 |
base_prompt = f"""
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
|
| 568 |
try:
|
| 569 |
while attempts < 3 and not forged:
|
| 570 |
attempts += 1
|
| 571 |
-
current_prompt = base_prompt if attempts == 1 else f"REPAIR LOGIC ERROR: {last_errs}\nPREVIOUS CODE: {last_raw}"
|
| 572 |
|
| 573 |
res = client.models.generate_content(
|
| 574 |
model=ATHENA_FLASH,
|
|
@@ -617,6 +642,7 @@ def generate_trial():
|
|
| 617 |
logger.error(f"v10.1 Global Failure: {e}")
|
| 618 |
return jsonify({"error": "The laws of the universe failed to stabilize. Retry."}), 500
|
| 619 |
|
|
|
|
| 620 |
# -----------------------------------------------------------------------------
|
| 621 |
# 5. THE CHIRON MENTOR & SYSTEM UTILS
|
| 622 |
# -----------------------------------------------------------------------------
|
|
|
|
| 463 |
|
| 464 |
# -----------------------------------------------------------------------------
|
| 465 |
# ODYSSEUS ENGINE V10.1: HARDENED GAME CONSOLE (SYNTAX GUARD + VICTORY HOOKS)
|
| 466 |
+
# DIFFICULTY CALIBRATION UPDATE: Human-feasible challenges with generous tolerances
|
| 467 |
# -----------------------------------------------------------------------------
|
| 468 |
|
| 469 |
# Enhanced Forbidden Patterns to prevent "Unexpected Token" errors in Babel
|
|
|
|
| 511 |
Odysseus v10.1: The Hardened Instrumentalist.
|
| 512 |
Architects bespoke, interactive React games with a 3-pass syntax repair loop.
|
| 513 |
Cost: 1 Spark.
|
| 514 |
+
|
| 515 |
+
DIFFICULTY TUNING: Now calibrated for human-achievable gameplay with forgiving mechanics.
|
| 516 |
"""
|
| 517 |
logger.info(">>> ODYSSEUS V10.1: FORGING HARDENED INSTRUMENT")
|
| 518 |
uid = verify_token(request.headers.get('Authorization'))
|
|
|
|
| 541 |
attempts, forged, last_raw, last_errs = 0, None, "", []
|
| 542 |
|
| 543 |
base_prompt = f"""
|
| 544 |
+
You are Athena's Master Game Architect. Forge an interactive scientific 'Instrument' for {subject}.
|
| 545 |
+
Context: {ctx_text}
|
| 546 |
+
|
| 547 |
+
TASK: Write a React component named 'Instrument'.
|
| 548 |
+
This is a GAME that requires user interaction to achieve a scientific victory.
|
| 549 |
+
|
| 550 |
+
TECHNICAL CONSTRAINTS (STRICT):
|
| 551 |
+
1. REACT ONLY: Use React hooks (useState, useEffect, useRef). No external libs. Use SVG/Canvas.
|
| 552 |
+
2. HANDSHAKE: Component receives `{{ onAction, onWin }}` as props.
|
| 553 |
+
- Call `props.onAction()` the moment the user interacts.
|
| 554 |
+
- Call `props.onWin()` when the specific scientific goal is reached.
|
| 555 |
+
3. WIN CONDITION: You MUST define a logic state (e.g., matching a frequency) that triggers `onWin()`.
|
| 556 |
+
4. NO COMMENTS: Do not use HTML comments <!-- -->. Use {{/* */}} if needed.
|
| 557 |
+
5. CAMELCASE: Use className, onClick, onMouseDown, etc.
|
| 558 |
+
6. ENTROPY: The system must fail/decay if the user stops interacting.
|
| 559 |
+
|
| 560 |
+
DIFFICULTY CALIBRATION (CRITICAL - HUMAN-FEASIBLE DESIGN):
|
| 561 |
+
7. GENEROUS TOLERANCES: Use ±10-20% margins for success conditions. "Close enough" = victory.
|
| 562 |
+
- Example: Target frequency 440Hz? Accept 400-480Hz range.
|
| 563 |
+
- Example: Alignment needed? Accept ±15px margin, not pixel-perfect.
|
| 564 |
+
8. HUMAN TIMING: Design for 300-800ms reaction windows. No frame-perfect precision required.
|
| 565 |
+
9. CLEAR FEEDBACK: Show visual progress indicators (color gradients, meters, proximity bars).
|
| 566 |
+
- Player should always know: "Am I getting closer?" and "How close am I to winning?"
|
| 567 |
+
10. ACHIEVABLE IN 20-60 SECONDS: Average player with focus should win in under a minute.
|
| 568 |
+
11. FORGIVING MISTAKES: Don't reset to zero on errors. Allow recovery and course correction.
|
| 569 |
+
12. EXPLICIT SUCCESS METRICS: controls_guide must state exact winning thresholds.
|
| 570 |
+
|
| 571 |
+
GOOD DIFFICULTY EXAMPLES:
|
| 572 |
+
- "Stabilize the pendulum angle between -10° and +10° for 3 seconds"
|
| 573 |
+
- "Match the wavelength within ±15nm (target: 550nm)"
|
| 574 |
+
- "Keep reaction rate in green zone (60-80%) for 5 seconds"
|
| 575 |
+
- "Align particles until overlap meter shows >75%"
|
| 576 |
+
|
| 577 |
+
BAD DIFFICULTY EXAMPLES (AVOID):
|
| 578 |
+
- "Match exactly 440.00000Hz" (too precise)
|
| 579 |
+
- "Click within 50ms of the flash" (inhuman timing)
|
| 580 |
+
- "Perfect circular motion required" (impossible with mouse/touch)
|
| 581 |
+
|
| 582 |
+
JSON OUTPUT SCHEMA:
|
| 583 |
+
{{
|
| 584 |
+
"engine": "odysseus_v10.1",
|
| 585 |
+
"instrument_name": "Title",
|
| 586 |
+
"mission_brief": "Goal with quantified success criteria.",
|
| 587 |
+
"controls_guide": "Explicit manual: 'Drag slider to keep value between X and Y', 'Maintain green zone for Z seconds to win'.",
|
| 588 |
+
"component_code": "const Instrument = (props) => {{ ... }}; export default Instrument;",
|
| 589 |
+
"feynman_truth": "Scientific revelation."
|
| 590 |
+
}}
|
| 591 |
+
"""
|
| 592 |
|
| 593 |
try:
|
| 594 |
while attempts < 3 and not forged:
|
| 595 |
attempts += 1
|
| 596 |
+
current_prompt = base_prompt if attempts == 1 else f"REPAIR LOGIC ERROR: {last_errs}\nPREVIOUS CODE: {last_raw}\n\nREMINDER: Make the game HUMANLY ACHIEVABLE with generous tolerances (±15% margins) and clear visual feedback showing progress."
|
| 597 |
|
| 598 |
res = client.models.generate_content(
|
| 599 |
model=ATHENA_FLASH,
|
|
|
|
| 642 |
logger.error(f"v10.1 Global Failure: {e}")
|
| 643 |
return jsonify({"error": "The laws of the universe failed to stabilize. Retry."}), 500
|
| 644 |
|
| 645 |
+
|
| 646 |
# -----------------------------------------------------------------------------
|
| 647 |
# 5. THE CHIRON MENTOR & SYSTEM UTILS
|
| 648 |
# -----------------------------------------------------------------------------
|