Skip to content

Instantly share code, notes, and snippets.

@asyncanup
Created March 23, 2026 07:58
Show Gist options
  • Select an option

  • Save asyncanup/405bfbe79524e47316a30324c5596e1d to your computer and use it in GitHub Desktop.

Select an option

Save asyncanup/405bfbe79524e47316a30324c5596e1d to your computer and use it in GitHub Desktop.
Work & Energy Level Designer — Design Conversation (GDD-345)

Work & Energy Level Designer — Design Conversation

Starting Point

User: Read this issue, download the images, understand the game design, and make a tool for designing levels: https://linear.app/notabot/issue/GDD-345/game-for-work-energy-and-force


Understanding the Game (from GDD-345)

Game concept: An isometric-view 2D physics puzzle game where:

  • An invisible character has an energy meter (vertical bar: blue = current energy, green arrow = target)
  • Goal: reach a specific target energy level through actions that are energy sinks or sources
  • Core physics: Work = Force x Distance, and friction requires more force

Level designs from the mockups:

  • Level 1: Box near wall. Pushing into wall = no work (blocked). Pulling away = energy decreases. Teaches that work requires displacement.
  • Level 2: Two surfaces (blue=smooth, red=rough). Pulling over smooth doesn't drain enough energy; rough surface does. Teaches friction.
  • Level 3: Adding a ramp as a third path. Ramp requires more Force x Distance = more work = more energy drain. Teaches combined concepts.

Game Idea Mockup

Game idea showing energy meter with start and done states

Level 1 — Push vs Pull

Level 1 showing box near wall with push/pull mechanics

Level 2 — Friction Surfaces

Level 2 showing smooth and rough surfaces

Level 3 — Ramp

Level 3 showing ramp as third path option


Design Phase

Claude: What form should this level design tool take?

  1. Interactive HTML canvas tool
  2. Extend the existing matplotlib approach
  3. Both

User: Interactive HTML canvas


Claude: What objects should the level designer be able to place?

User: Let's keep to box, wall, start point, destination point, and friction surfaces for now. Starting energy level is the target energy to finish (so reach destination point at 0 energy left). No max moves beyond that.


Claude: How should the isometric grid work?

  1. Top-down 2D grid (simpler, more usable)
  2. Isometric grid in the editor

User: Top down is fine for level design


Claude: What should the output format look like? (proposed JSON structure)

User: Sure


Claude: Presented the full design summary.

User: Looks good


First Implementation

Built the initial level designer as a single HTML file with:

  • Left palette (Select, Start Point, Destination, Box, Wall, Friction Surface, Eraser)
  • Center canvas grid
  • Right properties panel
  • JSON export/import
  • LocalStorage persistence

Major Redesign — Graph Model

User: Wall should have been a barrier between vertices (should delete an edge in the graph), and X (forbidden cell, should delete a vertex in the graph). Make friction surface be represented by vertex weight of integers 1 to 5. Add a Calculate button that produces the histogram showing number of paths available by total energy used. Don't need a box separately, start is where box is placed. This is just a weighted graph walking problem.

Claude: Rewrote the entire tool with the new graph-based model:

  • Cells = vertices with weight 1-5 (energy cost to traverse)
  • Adjacencies = edges (removable via walls)
  • Forbidden (X) = deleted vertices
  • Total energy = sum of vertex weights along path
  • Wall tool detects clicks near grid lines between cells (edge detection)
  • Calculate Paths runs DFS to find all simple paths, shows histogram

Iterative Refinements

User: Calculation seems off by 1. Include only S in the path weights, not E.

Claude: Fixed — destination vertex weight excluded from path cost.


User: Turn the histogram oriented sideways (joules on the bottom, bar height as number of paths).

Claude: Rewrote histogram to vertical bars with energy on X-axis, path count on Y-axis.


User: Provide a way to see the paths themselves, maybe allow clicking on the histogram bars which opens a horizontally scrollable panel of visual icons showing the different paths, clicking on whom would update the main grid with that path (arrows to show motion through the vertices).

Claude: Added three-level drill-down:

  1. Histogram — click a bar to select an energy bucket
  2. Path browser — horizontally scrollable panel of mini canvas thumbnails showing each path
  3. Main grid overlay — gold arrows showing the selected path's route through vertices

User: Call the forbidden X — obstacles instead. So walls (edge barriers) and obstacles (deleted vertices).

Claude: Renamed "Forbidden (X)" to "Obstacle (X)" in all UI text.


User: Color the histogram bars with smallest value as greenest and largest value as reddest going through yellow for the middle.

Claude: Implemented continuous green-yellow-red gradient based on path count:

  • Green = fewest paths (hardest for player)
  • Yellow = middle
  • Red = most paths (easiest)

User: Need to scale up histogram bar height more, they're all showing as a thin bar.

Claude: Switched from percentage-based heights to pixel heights (8px min, 90px max).


Deployment

User: Move the level-designer.html file to ~/src/website/public/tools/work-energy-level-designer.html

Claude: Moved the file.


User: Commit, pull, push ~/src/website

Claude: Committed as "Add work energy level designer tool", rebased on latest main, pushed.


Linear Issue Update

User: Update the linear issue with a link to the tool and a screenshot.

Claude: Posted comment on GDD-345 with link to https://notabot.ai/tools/work-energy-level-designer.html, features list, and technical description.


Final Rename

Renamed "Start Energy" to "Target Work" in the tool's UI labels, committed and pushed.


Final Tool

Deployed at: notabot.ai/tools/work-energy-level-designer.html

Key Design Decisions

  1. Weighted graph model — The entire game reduces to a graph problem: cells are vertices with integer weights, adjacencies are edges. Walls delete edges, obstacles delete vertices. Energy cost = path weight.

  2. Edge click detection — The wall tool detects mouse proximity to internal grid lines (within 12px threshold), determining which two cells a line separates. This gives a natural "click between cells" interaction.

  3. All-paths DFS — Enumerates all simple paths (no revisiting vertices) via DFS with backtracking. For typical level sizes (up to 8x8) this is tractable. Capped at 50k paths for safety.

  4. Green-to-red histogram — Colors encode difficulty: green bars (fewest paths) represent energy values that are hardest for the player to achieve, making them ideal targets for level design.

  5. Single-file HTML — No dependencies, no build step. Vanilla JS + Canvas API. Runs anywhere, instantly shareable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment