wobblyhead hg > minor_monsters
comparison doc/architecture.md @ 23:2f555a54c332
layout fixes and balancing
| author | ark |
|---|---|
| date | 2026-10-20 12:04 +0200 |
| parents | ad1b478fc4dc |
| children | 3f2811aebb3d |
comparison
equal
deleted
inserted
replaced
| 22:ad1b478fc4dc | 23:2f555a54c332 |
|---|---|
| 19 art/ drawings as supplied: scans, masks, sprites | 19 art/ drawings as supplied: scans, masks, sprites |
| 20 sound_sources/ voice recordings as supplied | 20 sound_sources/ voice recordings as supplied |
| 21 sounds/ sounds cut from the recordings (tools/cut_sounds.py) | 21 sounds/ sounds cut from the recordings (tools/cut_sounds.py) |
| 22 config/ hand-edited game settings (toml) | 22 config/ hand-edited game settings (toml) |
| 23 game.toml numbers from balance.md, waves, debug switches | 23 game.toml numbers from balance.md, waves, debug switches |
| 24 routes.toml manual corrections to the extracted routes | |
| 25 tools/ python build scripts | 24 tools/ python build scripts |
| 26 game/ hand-written game files | 25 game/ hand-written game files |
| 27 index.html | 26 index.html |
| 28 style.css | 27 style.css |
| 29 js/ game code | 28 js/ game code |
| 153 coverage of each tower's range, and per wave the coins on hand, the | 152 coverage of each tower's range, and per wave the coins on hand, the |
| 154 damage rate both demands need and the coins the naive and greedy players | 153 damage rate both demands need and the coins the naive and greedy players |
| 155 need to hold the wave | 154 need to hold the wave |
| 156 - balance_value.png: value per coin by tower level | 155 - balance_value.png: value per coin by tower level |
| 157 - balance_map0.png to balance_map3.png: coins per wave, and the surplus at | 156 - balance_map0.png to balance_map3.png: coins per wave, and the surplus at |
| 158 the last wave and the hearts left against a factor on all monster hp | 157 the last wave and the hearts left against a wave size factor. the factor |
| 158 scales the number of regular monsters in every wave; the coins they drop | |
| 159 follow | |
| 160 | |
| 161 `tools/balance.py --draft` prints wave lists made from the draft numbers in | |
| 162 each map's section of the config (balance.md, waves), as toml to paste over | |
| 163 the map's [[map.N.wave]] lists. `--draft 2` does map2 only. below each map | |
| 164 it prints what the calculation makes of the drafted lists. nothing is | |
| 165 written in this mode. | |
| 159 | 166 |
| 160 tools/build.py does not count balance.py as one of its inputs, so changing | 167 tools/build.py does not count balance.py as one of its inputs, so changing |
| 161 it does not rebuild the game. | 168 it does not rebuild the game. |
| 162 | 169 |
| 163 a headless simulation will check the calculation. it runs the game logic | 170 tools/simulate.js checks the calculation by playing the real game logic |
| 164 from game/js/ in node, with MM.audio and MM.assets.size replaced by stubs, | 171 with scripted players. it is run by hand with node after a build: |
| 165 and plays the naive and greedy players. the seeded random generator makes a | 172 |
| 166 run repeatable. it is built after the calculation. | 173 node tools/simulate.js |
| 174 node tools/simulate.js --maps 2 --players naive,naive_t0 --seeds 10 | |
| 175 | |
| 176 it loads www/data/config.js, www/data/maps.js and the logic files util.js, | |
| 177 assets.js, map.js, monster.js, tower.js, projectile.js, wave.js and | |
| 178 game.js, as the browser would, with window set to the global object. | |
| 179 render.js, ui.js, input.js and main.js are left out. MM.audio is the only | |
| 180 stub; assets.js loads unchanged, since sprite sizes come from the config | |
| 181 and images are only loaded by main.js. the debug switches are forced off. | |
| 182 | |
| 183 the game advances in steps of 1/60 s, as in the browser; game speed plays | |
| 184 no part. each run has its own seed, passed to the game. the players build, | |
| 185 upgrade and start waves through the game's own functions (shop choice, | |
| 186 preview, build, tower selection, upgrade, early start), so placement rules | |
| 187 and prices are the game's. the players and their rules are listed at the | |
| 188 top of the file; naive and greedy follow balance.md, balancing, and pick | |
| 189 cells as tools/balance.py does, from the placement grid in maps.js. | |
| 190 | |
| 191 the coins a wave needs are measured by playing that wave alone from an | |
| 192 empty map with the first purchases of the player's list, and searching | |
| 193 for the fewest that lose no heart. every wave starts on an empty map in | |
| 194 the game, so this matches the wave in a full run, apart from towers | |
| 195 bought during the wave. | |
| 196 | |
| 197 it writes temp/preview/simulate.txt (per map and player: maps won, hearts | |
| 198 left, coins on hand and the surplus at the start of the last wave, hearts | |
| 199 lost per wave) and temp/preview/simulate.json, which tools/balance.py reads | |
| 200 for the hits per t0 attack. `--need all` measures the coins needed for | |
| 201 every wave, `--waves` takes wave lists from a json file in place of the | |
| 202 config's, for trying drafts without a build. | |
| 167 | 203 |
| 168 | 204 |
| 169 routes | 205 routes |
| 170 ------ | 206 ------ |
| 171 | 207 |
| 184 no junction twice | 220 no junction twice |
| 185 5. smooth each route and reduce it to a few points per bend | 221 5. smooth each route and reduce it to a few points per bend |
| 186 6. record length and turning for each route | 222 6. record length and turning for each route |
| 187 | 223 |
| 188 map0 and map3 give one route each. map1 and map2 give several; map2 may give | 224 map0 and map3 give one route each. map1 and map2 give several; map2 may give |
| 189 more than wanted. config/routes.toml can drop routes, set fixed weights, or | 225 more than wanted. where the automatic result is wrong, the mask is redrawn. |
| 190 replace a route with hand-placed points, for cases where the automatic result | |
| 191 is wrong. | |
| 192 | 226 |
| 193 the game walks a monster along the route's centre line, by distance, and | 227 the game walks a monster along the route's centre line, by distance, and |
| 194 draws it beside the line. the offset is set per monster at spawn | 228 draws it beside the line. the offset is set per monster at spawn |
| 195 (balance.md, monsters) and needs no route data from the build. when a map | 229 (balance.md, monsters) and needs no route data from the build. when a map |
| 196 loads, each route works out the sideways direction at its points and how far | 230 loads, each route works out the sideways direction at its points and how far |
| 273 - the canvas fills the window. the map is scaled to fit and centred, with | 307 - the canvas fills the window. the map is scaled to fit and centred, with |
| 274 borders where the shapes differ | 308 borders where the shapes differ |
| 275 - the canvas resolution follows the device pixel ratio, so drawings stay sharp | 309 - the canvas resolution follows the device pixel ratio, so drawings stay sharp |
| 276 on high-resolution screens | 310 on high-resolution screens |
| 277 - layout: top bar with coins, hearts, wave, countdown, sound, speed and | 311 - layout: top bar with coins, hearts, wave, countdown, sound, speed and |
| 278 pause. the | 312 pause. on a narrow screen the buttons move to a second row under the |
| 279 tower shop sits on the right in landscape and at the bottom in portrait | 313 counters. the tower shop sits on the right in landscape and at the bottom in portrait |
| 280 - buttons are at least 48 css pixels for touch | 314 - buttons are at least 48 css pixels for touch |
| 281 | 315 |
| 282 input: | 316 input: |
| 283 | 317 |
| 284 - pointer events cover mouse and touch alike | 318 - pointer events cover mouse and touch alike |
