Agent Functions

A program that controls the agent

15 steps. One text file in. One tested game out. The programmer writes the pipeline. The AI agent does the work. Every step validated. Every decision auditable.

← Back to the story
Requirements Game Design Architecture Planning Build Evaluate & Fix Documentation Summary 1 extractGameRequirements Parse description.txt + detect genre 2 createGameDesign Full Game Design Document 3 improveGameDesign Critically review and improve allRequirements Covered? max 5 pass fail 5 createGameArchitecture Phaser 3 / Matter.js architecture 6 improveGameArchitecture Review and improve allElements Covered? max 5 pass fail 8 createImplementationPlan Step-by-step build plan 9 improveImplementationPlan Review and improve allElements Covered? max 5 pass fail 11 buildGame Generate Phaser 3 game + bridge index.html + game.js + styles.css Phaser CDN + GAME_STATE bridge 12 setupTestInfrastructure Install Playwright + local server 13 evaluateAndImprove Load game, play-test, find #1 issue, fix it P0: crash > P1: broken > P2: missing > P3: polish > P4: juice game Complete? yes no — iterate max 7 max reached → docs 14 generateDocumentation Write README.md with controls 15 generateFinalSummary Write SUMMARY.md DONE
Requirements
Game Design
Architecture
Planning
Build
Evaluate & Fix
Documentation
Summary
Step 13: evaluateAndImprove — The core of the pipeline. Each iteration, the AI agent:
1. Starts a local server and loads the game in Playwright
2. Reads window.GAME_STATE bridge to check scene transitions, input, scoring, game loop
3. Takes screenshots of title, gameplay, and game over states
4. Captures all console errors
5. Reads the source code and compares against REQUIREMENTS.md
6. Identifies the single most impactful issue by priority: P0 (crash) > P1 (broken core) > P2 (missing feature) > P3 (polish) > P4 (juice)
7. Creates a git snapshot, then fixes that one issue
8. Appends to EVALUATION_LOG.md for a full history of what was found and fixed
9. Returns gameComplete: true when all requirements are met and no significant issues remain

Max 7 iterations. If the game is complete before that, it exits early to documentation.

Step Reference

#FunctionDescriptionOutputNext
1extractGameRequirementsParse description.txt, detect genreREQUIREMENTS.md→ 2
2createGameDesignFull Game Design DocumentGAME_DESIGN.md→ 3
3improveGameDesignReview and improve designGAME_DESIGN.md→ 4
4evaluateGameDesignGate: all requirements covered?DESIGN_EVALUATION.mdpass→5 | fail→3 (max 5)
5createGameArchitecturePhaser 3 / Matter.js architectureARCHITECTURE.md→ 6
6improveGameArchitectureReview and improve architectureARCHITECTURE.md→ 7
7evaluateGameArchitectureGate: all design elements covered?ARCHITECTURE_EVALUATION.mdpass→8 | fail→6 (max 5)
8createImplementationPlanStep-by-step build planPLAN.md→ 9
9improveImplementationPlanReview and improve planPLAN.md→ 10
10evaluateImplementationPlanGate: all architecture covered?PLAN_EVALUATION.mdpass→11 | fail→9 (max 5)
11buildGameGenerate Phaser 3 game filesindex.html, game.js, styles.css→ 12
12setupTestInfrastructureInstall Playwright + serverpackage.json, playwright.config.js→ 13
13evaluateAndImprovePlay-test, find #1 issue, fix itEVALUATION_LOG.md, modified filescomplete→14 | else→13 (max 7→14)
14generateDocumentationWrite README.mdREADME.md→ 15
15generateFinalSummaryWrite SUMMARY.mdSUMMARY.md→ DONE