# WHAT THE HARNESS ALREADY KNOWS ABOUT THIS GAME

Handed over so you do not spend your budget rediscovering it. None of it is a diagnosis.

## WHAT THE GAME SAYS IT SHOULD DO (its own design document)

# GAME DESIGN DOCUMENT — Hajimi Defense: The Mung Bean Crisis

## 0. Technical Architecture

- **Archetype:** `tower_defense`
- **Physics Profile:** top-down path-following enemies, grid-constrained tower placement, no gravity.
- **Resolution:** 1152 x 768 (template standard; do not change).
- **Primary gameplay base class:** `BaseTDScene` via copied `_TemplateTDLevel.ts`.
- **Scene flow:** `TitleScreen -> LivingRoomDefenseScene -> GameCompleteUIScene`; `LivingRoomDefenseScene -> GameOverUIScene` when sanity reaches 0.
- **LevelManager.LEVEL_ORDER:** `["LivingRoomDefenseScene"]`
- **Registered scene keys:**
  - `TitleScreen`
  - `LivingRoomDefenseScene`
  - `UIScene`
  - `PauseUIScene`
  - `VictoryUIScene`
  - `GameOverUIScene`
  - `GameCompleteUIScene`

## 1. Visual Style & Asset Registry

**Style Anchor:** Cute saturated kawaii pixel art on a warm living-room floor: chubby meme cats, rounded household threats, bright candy-like projectiles, soft outlines, high readability, and playful absurdity.

| type | key | description | params |
|------|-----|-------------|--------|
| background | living_room_bg | Top-down cute pixel art wooden living-room floor with warm planks, small rugs, toy mice, yarn balls, and cozy scattered cat toys; no text; clear central space for path overlay | resolution: "1536*1024" |
| image | tower_slot | Round fluffy cushion tower placement marker, top-down, pastel cream with soft rim, highly readable on wood floor | - |
| image | defense_target | Golden tuna can treasure, shiny warm yellow can with fish motif but no readable text, front/top three-quarter pixel art, defended goal object | - |
| image | spawn_door | Open living-room door at top-left, top-down/angled pixel art, warm wood frame and dark doorway, enemy spawn marker | - |
| image | obstacle_box | Cute destructible cardboard box, taped and dented, rounded pixel art edges, no text | - |
| image | obstacle_shoe | Pile of soft colorful shoes, top-down clutter obstacle, rounded cartoon forms | - |
| image | cat_tabby | Orange tabby cat tower, front/top three-quarter view, cheeks puffed as if spitting mung beans, cute meme expression | - |
| image | cat_siamese | Elegant Siamese cat tower, front/top three-quarter view, squinting sniper focus, poised and dramatic | - |
| image | cat_fat | Chonky orange cat tower lying down holding a red bean bun, lazy funny expression, large rounded body | - |
| image | cat_calico | Calico cat tower drinking milk tea with boba straw, cute focused expression, crowd-control vibe | - |
| image | proj_mung | Tiny round green mung bean projectile, simple bright pixel art bead, distinct green | - |
| image | proj_bone | Elongated white fish bone projectile, clean readable silhouette, slightly cream highlight | - |
| image | proj_bun | Round brown-red bean bun projectile, chunky snack ball, warm red-brown color | - |
| image | proj_boba | Round black tapioca pearl projectile, glossy dark purple-black bubble with small highlight | - |
| image | enemy_cucumber | Small fast walking cucumber enemy, green rounded veggie with terrified/funny eyes, tiny feet | - |
| image | enemy_dust | Tiny grey dust bunny puffball enemy with eyes, soft fluffy pixel art, swarm unit | - |
| image | enemy_vacuum | Large round robot vacuum cleaner enemy with red light, cute menacing appliance, top-down | - |
| image | enemy_mailman | Giant comedic mailman boss figure, oversized cap and mailbag, rounded pixel art silhouette, no readable text | - |
| image | icon_kibble | Cat food bowl currency icon filled with golden kibble pellets, cute pixel art | - |
| audio | bgm_playful | Funny bouncy 8-bit chiptune living-room defense loop, playful chaos, light percussion | audioType: "bgm", duration: 20 |
| audio | sfx_tower_place | Soft cute plop sound for placing a cat on a cushion | audioType: "sfx" |
| audio | sfx_tower_sell | Quick soft whoosh sound for selling/removing a cat | audioType: "sfx" |
| audio | sfx_tower_upgrade | Sparkly chime for cat upgrade | audioType: "sfx" |
| audio | sfx_spit | Cute short pfft spit sound for cat firing | audioType: "sfx" |
| audio | sfx_bonk | Light bonk impact sound for projectile hitting enemy | audioType: "sfx" |
| audio | sfx_break | Cardboard/shoe clutter cracking break sound | audioType: "sfx" |
| audio | sfx_combo | Exciting quick combo chime | audioType: "sfx" |
| audio | sfx_wave_clear | Triumphant short wave-clear jingle | audioType: "sfx" |
| audio | sfx_enemy_death | Soft pop enemy defeated sound | audioType: "sfx" |

