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

1.6 KiB
Raw Blame History

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