Skip to content

feat: add Baba Is AI demo — knowing-doing gap in spatial puzzles#38

Merged
JNK234 merged 5 commits into
mainfrom
baba-is-ai-demo
Mar 19, 2026
Merged

feat: add Baba Is AI demo — knowing-doing gap in spatial puzzles#38
JNK234 merged 5 commits into
mainfrom
baba-is-ai-demo

Conversation

@JNK234

@JNK234 JNK234 commented Mar 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a "Baba Is You" inspired demo where an LLM agent solves puzzles by pushing word-blocks that define the rules of the world
  • Demonstrates the knowing-doing gap: LLMs understand rules perfectly but cannot execute spatial reasoning to manipulate them (BALROG benchmark: ~0% on Baba Is You)
  • 3 progressive levels: Navigate (trivial), Break the Wall (push one block), Push and Rearrange (rocks + walls)

Key Features

  • Rule engine — scans horizontal/vertical 3-tuples of word-blocks to detect active rules
  • Push system — chain-push mechanics with boundary and STOP collision checks
  • LLM integrationllm:choose with constrained choices ["up", "down", "left", "right"]
  • Rich observations — grid map, adjacency info, directional hints, STOP block coordinates, loop detection
  • History persistence — agent remembers past moves across ticks
  • Rate limit handling — waits and retries on TPM throttling
  • History cap — trims to system msg + last 10 exchanges to control token usage

Test Plan

  • Level 1: Agent walks to flag — should pass easily
  • Level 2: Agent hits wall, breaks WALL IS STOP by pushing STOP block, walks through
  • Level 3: Agent navigates rocks + walls — expected to struggle (demonstrates the gap)
  • Active Rules monitor updates when blocks are pushed
  • Rate limit handling works under rapid ticking
  • Permanent rules on row 8 remain intact throughout gameplay

JNK234 added 5 commits March 18, 2026 15:15
Ollama config with qwen2.5:7b defaults and YAML template documenting
the prompt context for the llm:choose-based action selection.
…egration

Complete Baba Is You puzzle demo with 3 levels of increasing difficulty:
- Level 1: Navigate (baseline path-finding)
- Level 2: Break the Wall (push STOP word-block to disable wall rule)
- Level 3: Push and Rearrange (rocks + walls + spatial reasoning)

Includes ABM rule engine that scans horizontal/vertical word-block
3-tuples, recursive push chain system, text observation builder for
LLM, and win/defeat detection. Uses llm:choose for constrained
action selection with accumulating history.
Covers the BALROG knowing-doing gap experiment context, setup
prerequisites, 3 level descriptions with expected results, provider
swapping instructions, and extension points.
…ules

- Add llm:set-history system message in setup so the LLM knows game
  mechanics (push word-blocks, break rules, reach the flag)
- Remove llm:clear-history from go loop so the agent remembers past
  moves and learns from failures
- Move BABA IS YOU and FLAG IS WIN to row 8 (top edge) across all
  levels so the agent never accidentally pushes permanent rules
- Improve observation builder with directional hints, fixed-width grid
  map, loop detection, and explicit blocked-move feedback
- Rewrite system prompt with explicit push mechanics and priority
  (break STOP first, then head to flag)
- Observation now shows exact STOP block coordinates when WALL IS STOP
  is active
- Extend wall columns to y=0-7 in levels 2 and 3 so agent cannot
  navigate around walls — must break the rule
- Cap history to system msg + last 10 exchanges to avoid token bloat
- Handle rate limit errors with 2s wait and retry on next tick

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9dd2168a6a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +162 to +164
create-word-block-at 0 5 "ROCK" "noun"
create-word-block-at 1 5 "IS" "verb"
create-word-block-at 2 5 "PUSH" "property"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent level 3 from becoming a straight-line solve

With these coordinates, the baba starts directly above the ROCK noun. Moving down twice breaks ROCK IS PUSH, and two more down moves push ROCK onto the IS STOP row, creating ROCK IS STOP and disabling WALL IS STOP. From there the wall column is passable and the player can walk straight to the flag without interacting with the rocks at (3,2) / (3,3) or solving the intended rearrangement puzzle, so the advertised hard level no longer tests the behavior described in the model.

Useful? React with 👍 / 👎.

Comment on lines +420 to +423
let action llm:choose obs ["up" "down" "left" "right"]
set last-action action
set total-moves total-moves + 1
set move-history lput action move-history

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle malformed llm:choose replies as failed turns

If the provider returns anything other than an exact option (for example right. or a brief explanation), llm:choose throws before total-moves or move-history are updated, and the error handler only logs the failure. In that scenario the forever go loop keeps resubmitting the same state indefinitely and never reaches max-moves, so a single non-conforming model response can wedge the demo while still burning LLM calls.

Useful? React with 👍 / 👎.

@JNK234
JNK234 merged commit 146d64f into main Mar 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant