Repository navigation
Opt-in job switching for workers who can't work - #126
Merged
Merged
Conversation
An NPC in a farming, mining or smithing job that has produced nothing for 20 days moves to the trade whose members actually earn the most (median realised income over 30 days, scaled to its skill), if that beats its own by 1.5x and 5 coin a day. One move a day, 60-day cooldown, nobody moves while on a live contract. A move keeps coin, goods and traits, brings site stock home and changes guild; the new guild buys any loan. Over 10 seeds x 1,500 days the stranded smiths of D3 become farmers (about 4 moves a run): hunger 3.7 -> 0.1; with loans too, tools stay near base on 10/10 seeds and the Gini falls 0.50 -> 0.22. Off by default; doesn't fix D1; refuses to combine with land claims. Two earlier designs churned (farmers chasing tool prices) or collapsed mining (miners leaving over short pauses); both are documented. Design reviewed by a Claude Fable 5.2 subagent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Economy impact (10 seeds × 6 scenarios, against
|
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.
What and why
D3: smiths go broke and never work again, so most baseline seeds lock into high tool prices with a few NPCs permanently hungry. Loans (#124) get broke workers back to work, but at normal prices the market only supports four or five of the eight smiths, so the rest stay in debt with no exit. This adds that exit.
Job switching, opt-in (
[mobility] enabled = true). Each day, before anyone works, an NPC in a mobile trade (farmer, miner or blacksmith by default) that has produced nothing for 20 days moves to the trade whose members actually earn the most. "Earn" means the median of members' realised income over 30 days, scaled to the mover's skill. It moves only if that beats its own realised income by 1.5 times and by at least 5 coin a day.Safeguards:
A move keeps the NPC's coin, goods and traits, brings stock left at the old site home, and switches guild. The new guild buys any outstanding loan from the old one in coin; if it can't afford to, the NPC stays put. Professions and sites go into the state hash only while switching is on, so existing hashes are unchanged.
TickStats.movesrecords every move. Combining switching with land claims is refused by the config, because claims belong to the gatherers who worked them at the start.Policy files:
job_switching.toml, andjob_switching_and_loans.toml, which extends the loans policy.mobility.is added to the rules a policy may change.Results (10 seeds × 1,500 days, averaged from day 365)
Switching makes about 4 moves a run: the stranded smiths become farmers. The NPCs who were permanently hungry were those smiths. It doesn't fix D1: the 20-day trigger is slow next to the 120-day mine disaster, and the ore glut is unchanged.
Two earlier designs failed, and both are documented in
docs/VALIDATION.mdD3:Only letting NPCs who can't work move made it stable.
Design review (Claude Fable 5.2 subagent). It found that my first trigger could only ever drain smiths, and that it compared crafting and gathering on biased terms. It also listed the couplings a mid-run profession change touches, each handled here:
Also fixes D3's "off" row, which said 2 of 10 seeds stay near base. Measured the same way as the other rows, it's 4 of 10 in the second year and 3 of 10 late.
How it was tested
New
tests/unit/test_mobility.py:audit);Full suite: 413 passed, 1 skipped, 3 xfailed. mypy, ruff and bandit are clean.
questless diff --base mainshows no change, and the golden hashes are unchanged.Checklist
mainand saw them fail)uv run ruff check .anduv run ruff format --check .passuv run pytestpasses (including the guarantee tests)uvx bandit -r src app experiments -llreports no medium or high findings🤖 Generated with Claude Code