**Code-drawn infrastructure:** path overlay line, range circles, hit rings, floating reward text, panel rectangles, and transient particles should use `Shapes.*` or Phaser graphics, not generated images. Projectile assets are brand-identifiable because each cat type requires a dedicated recognizable projectile image.

## 2. Game Configuration

Merge the following game-specific configuration into the existing `src/gameConfig.json` without removing `screenSize`, `debugConfig`, `renderConfig`, or `difficultyConfig`.

- `difficultyConfig.nLevels`: 1
- `difficultyConfig.enemyCount`: 5 (minimum Wave 1 audit baseline; actual waves are defined in `towerDefenseConfig.waves`)
- `difficultyConfig.enemySpeedFactor`: 1
- `difficultyConfig.hazardCount`: 4 (obstacles)
- `difficultyConfig.healthPickups`: 0
- `difficultyConfig.timeLimitSec`: 0 (no hard timer; wave countdowns are separate)

**`towerDefenseConfig`:**
- `startingGold`: 120
- `startingLives`: 10
- `gridCellSize`: 64
- `gridWidth`: 16
- `gridHeight`: 10
- `timeBetweenWavesMs`: 12000
- `obstacleClicksToDestroy`: 5
- `obstacleReward`: 15
- `comboWindowMs`: 2000
- `comboBonusPerLevel`: 2
- `sellRefundRate`: 0.7
- `waves`:
  1. `{ wave: 1, enemies: [{ type: "cucumber", count: 5 }], spawnIntervalMs: 1200, reward: 20 }`
  2. `{ wave: 2, enemies: [{ type: "dust", count: 8 }, { type: "vacuum", count: 2 }], spawnIntervalMs: 800, reward: 30 }`
  3. `{ wave: 3, enemies: [{ type: "cucumber", count: 4 }, { type: "dust", c

## WHERE THE CODE IS

43 TypeScript files, largest first. `A -> B` means A extends B.

    843 lines  src/scenes/BaseTDScene.ts                            BaseTDScene -> Phaser.Scene
    794 lines  src/utils.ts                                         
    404 lines  src/enemies/BaseTDEnemy.ts                           BaseTDEnemy -> Phaser.Physics.Arcade.Sprite
    373 lines  src/towers/BaseTower.ts                              BaseTower -> Phaser.GameObjects.Image
    352 lines  src/scenes/LivingRoomDefenseScene.ts                 LivingRoomDefenseScene -> BaseTDScene
    312 lines  src/scenes/_TemplateTDLevel.ts                       _TemplateTDLevel -> BaseTDScene
    241 lines  src/scenes/TitleScreen.ts                            TitleScreen -> Phaser.Scene
    237 lines  src/shapes.ts                                        
    191 lines  src/systems/WaveManager.ts                           WaveManager
    179 lines  src/entities/BaseObstacle.ts                         BaseObstacle -> Phaser.GameObjects.Image
    176 lines  src/scenes/GameOverUIScene.ts                        GameOverUIScene -> Phaser.Scene
    153 lines  src/rlenv.ts                                         
    137 lines  src/scenes/UIScene.ts                                UIScene -> Phaser.Scene
    136 lines  src/scenes/VictoryUIScene.ts                         VictoryUIScene -> Phaser.Scene
    135 lines  src/StateMachine.ts                                  StateMachine
    132 lines  src/scenes/PauseUIScene.ts                           PauseUIScene -> Phaser.Scene
    119 lines  src/scenes/GameCompleteUIScene.ts                    GameCompleteUIScene -> Phaser.Scene
    117 lines  src/towers/_TemplateTower.ts                         _TemplateTower -> BaseTower
    109 lines  src/LevelManager.ts                                  LevelManager
     98 lines  src/test/helpers/phaser.ts                           
     92 lines  src/enemies/_TemplateTDEnemy.ts                      _TemplateTDEnemy -> BaseTDEnemy
     77 lines  src/towers/BobaTower.ts                              BobaTower -> BaseTower
     76 lines  src/main.ts                                          
     76 lines  src/systems/EconomyManager.ts                        EconomyManager
     73 lines  src/towers/ChonkyTower.ts                            ChonkyTower -> BaseTower
     68 lines  src/scenes/Preloader.ts                              Preloader -> Phaser.Scene
     60 lines  src/entities/_TemplateObstacle.ts                    _TemplateObstacle -> BaseObstacle
     56 lines  src/towers/SiameseTower.ts                           SiameseTower -> BaseTower
     53 lines  src/towers/TabbyTower.ts                             TabbyTower -> BaseTower
     49 lines  src/enemies/CucumberEnemy.ts                         CucumberEnemy -> BaseTDEnemy
     49 lines  src/enemies/MailmanBossEnemy.ts                      MailmanBossEnemy -> BaseTDEnemy
     46 lines  src/enemies/RobotVacuumEnemy.ts                      RobotVacuumEnemy -> BaseTDEnemy
     45 lines  src/enemies/DustBunnyEnemy.ts                        DustBunnyEnemy -> BaseTDEnemy
     40 lines  src/test/hajimi-smoke.test.ts                        
     34 lines  src/entities/ShoePileObstacle.ts                     ShoePileObstacle -> BaseObstacle
     33 lines  src/entities/CardboardBoxObstacle.ts                 CardboardBoxObstacle -> BaseObstacle
     25 lines  src/chrome/chrome.d.ts                               
     12 lines  src/test/setup.ts                                    
      7 lines  src/enemies/index.ts                                 
      7 lines  src/towers/index.ts                                  
      5 lines  src/entities/index.ts                                
      4 lines  src/scenes/index.ts                                  
      4 lines  src/systems/index.ts                                 

## CONTROLS (parsed from this game's own source)

  control   event          on <scope>              file:line

  pointer   pointerdown    on BaseObstacle           src/entities/BaseObstacle.ts:55
  esc       keydown-ESC    on BaseTDScene            src/scenes/BaseTDScene.ts:203
  space     keydown-SPACE  on BaseTDScene            src/scenes/BaseTDScene.ts:212
  pointer   pointermove    on BaseTDScene            src/scenes/BaseTDScene.ts:191
  pointer   pointerdown    on BaseTDScene            src/scenes/BaseTDScene.ts:195
  enter     Key(ENTER)     on GameCompleteUIScene    src/scenes/GameCompleteUIScene.ts:66
  space     Key(SPACE)     on GameCompleteUIScene    src/scenes/GameCompleteUIScene.ts:69
  pointer   pointerdown    on GameCompleteUIScene    src/scenes/GameCompleteUIScene.ts:74
  enter     Key(ENTER)     on GameOverUIScene        src/scenes/GameOverUIScene.ts:88
  space     Key(SPACE)     on GameOverUIScene        src/scenes/GameOverUIScene.ts:91
  pointer   pointerdown    on GameOverUIScene        src/scenes/GameOverUIScene.ts:85
  esc       keydown-ESC    on PauseUIScene           src/scenes/PauseUIScene.ts:86
  space     keydown-SPACE  on PauseUIScene           src/scenes/PauseUIScene.ts:91
  enter     keydown-ENTER  on PauseUIScene           src/scenes/PauseUIScene.ts:96
  esc       keydown-ESC    on UIScene                src/scenes/UIScene.ts:99
  enter     Key(ENTER)     on VictoryUIScene         src/scenes/VictoryUIScene.ts:71
  space     Key(SPACE)     on VictoryUIScene         src/scenes/VictoryUIScene.ts:74
  pointer   pointerdown    on VictoryUIScene         src/scenes/VictoryUIScene.ts:79

## COORDINATES

  The game's own space is 1152x768; it is drawn into a canvas of 960x640. Click positions in the steps above are in the canvas space.

## THE STEPS THAT ARE THE EVIDENCE, VERBATIM

Taken from the session that found this. Not a summary -- what was sent and what came back.

  step 3: press_key {"key": " "}
      it expected: Enter left the title prompt visible, so I am trying another advertised start input.
      the game answered: null
      96.7% of the screen changed
  step 4: read_state {}
      it expected: Reading HUD/state after reaching gameplay to identify resources, lives, wave, tower selection, and object counts before acting.
      the game answered: {"px": 1064, "py": 640, "vx": 0, "vy": 0, "onGround": 0, "hp": 10, "maxHp": 100, "score": 0, "enemyDx": -357.6999999999998, "enemyDy": -256, "enemyAlive": 1, "hasPlayer": 1, "won": 0, "lost": 0, "done": false}
      0.3% of the screen changed
  step 5: read_text {}
      it expected: Reading visible text to capture HUD labels and see whether tower purchase controls are shown.
      the game answered: {"hud_text": "PAUSE", "canvas_text": []}
      0.4% of the screen changed
  step 15: press_key {"key": "Enter"}
      it expected: Retry click did not change the Game Over screen, so I am trying the advertised keyboard retry input.
      the game answered: null
      93.6% of the screen changed
  step 17: click {"x": 340, "y": 210}
      it expected: Trying to select a visible cat tower/projectile source to see if upgrade/sell/range UI appears.
      the game answered: null
      0.1% of the screen changed

## HOW TO RUN THE GAME, NOT JUST BUILD IT

Building is not the test. A build that compiles says nothing about whether the HUD appeared or whether a click places a tower, which is usually what is being reported. So drive it:

```
PYTHONPATH=/home/tiger/GameAgent/minghao/OpenGame_verify_fix/.claude/worktrees/negative-evidence-scope/agent-test \
python3 -m gamedoctor.evolve.play_cli . --steps '[
  {"action":"boot"},
  {"action":"read_text"},
  {"action":"press_key","key":"Enter"},
  {"action":"wait","ms":2000},
  {"action":"read_state"},
  {"action":"click","x":286,"y":181,"times":2},
  {"action":"read_scene_fields","fields":["towersGroup"]}]'
