Lucky Lenny Learning

The Price of a Decision

The Story

A game-playing program can make a decision quickly, or spend more computation trying to make a better one. But when does the extra thinking pay for itself? Imagine a program that answers “bank” or “roll” with a tiny rule, another that consults a table learned from practice, and a third that simulates possible next rolls. The central question is practical: how many decisions per second does each tool deliver on this machine, and when does the slowest one earn its keep?

This chapter is for Computer Architecture students, and for anyone curious about how software turns processor time into a choice. A decision here is one call to a strategy after a successful roll. The timing is local: it describes how this Python program behaved on the author's machine. Those measurements are machine-dependent and are not reproducible values or universal speed rankings.

Dragnet: Just the Facts

One game, one track

This chapter uses the classroom track, farkle-classroom-v1, implemented in src/farkle_ml. All scoring dice are kept automatically. After a scoring roll, the strategy's only choice is to bank or roll. This is not the research game in game_mechanics, where players choose which scoring dice to keep. The two tracks answer different questions, and their results must not be combined.

The script compares three kinds of work:

For each strategy, the script times repeated calls on the same public state using Python's high-resolution perf_counter. It reports the median of five batches. The decision rate is the reciprocal of seconds per decision. A log10 ladder makes large speed gaps easier to see: a difference of one means ten times as many decisions per second.

Speed alone is not usefulness. The script also pits each method against bank_at_300 using three fixed seeds, the same number of games for each seed, and alternating starting positions. It reports the strategy's win fraction and Wilson 95% interval. The interval is a range expressing sampling uncertainty in that fraction. If it includes 50%, the output labels the result tie; this means the run does not separate the win rate from 50%, not that the strategies have been proven equal.

The learner has a one-time cost. The run reports preparation time and average game-time saved relative to bank_at_300; both are machine-dependent and are excluded as reproducible claims here. The script calculates break-even games as preparation time divided by time saved per game. If the learner does not save time in that run, it reports no finite break-even count. This is a runtime comparison, not a claim that the learner wins more often.

The local-model records come from a different host and workload. Their timings and derived calls-per-second are machine-dependent and excluded as reproducible claims here; they cannot be compared as controlled benchmarks against the local timings.

One real surprise from repository work came from the energy sampler. Its tests and security review had passed, but its first run on a real machine stopped at PRECHECK: no RAPL zones found. The host represented powercap entries as symlinks, and the directory walk did not follow them. The test fixtures had missed the real layout. This is a reminder that a clean test result does not establish performance or behavior on a different machine; measurement needs a faithful setup.

Evidence table

The following run was made in this worktree on the machine running the authoring session. Timing values describe this machine only. Win intervals are Wilson 95% intervals calculated by the script. They all include 50%, so none separates the strategy from an even win rate in this small run.

ClaimVALUECommitted source path or reproducing commandCommit read from
Classroom benchmark rule identity and targetfarkle-classroom-v1; default target 4000docs/rules.md; src/farkle_ml/engine.pye108e57; ec66eb1
Classroom decisions are bank or roll after automatic scoringbank / roll; no keep choicedocs/rules.md; src/farkle_ml/engine.pye108e57; ec66eb1
Compared strategies and rollout sizesbank_at_300; learner table; rollout 1, 10, 25, 100, 400src/farkle_ml/strategies.py; capstone/curriculum/examples/decision_price_ladder.py1317d54; this branch (pin at merge), branch flo/ch-c13
Number of timing batches5; median reportedcapstone/curriculum/examples/decision_price_ladder.pythis branch (pin at merge); branch flo/ch-c13
Training repetitions for the default run2000 learner turnscapstone/curriculum/examples/decision_price_ladder.pythis branch (pin at merge); branch flo/ch-c13
Comparison seed bundle13001, 13002, 13003; 4 games per seed, 12 totalcapstone/curriculum/examples/decision_price_ladder.pythis branch (pin at merge); branch flo/ch-c13
One-run decision time and rateMachine-dependent; typical on the author's machine, will differ; not reproducible and excluded from claimspython3 capstone/curriculum/examples/decision_price_ladder.pythis branch (pin at merge); branch flo/ch-c13
Win counts and Wilson 95% intervals vs bankat300bank 7/12, [0.3195, 0.8067]; learner 5/12, [0.1933, 0.6805]; rollout 1 5/12, [0.1933, 0.6805]; 10 8/12, [0.3906, 0.8619]; 25 9/12, [0.4677, 0.9111]; 100 7/12, [0.3195, 0.8067]; 400 5/12, [0.1933, 0.6805]. All labelled tie because intervals contain 50%.python3 capstone/curriculum/examples/decision_price_ladder.pythis branch (pin at merge); branch flo/ch-c13
Learner preparation, saved game time, and break-evenPreparation and saved-time values are machine-dependent; typical on the author's machine, will differ; not reproducible and excluded from claims. The script reports no finite break-even when the measured learner game time is not lower.python3 capstone/curriculum/examples/decision_price_ladder.pythis branch (pin at merge); branch flo/ch-c13
Local-model practice records (not a controlled benchmark)Machine-dependent timing and derived calls-per-second are excluded from claims; different host and workloadartifacts/three_games_v1/farkle_practice/gemma3_12b.json; artifacts/three_games_v1/farkle_practice/qwen3_5_9b.json4fe0254 (both JSON files, from origin/main)
Sampler first real-run surprise and causePRECHECK: no RAPL zones found; /sys/class/powercap entries were symlinks and os.walk(followlinks=False) skipped themsidecar/reports/workflow-notes/sasha.md2dfa396

The Scripted Journey

From the repository root, run:

python3 capstone/curriculum/examples/decision_price_ladder.py

The script uses only the Python standard library in addition to this repository's classroom strategy package. It prints the five-repeat median cost, decisions per second, the log10 ladder, the three-seed win comparison, preparation time, and measured learner break-even estimate. Timing and preparation outputs are typical on the author's machine, will differ, and are not reproducible; do not treat them as claims. --quick runs a smaller deterministic smoke comparison:

python3 capstone/curriculum/examples/decision_price_ladder.py --quick

Look first at the fastest and slowest decision rates. Then compare the rollout win intervals with the time they cost. Ask whether a larger rollout changes outcomes enough to justify its added computation. Finally, inspect learner preparation and saved game time as machine-dependent outputs: a table that is quick to consult may still need many games to repay its training cost.

What you can now do: distinguish decision time from preparation time, estimate decisions per second, read a Wilson interval without treating overlap as proof of equality, and estimate a learner's runtime break-even point. Which amount of extra computation would you choose for a game whose decision must arrive before a strict deadline? Make your own prediction, then run the script and see whether its evidence changes it.