You are an AI agent optimizing a binary maze level.Your goal is to achieve a longest shortest path of ~256while maintaining exactly 1 connected region.
## CurrentLevel (rows are y, columns are x, 0-indexed):
## calculate_stats Description: Calculates statistics forthe current level including path (the longest shortest path between any two empty tiles) and num_connected_regions (numberof separate connected regions of empty tiles). Returns metrics, targets, and gaps to help guide optimization. Parameters: - level_string (string) (optional): Optional: ASCII level representation to evaluate. If not provided, evaluates the current level.
## place_tile Description: Places a tile onthe level. Supported tile types: empty, wall. Supports three modes: - 'single': place one tile at (y, x). - 'line': place a straight horizontal or vertical segment. Specify the endpoint using ONE of: (a) direction ('up'/'down'/'left'/'right') + length, (b) end_y + end_x for an explicit endpoint, (c) end_x only (end_y defaults to y, drawing a horizontal line), or (d) end_y only (end_x defaults to x, drawing a vertical line). Example horizontal line: {mode:'line', y:5, x:0, end_x:10} Example vertical line: {mode:'line', y:0, x:3, end_y:8} - 'rect': fill a rectangle from (y, x) to (end_y, end_x). Requires end_y and end_x. Parameters: - mode (string) (required): Mode of operation: 'single' for one tile, 'line' for a segment, 'rect' for rectangle - tile_type (string) (required): Type of tile to place: empty, wall - y (integer) (required): Row coordinate (0-indexed). For line/rect, this is start_y. - x (integer) (required): Column coordinate (0-indexed). For line/rect, this is start_x. - end_y (integer) (optional): Ending row coordinate. Required for rect mode. For line mode: if only end_y isgiven (no end_x), draws a vertical line from y to end_y at column x. If both end_y and end_x are given, draws a line from (y,x) to (end_y,end_x). - end_x (integer) (optional): Ending column coordinate. Required for rect mode. For line mode: if only end_x isgiven (no end_y), draws a horizontal line from x to end_x at row y. If both end_y and end_x are given, draws a line from (y,x) to (end_y,end_x). - direction (string) (optional): Direction to extend from (y,x) --- alternative to end_y/end_x for line mode. Must be paired with 'length'. - length (integer) (optional): Number of tiles to place in 'direction' (for line mode with direction). Must be paired with 'direction'. - filled (boolean) (optional): For rect mode: iftrue, fill entire rectangle; iffalse, only draw border'
## generate_bsp Description: Ignores the current level and generates a new room-and-corridor layout using Binary Space Partitioning. Recursively splits thespaceinto rectangles, carves a room inside each partition, and connects adjacent rooms with corridors. Works regardless ofthe current level state. Output has open rectangular rooms linked by narrow passages --- typically 1 connected region with moderate path lengths. Increase splits for more, smaller rooms (longer paths); decrease for fewer, larger rooms (shorter paths). Calling this again discards all previous progress. Parameters: - splits (integer) (optional): Number of recursive splits (default 3) - min_width (integer) (optional): Minimum partition width (default 5) - min_height (integer) (optional): Minimum partition height (default 5)
## generate_ca Description: REFINEMENT tool: evolves the CURRENT level in-place using cellular automata rules --does NOT discard previous work. Each iteration, every tile checks its 8 neighbors (Moore neighborhood): if wall-neighbor count <= solid_count the tile becomes wall; if empty-neighbor count >= empty_count the tile becomes empty. Effect: smooths noisy layouts into organic cave-like shapes by removing isolated tiles and filling small holes. IMPORTANT: has no effect on a blank (all-empty or all-wall) level --- needs a mix of wall and empty tiles to work. Best used after generate_random or generate_digger to smooth rough output. Fewer iterations = subtle smoothing; more iterations = stronger smoothing toward large blobs. Parameters: - iterations (integer) (optional): Number of CA iterations (default 10) - solid_count (integer) (optional): Neighbor threshold for becoming/staying wall (default 2) - empty_count (integer) (optional): Neighbor threshold for becoming empty (default 6)
## generate_connect Description: REFINEMENT tool: post-processes the CURRENT level in-place to fix connectivity --does NOT discard previous work. Finds all connected empty regions, removes regions smaller than smallest_region_size (fills them with wall), then connects remaining regions with straight corridors. Effect: reduces num_connected_regions toward 1 and increases path length by linking previously isolated areas. IMPORTANT: has no effect on a blank (all-empty) level since it is already one region. Best used as a final pass after any generator (especially generate_random, generate_ca, or generate_digger) to ensure the level is fully connected. Can also be called after manual place_tile edits that may have split the level. Parameters: - smallest_region_size (integer) (optional): Minimum region size to keep; smaller regions become wall (default 5)
## generate_digger Description: Ignores the current level and generates a new cave layout using a random-walk digger. Starts from an all-solid grid at a random position and carves empty tiles by walking in random directions, occasionally carving rooms. Stops when the fraction of empty tiles reaches stop_size. Works regardless ofthe current level state. Output is a single naturally-connected cave with organic, irregular shape --- guaranteed 1 connected region. Higher stop_size = more open space (shorter paths); lower stop_size = tighter tunnels (longer paths). Follow up with generate_ca to smooth rough edges. Calling this again discards all previous progress.
Parameters: - change_prob (number) (optional): Probability of changing walk direction (default 0.15) - room_prob (number) (optional): Probability of carving a room instead of a single tile (default 0.01) - room_size (integer) (optional): Half-size of carved rooms (actual size is2*room_size+1, default 3) - stop_size (number) (optional): Stop when empty tile fraction reaches this value (0.0-1.0, default 0.3)
## Instructions: 1. Analyze the current level andits metrics 2. Plan edits to improve the score (move metrics toward goals described above) 3. Execute tool calls to modify the level 4. You may call calculate_stats to evaluate changes before committing
## Response Format: Respond with a JSON object of one of these types:
### STEP - To execute tools: ```json { "type": "STEP", "rationale": "explanation of your reasoning", "plan": "high-level plan for improvement", "tool_calls": [ {"tool_name": "place_wall_segment", "parameters": {...}}, {"tool_name": "calculate_stats", "parameters": {}} ], "acceptance_hint": "hint about whether to accept changes" }
PROPOSE_SKILL - To propose a new tool:
1
json { "type":"PROPOSE_SKILL", "rationale":"why this tool would help", "skill_spec": { "name":"tool_name", "description":"what it does", "parameters": {}, "implementation_hint":"how to implement" } }
STOP - To terminate optimization:
1
Json { "type": "STOP", "rationale": "why stopping now", "final_notes": "observations about the result" }
Respond with ONLY the JSON object, no additional text.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
```jsx You are an AI agent optimizing a Super Mario Bros level. Your goals are: 1. Create a completable level (Mario can reach the end) 2. Have proper tube/pipe structures (tubes must span 2 tiles properly) 3. Achieve ~3 enemies killed, ~5 jumps performed, ~3 coins collected during gameplay simulation 4. Minimize horizontal noise for smoother gameplay 5. Add coins and question blocks for rewards
## How Evaluation Works A Mario AI agent (A* solver) plays your level from left to right. The metrics below reflect the **gameplay outcome**, not the tile layout: - **enemies_killed**: Number of enemies the player stomped or hit with shells during play. Enemies that fall off cliffs on their own do NOT count. Simply placing enemy tiles does not guarantee kills --- enemies must be on the player's path where they cannot be avoided. - **coins_collected**: Number of coins the player picked up during play. Coins must be on or near the traversal path. - **jumps**: Number of voluntary jumps the player performed from the ground. Bouncing off enemies (stomp bounces) does NOT count. More gaps and elevated platforms force more jumps. - **complete**: Whether the player reached the end flag (1.0 = yes).
To increase enemies_killed, place enemies on narrow ground platforms that the player must cross (not on optional platforms). To increase coins_collected, place coins along the main path or on mandatory platforms. To increase jumps, create gaps in the ground and elevated platforms that force the player to jump from the ground --- enemy stomps do not count as jumps.
## Current Level (rows are y, columns are x, 0-indexed):
Legend:'*' = Mario's path (empty tiles only), '!' = enemy killed here Note: Enemies move during simulation. '!' marks where Mario was when the kill happened, not the enemy's spawn position. Enemies that were avoided or not reached are still shown at their original tile positions (G/K/Y).
## Simulation Results The Mario AI agent played through the level. Here is what happened: - Completion: 100% (reached the flag) - Enemies killed: 2 (goomba stomped at tile [1, 14], goomba stomped at tile [17, 6]) - Coins collected: 3 - Jumps performed: 4 (stomp bounces: 2, not counted as jumps) - Mario traversed from column 0to column 31
Enemy behavior during simulation: - Goomba (G): Walks horizontally, reverses on walls. Speed ~1.75 px/frame. - Koopa (K): Green koopa walks horizontally, falls off cliffs. Becomes a kickable shell when stomped. - Spiny (Y): Walks horizontally like goomba but CANNOT be stomped (hurts Mario). Must be avoided or killed with shell/fireball.
## place_tile Description: Places a tile on the level. Supported tile types: empty, solid, ladder, brick, question, tube, coin, goomba, koopa, spiny. Supports three modes: - 'single': place one tile at (y, x). - 'line': place a straight horizontal or vertical segment. Specify the endpoint using ONE of: (a) direction ('up'/'down'/'left'/'right') + length, (b) end_y + end_x for an explicit endpoint, (c) end_x only (end_y defaults to y, drawing a horizontal line), or (d) end_y only (end_x defaults to x, drawing a vertical line). Example horizontal line: {mode:'line', y:5, x:0, end_x:10} Example vertical line: {mode:'line', y:0, x:3, end_y:8} - 'rect': fill a rectangle from (y, x) to (end_y, end_x). Requires end_y and end_x. Parameters: Parameters: - mode (string) (required): Mode of operation: 'single' for one tile, 'line' for a segment, 'rect' for rectangle - tile_type (string) (required): Type of tile to place: empty, solid, ladder, brick, question, tube, coin, goomba, koopa, spiny - y (integer) (required): Row coordinate (0-indexed). For line/rect, this is start_y. - x (integer) (required): Column coordinate (0-indexed). For line/rect, this is start_x. - end_y (integer) (optional): Ending row coordinate. Required for rect mode. For line mode: if only end_y is given (no end_x), draws a vertical line from y to end_y at column x. If both end_y and end_x are given, draws a line from (y,x) to (end_y,end_x). - end_x (integer) (optional): Ending column coordinate. Required for rect mode. For line mode: if only end_x is given (no end_y), draws a horizontal line from x to end_x at row y. If both end_y and end_x are given, draws a line from (y,x) to (end_y,end_x). - direction (string) (optional): Direction to extend from (y,x) --- alternative to end_y/end_x for line mode. Must be paired with'length'. - length (integer) (optional): Number of tiles to place in'direction' (for line mode with direction). Must be paired with 'direction'. - filled (boolean) (optional): For rect mode: iftrue, fill entire rectangle; iffalse, only draw border
## Instructions: 1. Ensure the level is completable (Mario can traverse from start toend) 2. Place solid ground (X) for Mario to walk on 3. Add platforms using bricks (B) and question blocks (?) 4. Place enemies (G, K, Y) on solid ground along the player's path --- enemies the player can avoid will not count 5. Place coins (C) along the main traversal path --- coins the player never reaches will not count 6. Avoid creating impossible jumps or dead ends
## Response Format: Respond with a JSON objectof one of these types:
### STEP - To execute tools:
json { “type”: “STEP”, “rationale”: “explanation of your reasoning”, “plan”: “high-level plan for improvement”, “tool_calls”: [ {“tool_name”: “place_tile”, “parameters”: {“mode”: “single”, “tile_type”: “solid”, “y”: 15, “x”: 1}} ], “acceptance_hint”: “hint about whether to accept changes” }
1 2
### PROPOSE_SKILL - To propose a new tool:
json { “type”: “PROPOSE_SKILL”, “rationale”: “why this tool would help”, “skill_spec”: { “name”: “tool_name”, “description”: “what it does”, “parameters”: {}, “implementation_hint”: “how to implement” } }
1 2
### STOP - To terminate optimization:
json { “type”: “STOP”, “rationale”: “why stopping now”, “final_notes”: “observations about the result” }
1 2 3 4 5
Respond with ONLY the JSON object, no additional text.
## Extra Instruction: Make level withtwo elevated platforms, requires travelling toupperplatformto solve