diff doc/balance.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/balance.md	Tue Oct 20 03:08:56 2026 +0200
+++ b/doc/balance.md	Tue Oct 20 12:04:42 2026 +0200
@@ -48,20 +48,27 @@
 monsters
 --------
 
-| monster | hp | coins | speed | source |
-|---------|----|-------|-------|--------|
-| m0      | 5  | 1     | 35    | hp, coins: notes; speed: guess |
-| m1      | 10 | 2     | 40    | as above |
-| m2      | 15 | 3     | 45    | as above |
-| m3      | 20 | 4     | 40    | as above |
-| m4      | 30 | 6     | 35    | as above |
-| b0      | 150 | 30   | 25    | hp: decided, 5 x the notes; coins: notes; speed: guess |
-| b1      | 250 | 50   | 25    | as above |
-| b2      | 350 | 70   | 25    | as above |
-| b3      | 500 | 100  | 25    | as above |
+| monster | hp | coins | coins per hp | speed | source |
+|---------|----|-------|--------------|-------|--------|
+| m0      | 5  | 1     | 0.20         | 35    | hp, coins: notes; speed: guess |
+| m1      | 10 | 1     | 0.10         | 40    | hp: notes; coins: decided (was 2); speed: guess |
+| m2      | 15 | 2     | 0.13         | 45    | hp: notes; coins: decided (was 3); speed: guess |
+| m3      | 20 | 2     | 0.10         | 40    | hp: notes; coins: decided (was 4); speed: guess |
+| m4      | 30 | 3     | 0.10         | 35    | hp: notes; coins: decided (was 6); speed: guess |
+| b0      | 150 | 30   | 0.20         | 25    | hp: decided, 5 x the notes; coins: notes; speed: guess |
+| b1      | 250 | 50   | 0.20         | 25    | as above |
+| b2      | 350 | 70   | 0.20         | 25    | as above |
+| b3      | 500 | 100  | 0.20         | 25    | as above |
 
-monsters and bosses drop 0.2 coins per hp (derived). the notes gave bosses
-hp equal to their coins; balancing raised it to 5 times that (decided).
+monster hp is the same on every map (decided). a monster that took two hits
+on one map must not take four on a later one. a map gets harder through the
+size of its waves and the mix of monsters.
+
+the notes had every monster drop 0.2 coins per hp. regular monster coins are
+now set apart from hp (decided): m0 keeps 0.2, the others drop 0.10 to 0.13.
+the mix of monsters then sets the coins per hp of a map. the notes gave
+bosses hp equal to their coins; balancing raised it to 5 times that
+(decided).
 
 time to walk the whole path at 35-45 speed (derived): map0 about 50 s, map3
 about 23 s.
@@ -107,8 +114,7 @@
   divided by the reference speed, limited to -1..1
 - route weight = 1 + bias * speed factor * (2 * route value - 1), at least 0.1
 - a monster at the reference speed sees all routes as equally likely
-- a boss always takes the shortest route (decided). a route with a fixed
-  weight of 0 is left out
+- a boss always takes the shortest route (decided)
 
 | parameter       | value | source |
 |-----------------|-------|--------|
@@ -222,41 +228,35 @@
 economy
 -------
 
-| map  | starting coins | coins dropped in total | boss coins | regular monster coins | regular monster hp |
-|------|----------------|------------------------|------------|-----------------------|--------------------|
-| map0 | 10             | 100                    | 30         | 70                    | 350                |
-| map1 | 20             | 200                    | 50         | 150                   | 750                |
-| map2 | 40             | 400                    | 70         | 330                   | 1650               |
-| map3 | 60             | 600                    | 100        | 500                   | 2500               |
+| map  | starting coins |
+|------|----------------|
+| map0 | 10             |
+| map1 | 20             |
+| map2 | 40             |
+| map3 | 60             |
 
-starting coins and the 10 x starting coins total are from the notes; the rest
-is derived. early wave bonuses come on top of this total.
-
-the source sheet gives 50 starting coins for map3. the notes raise it to 60 to
-make the step from map1 to map3 more even (10, 20, 40, 60 instead of 10, 20,
-40, 50). likely to change after playtesting.
-
-share of the regular monster coins by monster level (guess). all monster
-levels appear on all maps (decided):
+starting coins are from the notes. the source sheet gives 50 for map3. the
+notes raise it to 60 to make the step from map1 to map3 more even (10, 20,
+40, 60 instead of 10, 20, 40, 50). likely to change after playtesting.
 
