Bench
Measuring the computer player.
The demo bot carries a dozen interacting constants -- how wide a bomb has to pass to count as a threat, what standing in cover costs, how long it holds one judgement, when it stops tidying the flanks -- and none of them can be reasoned about reliably in isolation. Widening the threat corridor from 30px to 60px cut deaths sixfold, which no amount of reading the code would have suggested. A more sophisticated dodge, which predicted where the cannon would be when each bomb landed, measured worse at every tuning.
So the constants get measured, not argued about, and this is what does the measuring. Run
it with bin/bench.
The measurement itself is pure: one discharges Game.step's Sound effect with
Sound.runWithNoOp, and the bot is a pure function of the world and its own hand. Given a
tuning and its fixed seeds, the benchmark is an ordinary fold with reproducible results.
Enums
| Flag | What the user asked for. |
Definitions
Runs the benchmark across the standard set of test seeds.
Runs the benchmark across the given list of test seeds.
Returns the highest level reached across all benchmark runs.
How long a game may run before it is cut short.
Generous: a good game ends on its own in well under this, and a benchmark that stops games itself is measuring its own budget.
Returns total player deaths across all benchmark runs.
Aggregates endgame statistics across all benchmark runs.
How many games ended with the formation landing rather than the lives running out.
Measures the demo player, and optionally searches for better numbers.
Mean level, in tenths, so it can be reported without floating point.
A single number for a tuning, so candidates can be ranked.
Mean level dominates, because clearing formations is what the game is. The worst seed breaks ties, and it earns its place: more than one tuning has lifted the mean while dropping a seed two levels, and a demo that collapses one game in six looks broken rather than fallible. Deaths break the remaining ties -- of two tunings that reach the same levels, prefer the one that is not being hit.
Plays one whole game and reports what happened.
The stopping condition is the same for every run -- the game ends, or the budget does. Nothing is allowed to stop early on a condition that a change under test could itself affect. Stopping at "level 2 reached" is how a measurement of bunker damage once reported every bunker perfectly intact: levels reset the bunkers, so the probe was sampling the state immediately after the reset.
A run that ends on the budget is reported as unfinished rather than as a result: it was
interrupted, not measured. See unfinished.
How far the cannon walked, and how long it took, per invader killed in the endgame.
The pair is the point. A change that makes the bot walk less is only an improvement if it does not take longer to kill: down-weighting hard-to-reach targets once cut pixels per kill from 139 to 130 while raising ticks per kill from 72 to 76, and was rejected on exactly that reading. Both are rates, so neither can be flattered by a shorter game.
Nought when nothing was killed, which is the honest answer to a ratio with no denominator -- an infinity here would sort as the best run ever measured.
A count per ten thousand ticks of play, in tenths.
Always compare rates. Two configurations that end their games at different times cannot be compared on totals, and the difference in when they end is usually the very thing being measured.
Per ten thousand rather than per thousand, and in tenths, because of the rarest event that matters. Deaths run at about four across seventy-eight thousand ticks; per thousand in tenths that prints as 0.0, which is what a bot dying twenty-four times also printed before it was fixed. A scale that cannot show the improvement it was built to detect is no better than no scale.
count per 10 000 ticks, in tenths.
Widened to Int64 for the multiplication, which is not defensive: count * 100000
leaves Int32 above 21 474, and a sixty-seed run of the shipped bot reports 24 871
kills. It printed as -277.-8 per 10 000 ticks -- visibly broken, which was luck. An
overflow a little smaller would have printed a plausible number instead.
Improves one parameter at a time, keeping any change that scores better.
Coordinate descent rather than anything cleverer, because the expensive part is playing the games and the surface is not smooth enough for gradients to mean much. Each parameter is offered a few multiples of its current value; the best wins and the search moves on carrying that improvement.
Bounded and deterministic: the same build searches the same way every time, so a
--recalc can be repeated and checked.
The merit of a tuning over the standard seeds, which is what the search maximises.
Always the same seeds, so two tunings are compared on the same games rather than on
their luck. bin/bench --wide then plays a set that shares no seed with this one, and
that is what a claim has to survive: a win here alone may only mean the tuning has been
fitted to these ten games.
The seeds a run reports on.
Fixed, and more of them than feels necessary. Bomb luck moves a single seed by two whole levels, so a change measured on three seeds is measuring noise -- and the temptation, having got a pleasing number, is to stop.
Returns the total ticks elapsed across all benchmark runs.
How many games hit the budget instead of finishing, which invalidates the run.
Sixty seeds, for deciding rather than for iterating.
Ten games separate things that differ by a level. They do not separate things that differ by a third of one, which is the size of every honest improvement this bot has had -- and on the ten above, the narrowing rule scores 4.6 against a 4.9 baseline while on these it scores 4.95 against 4.52. A change adopted on ten seeds was adopted on a coin toss.
Two families rather than one long run of a single multiplier, so a result cannot be an
artifact of how the seeds were generated. They are deliberately not the ten above: the
recorded figures in docs/ARCHITECTURE.md are on those, and a sample that quietly
changed underneath them would make every number in that file incomparable.