Prince of Persia (1989) runs at 12 Hz (83 ms/tick) and drops an unarmed player into a multi-room dungeon of pits, spikes, timed gates, potions, and guards. By letting Antigravity autonomously design, test, debug, and iterate on an agent powered by the Gemini Decisions API (gemini-decision-1, 0 output tokens), it figured out how to clear both Level 1 and Level 2 with 0 deaths—hitting 3-of-3 consecutive clears on Level 1 (7–18 API calls, 83–115 steps) and 2-of-2 consecutive clears on Level 2 (6–7 API calls, 69–77 steps, 5 guards defeated)—with zero hardcoded routes, zero map spoilers, and no vision model.

Full code and offline test suite (184 tests): github.com/MahadevanSrinivasan/pop-gemini-agent


How Antigravity Figured It Out

Instead of hand-crafting a solver, Antigravity ran live episodes against stock SDLPoP, inspected failure telemetry, built 184 offline unit tests, and converged on a clean separation between strategic room-level decisions and local 12 Hz physics:

  • Live 10×3 State Readout (~56 ms): Rather than waiting ~418 ms per raw frame and guessing edges from pixels, the controller reads the active room’s 10×3 tile grid, character coordinates, and potion types directly from the running game.
  • Commit-Per-Room Decisions (gemini-decision-1, 0 output tokens): Early runs gave the model 16 micro-actions per step (~150 API calls/level), where small per-step errors compounded into 2–5 deaths. Antigravity narrowed the model’s choice space to only the 2–5 reachable room-level goals (GO_LEFT, GO_RIGHT, GO_UP, GO_DOWN, PRESS_BUTTON, PICKUP_SWORD, DRINK_POTION, FIGHT_GUARD, ENTER_EXIT_DOOR) and committed to each chosen goal until the room or objective changed—cutting cloud decisions by >85% down to 6–18 calls per level.
  • 30-Tile RoomNavigator: Sees only the current room’s 30 tiles and executes exact 12 Hz motor skills (walk_to, standing_jump, running_jump, climb_ledge, safe_hang_drop, drink_potion, fight_guard).
  • Self-Learned FogOfWarMap: Starts completely empty ({}) on a new level and persists discovered room layouts, switches, gates, landmarks, and fatal pits across restarts—just like a human player remembering rooms they already explored.

Example Decision Input & Output

When the Prince enters a room with more than one reachable goal, simple_agent.py sends a compact fog-of-war summary plus only the currently legal room goals to gemini-decision-1 (v1beta):

Input (decisions.create):

{
  "model": "gemini-decision-1",
  "input": "target_exit_dir: LEFT  entered_from: 6\nfrontier: here->rm8[left->7]\nvisited=[1, 2, 6, 8] sword=0\nrecent_rooms: 1->2->6->8\n*rm8(v=1)[BTN]:ex[left->?UNVISITED,right->6]\nroom=8 c=7 r=1 hp=3\ngrid:\nr0:______B..O\nr1:TT.__.PK.W\nr2:WWW__WWWWW",
  "questions": {
    "goal": {
      "type": "choice",
      "criteria": {
        "PRESS_BUTTON": "Press button r=1 c=7",
        "GO_LEFT": "Exit left to rm7",
        "GO_RIGHT": "Exit right to rm6"
      }
    }
  }
}

Output (0 output tokens generated):

{
  "answers": {
    "goal": {
      "choice": "PRESS_BUTTON",
      "confidence": 0.962,
      "probabilities": {
        "PRESS_BUTTON": 0.962,
        "GO_LEFT": 0.031,
        "GO_RIGHT": 0.007
      }
    }
  }
}

Once PRESS_BUTTON opens the border gate (G → O), the local RoomNavigator commits to the chosen goal across every intra-room step without re-querying the model until the room or objective changes.


The Maps the Agent Built on Its Own

Starting from empty fog-of-war graphs in both levels, the Prince mapped 11 rooms on Level 1 (exploring west for the Sword in Room 15, backing out of a spiked dead-end in Room 14 after a single visit, and backtracking east to defeat the Guard in Room 3 and open the Exit in Room 9) and 17 rooms on Level 2 (clearing 5 guards, spotting the Big Life Jar in Room 20 while walking past the blue poison flask in Room 13, and conquering the Room 9 exit switch). Click any room to see how the agent mapped its dungeon tiles:

Self-Discovered Dungeon Maps (Click any room)
Rm 1Start Rm 2Hub Rm 6Spikes Rm 8Timed Gate Rm 7Gate Hub Rm 14Dead-End Rm 20Switches Rm 12Gate Rm 15Sword! Rm 3Guard Rm 9Exit!
Level 1 · Room 15 — Sword! (10 visits)
Found and picked up the Sword, then retraced east.
Hover any tile in the room drawing to inspect it.

Results

Run Mode Cleared Deaths Motor Steps API Calls Guards Defeated
Level 1 (Cold Start) Blank map Yes 0 115 18 1
Level 1 (Warm Restart #1) Self-learned map Yes 0 83 7 1
Level 1 (Warm Restart #2) Self-learned map Yes 0 108 12 1
Level 2 (Run #1) Self-learned map Yes 0 77 7 5
Level 2 (Run #2 + HUD) Self-learned map Yes 0 69 6 5

Most failures that looked like model mistakes turned out to be 12 Hz physics or perception bugs: holding UP for 1.3 s so ledge pull-ups finish, switching to zero-skid steps near pits (while disabling LEFTSHIFT near blue poison potions so careful-stepping doesn’t drink them), distinguishing open (O) from closed (G) border gates, and discovering that Level 2’s infamous 2-tile-island return jump over a 3-tile chasm needs a pixel-lip standing edge-jump plus mid-air LEFTSHIFT ledge grab (x=95 → c=5) rather than a running jump. Once Antigravity separated strategic room goals (gemini-decision-1) from single-room physics and gave the agent persistent fog-of-war memory, both Level 1 and Level 2 cleared cleanly with zero deaths.

Source code: github.com/MahadevanSrinivasan/pop-gemini-agent