-| map  | m0   | m1   | m2   | m3   | m4   |
-|------|------|------|------|------|------|
-| map0 | 40 % | 25 % | 15 % | 10 % | 10 % |
-| map1 | 30 % | 25 % | 20 % | 15 % | 10 % |
-| map2 | 20 % | 20 % | 20 % | 20 % | 20 % |
-| map3 | 15 % | 15 % | 20 % | 25 % | 25 % |
+the notes set the coins dropped per map to 10 times the starting coins. this
+is no longer a target (decided): the coins a map pays follow from its waves.
+the build prints, per map, the coins dropped by regular monsters and the
+boss, the total with the starting coins, and the coins per hp of the regular
+monsters.
 
-resulting monster counts (derived, rounded):
+coins per map from the current wave lists (derived):
 
-| map  | m0 | m1 | m2 | m3 | m4 | monsters | coins |
-|------|----|----|----|----|----|----------|-------|
-| map0 | 28 | 9  | 4  | 2  | 1  | 44       | 72    |
-| map1 | 45 | 19 | 10 | 6  | 2  | 82       | 149   |
-| map2 | 66 | 33 | 22 | 16 | 11 | 148      | 328   |
-| map3 | 75 | 38 | 33 | 31 | 21 | 198      | 500   |
+| map  | regular monsters | boss | dropped in all | with starting coins | regular hp | coins per hp |
+|------|------------------|------|----------------|---------------------|------------|--------------|
+| map0 | 48               | 30   | 78             | 88                  | 395        | 0.12         |
+| map1 | 139              | 50   | 189            | 209                 | 1145       | 0.12         |
+| map2 | 326              | 70   | 396            | 436                 | 2615       | 0.12         |
+| map3 | 157              | 100  | 257            | 317                 | 1160       | 0.14         |
 
-the build prints these totals from the actual wave lists and warns when a map
-is more than 5 % off its coin total.
+early start bonuses come on top.
+
+all monster levels appear on all maps (decided).
 
 
 waves
@@ -266,17 +266,58 @@
 |------------------------------------|---------------------|--------|
 | waves per map                      | 6, 8, 10, 12        | guess  |
 | break before the first wave        | 40 s                | guess  |
-| break between waves               | 25 s                | guess ("longer", decided) |
-| time between spawns               | 1.0, 1.0, 0.8, 0.7 s by map | guess |
+| break between waves, from the last spawn of a wave | 25 s | guess ("longer", decided) |
+| time between spawns               | 1.0, 0.65, 0.65, 0.5 s by map | guess, fitted in the simulation |
 | early start bonus, coins per second left | 0.05, 0.1, 0.2, 0.3 by map | guess (starting coins / 200) |
 
 the bonus is rounded down. if every break is skipped at once, the bonus adds
 about 6, 17, 45 and 82 coins per map (derived).
 
-suggested shape of a map's waves (guess): the coin value of wave n grows in
-proportion to n, so the last wave is the largest. the boss comes in the last
-wave and spawns first. later waves mix monster levels; early waves are mostly
-m0 and m1.
+shape of a map's waves (decided): each wave is at least as hard as the one
+before, and the last wave is the largest. the boss comes in the last wave and
+spawns first. early waves are mostly m0 and m1; later waves mix monster
+levels.
+
+the wave lists in the config are drafted by tools/balance.py
+(architecture.md) from a few numbers per map, and may be edited by hand
+afterwards:
+
+- the number of waves
+- the number of regular monsters in the first and in the last wave. the waves
+  between grow in equal steps
+- the share of each monster level in the map's regular monsters, by count
+- the wave in which each monster level first appears
+
+each monster level gets a weight per wave that grows by one per wave from its
+first wave. the weights are scaled until the wave sizes and the shares are
+met, then rounded to whole monsters per wave. later waves therefore hold more
+of the levels that came in late. every level keeps at least one monster.
+
+the draft numbers are kept in the map's section of the config, next to the
+other map settings. the game does not read them.
+
+draft numbers, fitted in the simulation to the targets in balancing
+(guess):
+
+| map  | waves | regular monsters, first and last wave | share by count, m0-m4 | first wave of m0-m4 |
+|------|-------|-----------------|---------------------|---------------|
+| map0 | 6     | 4, 7            | 36, 25, 18, 12, 9 % | 1, 2, 2, 4, 5 |
+| map1 | 8     | 6, 17           | 36, 25, 18, 12, 9 % | 1, 2, 3, 5, 6 |
+| map2 | 10    | 10, 36          | 39, 26, 17, 11, 7 % | 1, 2, 4, 6, 8 |
+| map3 | 12    | 5, 16           | 52, 26, 13, 6, 3 %  | 1, 2, 4, 6, 9 |
+
+resulting monster counts (derived):
+
+| map  | m0 | m1 | m2 | m3 | m4 | regular monsters |
+|------|----|----|----|----|----|------------------|
+| map0 | 12 | 9  | 5  | 4  | 3  | 33               |
+| map1 | 32 | 22 | 17 | 12 | 9  | 92               |
+| map2 | 90 | 59 | 39 | 27 | 15 | 230              |
+| map3 | 65 | 33 | 17 | 8  | 3  | 126              |
+
+map3 has fewer and weaker monsters than map2. its 60 starting coins already
+pay for much of what the naive player needs against b3, so the waves before
+may pay only about 130 coins (see balancing).
 
 
 hearts