```

The two steps in the middle are not padding. These games open on a title screen and construct the scene asynchronously after the start key, so a `read_state` fired immediately comes back `ok:false` -- which means the reading could not be taken, NOT that the game is empty. Read the text first to see which screen you are on, press the key the game advertises, then give it a beat.

It prints JSON: one row per step, `observed` for readings and `frame` for a screenshot path you can open. Actions: boot, press_key, hold_key, click (with `times` for repeats), wait, read_state, read_text, read_scene_fields, read_bindings, screenshot. Run it from the game directory.

THE MOST USEFUL THING IT DOES is the matched interval: do nothing for N ms, read; then do the thing for the same N ms, read. A number that should differ and does not is the defect, and a number that moves on its own is a confound you would otherwise blame on your own change.

BEFORE YOU STOP, run the game and read back the same thing the evidence above measured. It is the only measurement of this property that exists -- a build that compiles and a test suite that passes do not observe it. If the reading has not moved, you have not finished.

Time spent driving the game is not charged against your reasoning budget. Inspect, edit, build, run and look as many times as you need.

## A TEST, IF ONE HELPS YOU ITERATE

The project runs vitest (`npm run test`) and ships headless Phaser helpers in `src/test/helpers/phaser.ts` -- `bootScene(SceneClass)` boots a scene with no browser. For a mechanism defect that is one assertion ("two clicks and `towersGroup.getLength()` is still 0"), that can be a faster loop than driving the whole game.

Optional, and not how your repair is judged -- that is still the session that plays the rebuilt game. A visual defect (contrast, a missing HUD) has no assertion that states it; use the screenshot.


======================================================================

A play session of this game found the following, and your job is to fix it.

WHAT WAS SEEN
  The gameplay screen does not show the promised tower-defense HUD or purchase/selection UI: no visible gold, lives/sanity, wave number/countdown, tower palette, tower costs, or placement instructions are present; only a PAUSE button is readable.

THE EVIDENCE FROM THAT SESSION
  The gameplay frames after steps 3, 4, 15, and 17 show the playfield/path/enemies but no resource, life, wave, or tower-purchase UI. Step 5 read_text found only 'PAUSE'. The design/config promises startingGold, startingLives, waves, grid-constrained tower placement, and multiple tower types, but the observed level exposes no visible way to buy or select them.

HOW THIS WILL BE JUDGED. Nobody reads your summary. The game is rebuilt and
played again by an agent sent to check this specific thing, and a reader decides
from THAT session whether it behaves now. A change that compiles and does not
alter what a player sees comes back as unfixed.

Fix the cause you can find, not the symptom you can reach. And do not break
what works -- your change will be combined with other repairs and the result is
played in full.

BEFORE YOU STOP, build the game. A repair that does not compile cannot be
played and cannot be judged.
