102# Map Editing Workflow with Test Harness
104## Tile Placement Flow
1051. Parse natural language: "Place water tile at (5, 7)"
107 a. overworld-find-tile to get water tile ID
108 b. Calculate screen coordinates from game coords
109 c. Generate GUI action: Click(overworld_canvas, x, y)
110 d. Generate GUI action: SelectTile(tile_id)
111 e. Generate GUI action: Click(target_x, target_y)
114- Game coords: Tile-based (0-31
for 32x32 map)
115- Screen coords: Pixel-based, depends on zoom/scroll
116- Conversion: screen_x = game_x * tile_size * zoom + canvas_offset_x
118## GUI Automation Best Practices
119- Always wait
for UI updates (Wait(100ms) between actions)
120- Assert widget states before clicking
121- Screenshot before/after
for verification
122- Use widget discovery to find exact IDs
124## Proposal System Integration
125- Read-only tools: Execute directly
126- Write operations: Submit as proposal first
127- Wait
for approval before proceeding
128- Show user what will change (diff view)
132std::string AgentPretraining::GetToolUsageExamples() {
134# Tool Usage Examples & Chaining
136## Example 1: Find and Analyze Sprites
137User:
"What enemies are in Hyrule Castle?"
1391. resource-search --type=dungeon --query=hyrule
1402. dungeon-list-sprites --dungeon=hyrule_castle
1413. resource-list --type=sprite (to get sprite names)
142Result:
"Hyrule Castle (dungeon 0) has 3 guards (sprite 0x41), 2 knights..."
144## Example 2: Palette Investigation
145User:
"What colors are used for grass?"
1471. overworld-find-tile --tile_id=0x20 (grass tile)
1482. palette-get-colors --group=0 --palette=0
1493. palette-analyze --type=palette --id=0/0
150Result:
"Grass uses palette 0/0 with colors: light green #98FB98..."
152## Example 3: Hex Pattern Search
153User:
"Find all chests in the ROM"
1551. hex-search --pattern=
"20 ?? ??" (
chest object code 0x20)
1562. For each match, hex-read context bytes
1573. Parse room numbers from addresses
158Result:
"Found 50 chests across 30 rooms..."
160## Example 4: Complex Edit Planning
161User:
"Add a new enemy to room 5"
1631. dungeon-describe-room --room_id=5 (check current sprites)
1642. resource-list --type=sprite (available enemies)
1653. todo-create --title=
"Add sprite to room 5" --steps=
"find_sprite,get_coords,write_data"
1664. hex-read --address=<room_5_sprite_addr> (check free slots)
1675. Submit proposal with hex-write
171std::string AgentPretraining::GeneratePretrainingPrompt(Rom* rom) {
172 std::string prompt = "# Agent Pre-Training Session\n\n
";
173 prompt += "You are being initialized with deep knowledge about this ROM.\n\n
";
175 if (rom && rom->is_loaded()) {
176 prompt += absl::StrFormat("## Current ROM: %s\n
", rom->title());
177 prompt += absl::StrFormat("Size: %zu bytes\n
", rom->size());
178 prompt += absl::StrFormat("Type: %s\n\n
", rom->is_expanded() ? "Expanded
" : "Vanilla
");
181 for (const auto& module : GetModules()) {
182 prompt += absl::StrFormat("## Module: %s\n
", module.name);
183 prompt += module.content;
184 prompt += "\n---\n\n
";
188## Your Capabilities After Training
191✓ ROM memory layout and addressing
192✓ How to chain tools for complex analysis
193✓ Hex pattern recognition and data structures
194✓ GUI automation for map editing
195✓ Proposal system for safe ROM modification
197**Test your knowledge**: When I ask about sprites, dungeons, or tiles,
198use multiple tools in one response to give comprehensive answers.