Skip to content

Budget the army a player may deploy - #14

Merged
aburston merged 1 commit into
masterfrom
claude/add-a-point-budget-pb7k3q
Aug 25, 2026
Merged

aburston merged 1 commit into
masterfrom
claude/add-a-point-budget-pb7k3q

Conversation

@aburston

Copy link
Copy Markdown
Owner

Nothing bounded an army. A player defined types during setup and deployed as many units of them as there were free squares - add unit was refused for an unknown type, an occupied square, or coordinates off the board, and for nothing else. On a 10x10 board that is up to a hundred units, decided by who typed fastest.

Designing well was free too. attack 10 health 10 energy 100 was strictly better than attack 1 health 1 energy 10 and cost the same, which is to say nothing, so there was one type worth defining and every game converged on it. The three statistics are meant to be a trade, and a trade needs a currency.

Each player is now registered with a point budget - add player <number> [budget], 100 by default, 1 to 1000, fixed for the life of the game. A type costs the sum of its statistics, so add type Cross X 1 10 10 costs 21, and every unit deployed from it costs 21 again. A deployment the pool cannot pay for is refused, naming the cost, what is left, and the budget it is left out of; one that spends exactly what is left is allowed.

Three decisions shaped this more than the arithmetic did.

Cost is read from the design a unit was made from, not from the values play wears down. UnitType already kept type_attack/type_health/type_energy beside them, for the reason its comment gives - a unit's current health is not its type's health. Pricing from those means a damaged unit still costs what it cost, and a destroyed one is not free.

Spend is derived, never counted. It is summed off the board's unit list every time it is asked, the way game-outcome already derives who is eliminated. A running total is a second record of a fact the board holds, and the only thing a second record can do is drift: one not decremented when a deployment is refused, or decremented twice when a draft is replayed, is a budget that quietly stops matching the army.

One rule, two enforcers. domain/budget.py holds the arithmetic and the sentence both. The client refuses at add unit; turn resolution rejects through the existing rejection channel, because a loaded player file or a hand-written order file reaches the board without passing through a client. Where more deployments arrive in one turn than the budget buys, they are charged in unit-name order - list order is what the determinism invariant forbids a rule from depending on. A deployment already refused for a contested square is not charged: it never reaches the board, and charging it could push another of that player's units over a budget it actually fits inside.

Budget privacy needed no filter. A session already reads only the player records it is entitled to, so a Player built for an opponent carries budget = None and the views draw -, or null in JSON.

A stored player record with no budget is refused rather than defaulted, in both backends - including a SQLite database whose memberships predates the column. A budget is a rule the game was set up under, and defaulting a missing one would carry on playing by rules the game was not set up with. Games saved before this change cannot be opened; games/ is gitignored, so nothing in the repository is affected. A player file handed to load player is configuration rather than stored state and may still leave budget: out.

show types gains COST and show players gains BUDGET, SPENT and LEFT.

Twenty-one existing fixtures needed their budgets raised to the maximum: their types were priced when deploying was free, and several cost more than 100 points on their own. They are tests of visibility, restore, outcomes and the protocol rather than of the budget, so GameHarness.create and established_game take a budget and those fixtures name one.

Both backends pass: 704 under YAML, 680 under SQLite. pylint src/ reports the same 175 messages it reported before this change.

Also documented in README.md: installing the package non-editable makes the suites that drive the roles as subprocesses run the copy in site-packages rather than src/, so they go green against the code you just replaced. That is how this change's CLI coverage was silently passing until the install was fixed.

Nothing bounded an army. A player defined types during setup and deployed as
many units of them as there were free squares - `add unit` was refused for an
unknown type, an occupied square, or coordinates off the board, and for
nothing else. On a 10x10 board that is up to a hundred units, decided by who
typed fastest.

Designing well was free too. `attack 10 health 10 energy 100` was strictly
better than `attack 1 health 1 energy 10` and cost the same, which is to say
nothing, so there was one type worth defining and every game converged on it.
The three statistics are meant to be a trade, and a trade needs a currency.

Each player is now registered with a point budget - `add player <number>
[budget]`, 100 by default, 1 to 1000, fixed for the life of the game. A type
costs the sum of its statistics, so `add type Cross X 1 10 10` costs 21, and
every unit deployed from it costs 21 again. A deployment the pool cannot pay
for is refused, naming the cost, what is left, and the budget it is left out
of; one that spends exactly what is left is allowed.

Three decisions shaped this more than the arithmetic did.

Cost is read from the design a unit was made from, not from the values play
wears down. `UnitType` already kept `type_attack`/`type_health`/`type_energy`
beside them, for the reason its comment gives - a unit's current health is not
its type's health. Pricing from those means a damaged unit still costs what it
cost, and a destroyed one is not free.

Spend is derived, never counted. It is summed off the board's unit list every
time it is asked, the way `game-outcome` already derives who is eliminated. A
running total is a second record of a fact the board holds, and the only thing
a second record can do is drift: one not decremented when a deployment is
refused, or decremented twice when a draft is replayed, is a budget that
quietly stops matching the army.

One rule, two enforcers. `domain/budget.py` holds the arithmetic and the
sentence both. The client refuses at `add unit`; turn resolution rejects
through the existing rejection channel, because a loaded player file or a
hand-written order file reaches the board without passing through a client.
Where more deployments arrive in one turn than the budget buys, they are
charged in unit-name order - list order is what the determinism invariant
forbids a rule from depending on. A deployment already refused for a contested
square is not charged: it never reaches the board, and charging it could push
another of that player's units over a budget it actually fits inside.

Budget privacy needed no filter. A session already reads only the player
records it is entitled to, so a `Player` built for an opponent carries
`budget = None` and the views draw `-`, or `null` in JSON.

A stored player record with no budget is refused rather than defaulted, in
both backends - including a SQLite database whose `memberships` predates the
column. A budget is a rule the game was set up under, and defaulting a missing
one would carry on playing by rules the game was not set up with. Games saved
before this change cannot be opened; `games/` is gitignored, so nothing in the
repository is affected. A player file handed to `load player` is configuration
rather than stored state and may still leave `budget:` out.

`show types` gains COST and `show players` gains BUDGET, SPENT and LEFT.

Twenty-one existing fixtures needed their budgets raised to the maximum: their
types were priced when deploying was free, and several cost more than 100
points on their own. They are tests of visibility, restore, outcomes and the
protocol rather than of the budget, so `GameHarness.create` and
`established_game` take a budget and those fixtures name one.

Both backends pass: 704 under YAML, 680 under SQLite. `pylint src/` reports
the same 175 messages it reported before this change.

Also documented in README.md: installing the package non-editable makes the
suites that drive the roles as subprocesses run the copy in `site-packages`
rather than `src/`, so they go green against the code you just replaced. That
is how this change's CLI coverage was silently passing until the install was
fixed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@aburston
aburston merged commit 08815b9 into master Aug 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant