math-tasks/tasks/space-route/CLAUDE.md

44 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Space Route Task Type
Navigate hex graph routes: player and enemy ships travel through a node graph. Child finds a path by following mathematical constraints between connected nodes.
## Generation
Generator script: `scripts/generate-route.mjs`
### Grid Rules
- 7×9 hex grid with jitter, nodes evenly distributed across map area
- Start nodes: Enemy = top-left corner, Player = bottom-left corner
- Start nodes trimmed to exactly 2 edges
### Route Rules
- No asteroids/decorations on route nodes or neighbors of start nodes
- Routes use waypoints: route goes toward an offset waypoint for ~40% of steps, then changes direction toward final target (prevents straight-line paths)
- Route length: 7-9 steps for enemy, player gets 10 empty cells
- Ship orientation: check each ship image and set `flipEnemy`/`flipPlayer` flags so ships face right
### Difficulty
- `diffRange: [minNodeValue, maxSpread]`
- First number = minimum node value
- Second = max |difference| between connected neighbors
## Scripts
- `scripts/generate-route.mjs` — full page generation (grid, edges, values, routes, HTML)
- `scripts/apply-edits.mjs` — apply editor JSON back to HTML (regex-based style replacement)
## Editor
`editor.html?file={docId}` — two edit modes:
**Objects mode** (default): drag space icons, edges auto-follow
**Nodes mode** (press M): Shift+click nodes, drag to reposition graph
Key controls:
- `M`: toggle Objects/Nodes mode
- `R`: toggle enemy route highlight
- `H`: flip selected object horizontally
- `+/-`: resize proportionally
- `[/]`: rotate ±5°
- Save: writes to `docs/{docId}.data.json`