diff doc/architecture.md @ 23:2f555a54c332

layout fixes and balancing
author ark
date 2026-10-20 12:04 +0200
parents ad1b478fc4dc
children 3f2811aebb3d
line wrap: on
line diff
--- a/doc/architecture.md	Tue Oct 20 03:08:56 2026 +0200
+++ b/doc/architecture.md	Tue Oct 20 12:04:42 2026 +0200
@@ -21,7 +21,6 @@
         sounds/         sounds cut from the recordings (tools/cut_sounds.py)
     config/         hand-edited game settings (toml)
         game.toml       numbers from balance.md, waves, debug switches
-        routes.toml     manual corrections to the extracted routes
     tools/          python build scripts
     game/           hand-written game files
         index.html
@@ -155,15 +154,52 @@
   need to hold the wave
 - balance_value.png: value per coin by tower level
 - balance_map0.png to balance_map3.png: coins per wave, and the surplus at
-  the last wave and the hearts left against a factor on all monster hp
+  the last wave and the hearts left against a wave size factor. the factor
+  scales the number of regular monsters in every wave; the coins they drop
+  follow
+
+`tools/balance.py --draft` prints wave lists made from the draft numbers in
+each map's section of the config (balance.md, waves), as toml to paste over
+the map's [[map.N.wave]] lists. `--draft 2` does map2 only. below each map
+it prints what the calculation makes of the drafted lists. nothing is
+written in this mode.
 
 tools/build.py does not count balance.py as one of its inputs, so changing
 it does not rebuild the game.
 
-a headless simulation will check the calculation. it runs the game logic
-from game/js/ in node, with MM.audio and MM.assets.size replaced by stubs,
-and plays the naive and greedy players. the seeded random generator makes a
-run repeatable. it is built after the calculation.
+tools/simulate.js checks the calculation by playing the real game logic
+with scripted players. it is run by hand with node after a build:
+
+    node tools/simulate.js
+    node tools/simulate.js --maps 2 --players naive,naive_t0 --seeds 10
+
+it loads www/data/config.js, www/data/maps.js and the logic files util.js,
+assets.js, map.js, monster.js, tower.js, projectile.js, wave.js and
+game.js, as the browser would, with window set to the global object.
+render.js, ui.js, input.js and main.js are left out. MM.audio is the only
+stub; assets.js loads unchanged, since sprite sizes come from the config
+and images are only loaded by main.js. the debug switches are forced off.
+
+the game advances in steps of 1/60 s, as in the browser; game speed plays
+no part. each run has its own seed, passed to the game. the players build,
+upgrade and start waves through the game's own functions (shop choice,
+preview, build, tower selection, upgrade, early start), so placement rules
+and prices are the game's. the players and their rules are listed at the
+top of the file; naive and greedy follow balance.md, balancing, and pick
+cells as tools/balance.py does, from the placement grid in maps.js.
+
+the coins a wave needs are measured by playing that wave alone from an
+empty map with the first purchases of the player's list, and searching
+for the fewest that lose no heart. every wave starts on an empty map in
+the game, so this matches the wave in a full run, apart from towers
+bought during the wave.
+
+it writes temp/preview/simulate.txt (per map and player: maps won, hearts
+left, coins on hand and the surplus at the start of the last wave, hearts
+lost per wave) and temp/preview/simulate.json, which tools/balance.py reads
+for the hits per t0 attack. `--need all` measures the coins needed for
+every wave, `--waves` takes wave lists from a json file in place of the
+config's, for trying drafts without a build.
 
 
 routes
@@ -186,9 +222,7 @@
 6. record length and turning for each route
 
 map0 and map3 give one route each. map1 and map2 give several; map2 may give
-more than wanted. config/routes.toml can drop routes, set fixed weights, or
-replace a route with hand-placed points, for cases where the automatic result
-is wrong.
+more than wanted. where the automatic result is wrong, the mask is redrawn.
 
 the game walks a monster along the route's centre line, by distance, and
 draws it beside the line. the offset is set per monster at spawn
@@ -275,8 +309,8 @@
 - the canvas resolution follows the device pixel ratio, so drawings stay sharp
   on high-resolution screens
 - layout: top bar with coins, hearts, wave, countdown, sound, speed and
-  pause. the
-  tower shop sits on the right in landscape and at the bottom in portrait
+  pause. on a narrow screen the buttons move to a second row under the
+  counters. the tower shop sits on the right in landscape and at the bottom in portrait
 - buttons are at least 48 css pixels for touch
 
 input: