current_value from
edsl.sharedstate for machine-context expressions. Survey scope selection uses
the distinct current object from the same module.
Pattern cookbook
The same small set of fields and effects recurs across many simulations. This section collects common patterns without hiding them behind new classes.Pattern: first-write-wins
Use this when each participant gets one binding submission, such as a vote, allocation, or sealed bid:set_once:
Pattern: latest-write-wins
Use ordinaryput when participants may revise their current response:
Pattern: append-only event history
Use a sequence when every event should remain available:Pattern: expose only recent history
The full log can persist while readers receive a bounded tail:Pattern: an atomic multi-field transition
Use one command when fields must agree with one another:Pattern: a staged interaction
A later command can require an earlier stage:Pattern: terminal actions
Some actions end an interaction immediately:Pattern: sealed collection and reveal
Expose only submission counts until close:Pattern: viewer-specific private information
Use typed viewer context rather than string interpolation:Pattern: private signal history
Store histories by participant and select only the viewer’s entry:choose evaluates only the selected branch.
Pattern: counters from checkbox selections
A checkbox answer may increment several configured counters atomically:Pattern: keep only the latest submission per participant
An append-only history can still produce a latest-value view:Pattern: dynamic payoff dictionaries
When participant names become result keys at runtime, usemap_of:
Pattern: claim from a capacity-limited pool
The requirement checks current availability, and the effects reserve the item and record the claim together:Pattern: several structures in one scope
Machines remain small and compose at theSharedState layer:
