Repository navigation
Lifeways: SimLife as artificial social science (example) - #430
Open
concordia-claw wants to merge 216 commits into
Open
concordia-claw wants to merge 216 commits into
concordia-claw wants to merge 216 commits into
Conversation
The asynchronous engine started one observe-act loop per entity when run_loop began and never another, so an entity added mid-run with Simulation.add_entity never acted. An entity's loop ended only on global termination or max_steps, so an entity that should leave kept polling the game master, and checkpoints were taken only by the first entity's loop, after it acted, so they stopped if that entity left or stopped acting. - run_loop now supervises the loops: an entity appended to the entities sequence it was given (Simulation.add_entity appends to it) gets its own loop, unless the run is terminating; an error in any loop stops the others and is raised, as before. - An entity removed from that sequence ends its loop at its next iteration. Simulation.remove_entity(name) removes an entity in place (e.g. one that died) and returns it. - Any loop may take the checkpoint for a step, once per step, so checkpoints continue whoever joins or leaves. With a fixed population the behaviour is unchanged, except that a step's checkpoint is taken by the first loop to complete that step rather than always by the first entity's.
An EntityAgent's context components were fixed at construction. Some models need an entity's decision logic to change during its life: a custom adopted from another agent, a skill learned, a belief dropped. - EntityAgent.add_component(name, component, spec=None) and remove_component(name). Requested while the agent is neither acting nor observing, a change applies at once; requested during act or observe (e.g. by one of the agent's own components, whose hooks run while the agent holds its control lock), it applies when that call ends, so the components never change in the middle of a phase. The component mapping is replaced rather than mutated, so concurrent readers are safe. - Guards: names are unique, a component owned by another entity is refused, and a component the acting component's explicit context order names cannot be removed. - EntityAgentWithLogging gives an added component a logging channel of its name, as at construction. - State: get_state records the specs of components added with one, and the built-in components removed. With an optional component_factory (name, spec) -> component, set_state rebuilds and removes components to match before restoring each component's state. A state without such a record restores the components given at construction. Agents that never add or remove components behave exactly as before.
The asynchronous engine buffered every log event in its collector until a pause or the end of the run, and Simulation kept the whole raw log, deep-copying it into every checkpoint. On a long or open-ended run both grew without bound. - Asynchronous(log_batch_size=64): log events are finalized into the log in batches as the run goes, whenever that many are waiting. None keeps the old behaviour (finalize on pause or at the end). - AsyncLogCollector serializes materialize, so batches finalized by different threads keep the order in which events were emitted. - Simulation.play(log_retention=N) keeps only the most recent N raw log entries during and after the run, trimming after each step and before each checkpoint, so the raw log, checkpoints and the returned log stay bounded. None (the default) keeps everything, as before. The full history can be kept elsewhere through step_callback.
Every datum published to a Measurements channel was kept for the life of the object. An entity's or game master's logging channels receive data on every act and observe (with the asynchronous engine, every poll of an entity waiting for its turn), so on a long run they grew without bound: in a 200-year example run, the game master's channels held most of the process's growing memory. Measurements(channel_retention=N) and ReactiveMeasurements(...) keep only the most recent N data of each channel. None (the default) keeps every datum, as before.
SimLife as artificial social science, on the stock asynchronous engine through the stock generic simulation. People are born, work, find partners, raise children and die, generation after generation, with no end. What evolves is culture: a person's customs are components of the person's own entity, inherited at birth and taken up from offers. - People (prefabs/person.py): memory, observation, a Constant identity, a Learner, and their customs as dynamic components (added and removed while they live, rebuilt on restore by the entity's component_factory). They act through the stock ConcatActComponent, or a factory (a person, a rule). - The World GM (prefabs/world_gm.py): SwitchAct over TurnGate (each participant answers once a year; the year closes when the last answer is in), Questions, Answers, the stock MakeObservation and Terminate, and the world. The world is built from the GM's own params; nothing is shared with any entity. - A year's answers resolve together in a fixed order, so a run never depends on thread timing: the same seed gives the same world. - Inheritance without reading minds: the GM keeps the public record of custom variants; a parent expecting a child names the ids it passes on, which are copied (with errors) or recombined by domain into the newborn's params. Work names the custom it follows; a skill counts only if the GM once gave it to that person. - Births add an entity (Simulation.add_entity) and deaths archive the person then remove it (Simulation.remove_entity), through a Lifecycle the harness wires. Logs, measurement channels and history windows stay bounded for runs that never end. - A deterministic mock model, a headless run.py (with a soak report) and tests: identical runs, births and deaths, inheritance, an exact restore of a saved year, the Learner. Builds on three core changes (google-deepmind#425, google-deepmind#426, google-deepmind#427).
Customs now spread among the living, not only at birth. A person's answer names the customs it follows (`gather food c3 c6`); the GM offers copies of those it once gave that person, with each channel's copying errors, as lines of next year's observations. It never reads a mind. - upbringing: children see what their parents do, and what they `teach`; - observation: those within a radius see the nearest few, and how well fed they are (for success-biased learners); - apprenticeship: a youth who chooses to `learn a craft` works beside the nearest skilled worker and may come to know the skill a level better. The Learner treats a kind of custom in a domain as a locus (a new custom replaces the one held there), takes a skill only if it is better, and counts each further person seen doing the same as another chance to take it up. The world forgets variants nobody living was given and hands them to the harness (`Lifecycle.forgotten`, `customs.jsonl`); names are unique by construction. The census adds moves, offers by channel, variants and the skill people work by; `Run.customs_census` reads what the living hold.
An allocation trace of years 200 to 300 found the remaining growth in the harness, not the game: - the stock `Simulation.play` has its engine print every observation and action, and the run captured that in an in-memory buffer. `Run.play` now sends it to the null device (`quiet=True`); - `Archive(keep=0)` kept every dead person's record (`del records[:-0]` deletes nothing). Also: the census reads the skill people worked by before the year's dead take their variants out of the record (a 400-year soak crashed on it), with a regression test.
Norms now come in two forms: internalized (a person's own, kept when nobody watches) and known (expected by others, kept when someone is within sight). What children are raised in, and what one keeps, becomes one's own; what one sees others keep, or is shamed for breaking, one knows. A known norm never displaces an internalized one. - Sharing: one with enough may `share food with` a needy person within sight; the world moves the food and those near see the norm kept. - Shame: one who keeps full stores and gives nothing to the needy near them is seen doing so. Next year those who saw may `shame` them, which shows the shamed the norm (the `sanction` channel). The world reports what was seen; whether it was wrong is each person's to judge. - Practice: keeping a norm one only knows offers it as one's own. Also: - a variant arising again (the same content) keeps its id, and norms always record their form; - founding customs may be held by a share of the founders (`held_by`); - one looking for a partner looks until paired; siblings never pair; - copying errors lose know-how and never add any (a skill improves only by an apprentice's care), so skill rises more slowly; - the census counts breaches, shares and shamings, and held norms by form.
- Arrivals: while fewer than `below` people live, a small group of strangers may come each year (the `arrivals` setting), holding their own people's customs, which then spread or not by the same channels as anyone's. In the Sandbox they are the Hill people, who keep their elders' ways, feed only their own and have children young. A nearly empty valley no longer dies out (one seed in six did, in 400 years). - The land's regrowth and seed bank are settings. The Sandbox's (0.5 and 0.06) keep six seeds' populations at a median of 28-48 over 400 years, mostly within 20-60; the old land fed up to 130 as skill rose. - The mock shares only by sharing norms that say to share. - `plot.py` draws a run's census: people, skill, customs held by channel, norms by form, and what people did with their years. - The prefabs document their params.
- A founding custom goes only to founders who hold nothing of its kind and domain yet, so a scenario can give a norm internalized to some founders, known to others and to nobody else. In the Sandbox: a quarter, a half and a quarter. Over six seeds the known form gives way to the internalized one within about 50 years, by upbringing and practice. - Shame now offers the norm as one's own (`sanction` channel, form internalized, uptake 0.3), as the design has it: compliance, shame and rites move a norm from known to internalized. Before, the shamed nearly always knew the norm already, and shaming changed nobody.
Customs can now wait in the world itself, like plasmids in the environment. One who can read (a skill a quarter of the founders have, passed on by teaching) may: - `found a library` (it costs food, and libraries stand apart); - `write at the library`: exact copies of the customs named go on its shelf, the oldest crumbling once a dozen are there; - `read at the library`: the new `reading` channel offers some of the shelf's texts. The GM credits reading only when the answer names a reading skill it once gave; watching someone read or write teaches nothing. Shelves outlive their writers, and the world keeps their customs on record. A library unused for 30 years is a ruin, whose texts can still be read but crumble one by one. Places live in `world/places.py`, owned by the world. The census counts libraries, ruins, texts, and readings that bring back a custom nobody living has (`rediscovered`); `Run.customs_census` adds customs held by kind and domain. Over six seeds and 400 years, literacy spreads from 3 founders to 26-63 readers in five, and dies out in one.
An adult may `found a school` and `teach at the school`: the customs named become its curriculum, and the teacher keeps the school for a term (five years in the Sandbox). Any child within sight who chooses to `go to school` during the term is taught the curriculum by the new `school` channel, whoever its parents are. Schools are places like libraries (a keeper and a shelf), standing apart and falling to ruin when unused. Over six seeds and 400 years, schools teaching reading make the whole population literate within 100-400 years, including in the seed where literacy had died out without them. Also: the inheritance test now checks each newborn in the year it is born (no child under five need be alive at a fixed year).
An adult may `build a shrine`. Its rite falls on a calendar (every fourth year in the Sandbox); then the first who leads it (`lead the rite`) sets the customs it is led by, and all who join it (`join the rite`) are offered them as their own by the new `rite` channel. A rite nobody leads offers nothing. Shrines are places like libraries and schools; the census counts them, and leading or joining a rite teaches no onlookers.
A read-only audit against the Concordia style guide found no violations, and these bugs and risks, now fixed with tests: - Only deeds are seen. Which moves onlookers copy is now an allow-list (`WITNESSED`: gathering, resting, moving, courting, having a child, sharing, shaming). Before, passing on, joining a rite, going to school and learning a craft were broadcast as if done by the customs named; in a 60-year run pass-on answers made a quarter of all observation offers. - A parent passes on only customs the GM once gave it, and only those offered the move to look for a partner are looking (no child courts). - A move is matched to a whole name: "share food with Karito" is not a share with Kari. - The founders are data, made once by `scenarios.founders` and given to both the person prefabs and the World GM (`World.found(founders)` adopts them); the harness no longer runs the GM's founding rule. - Inherited customs pass through the Learner's limits (`Learner.inherit`). - `Run.world_state()` copies the world under the GM's lock, for readers on other threads; `Run.world()` is for Lifecycle callbacks. - The land restores its terrain and food, not its settings. - `history_kept: 0` keeps nothing; the restore uses the stock load to add people born since. - GM components take their world and terminate keys as arguments; channels, kinds and domains are named constants, and the mock uses the world's moves; the Experimenter's name is the World's; log retention is defined once (`prefabs/measures.py`); non-serializable params are documented; run.py and plot.py log instead of printing and open files in `with`; annotations and Args/Returns docstrings where missing.
- An elder may `tell a story` of the customs it names to all within sight. The `story` channel retells with many errors (mutation 0.2), so stories breed variants. - Anyone may `preach` one custom to all within sight. The `preaching` channel is content-biased: learners take up preached beliefs and values more readily than other kinds, and never a skill. Neither is a deed onlookers copy: the listeners are the audience. The run test now requires offers on every channel.
The custom designer. The Experimenter never edits a mind: it may release a custom into the world, `release <kind> <domain> as a <text or song> at <row>,<col>: <what it says>`. The world records the new variant (origin `release`) and either leaves it as a text on the shelf of the nearest library within sight of the place (or of a new one there), or offers it as a song to everyone within sight of it, by the new `release` channel. Whether anyone takes it up is each Learner's choice. A scenario's `plan` gives the rule-played Experimenter its moves by year (the `Plan` rule reads the year from what the Experimenter observed); the page will let a person play it through `HumanActComponent`. The census counts releases.
A dialect is a custom of its own kind (`dialect`, domain `language`): a list of words. Each person speaks one, as raised; a child speaks as its mother does, a word drifting with `dialect_drift`. Two people understand each other as well as their words agree (`culture.intelligibility`), and talk between dialects garbles what passes: the chance of a copying error in any offer from one person to another rises by `garble` times their misunderstanding. The Sandbox's River people and the Hill people who may arrive speak different tongues. The census counts the tongues spoken and the mean understanding between two of the living. A person now holds up to ten customs by default (the dialect is a ninth). The run test asserts what one seed's 80 years reliably show (the common channels taken up, at least seven offered); each channel keeps its own deterministic test.
- Descent: each person is of a people (`descent`), its mother's; the founders of the scenario's `people`, arrivals of theirs. - Courting: one may look for anyone (`look for a partner`) or court one by name (`court <name>`) among the nearest grown singles, shown as anyone can see them (how they speak, their people). Choices stand until paired; two pair when each would have the other. - Marriage rules are customs of their own kind (`marriage`, domain kinship): marry one who speaks as we do (`within: tongue`), or only our own people (`within: descent`). They shape whom a mind courts; the world never enforces them. The Sandbox's Hill people marry only their own. - `Run.peoples` (harness, measurement only) counts the peoples: clusters of the grown whose marriage rules allow each other; `run.py` writes it into the census.
The presets (settings, not code): - Plasmid Soup: everyone buds alone; customs move freely (wide observation, texts the Experimenter leaves, sermons); no peoples. New variants sweep: by year 400 a late variant is held by 87-100% of people in five seeds of six. - Two Valleys: two peoples with their own tongues, beliefs and marriage rules, founded in valleys a ridge parts but for a pass. Over six seeds and 400 years both persist, apart, their balance shifting; understanding between them stays near half. Founders now come in groups (`groups`: people, home, founders, customs), each founder of its group's people; the land may have a ridge with a pass. Fixes found on the way: - An offer line now carries the custom's full params (JSON at its end). Before, a marriage rule offered by teaching lost its terms and a dialect its words, so learners held rules that allowed anyone. - The courted see who courts them (they come first among their suitors, marked "courting you"), so two choosy people can find each other. - Dialects drift more slowly (2% a birth): at 10%, a people whose rule is to marry within its tongue soon could not marry at all. Demography: without arrivals the Sandbox shrank in every seed while its land stayed full, because people spent whole years not gathering and crowded the land around their first home. Now everyone forages a little whatever it does (`subsistence`), one who moves looks for better land within a few steps (`roam`), and a poorer land (richness 0.25) feeds about 40 (25-80) with no one arriving: the land regulates the population.
`python -m examples.lifeways.web.server` serves a running world to a phone-first page: the valley with its peoples and places, the census as graphs, a tapped person's customs (and how each came), time controls and the custom designer. - `web/session.py`: the harness. It builds the simulation with the Experimenter played by a person (the stock `HumanActComponent` and a `PageInput` adapter), plays it in a thread, and reads it: a locked copy of the world, the census rows, a person's customs. Each year the Experimenter answers with the move the person queued, or else the person's standing choice (watching), at the pace the person sets; closed, the adapter raises rather than invent a move. - `web/server.py`: a stdlib HTTP server for the page and its JSON API. - `web/static/`: the page (HTML, JS, CSS), with node tests of its helpers. - The World: the Experimenter may `stop the world`; the World GM's `Terminate` ends the run (`YearOutcome.stopped`). - `simulation.build_simulation(experimenter=...)` gives the Experimenter an acting component.
…hen played - The Sandbox's land is poorer (richness 0.2): over a thousand MOCK years the population stays within 20-60 in 976 of them (median 42, max 69), with eight arrivals; at 0.25 it rose with skill to a median of 53. Plasmid Soup, where everyone buds, at 0.17. - The page's state says how long since the person last did anything (`idle_seconds`), so a redeploy never replaces a world played within the hour.
- `run.py --model=ollama:<name>` lets people think with a local model
(Concordia's contrib `OllamaLanguageModel`); the run is labelled LIVE.
`--founders` sets a smaller world for slow minds.
- The world reads the move an answer names first (`first_move`): minds
add explanations ("gather food c3. Since it is year 1, ..."). A parent
asked what it passes on passes on the ids it names, whatever words come
with them.
- Founders are "born 27 years before the valley was settled", not "in
year -27" (a live mind took that for a newborn).
A LIVE run on llama3.2:3b (6 founders, 6 years) took 214 s; it read all
22 answers of the years logged, and its people cite their customs, so
observation and practice offers flow. The plan test no longer depends on
who stands near the place of a song.
The Experimenter may ask a person a question (`ask <name>: <question>`). The next year the GM puts it to the person before its move (the `interview` question): the person answers in its own words, then makes its move. The answer goes into the world's transcripts (the latest fifty, in its state), to the Experimenter as an observation, and to the page, where a tapped person can be asked from the inspector.
- `run.py --model=<api>:<model>` builds the model with Concordia's `language_model_setup` (Ollama, Together, ...), passing a Together key from the environment explicitly and never logging it. The model is wrapped in the stock `ProfiledLanguageModel`, and the summary reports the calls and the (estimated) tokens. - `--settings` adds settings as JSON (e.g. an Experimenter plan of interviews); the summary keeps the interviews' transcripts. A LIVE run on Together's DeepSeek-V4.1-Flash (12 founders, 20 years, 334 calls, about $0.39) answered its interviews from its customs: asked what he lives by, Kaka named his people's customs, "as I have seen Sane and Hara do", "Because these are ours."
The `free` setting: a year also closes after so many seconds, whoever has not answered doing nothing that year (TurnGate's deadline). Slow minds lag and runs depend on timing; tick mode (the default) stays reproducible. Tests: in free mode years pass while the page's Experimenter waits; in tick mode the year waits for everyone.
A read-only audit against the style guide found no violations; these bugs and risks are fixed, with tests: - Free mode: a person named before a deadline close and dead at it no longer crashes the run (`Questions` answers "skip this step" when the person may not act); and an answer is filed by the question it answers (`World.asked`, kept in state), so a late move is dropped rather than filed as an interview answer or as next year's move. - A release whose text would read as an offer's protocol (`|params=`, `[custom`) is refused, and a Learner passes over an offer whose params it cannot read rather than raising. A song needs its channel; a released skill's level is kept within 1..MAX_LEVEL. - The Experimenter, who lives as long as the world, keeps only its latest 32 memories (`components/memory.RecentMemory`, a stock `ListMemory`). - The stdout redirect is one for the process, counted across runs, so two worlds can play at once. - The page pauses through the engine's own `pause()`/`play()`, and its people wait for their turn at 50 ms: a paused world went from 149% of a core to 0%. - `history_kept: 0` no longer breaks the census callbacks; the dead leave the observation queue atomically (and are compacted out in tick mode); the Plan reads the year from the World's status line only; the Experimenter hears when a question is not understood or its interviewee dies. - The server refuses malformed requests (400), redirects the bare prefix, and defaults to port 8921; the page takes the grown age, the highest skill level and the rows kept from the state. - Mode constants, docstrings, annotations; `run.py --founders` refuses presets with founder groups; the README is current.
concordia-claw
added a commit
to concordia-claw/concordia
that referenced
this pull request
Oct 30, 2026
A Grid is a seeded map of terrain kinds (grass, forest, river, coast, hills, marsh), each tile carrying food up to its kind's capacity and growing it back each step, logistically, with a seed bank; ridges of hills may part it into valleys, with a pass. Entities forage the richest tiles within a day's walk (sparing some, if they would), and a mover looks for the best land within a few steps. GridWorld holds a grid as a game master's context component: one map, one lock, saved and restored with the GM, adding nothing to its prompts. Generalized from the land of the Lifeways example (google-deepmind#430).
The asynchronous engine buffered every log event in its collector until a pause or the end of the run, and Simulation kept the whole raw log, deep-copying it into every checkpoint. On a long or open-ended run both grew without bound. - Asynchronous(log_batch_size=64): log events are finalized into the log in batches as the run goes, whenever that many are waiting. None keeps the old behaviour (finalize on pause or at the end). - AsyncLogCollector serializes materialize, so batches finalized by different threads keep the order in which events were emitted. - Simulation.play(log_retention=N) keeps only the most recent N raw log entries during and after the run, trimming after each step and before each checkpoint, so the raw log, checkpoints and the returned log stay bounded. None (the default) keeps everything, as before. The full history can be kept elsewhere through step_callback.
Every datum published to a Measurements channel was kept for the life of the object. An entity's or game master's logging channels receive data on every act and observe (with the asynchronous engine, every poll of an entity waiting for its turn), so on a long run they grew without bound: in a 200-year example run, the game master's channels held most of the process's growing memory. Measurements(channel_retention=N) and ReactiveMeasurements(...) keep only the most recent N data of each channel. None (the default) keeps every datum, as before.
…ion of the core PRs
…the measurements fix)
…sing years On 5 Nov the phone's world closed no year from 01:46 (year 383,605) and served a frozen world until a redeploy; its shutdown then hung on one thread waiting on a lock, and there was no way to see which. Now: - `serving.watch_for_stalls`: a watch thread reads the year and the pace, without the World GM's lock, and once a playing, unpaused world closes no year for `--stall_minutes` (10 by default), logs a warning and every thread's stack (`faulthandler`), once a stall. - `kill -USR1 <pid>` logs every thread's stack at any time. - `PageInput.paused`: the pace's pause, read without the input's lock. Tests: a stuck stand-in world is reported once; a paused one and one whose years advance are not.
`SocialTies` is a weighted, undirected network between named participants, kept by a game master as state and rules for its other components to call by key (`DEFAULT_SOCIAL_TIES_COMPONENT_KEY`). Whatever brings two together strengthens their tie, saturating towards 1 (`strengthen`, with a kind of bond such as kin or work); every step each tie fades and the faintest are forgotten (`step`); each participant keeps its strongest `max_ties`, so an indefinite run stays bounded. `contacts` gives the network as a contact structure for other mechanics (rumours, reputation, contagion); `strengthen_all` ties everyone in groups that met. Thread-safe, JSON-safe state with a total reader (a state without ties restores an empty network), no randomness, and nothing added to prompts. Tests: strengthening and saturation, fading and forgetting, the bound on ties, ordering and kinds, contacts, leaving, groups, settings, and a round trip through a game master entity's state.
The World GM prefab builds the contrib `SocialTies` from the new `ties` setting (on in the Sandbox: decay 0.1, floor 0.05, at most 12 each), registers it under `__social_ties__` and hands it to the `World`, which: - records each year's encounters: kin (partners, parents and children), work (gathering or sowing on one tile), every custom passed on (by its channel, so upbringing, school, rites, apprenticeship, stories... count; a sanction does not), food shared and visits; - at the year's close (after transmission) turns them into ties and lets every tie fade (`_tie_up`); the dead's ties are forgotten; - offers the grown `visit <name>` for their two closest: the host is told, and sees the customs the visitor names (observation); - counts `ties` and `closeness` in the census. The page: a person's panel lists whom they are close to and what brought them together, linked; the World GM's anatomy explains the component. The person API reads the GM component through `Run.gm_component` (H3). The mock mind visits now and then when it has food to spare. A save without ties restores with none (the stock `set_state` skips a component a state lacks), so the phone's world gains them. Tests: World ties (kin, work, visits, sharing, death, no ties), the person API, the page's wording. MOCK 40 years twice identical.
…goes `Rumors` keeps the news going round a world and who heard which version, as state and rules for a game master's other components to call by key (`DEFAULT_RUMORS_COMPONENT_KEY`). A rumour starts with those who saw what it tells (`start`, optionally about someone and of a kind). Each step (`spread`), everyone who heard it within `tell_for` steps tells it to each contact the game gives (e.g. `SocialTies.contacts`) with chance `chance`; a retelling keeps `keep` of the teller's fidelity and with chance `garble` drops a word (never the first, never below three). `spread` returns who heard what from whom, for the game to tell. Rumours untold for `forget_after` steps are forgotten and at most `max_rumors` are kept, so an indefinite run stays bounded. Draws are seeded by the rumour, the step and the names (crc32), so a run replays. Tests: a chain a link a step, telling for a while only, garbling, replay and chance, forgetting and the bound, what one heard and leaving, settings, and a GM round trip after which both copies play on alike.
`Reputation` keeps, for each observer, a view of each actor it has seen or heard of: a score per quality the game names (e.g. generous, honest), above zero for good report and below for bad. It is state and rules for a game master's other components to call by key (`DEFAULT_REPUTATION_COMPONENT_KEY`): - `witness`: a deed seen first-hand moves each witness's view; - `hear`: word of a deed moves the listener's view by a weight the game chooses (`hearsay_weight`: the deed's weight times how sure the word is times `HEARSAY`), e.g. from a contrib `Rumors` rumour about the actor; - `step`: every view fades by `decay`, the faintest are forgotten; - `standing` (the mean view held), `view`, `known_by`, `known_for`, and `ranked` (by public standing or one observer's views); - `forget`: one who leaves, as observer and as actor. Each observer keeps views of at most `max_known` actors (the strongest), so an indefinite run stays bounded. Thread-safe, JSON-safe state with a total reader, no randomness, nothing added to prompts. Tests: seen and heard, good against bad, fading, the bound, ranking, leaving, settings, and a GM round trip.
The World GM prefab builds the contrib `Rumors` from the new `rumours` setting (on in the Sandbox), registers it under `__rumors__`, and hands it to the `World` with the ties through a typed `world.Mechanics` record (the prefab's `make_mechanics` builds them all), so the World's constructor stays one argument however many mechanics come. News starts among those who know it: a disaster, among those near who lived; an elder's death, among kin and those within sight; and the Experimenter's new move `spread word at <row>,<col>: <words>`, among those within sight of the place (who are told they hear it said). Each year the word passes along ties at least `RUMOR_TIE` close (between those within sight where no ties are kept), a link a year; a retelling may drop a word and is less sure. Each hearer is told "Word reaches Bo from Ada: ...". The dead hear no more. Census: `rumours`, `heard`. The page: "Shape the valley" spreads word at the ring and lists the word going round (the Experimenter's first, then disasters, then deaths), as first told and as it reached the furthest; a person's panel shows the word they heard and from whom; the anatomy explains the component. Tests: World rumours (a disaster's word a link a year, an elder's death, the Experimenter's word, none kept), word spread from the page, the page's wording. 283 tests; MOCK 40 years twice identical.
`Reciprocity` is a ledger of obligations between named participants, as state and rules for a game master's other components to call by key (`DEFAULT_RECIPROCITY_COMPONENT_KEY`): - `give`: a gift or loan leaves the receiver owing the giver a return (`return_share` of it by default, or what the game says) within `term` steps; - `repay`: a return settles the debtor's oldest debts to that creditor first; `forgive`: a creditor lets all of a debtor's go; - `overdue`: debts past due are reported as defaults, once each, for the game to judge (they stay owed and may still be repaid); - `settle_estate`: one who leaves passes its claims to an heir (or they are cancelled), and its debts are cancelled or pass on; - `owed_by`, `owed_to`, `owes`, `size`. It moves no goods (the game does, and records the obligation). Each debtor keeps at most `max_open` open debts, so an indefinite run stays bounded. Thread-safe, JSON-safe state with a total reader, nothing added to prompts. Tests: the term, returns oldest first, defaults reported once, forgiving, estates, the bound, settings, and a GM round trip.
…hanic 3)
The World GM prefab builds the contrib `Reputation` from the new
`reputation` setting (on in the Sandbox: decay 0.05, at most 20 known
each), registers it under `__reputation__`, and hands it to the `World`
through `world.Mechanics`.
- Deeds seen: food shared with one who had none is good report for
`generous`, among the receiver and those within sight; full stores kept
while a neighbour had none is bad report, among those within sight.
- Word of deeds: each starts a rumour of praise or blame about the doer
(the contrib `Rumors`); hearing it moves the hearer's view at the
hearsay weight times how sure the word is. Three mechanics compose:
ties carry rumours, rumours carry reputation.
- What it sways: courting prefers the one thought best of before the
nearest, in the suitors offered and in who pairs.
- Views fade yearly; the dead are forgotten. Census: `renowned` and
`shunned` (standing at least 0.5 either way).
The page: a person's panel says what they are known as ("Known as stingy
by 1 who saw or heard of it"); the anatomy explains the component.
Tests: seen then heard, hoarding, courting by regard, the dead; the page's
wording; the person API. 270 tests; MOCK 40 years twice identical.
`Contagion` follows one disease through a population by contact, as state and rules for a game master's other components to call by key (`DEFAULT_CONTAGION_COMPONENT_KEY`). Each participant is susceptible, exposed (`incubation` steps), infectious (`infectious_for` steps) or immune (`immunity_for` steps, then susceptible again). Each `step`, every infectious participant passes it to each susceptible contact the game gives with chance `transmission`, unless the game says that contact is protected this step; then illnesses move on, and one that ends is death with chance `mortality` times a vulnerability the game gives (by age, say), else recovery. `infect` seeds cases from outside; `status`, `counts`, `infectious`, `forget`. Several diseases are several components. Draws are seeded by the step and the names (crc32), so a run replays; only the sick and the immune are recorded, so an indefinite run stays bounded. Thread-safe, JSON-safe state with a total reader, nothing added to prompts. Tests: a link a step and recovery, incubation, protection and immunity, waning, vulnerability and replay, leaving, settings, and a GM round trip after which both copies play on alike.
The World GM prefab builds the contrib `Reciprocity` from the new `debts` setting (on in the Sandbox: a six-year term, all owed back, at most six open debts each), registers it under `__reciprocity__`, and hands it to the `World` through `world.Mechanics`. - Food shared with one who had none is owed back; the debtor is told what it owes and by when. - `repay <name>` is offered while the stores allow (a year's eating kept); a return goes to the giver, who thinks the debtor reliable (half a deed's weight in the contrib `Reputation`). - A debt left past due is a default, once: the giver thinks the debtor does not repay, and word of it goes round as a rumour whose hearers think so too (`NEWS_REPORT` maps each kind of news to what it says). - At death, claims pass to the heir (the eldest living child, else the partner: `_heir_of`, now shared with the fields' bequest); debts are let go. - Census: `debts`, `repaid`, `defaults`. The mock returns a debt when its stores allow, most years. The page: a person's panel lists their debts both ways and says whether they are known as reliable or as one who does not repay; the anatomy explains the component. The twin test's wait for two worlds' twenty years is 240 s (it timed out at 120 s once, beside the other tests' worlds, and passes alone in 25 s). Tests: owed and returned, defaults and word of them, estates; the page's wording; the person API. 273 tests; MOCK 40 years twice identical.
…ther `Gatherings` is a calendar of gatherings (festivals, market days, councils) held at named places, as state and rules for a game master's other components to call by key (`DEFAULT_GATHERINGS_COMPONENT_KEY`). Each is held every `every` steps at its `phase`, and, with a `chance` below 1, only when a draw seeded by the gathering and the step says so (`due`). While one is due, participants `attend` it; `close` hands the game who came to each (`Gathered`), for it to decide what coming together does, and clears the step's attendance. Each keeps how often it was held, its last and its largest attendance; `next_held` says when it next falls; `add`, `remove`, `forget`, `gatherings`. At most `max_gatherings` are kept, so an indefinite calendar stays bounded. Thread-safe, JSON-safe state with a total reader, nothing added to prompts. Tests: the schedule, attendance handed over and cleared, chance and replay, the bound and leavers, settings, and a GM round trip after which both play on alike.
The World GM prefab builds the contrib `Contagion` from the new `sickness` setting (on in the Sandbox: transmission 0.3, a two-year illness, 15 years immune after, mortality 0.08, and a 3% chance a year that it comes from outside), registers it under `__contagion__`, and hands it to the `World` through `world.Mechanics`. - Each year, after disasters and before everyone eats, the sickness passes from the sick to those within sight and to close kin and friends (ties at least `SICK_TIE`); illnesses end in recovery or death, 2.5 times as likely for small children and elders (`FRAIL`). Those who fall sick or recover are told; its dead die through `_die` like any other. - The sick gather half as much, and their status says so. - `keep apart from the sick` is offered while someone within sight is sick: the one who keeps apart cannot catch it that year, and does no other work. The mock keeps apart on some draws. - A plague sent now brings the sickness to all within reach (in a world that keeps one), and an outbreak from outside is news that goes round. - Census: `sick`, `immune`, `died_sick`. Tuning: at 0.15 and a one-year illness each case passed it to fewer than one other and it never spread; at 0.3 and two years, seed 0's first 100 MOCK years see an epidemic of 19 sick at once and 5 dead, with 21 keeping apart. The page: the map notes who is sick, a person's panel says whether they are sick or safe from it for how long, the plague's hint says it spreads, and the anatomy explains the component. Tests: spreading within sight, gathering less, keeping apart, the plague, death; the page's wording. 277 tests; MOCK 40 years twice identical.
`Assembly` keeps a body's motions and the laws it passed, as state and rules for a game master's other components to call by key (`DEFAULT_ASSEMBLY_COMPONENT_KEY`). A member proposes a motion (`propose`, with the game's kind and plain data; the same text open twice is one motion); it is open from the next step for `open_for` steps, while members `vote` for or against (once each, a later vote replacing an earlier). `close` decides the motions whose time is up with the members eligible then: they pass if at least `quorum` of them voted and the votes meet the rule (`majority`, `two_thirds` or `consensus`), each `Decision` saying who voted how and why one failed. A motion passed is a law in force for `term` steps (0: until repealed); the game decides what a law does. `open_motions`, `in_force`, `repeal`, `forget`. At most `max_laws` laws and `max_motions` open motions, so an indefinite assembly stays bounded. Thread-safe, JSON-safe state with a total reader, no randomness, nothing added to prompts. Tests: a motion's life into law, each rule (parameterized), quorum and eligibility, the open period, lapsing, repeal and the bound, one motion per text, settings, and a GM round trip after which both decide alike.
`Offices` keeps a body's offices (a chief, a priest, a judge), as state and
rules for a game master's other components to call by key
(`DEFAULT_OFFICES_COMPONENT_KEY`). Each has a holder or is vacant, a `term`
in steps (0: for life) and its succession in the game's word ('election',
'heredity', 'acclaim'). The game `install`s a holder (the one before steps
down); a term run out (`expire`), a holder who leaves (`forget`) or steps
down (`vacate`) leaves the office vacant, each ending a `Tenure` (when,
how had, why ended). `vacant` lists the offices to fill with their
succession, for the game to fill by its own vote, an heir or the best
reputed. `holder`, `holds`, `tenure`, `history`, `offices`. Each office
remembers its last `max_history` holders, so an indefinite body stays
bounded.
Thread-safe, JSON-safe state with a total reader, no randomness, nothing
added to prompts.
Tests: vacancy, install and term, leaving and succession, stepping down
and the bound, settings, and a GM round trip.
Assembly (mechanics 6 and 7) Gatherings (the new `gatherings` setting: every 5 years, within 6 steps, 6 at most). The World GM prefab builds the contrib `Gatherings` and hands it to the `World`. A world keeps a gathering at its most crowded place from its first year (a restored world, from its next); the Experimenter may `call a gathering at <row>,<col>`. The grown and youths within reach may `go to the gathering at <row>,<col>` (their status says it is held). Those who come grow closer (a `gathering` tie), each sees the customs three others drawn among them enacted that year, and word passes among them. "Shape the valley" lists them (when next, how many came last) and calls one at the ring. Census: `gathered`, `gatherings`. The assembly (the new `assembly` setting: majority, quorum 0.3, open a year, laws stand 40 years, 3 at most). An elder may `propose the law: <text>`, one of three the World can judge (`LAWS`: spare the fields others tend; share with the hungry in lean years; keep apart when sickness comes near). The next year the grown may vote for or against it instead of working; the year's close decides it with the grown alive then, and tells them. Laws in force are in everyone's status; breaches seen (judged on the year's moves before that year's motions are decided) make one thought less `lawful` by those who saw (contrib `Reputation`). "Shape the valley" lists the laws and the motion open; a person's panel says if they are known as law-abiding or a lawbreaker. Census: `laws`, `votes`, `law_breaches`. The mock votes for a law in keeping with its customs (two words alike) and elders now and then propose one. In seed 0's first 100 MOCK years: 15 proposals, several failing the quorum, three laws standing by year 90, 31 breaches seen. Tests waiting for many years use one allowance, `_SLOW` (240 s): the suite plays a world in each worker, and each mechanic is a GM component the stock entity calls on a thread of its own (40 MOCK years: 18.5 s with one mechanic, 28 s with seven), so 120 s ran out under load. Tests: World gatherings and assembly; the page's wording. 283 tests; MOCK 40 years twice identical.
`Pacts` keeps the agreements between participants (or groups the game names), as state and rules for a game master's other components to call by key (`DEFAULT_PACTS_COMPONENT_KEY`). One `offer`s a pact of a kind, with terms in the game's words and plain data (the same kind between the same two is one offer; none while they hold one); the other may `accept` it within `answer_within` steps, or `decline`; unanswered offers lapse. A pact holds for `lasts` steps (0: until ended). The game decides what a pact asks and records each `breach`; past `tolerance` breaches the pact is broken. Pacts also end when the term runs out (`expire`), a party leaves (`forget`) or by the game's word (`end`). `offers_to`, `pacts_of`, `between`, `history`, `size`. At most `max_pacts` hold, `max_offers` wait and `max_history` ended are remembered, so an indefinite world stays bounded. Thread-safe, JSON-safe state with a total reader, no randomness, nothing added to prompts. Tests: offer, acceptance and term; lapsing and declining; breaches and tolerance; one pact a kind and leaving; the bounds; settings; and a GM round trip.
The World GM prefab builds the contrib `Offices` when the new `offices` setting is on (the Sandbox: a twenty-year term) and hands it to the `World`. At a year's close (after the assembly decides), the chiefdom is created once (succession by acclaim), terms that ran out end, and a vacant chiefdom goes to the grown person of the best name: the sum of its public standing as generous, reliable and lawful (contrib `Reputation`), the eldest among equals, or the eldest grown with no reputation kept. A chief who dies leaves it vacant (`Offices.forget`). Everyone's status names the chief. The chief may propose a law in any year (elders may too), and `call a gathering where you live` (contrib `Gatherings`). The mock chief calls one now and then. Census: `chief`. The page: "Shape the valley" says who is chief, since when and until when; the chief's panel says what a chief may do; the anatomy explains the component. Tests: acclaim (the eldest, then the better name at the term's end), a chief's gathering, succession at death; the page's wording. 285 tests; MOCK 40 years twice identical (four chiefs in them).
`Feuds` keeps the grievances groups hold against one another (the game's groups: peoples, clans, households or single participants), as state and rules for a game master's other components to call by key (`DEFAULT_FEUDS_COMPONENT_KEY`). An injury adds to the injured group's grievance against the injurer (`grieve`); each `step` grievances fade by `decay` and the faintest are forgotten; a grievance at `threshold` is a feud (`hostile`). A `raid` is a contest the game stages, each side with a strength it reckons: the attackers win with chance attack / (attack + defence), drawn from the seed, the step, the groups and the raid's number; the defenders' grievance grows by `injury` (twice if they lost), so feuds feed themselves, and a raid ends any truce. `make_peace` clears the grievances both ways and holds a truce for `truce` steps (`at_peace`), under which grievances do not grow. `feuds`, `truces`, `forget`. Thread-safe, JSON-safe state with a total reader, nothing added to prompts. Tests: grievance, feuds and fading; a raid as a contest that feeds the feud; replay and strength; peace, truce and a raid ending it; a group gone; settings; and a GM round trip after which both raid alike.
The World GM prefab builds the contrib `Pacts` from the new `pacts` setting (on in the Sandbox: twenty years, no refusal borne) and hands it to the `World`. - The grown may `offer a pact of aid to <name>`, one of their two closest (contrib `SocialTies`) with whom they hold none; the other is told and may `accept the pact of aid with <name>` the next year (an unanswered offer lapses). Both are told; the two grow closer. - A pact of aid binds both to share when one goes hungry: a year one had none and the other could share with it (it was offered `share food with`) and did not, the pact breaks. The betrayed is told and thinks the betrayer unreliable (contrib `Reputation`), and word of the betrayal goes round (`BETRAYAL_NEWS` in `NEWS_REPORT`). Pacts end at their term, or when a party dies. - Census: `pacts`, `pacts_broken`. The mock mostly accepts an offer and now and then makes one. The page: a person's panel lists their pacts of aid (with whom, since and until when); the anatomy explains the component. Tests: offered and accepted, broken by a refusal, kept by sharing; the page's wording. 288 tests; MOCK 60 years twice identical (up to four pacts at once, none broken).
The World GM prefab builds the contrib `Feuds` from the new `feuds` setting (on in the Sandbox: decay 0.1, threshold 1, injury 0.5, a truce of twenty years) and hands it to the `World`. The groups are peoples, by descent. - Injuries a people remembers: gathering from fields another people tends (`GRIEF_FIELD`), and keeping full stores while one of another people had none (`GRIEF_HOARD`). - A grudge at the threshold is a feud: the grown of that people may `raid the <people>` where one of it lives within `RAID_REACH`. A raid, after the year's foraging, is a contest: the raider and its people's raiders within sight against the richest of that people near and its grown within sight (`ALLY` each). The winner keeps or takes half the stores, the loser may die (`RAID_DEATH`), word of the raid goes round, and the raided people's grudge deepens. - An elder or the chief may `offer peace to the <people>`: a pact between the peoples (contrib `Pacts`, kind `PEACE`, the parties being peoples) that the grown of the other may `accept peace with the <people>` the next year; grudges are cleared and a truce holds. Grudges fade yearly; peoples that are gone are forgotten (by the feuds and the pacts). - Statuses say which grudges and truces one's people holds. Census: `feuds`, `raids`, `raid_deaths`. The mock raids on some draws when in a feud, offers peace once its status says it bears a grudge, and mostly accepts peace. In seed 0's Sandbox few strangers come and grudges rarely reach a feud; in Two Valleys (two peoples parted by a ridge) a feud forms near year 30, one raid follows, and peace is made three times in 150 years. The page: "Shape the valley" lists grudges, feuds and truces; news names raids, deeds, debts and betrayals; the anatomy explains the component. Tests: a grudge from a field taken, raids that deepen the other's grudge, peace offered by an elder and accepted; the page's wording. 561 tests (Lifeways and contrib game master); MOCK 40 years twice identical.
… every kind A gathering a chief called read as "the valley's own"; it now says "called by the chief <name>". The "Word going round" hint named only disasters, deaths and the Experimenter's word; it now names raids, deeds, unpaid debts and broken pacts too (seen in a screenshot of a test server at year 53).
Register it in the game master prefab under its key and call it from the GM's own components by key (the canonical use); Lifeways's prefab instead hands the same objects to its World, which owns the year's close.
…s caught From an audit of the ten mechanics against the style guide: - Every `set_state` now parses into locals, skips a malformed record, and assigns everything at once under the lock. Before, a bad record raised half way, and `EntityAgent.set_state` swallows the error, leaving a half restored component. - The id counters (rumours, debts, motions and laws, pacts) are never restored below the ids restored, so a state without its counter cannot make a new record overwrite `r1`, `d1`, `m1` or `p1`. - `Contagion`: a case keeps the step it began. A case caught at a step (`infect`, or exposed in `step`) neither passes the sickness on nor moves on in that step; it begins with the next. Before, `infect` said so but a game that infected and stepped in one step had the case spread at once and be ill a step less. States from before restore as begun long ago. - `Pacts`: a pact's data is read-only (`MappingProxyType`), as it is handed out with the pact. - Docstrings: one-line summaries; Args and Returns where a parameter's meaning is not obvious; `Offices` no longer claims to bound the number of offices (the game creates them). Tests: every round trip goes through JSON, as a checkpoint is saved; a malformed record is skipped and a counter clears the ids restored (rumours, pacts); pact data is read-only; a case caught in a step begins with the next. 80 tests.
From an audit of the ten mechanics' use against the style guide: - G6: components find each other by key. `game_master.MECHANICS` maps each `world.Mechanics` field to its key and class; `WorldComponent. bind_mechanics` finds the GM's mechanics with `get_component` and hands them to the `World` (`World.bind`), as `TurnGate` and `Questions` begin, under the world's lock. The prefab registers them by the same table and no longer hands objects to the `World`, so a mechanic replaced under its key is the one called and the one saved. - A pact of aid breached within its tolerance is not broken: only a breach that ends it counts, tells the betrayed, costs the name and starts word (`Pacts.breach` returns the pact either way). A tolerated breach is told as such. - Peace made this year stops raids still planned against that people, and a raid ends any peace pact between the two, so the truce (in `Feuds`) and the pact (in `Pacts`) cannot drift apart. - Word about the dead makes no name for them: hearsay moves reputation only for the living (the dead were forgotten, then came back). - A law already proposed this year is not announced again by a second proposer. - The page reads the world and its mechanics in one hold of the World GM's lock, so a reply never mixes two years. - Defaults are named (`PACT_YEARS`, `CHIEF_TERM`, `GATHERING_EVERY`, `GATHERING_REACH`, the library's `TRUCE`); `make_mechanics` reads every setting (feuds' floor, pacts' answer and bounds, offices' history). - `Run.gm_component` checks the GM's type instead of a pyrefly pragma. - Sickness tests infect before the year they test (with `Contagion`'s timing, a case caught in a year begins with the next); the keep-apart test checks that one who did not keep apart did catch it. - The restore test's snapshot (K3) includes every mechanic's state: a restored year plays on exactly, mechanics and all. 562 tests (Lifeways and contrib game master); MOCK 40 years twice identical; 71 JS tests.
This branch has not been deployed
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.
Draft. Depends on #426 and #427. #425 is in main (7ec68db) and this branch is built on it. The commits of #426 and #427 are included here until they land. This PR's own change is
examples/lifeways/**; review the core PRs first. It also carries ten new contrib game master mechanics that Lifeways uses (social ties, rumours, reputation, gifts and debts, contagion, gatherings, an assembly, offices, pacts, feuds); they are on their own branch,concordia-claw:lifeways-library(main plus those ten modules only), for a PR of their own.What it is
Lifeways is SimLife as artificial social science. A 2D valley runs indefinitely: people are born, learn, marry and die, and their culture evolves.
Learneradds or removes them (Entity agents can add and remove context components while they live #426). The game master never reads a mind: customs reach people only as offers in observations.How it fits Concordia
EntityAgentWithLoggingfrom a prefab in aprefab_lib.Config.SwitchAct.Asynchronousengine runs it, through the stockgeneric.Simulation.PlayerRoster(PlayerRoster: players join and leave a game through its game master #425, in main); the engine's threads follow the entities list. Neither the simulation nor the engine is told.Running it
MOCK minds are the default.
Live minds:
--model=ollama:llama3.2:3b, or Together through the contrib model setup.The phone-first page plays a running world, with you as the Experimenter. It offers:
The world is saved and restored across restarts.
Experiments compare a lever against a control over seeds. Example: richer land (0.5 against 0.2), 5 seeds × 200 years:
Each measure rose in all 5 seeds. This is the population-size effect on cumulative culture.
Evidence
Tests
pytest examples/lifeways: 132 tests. The page's helpers: 19 node tests (node --test examples/lifeways/web/static/app.test.js). pyrefly and pylint are clean, and pyink is applied.Related contrib PRs: #428 (
RuleActComponent), #429 (Rounds), #431 (customs and theLearner, on #426). (#432, population and archive, is superseded by the roster.) Once they land, the example will use them in place of its own copies.🤖 Generated with Claude Code