[#84] Simultaneous turn phases: phase-start snapshots for public reads #85
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Winnie/bankwars!85
Loading…
Reference in a new issue
No description provided.
Delete branch "84-simult"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #84.
The bug
All players are meant to act simultaneously in each phase, but three public reads leaked current-turn information by seat order:
deposit-ratehooks run in seat order and each posted rate is written immediately, so a later seat'smarket-deposit-rates/market-avg-rateread this turn's rates from earlier seats.bond-offershooks: a later seat'smarket-bondssaw earlier seats' fresh offers.bond-takehooks: a later seat saw a market already thinned by earlier seats' takes.The fix
Per-phase snapshots, taken at the phase's start, served to every seat during the phase:
Game.snapDepositPhase()/Game.snapBondPhase()capture the posted rates (+ deposit-weighted average) and a value copy of the standing bond market.market-deposit-rates,market-avg-rate,market-bondsserve the snapshot while their phase is in progress; the snapshot is cleared at phase end, so reads in other phases (e.g. bond-market reads during the loan phase) stay live and unchanged.Tests
simult_test.gopins all three phases: seat 0 acts (posts 10%, offers 900x10, takes 5000), and seat 1's hooks must see exactly the phase-start view. All three pass; full suite green.Verification
go build+go test -count=1(all pass) +go vet ./...clean.[aierrors, 0 ACCT/CF DIVERGENCE.docs/ai-api.mddocuments the simultaneity contract.Behavior note: brains now see last-turn rates during the deposit phase (as intended); bench win distributions may shift slightly vs the pre-fix baseline.