@@ -298,7 +339,8 @@
 | most coin sprites for one death  | 8     | guess  |
 
 coins are added to the counter at the moment the monster dies; the flying
-coins only show it (guess). this keeps the counter correct for a player who
+coins only show it (guess). the same holds for an early start bonus, whose
+coins fly from the exits. this keeps the counter correct for a player who
 builds right after a kill.
 
 
@@ -313,9 +355,9 @@
 balancing
 ---------
 
-the values above were set without a way to estimate their effect, and the
-game is far too easy. two t1 towers win every map, t2 is never needed, and
-many coins are left over when a map is won. the aim is a game where the
+the first values were set without a way to estimate their effect, and the
+game was far too easy. two t1 towers won every map, t2 was never needed, and
+many coins were left over when a map was won. the aim is a game where the
 player has to think about where to place towers and which ones to build. a
 player who only buys plain firepower should need nearly every coin a map
 pays in order to win it. coins left over then come from better choices.
@@ -336,9 +378,11 @@
   attack times
 - shop prices are set first. hp, damage and the wave mix are then fitted to
   them
-- the main control is coins per hp. regular monsters drop 0.2 coins per hp,
-  so a map's difficulty and its income grow together. a map gets harder when
-  its hp go up while its coins stay the same
+- the main control is coins per hp, set by the mix of monsters. m0 drops
+  0.2 coins per hp, the other regular monsters 0.10 to 0.13. a mix with
+  fewer m0 pays less for the same hp
+- monster hp stays the same on every map. wave size and the mix make a map
+  harder
 
 the coins of the last wave, the boss's included, arrive when the map is as
 good as won. leftover coins are therefore measured at the start of the last
@@ -402,13 +446,45 @@
 level 1 reaches 0.67 against a single target, kills an m0 in one hit and
 damages every monster in range. it may be the better buy for a naive
 player than t1, so the calculation lists value per coin for every tower and
-level, area damage included.
+level, area damage included. the simulation measures 1.2 to 1.7 monsters
+hit per t0 attack over whole runs, on median cells as on the best ones.
+at that rate t0 at level 1 gives 0.8 to 1.1 against m0, two to three times
+t1.
 
 t2 works as a time multiplier. a slow to 0.6 of the speed gives 1.67 times
 the time in range for every tower covering the same stretch. this only
 helps against the single target demand, so t2 needs faster monsters or
 tough monsters spaced apart to pay off. it is tuned after the t1 baseline.
 
+tools/simulate.js (architecture.md) plays the same two players in the game
+code. with the fitted waves, the two tools agree on the coins on hand at
+each wave. they differ in the coins a wave needs:
+
+- the boss needs 5 to 20 % more in the simulation: 49, 143, 338 and 206
+  coins for the naive player against 40, 130, 320 and 170 in the
+  calculation. faster monsters overtake the boss and draw fire away from it
+- regular waves on map2 need up to 1.5 times as much. towers on median
+  cells cover the six routes unevenly, and monsters on a route with little
+  cover get through. the mean over routes hides this
+- about a tenth of the shots are lost because the target died before the
+  projectile arrived
+- route preference changes nothing: with bias 0 the results are the same,
+  since the speeds lie close to the reference speed
+- the players in the simulation also build during a wave, with coins from
+  the monsters killed in it
+
+tools/balance.py was left as it is. the waves were fitted with the
+simulation.
+
+with the fitted waves the naive player loses hearts to regular monsters
+only in the first two or three waves. towers stay and add up. what a wave
+demands, hp arriving per second, follows from the mix and the spawn
+interval; wave size sets how long the wave lasts and what it pays. the boss
+is the one demand that grows faster than the coins. the naive player loses
+its hearts there, 5 at once, in most runs. the target of about 5 hearts
+left is met on average over the seeds: the boss gets through in most runs
+and dies in a few.
+
 order of work (decided):
 
 1. the calculation, tools/balance.py (architecture.md): value per coin for