Repository navigation
Budget the army a player may deploy - #14
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nothing bounded an army. A player defined types during setup and deployed as many units of them as there were free squares -
add unitwas 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 100was strictly better thanattack 1 health 1 energy 10and 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, soadd type Cross X 1 10 10costs 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.
UnitTypealready kepttype_attack/type_health/type_energybeside 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-outcomealready 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.pyholds the arithmetic and the sentence both. The client refuses atadd 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
Playerbuilt for an opponent carriesbudget = Noneand the views draw-, ornullin JSON.A stored player record with no budget is refused rather than defaulted, in both backends - including a SQLite database whose
membershipspredates 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 toload playeris configuration rather than stored state and may still leavebudget:out.show typesgains COST andshow playersgains 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.createandestablished_gametake 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-packagesrather thansrc/, 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.