From 9da3b89032d4c45519dc217f52f3d5bbf99996ff Mon Sep 17 00:00:00 2001 From: Kyler Ramsey Date: Thu, 24 Sep 2026 01:37:08 -0700 Subject: [PATCH 1/2] Writing style: README, website and FAQ written short and plain Kyler, 2026-09-24: "simplicity and elegance is effective and desirable." The README, the four site pages and the FAQ are rewritten for a player: one idea per sentence, each thing said once, no internals and no history. Status, credits, the unofficial line and safety facts are kept. - README 197 -> 121 lines (changelog unchanged). Build and test, how a pass works inside, costs and budgets, saved-state sizes, determinism and the test list move to a new DEVELOPING.md. - Site: text changed inside the existing components only; every id, anchor and data-* hook is kept. Duplicates removed (install's second pass-line key, the FAQ's repeated conflict sentence, rules already stated in the features), internals dropped (budget numbers, remembered-cost ages, class names), troubleshooting answers turned into numbered steps. - Facts checked against the code: a paused workplace still counts (GameAdapter.JobOf), so "the workplace is disabled or in another district" is gone; the Iron Teeth answer loses "only handles beaver dwellers"; the home comparison note links the FAQ's "Is it the best?" and keeps the looser-bed-rules caveat. - CLAUDE.md gains "Writing README and website text", pointed at from the content rules and the release checklist; build references and the MixedStorage release.js path (now docs/assets/) are updated. PRODUCT.md's voice line gains the short-and-plain sentence. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 30 +++++- DEVELOPING.md | 88 +++++++++++++++++ PRODUCT.md | 4 +- README.md | 192 ++++++++++++-------------------------- docs/faq.html | 51 +++++----- docs/index.html | 41 ++++---- docs/install.html | 43 ++++----- docs/troubleshooting.html | 86 +++++++++-------- 8 files changed, 280 insertions(+), 255 deletions(-) create mode 100644 DEVELOPING.md diff --git a/CLAUDE.md b/CLAUDE.md index febd70f..5c3caae 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,8 +7,8 @@ PR → merge. - **Tests (what CI runs, `.github/workflows/tests.yml`, SDK 8):** `dotnet run --project OptimizedLocalHousing.Tests -c Release` must end with `40 checks passed.` (41 exist; the compiled-adapter check needs the built mod and the game, so it runs - only locally with two extra arguments; see README "Build and test"). -- **Build and package** (needs a local Timberborn install; never done in CI): see README "Build and test", then `./package.ps1`. + only locally with two extra arguments; see `DEVELOPING.md`). +- **Build and package** (needs a local Timberborn install; never done in CI): see `DEVELOPING.md`, then `./package.ps1`. ## Standing rules @@ -18,6 +18,24 @@ PR → merge. - Compare fairly with Bobingabout's Housing Optimize and Commute Balancer, by what their Workshop pages say. Never "the best housing mod". The 25.6 vs 24.1 figure is a model with straight-line distances, not a benchmark. +## Writing README and website text + +Kyler, 2026-09-24: "simplicity and elegance is effective and desirable." Every change to the README, the website +text and the player docs follows these rules. + +- **Write for a Timberborn player** who wants to download, install and use the mod. Developer detail goes in + `DEVELOPING.md` or the changelog; link to it rather than repeating it. +- **Short.** One idea per sentence, most under about 20 words. A paragraph or FAQ answer is one to three sentences, + a troubleshooting answer a few numbered steps. +- **Lead with the action.** Menu paths as arrow chains; on-screen labels in bold, exactly as in game. +- **Say each thing once**, where a player would look for it; link to it elsewhere. +- **Plain words.** No internals (class names, ids, formats) unless the player needs them to act. +- **Cut** filler, repeated caveats, edge cases a player won't meet, and history ("since …", "no longer", older + builds). Describe the mod as it is now. +- **Check every fact against the code** before writing it; changelogs lag. +- **Keep, briefly:** credits, the unofficial line, the status, and safety facts. +- **Reread as a new player before publishing.** Every step works as written, and nothing is said twice. + ## Website - **Where:** `docs/`: `index.html`, `install.html`, `troubleshooting.html`, `faq.html`, `404.html`, `style.css`, @@ -93,6 +111,7 @@ PR → merge. ### Content rules +- Every text change follows *Writing README and website text* above. - Describe the mod as it is now. No "New in ", "added in …" or version history on player pages; that belongs in the README changelog and the GitHub release notes. Upgrade steps players need are the only exception. - The played and not-played status matches the README exactly: the 1.0 code (released as 1.0.0) ran 16 passes in a @@ -104,12 +123,13 @@ PR → merge. - Terminology: pass; move cycle; route cost / route-cost unit (the game's own, not straight-line); commute; adults, children, homes, workplaces, districts; the 32 nearest homes; rejected, stale; Hungarian algorithm. - `docs/release.js` is shared across timbermods sites and byte-identical: replace it, never edit it. Check: - `git hash-object docs/release.js` equals `gh api repos/timbermods/MixedStorage/contents/site/assets/release.js -q .sha`. + `git hash-object docs/release.js` equals `gh api repos/timbermods/MixedStorage/contents/docs/assets/release.js -q .sha`. - `404.html` uses absolute `/OptimizedLocalHousing/` paths and loads no scripts (unstyled on the local preview; that's expected). ### Update the website for a new release -When asked to "update the website for the latest release, consistent with the design": +When asked to "update the website for the latest release, consistent with the design" (write every change by +*Writing README and website text* above): 1. Read the release and the docs: `gh release list -R timbermods/OptimizedLocalHousing -L 5`, `gh release view -R timbermods/OptimizedLocalHousing`, README (incl. Changelog and "What has not been measured"), PRODUCT.md. List every player-facing change. @@ -125,7 +145,7 @@ When asked to "update the website for the latest release, consistent with the de - Requirements and game version (built against 1.1.2.4, minimum 1.1.0.0): install `#requirements`, FAQ `#which-game-versions-operating-systems`, troubleshooting `#update`, index hero lead and meta description. - Behaviour: index `#features` (six rules; the head says "Six rules"), `#how` steps, `#rules` always / never, - `#compare` table, `#results`; FAQ `#does-it-have-settings` (tuning constants); log messages in troubleshooting + `#compare` table, `#results`; FAQ `#does-it-have-settings` (links the tuning constants in `DEVELOPING.md`); log messages in troubleshooting `#log` table and symptoms; install `#layout` (the `version-1.1` folder tree), `#update`, `#uninstall`. - `` / `og:description` on every page, and PRODUCT.md's Operating Context. 3. Put new content into the existing components: a rule → `ul.rules-key` item (h3 + p); always / never → `ul.checks` / diff --git a/DEVELOPING.md b/DEVELOPING.md new file mode 100644 index 0000000..2e12e11 --- /dev/null +++ b/DEVELOPING.md @@ -0,0 +1,88 @@ +# Developing Optimized Local Housing + +For people who build, test or change the mod. Players want the [README](README.md) and the +[website](https://timbermods.github.io/OptimizedLocalHousing/). The website's own rules are in `CLAUDE.md`. + +## Build and test + +Requires .NET SDK 8. Building the mod also needs a local Timberborn installation; no game DLLs are redistributed. +The tests compile only the game-independent engine and restore Newtonsoft.Json from nuget.org (13.0.4, the same +release the game ships), so they run without the game. CI (`.github/workflows/tests.yml`) runs them that way on +every push to main and every pull request, without the two arguments below: the compiled-adapter check needs the +built mod and the game, so it runs only locally. + +```powershell +dotnet build OptimizedLocalHousing/OptimizedLocalHousing.csproj -c Release -p:GameManaged="C:\path\Timberborn_Data\Managed" +dotnet run --project OptimizedLocalHousing.Tests -c Release -- OptimizedLocalHousing/bin/Release/netstandard2.1/OptimizedLocalHousing.dll "C:\path\Timberborn_Data\Managed" +./package.ps1 +``` + +The tests cover the solver against brute force, pause/resume at every row, cycle splitting, optimality on +random colonies with one to three districts, route queries that stay inside a district, each district solved on +its own (the same homes as a colony of that district alone, in no more ticks), the safety rules in the README, +stale-world handling, route costs carried from one pass to the next and priced again when they come due, +determinism between peers, save/reload at every tick of three passes (the first, the next, and the one where the +first pass's remembered costs come due; with one district and with several), per-tick work bounds (route +queries, and solver operations with one budget across districts), large colonies whose passes end within the +daytime with budgets set from the colony (in lockstep across a reload mid-pass), and the compiled adapter against +the installed game's component blacklist. Omitting the two arguments skips the compiled-adapter check. + +## How a pass works + +`GameAdapter.cs` is the thin bridge to the game; `PassEngine.cs` and `Assignment.cs` hold everything else. Each pass: + +1. **Capture.** Every housed adult beaver, its home, and its assigned workplace. +2. **Price.** For every workplace, real route costs (`Accessible.FindRoadPath`, so ziplines and stairs count) + from the 32 nearest homes in its district. Homes in other districts are never queried, because the game's + route search never leaves a district. Homes farther away are estimated, and any move to one is re-checked + with a real route before it is allowed. +3. **Solve.** The optimal way to reassign the adults to the beds that adults occupy today (the Hungarian + algorithm). Nobody moves between districts, so each district is solved on its own, one after another. In a + colony with several districts that takes far fewer ticks and far less memory than solving them as one (47 solve + ticks instead of 157 for four districts of 300 adults), and reaches the same optimum. +4. **Verify.** Every proposed move is re-priced with fresh routes. A whole cycle of moves is dropped if it would + leave a beaver who can reach work today unable to, and each cycle must save at least half a route-cost unit in + total. The fresh costs of homes beyond the 32 nearest are remembered in place of estimates, so a move that was + turned down is not proposed again every day (anything proposed is still re-priced first). A remembered cost is + used for seven passes. The seventh prices it again, and keeps it, if one of that workplace's workers lives in + the home or if there was no route (so a road that comes back is noticed); otherwise it lapses to the estimate. +5. **Apply.** Moves are applied as whole cycles (A takes B's bed, B takes C's, C takes A's), in one game tick. + +Each beaver gets a one-route-cost-unit bonus for staying put (`StayBonus`), so a rearrangement must save at least one +unit for every beaver it moves. + +## Cost + +- Work is spread over ticks with budgets per tick: **32 route queries** and about 250,000 solver operations on a + colony of a few hundred adults. A pass takes roughly a fifth of a game day (147 ticks on a 266-beaver colony), + never one long stall. +- A larger colony's pass takes larger budgets, set from the colony when the pass starts and saved with it, so + that it still ends within the day's 512 daytime ticks: at most **128 route queries** and about 1,000,000 solver + operations per tick (plus the solver row it started last). On test colonies of 1,600 adults in one district a + pass takes 480 ticks on randomly housed adults (1,118 with the smallest budgets), and about 216 (740) once they + are settled. The route-query budget stops growing at about 770 staffed workplaces, and the solver budget at about + 1,150 adults in one district (about 920 in each of two, or 800 in each of three), so a still larger colony's + pass takes longer instead (609 ticks on 2,000 randomly housed adults in one district). +- The replay of the real 266-beaver colony took 147 ticks, 4,388 route queries and about 22 ms of total CPU. +- Not measured: frame-time impact. The per-tick work is bounded, but the cost of a real path query has not been + timed, nor the larger solver budget that large districts get: more than about 730 adults in one district, about + 580 in each of two, or about 500 in each of three. + +## Multiplayer and saved state + +- All decisions use integer arithmetic and sorted IDs, and the whole pass state (snapshot, prices, solver rows, + verification results, and the route costs kept from earlier passes) is saved with the game. Reloading mid-pass, + or a peer that loads a save taken mid-pass while another peer keeps running, continues exactly where the pass + was and does the same work on every following tick, so every peer applies the same moves on the same tick. + There is no wall-clock or frame-time rule anywhere. +- For Timber Together: the mod only ticks inside the simulation, draws no random numbers, never moves a beaver + between districts (so colonies stay separate), and nothing it touches is patched by BeaverBuddies. +- The saved state is a few hundred bytes when idle on a settled colony, and a few KB (about 20 KB at 1,300 + adults) where beavers keep changing jobs. For seven days after a pass that moved many beavers it also holds the + route costs that pass checked, capped at 1,024 (about 11 KB for 240 adults, about 85 KB at the cap). During a + pass it grows with the colony: about 70 KB for 240 adults, 100 KB for 350 to 400, 380 KB for 1,300. + +## Tuning constants + +There are no settings. The tuning constants are in the source: `NearHomes`, `QueriesPerTick` and the other +per-tick budgets in `PassEngine.cs`, and `StayBonus` in `Assignment.cs`. diff --git a/PRODUCT.md b/PRODUCT.md index 03d6b55..875e2c0 100644 --- a/PRODUCT.md +++ b/PRODUCT.md @@ -145,7 +145,9 @@ Success, in order: ## Brand Commitments - **Voice:** a fellow player explaining a useful mod: clear, exact, a little proud of the math, never hype. "Straight - answers, including the ones that aren't flattering." Numbers are given with their caveats. + answers, including the ones that aren't flattering." Numbers are given with their caveats. Short and plain: one + idea per sentence, each thing said once, no internals and no history (see CLAUDE.md, *Writing README and website + text*). - **No official Timberborn logos or key art.** The game's own item icons are allowed where used (none are used today). The site's marks are its own: `favicon.svg` (a house linked to a workplace) and simple line icons. - **License:** MIT, copyright Timbermods, for the code, docs and site. diff --git a/README.md b/README.md index 261eef5..e1c57b2 100644 --- a/README.md +++ b/README.md @@ -1,170 +1,93 @@ # Optimized Local Housing -**Website:** https://timbermods.github.io/OptimizedLocalHousing/ (install guide, troubleshooting, FAQ) +A Timberborn 1.1 mod that moves adult beavers into the homes that give the colony the **shortest total commute**. +Beds are limited, so not everyone can live next to work. Once a day, the mod works out the arrangement where the +whole colony walks the least, and moves the beavers that need moving. + +Version **1.1.1**. -A Timberborn 1.1 mod (built against **1.1.2.4**) that moves adult beavers into the homes that give the -**shortest total commute** between where they live and where they work. Version **1.1.1**. +**Website:** https://timbermods.github.io/OptimizedLocalHousing/ (install guide, troubleshooting, FAQ) -Everyone can't live in the house nearest their workplace, because beds are limited. The best you can do is -minimize the total travel across the whole colony, and that is exactly what this mod solves, once a day, with -an optimal assignment (the Hungarian algorithm), instead of nudging beavers around one swap at a time. +## Install -## Installation +You need Timberborn 1.1 (built against 1.1.2.4) and no other mods. Back up your save first: the mod's moves can +only be undone by loading an earlier save. -1. Download the `OptimizedLocalHousing-vX.Y.Z.zip` file under **Assets** on the +1. Download `OptimizedLocalHousing-vX.Y.Z.zip` under **Assets** on the [latest release](https://github.com/timbermods/OptimizedLocalHousing/releases/latest) (not "Source code"). -2. Close Timberborn. Extract the ZIP into `Documents\Timberborn\Mods`. It contains one +2. Close Timberborn. Extract the zip into `Documents\Timberborn\Mods`. You should get one `OptimizedLocalHousing` folder. -3. Launch Timberborn, enable **Optimized Local Housing** in the Mods menu, and restart. -4. Load your save (back up important saves first, as with any mod). On a save the mod has not seen before, the - first pass starts as soon as the game is ticking, then it runs again at the start of every day. One line per - pass is written to `Player.log` (look for `[OptimizedLocalHousing]`). +3. Start Timberborn, enable **Optimized Local Housing** in the Mods menu, and restart. +4. Load your save and let the game run. On a save the mod hasn't seen, the first pass starts as soon as the game + runs. After that, a pass runs at the start of every in-game day. + +**Don't run it with Housing Optimize or Commute Balancer.** If either is enabled, this mod turns itself off and +logs a warning. + +**Multiplayer:** every player installs the same mod version and runs the same game version. Update together. -Standalone, no dependencies. **Do not run it together with Housing Optimize or Commute Balancer.** When a -game loads, this mod checks for their mod IDs (`BobHousingOptimize`, `BobCommuteBalancer`, `housingoptimize`). If one is enabled, it logs a warning and does nothing for that game. In -multiplayer, every player must install the same version of the mod and run the same game version. +**To check it works,** quit the game and open `%USERPROFILE%\AppData\LocalLow\Mechanistry\Timberborn\Player.log`. +Search for `[OptimizedLocalHousing]`: there is one line at startup and one after each pass. +[What the pass line means](https://timbermods.github.io/OptimizedLocalHousing/troubleshooting.html#zero). ## What it does -Each pass: - -1. **Capture.** Every housed adult beaver, its home, and its assigned workplace. -2. **Price.** For every workplace, real route costs (`Accessible.FindRoadPath`, so ziplines and stairs count) - from the 32 nearest homes in its district. Homes in other districts are never queried, because the game's - route search never leaves a district. Homes farther away are estimated, and any move to one is re-checked - with a real route before it is allowed. -3. **Solve.** The optimal way to reassign the adults to the beds that adults occupy today. Nobody moves between - districts, so each district is solved on its own, one after another. In a colony with several districts that - takes far fewer ticks and far less memory than solving them as one (47 solve ticks instead of 157 for four - districts of 300 adults), and reaches the same optimum. -4. **Verify.** Every proposed move is re-priced with fresh routes. A whole cycle of moves is dropped if it would - leave a beaver who can reach work today unable to, and each cycle must save at least half a route-cost unit in - total. The fresh - costs of homes beyond the 32 nearest are remembered in place of estimates, so a move that was turned down is - not proposed again every day (anything proposed is still re-priced first). A remembered cost is used for seven - passes. The seventh prices it again, and keeps it, if one of that workplace's workers lives in the home or if - there was no route (so a road that comes back is noticed); otherwise it lapses to the estimate. -5. **Apply.** Moves are applied as whole cycles (A takes B's bed, B takes C's, C takes A's), in one game tick. - -### Rules it keeps - -- **Every home keeps exactly the same number of adults.** So homes never overfill, breeding capacity and - newborn beds are untouched, and vacant beds are left for the game to fill. -- **Children never move.** Neither do beavers in paused, blocked or otherwise unusable homes, and nobody is - moved into one. Nobody crosses districts. Beavers are never made homeless. -- **Unemployed adults** don't care where they live, so they give up good beds to people who commute. -- **No churn.** Each beaver gets a one-route-cost-unit bonus for staying put, so a rearrangement must save at least - one unit for every beaver it moves. An optimized colony is left alone: a second pass on the same colony changes - nothing. -- **Disconnected commutes are repaired.** A beaver whose home can no longer reach its workplace is moved to a - home that can, as long as a bed can be arranged. If none can, it may be moved to another cut-off home when that - helps others; the pass log's "disconnected commutes repaired" counts only beavers whose new home reaches work. - -### Cost and multiplayer - -- Work is spread over ticks with budgets per tick: **32 route queries** and about 250,000 solver operations on a - colony of a few hundred adults. A pass takes roughly a fifth of a game day (147 ticks on a 266-beaver colony), - never one long stall. -- A larger colony's pass takes larger budgets, set from the colony when the pass starts and saved with it, so - that it still ends within the day's 512 daytime ticks: at most **128 route queries** and about 1,000,000 solver - operations per tick (plus the solver row it started last). On test colonies of 1,600 adults in one district a - pass now takes 480 ticks instead of 1,118 on randomly housed adults, and about 216 instead of 740 once they are - settled. The route-query budget stops growing at about 770 staffed workplaces, and the solver budget at about - 1,150 adults in one district (about 920 in each of two, or 800 in each of three), so a still larger colony's - pass takes longer instead (609 ticks on 2,000 randomly housed adults in one district). -- All decisions use integer arithmetic and sorted IDs, and the whole pass state (snapshot, prices, solver rows, - verification results, and the route costs kept from earlier passes) is saved with the game. Reloading mid-pass, - or a peer that loads a save taken mid-pass while another peer keeps running, continues exactly where the pass - was and does the same work on every following tick, so every peer applies the same moves on the same tick. - There is no wall-clock or frame-time rule anywhere. -- The saved state is a few hundred bytes when idle on a settled colony, and a few KB (about 20 KB at 1,300 - adults) where beavers keep changing jobs. For seven days after a pass that moved many beavers it also holds the - route costs that pass checked, capped at 1,024 (about 11 KB for 240 adults, about 85 KB at the cap). During a - pass it grows with the colony: about 70 KB for 240 adults, 100 KB for 350 to 400, 380 KB for 1,300. - Uninstalling is safe: beavers keep the homes they have. +- **The whole colony, not each beaver.** One beaver may walk a little farther so everyone together walks less. + Each district is solved exactly, with the game's own route costs, so stairs, platforms and ziplines count. +- **Every home keeps the same number of adults.** Homes never overfill and breeding is untouched. Empty beds are + left for the game to fill. +- **Children never move.** Neither do beavers in paused, blocked or automation-off homes, and nobody moves into one. +- **Nobody crosses districts, and nobody is made homeless.** +- **Commutes stay possible.** A beaver who can reach work is never moved to a home that can't. One who can't is + moved to a home that can, when a bed can be arranged. +- **Unemployed adults** give up good beds to beavers who commute. +- **No churn.** A move must save at least one route-cost unit for each beaver moved. Once a colony is arranged, + another pass changes nothing. +- **Nothing to set.** No settings, no menu. The work is spread over many ticks, so there is no long freeze. + +[How a pass works](https://timbermods.github.io/OptimizedLocalHousing/#how), step by step. ## Results -### Replay of a real colony - -Replaying a real 266-beaver colony (222 employed adults, 89 homes) through the actual pass engine, with -straight-line distance standing in for route cost: +A real 266-beaver colony (222 employed adults, 89 homes), replayed through the pass engine with straight-line +distance standing in for route cost: | | Average commute | |---|---| | Before | 53.1 | | After one pass | **24.1** | -| True optimum (brute-force-verified solver) | 24.0 | - -The pass took 147 ticks, 4,388 route queries and about 22 ms of total CPU, rehomed 182 beavers in 20 cycles, -and a second pass changed nothing. - -### In the live game +| True optimum | 24.0 | -The game logs of the maintainer's own colony, running the code released as 1.0.0, show 16 consecutive passes (numbers 23 to 38) completing without a -single error, warning or rollback, on a colony of about 350 adults, 104 homes and 167 workplaces. Each pass took -about 183 ticks and about 5,350 route queries, and applied between 0 and 4 move cycles. In 10 of the 16 passes a -cycle was skipped because a beaver changed job or home while the pass was running ("stale"). That is expected, -and those beavers are reconsidered in the next pass. +That pass took 147 ticks and rehomed 182 beavers in 20 cycles. A second pass changed nothing. -That included a hosted co-op session with a second player running the same mod version: about 11,000 ticks and -15 passes, with no desync reported in the host's log. +## Status -### What has not been measured +**Stable.** That means the evidence below plus automated tests, not that every situation has been tried. -- Frame-time impact. The per-tick work is bounded (32 route queries on a colony of a few hundred adults, at most - 128 on the largest), but the cost of a real path query has not been timed, nor the larger solver budget that - large districts get: more than about 730 adults in one district, about 580 in each of two, or about 500 in each - of three. -- The Iron Teeth faction, and operating systems other than Windows. -- Multiplayer beyond that one hosted session, and the client's side of it. No live two-player session has been - played on 1.1.0 or 1.1.1 yet. -- Timber Together in a live session. Its code was audited against this mod: the mod only - ticks inside the simulation, draws no random numbers, uses no wall-clock or frame time, never moves a beaver - between districts (so colonies stay separate), and nothing it touches is patched by BeaverBuddies. Every player - needs the same version enabled; BeaverBuddies warns at join time when the mod lists differ. +- **Played:** the 1.0 code ran 16 passes in a row on the maintainer's colony (about 350 adults, 104 homes, 167 + workplaces), with no errors, warnings or rollbacks. That included one hosted co-op session with a second player: + about 11,000 ticks, 15 passes and no desync in the host's log. +- **Tested, not played:** the 1.1 code. 41 automated checks cover it; 40 run on every change. +- **Not tried yet:** a live two-player session on 1.1, the second player's side of a co-op session, frame-time + impact, the Iron Teeth faction, systems other than Windows, and Timber Together in a live session (its code was + checked against this mod's, not played with it). ## Limits -- Only beds already occupied by adults are used, so vacant beds are not filled by this mod (the game still fills - them normally). - The first pass on a badly housed colony moves most adults at once, so parents can end up living away from their children. Later passes move only a few. -- If a beaver changes home or job while a pass is running, the move cycle it belongs to is skipped and retried - in the next day's pass. -- Home candidates are the 32 nearest by block distance in each workplace's district. A home much farther by - straight line but cheaper by zipline could be missed. -- Homes must have a single access and a valid route, like the game's own assigner requires. -- No settings and no UI. The tuning constants (`NearHomes`, `QueriesPerTick`, `StayBonus`) are in the source. - -## Build and test - -Requires .NET SDK 8. Building the mod also needs a local Timberborn installation; no game DLLs are redistributed. -The tests compile only the game-independent engine and restore Newtonsoft.Json from nuget.org (13.0.4, the same -release the game ships), so they run without the game. CI (`.github/workflows/tests.yml`) runs them that way on -every push to main and every pull request, without the two arguments below: the compiled-adapter check needs the -built mod and the game, so it runs only locally. - -```powershell -dotnet build OptimizedLocalHousing/OptimizedLocalHousing.csproj -c Release -p:GameManaged="C:\path\Timberborn_Data\Managed" -dotnet run --project OptimizedLocalHousing.Tests -c Release -- OptimizedLocalHousing/bin/Release/netstandard2.1/OptimizedLocalHousing.dll "C:\path\Timberborn_Data\Managed" -./package.ps1 -``` - -The tests cover the solver against brute force, pause/resume at every row, cycle splitting, optimality on -random colonies with one to three districts, route queries that stay inside a district, each district solved on -its own (the same homes as a colony of that district alone, in no more ticks), the safety rules above, -stale-world handling, route costs carried from one pass to the next and priced again when they come due, -determinism between peers, save/reload at every tick of three passes (the first, the next, and the one where the -first pass's remembered costs come due; with one district and with several), per-tick work bounds (route -queries, and solver operations with one budget across districts), large colonies whose passes end within the -daytime with budgets set from the colony (in lockstep across a reload mid-pass), and the compiled adapter against -the installed game's component blacklist. Omitting the two arguments skips the compiled-adapter check. +- If a beaver changes home or job during a pass, its move cycle is skipped and retried the next day. +- Each workplace checks real routes to its 32 nearest homes. A far home made cheap by a zipline could be missed. ## Uninstall Disable the mod and restart. Beavers keep their current homes. +## Developing + +Build steps, how a pass works inside, costs, saved data and the test list are in +[DEVELOPING.md](https://github.com/timbermods/OptimizedLocalHousing/blob/main/DEVELOPING.md). + ## Changelog - **1.1.1**: maintenance release. The conflict check now covers only Housing Optimize and Commute Balancer. @@ -194,4 +117,5 @@ Disable the mod and restart. Beavers keep their current homes. ## License -MIT. +MIT, maintained by [Timbermods](https://github.com/timbermods). An unofficial community mod for Timberborn, not +affiliated with or endorsed by Mechanistry. Housing Optimize and Commute Balancer are Bobingabout's. diff --git a/docs/faq.html b/docs/faq.html index c3bdce5..3c6d01f 100644 --- a/docs/faq.html +++ b/docs/faq.html @@ -50,25 +50,25 @@

The basics

What does it do, in one sentence? -

Once a day it works out the arrangement of adult beavers into their existing beds that makes the colony's total home-to-workplace travel as short as possible, and moves the beavers that need moving.

+

Once a day, it moves adult beavers between the existing beds so the colony's total walk to work is as short as possible.

How often does it run, and how long does a pass take?
-

A pass starts as soon as the game is ticking the first time the mod sees a save, then at the start of every in-game day. A pass took 147 ticks on a 266-beaver colony in the replay, and about 183 ticks on a live colony of about 350 adults, roughly 90 seconds to two minutes at normal speed. The work is spread across those ticks, with up to 32 route queries per tick. A larger colony's pass does more per tick (up to 128 route queries), so that it still ends within the day's daytime; only the very largest colonies' passes run longer.

-

Moves are applied when a pass finishes, which can be at any time of day. Beavers walk to their new home the next time they go home.

+

The first pass starts as soon as the game runs on a save the mod hasn't seen. After that, a pass runs at the start of every in-game day. On a colony of a few hundred beavers, a pass takes about 150 to 200 ticks: roughly 90 seconds to two minutes at normal speed.

+

Moves are applied when a pass ends, which can be at any time of day. Beavers walk to their new home the next time they go home.

Does it have settings? -

No. The mod has no menu and no options. The tuning values are constants in the source if you're willing to rebuild it: NearHomes and QueriesPerTick in PassEngine.cs, and StayBonus in Assignment.cs. A relaxed "let adult counts change" option was considered and dropped, and the reason is below.

+

No. There is no menu and nothing to set. The tuning constants are in the source for people who rebuild the mod; see DEVELOPING.md.

What is a "move cycle"? -

A group of beavers that each take the next beaver's bed, and the last takes the first's, like A→B→C→A. Every home in the cycle ends up with as many adults as it started with. Cycles are applied all at once, or not at all if anything about them has changed. A simple two-beaver swap is the smallest cycle.

+

A group of beavers who each take the next one's bed, like A→B→C→A. Every home in it keeps as many adults as it had. A cycle is applied all at once, or not at all if anything in it has changed; a two-beaver swap is the smallest.

How it decides

@@ -76,7 +76,7 @@

How it decides

What does "shortest" mean here?
-

It uses the game's own route cost between a home and the beaver's assigned workplace, so stairs, platforms and ziplines count. It isn't straight-line distance. To keep the work small, each workplace prices the 32 nearest homes in its own district by block distance; anything farther is only estimated, and every move is re-priced with fresh routes before it happens. Those fresh costs are remembered in place of the estimates for the next seven passes. The seventh checks a cost again, and keeps it, if one of that workplace's workers lives in the home or there was no route.

+

The game's own route cost from home to the beaver's assigned workplace, so stairs, platforms and ziplines count. Each workplace prices its 32 nearest homes in its district; farther ones are estimated. Every move is priced again with a fresh route before it happens.

@@ -86,7 +86,7 @@

How it decides

  • It is already in the best place the total allows. Someone else needed that bed more.
  • Moving wouldn't be worth it. A rearrangement has to save at least one route-cost unit for each beaver it moves, so the colony doesn't churn.
  • -
  • Its workplace is disabled or in another district, or it has no job, so its commute isn't measured.
  • +
  • It has no job, so its commute isn't measured.
  • Its home is paused, blocked, or switched off by automation. Those homes are skipped.
  • It was skipped this time because something changed mid-pass, and it will be reconsidered tomorrow.
@@ -95,14 +95,14 @@

How it decides

What happens to unemployed adults? -

They don't care where they live, so they are treated as free to take whatever bed is left. That means an unemployed beaver may give up a home next to a workplace so a working beaver can have it.

+

They don't care where they live, so they take whatever bed is left. An unemployed beaver may give up a home next to a workplace so a working beaver can have it.

Why doesn't it fill empty beds, or let homes end up with different numbers of adults?
-

We tested exactly that, and it isn't worth it. On the real 266-beaver colony we replayed, letting the solver change how many adults each home holds shortened the average commute by only about 4% (24.0 to 23.1). But it used up the beds where babies could be born: homes able to have a baby fell from 11 to 1. Keeping those baby beds empty brought the gain back to nothing.

-

So every home keeps its adult count. This was measured on one colony, with a straight-line stand-in for route cost and child-bed limits inferred from household sizes, so other colonies will differ, but a 4% gain wasn't worth risking population growth.

+

We tested it, and it isn't worth it. On the real 266-beaver colony we replayed, letting homes change their number of adults shortened the average commute by only about 4% (24.0 to 23.1). But homes able to have a baby fell from 11 to 1, and keeping those baby beds free erased the gain.

+

So every home keeps its adult count, and empty beds are left for the game and for babies. That was one colony with a straight-line stand-in for route cost, so others will differ.

@@ -111,8 +111,7 @@

Breeding, children and saves

Does it affect breeding?
-

It's built not to. In the game's code a baby needs a home with a free bed, at least two adults, and fewer children than half its adults. Optimized Local Housing keeps every home's number of adults exactly the same and never moves children, so each home keeps the same free beds and the same number of pairs. The chance of a birth in each home is untouched.

-

What changes is which adults live in a home. By construction, breeding capacity is identical before and after a pass.

+

It's built not to. Every home keeps the same number of adults and children never move, so each home keeps the same free beds and the same chance of a birth. Only which adults live there changes.

@@ -123,50 +122,50 @@

Breeding, children and saves

Can a beaver end up homeless, or in a home it can't reach? -

No beaver is made homeless, by design. Every move is applied as a whole cycle in one tick and rolled back if the game refuses any part of it. Every destination's route to the beaver's workplace is checked with a fresh query first, and a cycle is thrown away if it would leave a beaver who can reach work today unable to. A beaver whose commute is already broken is moved to a home that can reach its workplace when a bed can be arranged. If none can, it may be moved to another home that is also cut off, when that helps the others.

+

No beaver is made homeless. A beaver who can reach work is never moved to a home that can't, and one who can't is moved to a home that can, when a bed can be arranged. Every move is checked with a fresh route first, and a cycle the game refuses is rolled back.

Is it safe for my save? What if I remove it? -

The mod stores a small amount of data in your save: a few hundred bytes to a few kilobytes when idle (for seven days after a pass that moved many beavers, up to about 90 kilobytes of route costs it checked), and during a pass about 100 kilobytes on a colony of 350 to 400 beavers, more on larger ones. If you remove the mod, the data is ignored and beavers keep their current homes. As with any mod, keep a backup of important saves.

+

The mod stores a little data in your save: up to about 100 KB on a colony of a few hundred beavers, more on larger ones. If you remove the mod, the data is ignored and beavers keep their homes. As with any mod, keep a backup of important saves.

Compatibility and comparisons

Can I use it with Housing Optimize or Commute Balancer? -

No. Two housing mods would keep reassigning each other's work. Optimized Local Housing checks for these mods when a game loads and turns itself off, with a warning in the log, if one is enabled. Don't run them together: Optimized Local Housing turns itself off if Housing Optimize or Commute Balancer is enabled. Pick one. See Troubleshooting.

+

No. Two housing mods would keep undoing each other's moves. If either is enabled, Optimized Local Housing turns itself off and logs a warning, so pick one. See Troubleshooting.

How is it different from Bobingabout's Housing Optimize and Commute Balancer?
-

As described on their Workshop pages:

+

As their Workshop pages describe them:

    -
  • Housing Optimize reassigns beavers once at the start of each day: it unassigns everyone and refills homes first-come-first-served, nearest first, all at once. Its author notes the result isn't guaranteed to be the best.
  • -
  • Commute Balancer works gradually over days, moving a beaver to a closer empty home or swapping when the benefit outweighs the other beaver's inconvenience.
  • -
  • Optimized Local Housing solves every district exactly, once a day, for the smallest total commute, keeps every home's number of adults, and spreads the work across ticks with budgets per tick.
  • +
  • Housing Optimize unassigns everyone at the start of each day and refills homes first-come-first-served, nearest first. Its author notes the result isn't guaranteed to be the best.
  • +
  • Commute Balancer works gradually over days. It moves a beaver to a closer empty home, or swaps when the benefit outweighs the other beaver's inconvenience.
  • +
  • Optimized Local Housing solves each district exactly, once a day, for the smallest total commute. Every home keeps its number of adults.
-

In a replay on one real colony, a first-come-first-served strategy like the one Housing Optimize describes averaged 25.6 (between 23.5 and 29.0 depending on the order workplaces were handled), against 24.1 for this mod, even though that model was given looser bed rules. That was a model with a straight-line stand-in, not a benchmark of either mod. Both of those mods have thousands of subscribers and much more real-world mileage. This one is newer.

+

Both have thousands of subscribers and far more real-world mileage; this one is newer. The comparison on the home page has one replay's numbers.

Is it the best housing mod?
-

We don't claim that. Because it solves the assignment exactly, it should reach the shortest total commute among the approaches above, and the tests support that. It has now run in live single-player and co-op play, but with far less mileage than long-established mods, and commute isn't the only thing that matters: stability, disruption and real-world track record count too.

-

The fair test is to run each mod on a copy of the same save for a few in-game days and compare the average commute afterward. If you do, we'd like to hear the result.

+

We don't claim that. Solving exactly should give the shortest total commute of the approaches above, and the tests support that. But this mod has far less mileage than the established ones, and stability and disruption matter too.

+

The fair test is to run each mod on a copy of the same save for a few in-game days, then compare the average commute. If you do, we'd like to hear the result.

Does it work in multiplayer, or with BeaverBuddies? -

It is designed for it. It uses whole-number math and sorted IDs, and the entire pass state is saved with the game, so every player should reach the same result even across a reload or a mid-pass join. Every player must install the same version of the mod and run the same game version. It has been used in a live hosted co-op session (about 11,000 ticks and 15 passes) with a second player on the same version, and the host's log shows no desync. That session ran the code the stable release started from; this release hasn't been played live by two players yet, so treat it as encouraging rather than conclusive.

+

It's designed for it: every player's game should make the same moves, even across a reload or a mid-pass join. Every player must install the same mod version and run the same game version.

One live hosted co-op session (about 11,000 ticks, 15 passes) showed no desync in the host's log. That session ran the code the stable release started from; this release hasn't been played live by two players yet, so treat it as encouraging rather than conclusive.

Does it work with the Iron Teeth faction? -

It hasn't been tested. It was developed and replayed on a Folktails colony, and it only handles beaver dwellers.

+

It hasn't been tested. It was developed and replayed on a Folktails colony.

@@ -184,12 +183,12 @@

The project

Is it open source? -

Yes, under the MIT license. The source, the test suite and the build script are on GitHub.

+

Yes, under the MIT license. The source, tests and build steps are on GitHub.

Is it stable? -

Yes. The code the stable release started from ran 16 consecutive passes in a live game, including a hosted co-op session, with no errors, warnings or rollbacks. This release's newer changes (pricing homes by district, remembered route costs, solving each district on its own, bigger budgets for large colonies) are covered by automated tests that run on every change, but haven't been played in a live game yet. "Stable" means that evidence plus the automated tests, not that every situation has been tried. See what is tested and what isn't.

+

Yes. The code the stable release started from ran 16 passes in a row in a live game, including a hosted co-op session, with no errors, warnings or rollbacks. This release's newer changes are covered by automated tests but haven't been played in a live game yet. See what is tested and what isn't.

diff --git a/docs/index.html b/docs/index.html index 4af5810..d2e1694 100644 --- a/docs/index.html +++ b/docs/index.html @@ -37,7 +37,7 @@

Optimized Local Housing

The shortest total walk the beds allow.

-

A Timberborn 1.1 mod. Once a day it works out where each adult beaver should live so the colony's whole walk between home and work is as short as it can be, and moves them there. Beds are limited, so not everyone lives next door to work; together, they walk the least.

+

A Timberborn 1.1 mod. Once a day, it moves adult beavers into the homes that make the colony's total walk to work as short as it can be. Beds are limited, so not everyone lives next door to work. Together, they walk the least.

  • The whole colony, not each beaver. One beaver may walk a little farther so that everyone together walks less.
  • Every home keeps its adults, and children never move. Breeding is untouched. Empty beds are left to the game.
  • @@ -100,7 +100,7 @@

    Optimized Local Housing

    185 hall's total walk, as the game left themRun the day's pass to see the arrangement the mod would choose.
-
An illustration: made-up beavers and straight-line distances, and this page simply tries every arrangement. The mod finds the best arrangement for your colony with the Hungarian algorithm, district by district, pricing homes with the game's own route costs.
+
An illustration with made-up beavers and straight-line distances; this page simply tries every arrangement. In your colony, the mod solves each district exactly, with the game's own route costs.
@@ -112,8 +112,8 @@

Optimized Local Housing

Homes shouldn't be a lottery.

-

By the look of the game's code, the built-in home assigner hands out beds without asking where a beaver works. Over time a colony ends up with beavers walking across the whole map every day, past homes right beside their job.

-

Not everyone can live next door to work, because beds are limited. So the real question is which arrangement of beavers into beds makes the total walking smallest. That is a classic assignment problem, and this mod solves it exactly, once a day, instead of nudging beavers around a swap at a time. It rearranges the adults already housed; the game's assigner still fills empty beds.

+

By the look of its code, the game hands out beds without asking where a beaver works. Beavers end up walking across the map every day, past homes right beside their job.

+

The real question is which arrangement of beavers into beds makes the total walk smallest. That is a classic assignment problem. This mod solves it exactly, once a day, instead of nudging beavers one swap at a time. It only rearranges the adults already housed.

@@ -126,12 +126,12 @@

How the plan is drawn up

Six rules the mod keeps every time it arranges your colony.

    -
  • Optimal, not first-come-first-served

    Every district is solved exactly with the Hungarian algorithm, so the colony's total commute is the smallest the rules allow, not whatever a greedy pass happens to leave over.

  • -
  • Real routes, not straight lines

    Homes are priced with the game's own route cost, so stairs, platforms and ziplines count. The 32 closest homes to each workplace, in its own district, get a real route query.

  • -
  • Families and breeding stay safe

    Every home keeps exactly the same number of adults, and children never move. Beds set aside for babies stay exactly where they are.

  • +
  • Optimal, not first-come-first-served

    Each district is solved exactly with the Hungarian algorithm. The colony's total commute is the smallest the rules allow.

  • +
  • Real routes, not straight lines

    Homes are priced with the game's own route cost, so stairs, platforms and ziplines count. Each workplace checks real routes to the 32 nearest homes in its district.

  • +
  • Families and breeding stay safe

    Every home keeps exactly the same number of adults, and children never move. Beds for babies stay where they are.

  • No pointless shuffling

    Beavers move only when the rearrangement saves at least one route-cost unit for each beaver moved. Once a colony is arranged, another pass changes nothing.

  • -
  • Smooth by design

    The work is spread across ticks with budgets per tick: 32 route queries on a colony of a few hundred beavers, and up to 128 on a large one, so its pass still ends within the daytime (only the very largest run longer).

  • -
  • Built with co-op in mind

    Whole-number math, sorted IDs and a fully saved pass state are meant to give every player the same result, even across a save, a reload or a mid-pass join. What has been played

  • +
  • Smooth by design

    The work is spread over many ticks, a little at a time, so there is no long freeze. A large colony does more per tick to finish within the daytime; only the very largest take longer.

  • +
  • Built with co-op in mind

    Every player's game should make the same moves, even across a save, a reload or a mid-pass join. What has been played

@@ -141,14 +141,14 @@

How the plan is drawn up

One pass, five steps

-

A pass runs as soon as the game is ticking the first time the mod sees a save, then at the start of every day. The steps are spread over many ticks, so there is no long freeze.

+

The first pass starts as soon as the game runs on a save the mod hasn't seen. After that, a pass runs at the start of every day.

  1. Capture

    Every housed adult beaver, its home and its assigned workplace, in one quick snapshot.

  2. -
  3. Price

    Real route costs from each workplace's 32 nearest homes in its district. Anything farther is estimated, or taken from a recent check, and any move to it is re-checked first.

  4. -
  5. Solve

    The best possible way to reassign the adults to the beds that adults occupy today, one district at a time, since nobody moves between districts.

  6. -
  7. Verify

    Every proposed move is priced again with fresh routes. A cycle of moves is thrown away if it would cut off a beaver who can reach work today, or if it doesn't save enough.

  8. +
  9. Price

    Real route costs from each workplace to its 32 nearest homes in its district. Farther homes are estimated.

  10. +
  11. Solve

    The best way to reassign the adults to the beds adults use today, one district at a time.

  12. +
  13. Verify

    Every proposed move is priced again with fresh routes. A cycle of moves is dropped if it would cut a beaver off from work, or if it saves too little.

  14. Apply

    Whole cycles of moves are applied in a single tick, and rolled back if the game refuses any of them.

@@ -183,17 +183,14 @@

One pass, five steps

What it always does

    -
  • Keeps every home's number of adults exactly the same.
  • Leaves unemployed adults free to give up good beds to beavers who commute.
  • Repairs a broken commute by moving a beaver to a home that can reach its workplace, when a bed can be arranged.
  • Skips a move if the beaver, its job or its home changed while the pass was running, and tries again the next day.
  • -
  • Turns itself off if Housing Optimize or Commute Balancer is enabled.

What it never does

    -
  • Move children.
  • Move anyone into a paused, blocked or automation-off home, or out of one.
  • Move a beaver who can reach work into a home that can't.
  • Move a beaver into another district.
  • @@ -223,7 +220,7 @@

    Next to Housing Optimize and Commute Balancer

-

In a replay of one real colony, a first-come-first-served model like the one Housing Optimize describes averaged 25.6 (23.5 to 29.0, depending on the order workplaces were handled) against 24.1 for this mod. That was a model with straight-line distances, not a benchmark of either mod. More in the FAQ

+

In a replay of one real colony, a first-come-first-served model like the one Housing Optimize describes averaged 25.6 (23.5 to 29.0, depending on the order workplaces were handled) against 24.1 for this mod. That was a model with looser bed rules and straight-line distances, not a benchmark of either mod. More in the FAQ

Don't run them together: Optimized Local Housing turns itself off if Housing Optimize or Commute Balancer is enabled.

@@ -281,7 +278,7 @@

Average commute

In the live game

-

The log of a real colony: about 350 adults, 104 homes, 167 workplaces. 16 passes in a row, each about 183 ticks and 5,350 route queries, applying between 0 and 4 move cycles, with no errors, warnings or rollbacks.

+

The log of a real colony of about 350 adults, 104 homes and 167 workplaces. 16 passes in a row, each about 183 ticks, applied 0 to 4 move cycles with no errors, warnings or rollbacks.

[OptimizedLocalHousing] Pass 26: 356 adults, 104 homes, 167 workplaces; 5354 route queries over 182 ticks; 2 move cycles applied (0 rejected, 0 stale), 0 disconnected commutes repaired, route cost saved 177.
@@ -302,7 +299,7 @@

In the live game

What is tested, and what isn't

-

Stable means the evidence below, not that every situation has been tried. Here is the honest picture.

+

Stable means the evidence below, not that every situation has been tried.

@@ -310,11 +307,7 @@

Tested

  • 16 passes in a row in a live game (about 350 adults, 104 homes, 167 workplaces) with no errors, warnings or rollbacks, on the code the stable release started from.
  • A hosted co-op session with a second player on the same version: about 11,000 ticks, 15 passes, and no desync in the host's log.
  • -
  • 41 automated checks: 40 run on every change, and one runs against the installed game. They include the solver against brute force, colonies with several districts, and large colonies.
  • -
  • Two simulated players stay identical at every tick of a pass, including when one reloads a save taken mid-pass.
  • -
  • Saving and reloading at any tick of a pass gives exactly the uninterrupted result.
  • -
  • Route queries and solver work stay within their per-tick budgets, and a large colony's pass ends within the daytime.
  • -
  • The compiled mod passes a check against the game's own component rules.
  • +
  • 41 automated checks: 40 run on every change, and one runs against the installed game. They cover the solver against brute force, several districts, large colonies, and two players staying in step through saves and reloads.
  • The replay of a real colony above.
diff --git a/docs/install.html b/docs/install.html index 7866938..d8c15df 100644 --- a/docs/install.html +++ b/docs/install.html @@ -31,7 +31,7 @@

Install guide

-

About five minutes. You need Timberborn 1.1 and nothing else: no other mods are required.

+

About five minutes. You need Timberborn 1.1 and no other mods.

@@ -50,30 +50,30 @@

Install guide

-

Back up first. As with any mod, keep a copy of your save so you can undo the moves the mod makes.

+

Back up first. The mod's moves can only be undone by loading an earlier save.

Requirements

    -
  • Timberborn 1.1. The mod is built against 1.1.2.4 and asks for 1.1.0.0 or newer. A future game update could break it.
  • -
  • Windows. That is the only system it has been checked on. It is an ordinary game mod, so other systems may work, but the Mods folder is in a different place there.
  • +
  • Timberborn 1.1. It needs 1.1.0.0 or newer and is built against 1.1.2.4. A future game update could break it.
  • +
  • Windows. It has only been checked on Windows. Other systems may work, but their Mods folder is elsewhere.
  • No other mods. No Harmony, no Mod Settings.
  • -
  • Do not run it alongside Bobingabout's Housing Optimize or Commute Balancer. It disables itself if it sees either of them enabled. See the FAQ.
  • +
  • Do not run it alongside Bobingabout's Housing Optimize or Commute Balancer. It turns itself off if either is enabled (why).

Step by step

    -
  1. Back up your save

    Copy the save you want to use from Documents\Timberborn\Saves so you can go back if you don't like the result.

  2. -
  3. Download the mod

    Download 1.1.1

    Get OptimizedLocalHousing-v1.1.1.zip from the release page. It is listed under Assets; don't download "Source code". The mod is distributed from GitHub, not the Steam Workshop.

  4. +
  5. Back up your save

    Copy the save you want to use from Documents\Timberborn\Saves.

  6. +
  7. Download the mod

    Download 1.1.1

    Get OptimizedLocalHousing-v1.1.1.zip from the release page. It's under Assets, not "Source code". The mod isn't on the Steam Workshop.

  8. Close Timberborn

    Make sure the game is fully closed before you copy files into its Mods folder.

  9. -
  10. Extract into your Mods folder

    Extract the ZIP into Documents\Timberborn\Mods. It contains one folder, OptimizedLocalHousing, and you should end up with the layout shown below. If you extracted into a new folder, you may have a doubled OptimizedLocalHousing\OptimizedLocalHousing: move the inner one up (the layout shows both).

  11. -
  12. Enable it and restart

    Start Timberborn, open Mods from the main menu, tick Optimized Local Housing, and restart the game when it asks. Don't run them together: Optimized Local Housing turns itself off if Housing Optimize or Commute Balancer is enabled. Menu wording can differ a little between game versions.

  13. -
  14. Load your save and let the game run

    On a save the mod hasn't seen before, the first pass starts as soon as the game is ticking (not while paused). After that it runs at the start of every in-game day. Check that it ran.

  15. +
  16. Extract into your Mods folder

    Extract the ZIP into Documents\Timberborn\Mods. You should get one OptimizedLocalHousing folder, as in the layout below.

  17. +
  18. Enable it and restart

    Start Timberborn and open Mods from the main menu. Tick Optimized Local Housing, then restart the game when it asks.

  19. +
  20. Load your save and let the game run

    On a save the mod hasn't seen, the first pass starts as soon as the game runs (not while paused). After that, a pass runs at the start of every in-game day. Check that it ran.

Folder layout

-

This is what a correct install looks like. The game reads the manifest and the DLL from the version-1.1 folder.

+

This is what a correct install looks like.

Right
@@ -105,34 +105,27 @@

Check that it works

  • Quit the game, then open %USERPROFILE%\AppData\LocalLow\Mechanistry\Timberborn\Player.log. If you have already restarted, the previous session is in Player-prev.log.
  • Search for [OptimizedLocalHousing]. You should see this at startup:
    [OptimizedLocalHousing] 1.1.1 loaded.
  • -
  • After a pass finishes you should see a summary line (roughly 90 seconds to two minutes at normal game speed on a colony of a few hundred beavers, faster at higher speeds). This is a real line from a live game, and your numbers will differ: +
  • After each pass you should see a summary line. On a colony of a few hundred beavers, a pass takes about 90 seconds to two minutes at normal speed. Here is a real one; your numbers will differ:
    [OptimizedLocalHousing] Pass 26: 356 adults, 104 homes, 167 workplaces; 5354 route queries over 182 ticks; 2 move cycles applied (0 rejected, 0 stale), 0 disconnected commutes repaired, route cost saved 177. -
    -
    356 adults, 104 homes, 167 workplaces
    who was in the plan
    -
    5354 route queries over 182 ticks
    the work, spread out
    -
    2 move cycles applied
    groups of beavers who swapped beds
    -
    0 rejected, 0 stale
    moves thrown out at the fresh check, or because something changed during the pass
    -
    0 disconnected commutes repaired
    beavers moved to a home that can reach their work
    -
    route cost saved 177
    how much shorter the colony's walk got
    -
  • -

    No line, or an error line? Head to Troubleshooting.

    +

    What the numbers mean. No line, or an error line? See Troubleshooting.

    Multiplayer

    -

    Every player must install the same version of the mod and run the same game version, because the mod changes which beaver lives where and all players' games have to agree. The pass is designed to give the same result on every machine and to resume correctly after a save, a reload or a join. It has been used in a live hosted co-op session (about 11,000 ticks and 15 passes) with no desync reported by the host. That session ran the code the stable release started from; this release hasn't been played live by two players yet, so if you try it please tell us how it went.

    +

    Every player must install the same version of the mod and run the same game version. The pass is built to make the same moves on every machine, even after a save, a reload or a join.

    +

    It ran in one live hosted co-op session (about 11,000 ticks and 15 passes) with no desync in the host's log. That session ran the code the stable release started from; this release hasn't been played live by two players yet. If you try it, please tell us how it went.

    Updating

    1. Close the game and delete the old Mods\OptimizedLocalHousing folder.
    2. Extract the new ZIP into Mods as above.
    3. -
    4. Start the game. Your saves keep working.
    5. -
    6. In multiplayer, every player must update to the same version together.
    7. +
    8. Start the game.
    9. +
    10. In multiplayer, every player updates together.

    Uninstalling

    -

    Untick it in the Mods menu and restart, or delete the OptimizedLocalHousing folder. Nothing else is needed. Beavers keep the homes they have, and any leftover mod data in your save is ignored. To undo the moves already made, go back to a save from before you installed it.

    +

    Untick it in the Mods menu and restart, or delete the OptimizedLocalHousing folder. Beavers keep the homes they have, and the mod's leftover data in your save is ignored.

    Verify the download (optional)

    In PowerShell, from the folder you downloaded to:

    diff --git a/docs/troubleshooting.html b/docs/troubleshooting.html index 5e13abd..66b7337 100644 --- a/docs/troubleshooting.html +++ b/docs/troubleshooting.html @@ -68,48 +68,47 @@

    Find your symptom

    The mod isn't in the Mods list
    -
      -
    • Wrong folder depth. The game needs Mods\OptimizedLocalHousing\version-1.1\manifest.json. A doubled OptimizedLocalHousing\OptimizedLocalHousing folder is the usual mistake. See the folder layout.
    • -
    • Wrong Mods folder. It must be the folder your other mods are in, normally Documents\Timberborn\Mods.
    • -
    • Old game. The mod needs Timberborn 1.1 or newer. Older versions won't load it.
    • -
    • Fully quit and restart the game after copying files.
    • -
    +
      +
    1. Check the folder depth. The game needs Mods\OptimizedLocalHousing\version-1.1\manifest.json. A doubled OptimizedLocalHousing\OptimizedLocalHousing folder is the usual mistake; see the folder layout.
    2. +
    3. Check the Mods folder. It must be the one your other mods are in, normally Documents\Timberborn\Mods.
    4. +
    5. Check the game version. The mod needs Timberborn 1.1 or newer.
    6. +
    7. Fully quit and restart the game.
    8. +
    It's enabled, but there is no [OptimizedLocalHousing] line in the log
    -
      -
    • Make sure you're reading the right session. The log is overwritten each launch, and the previous one is Player-prev.log.
    • -
    • Check the mod list near the top of the log. Optimized Local Housing (v1.1.1) should be listed. If it isn't, it wasn't enabled, or you didn't restart after enabling it.
    • -
    • If it's listed but the loaded. line is missing, check the game didn't fail to load the mod's DLL further down the log, and report it with that log.
    • -
    +
      +
    1. Make sure you're reading the right session. The log is overwritten at each launch; the previous one is Player-prev.log.
    2. +
    3. Find the mod list near the top of the log. Optimized Local Housing (v1.1.1) should be in it. If it isn't, enable the mod and restart.
    4. +
    5. If it's listed but there's no loaded. line, look further down for an error loading the mod's DLL, and report it with that log.
    6. +
    It says loaded. but I never see a Pass line
    -
      -
    • The game has to run. Passes only progress while the game is ticking. Paused time doesn't count. A pass takes roughly 150 to 200 ticks on a colony of a few hundred beavers, about 90 seconds to two minutes at normal speed.
    • -
    • Saves the mod has already seen start their next pass at the beginning of the next in-game day, not straight away. Only a save the mod hasn't seen before starts a pass immediately, and a save made during a pass carries on with it.
    • -
    • You quit the game before the pass finished. Let it run a little longer, and note the line is written when the pass ends.
    • +
        +
      1. Unpause and let the game run. A pass takes about 150 to 200 ticks on a colony of a few hundred beavers: roughly 90 seconds to two minutes at normal speed.
      2. +
      3. Don't quit too early. The line is written when the pass ends.
      4. +
      5. Wait for the next day on a save the mod has seen before. Only a save it hasn't seen starts a pass straight away.
      6. Look for "Disabled because…" or "Pass abandoned…" in the log.
      7. -
    +
    The log says Disabled because another housing assignment mod is enabled
    -

    Optimized Local Housing turns itself off when it sees another mod that reassigns beavers' homes, because two of them would keep undoing each other. The message ends with the ID it found. It checks for these:

    +

    Disable the other housing mod in the Mods menu and restart. Two housing mods would keep undoing each other's moves. The message ends with the ID of the mod it found:

    • BobHousingOptimize (Bobingabout's Housing Optimize)
    • BobCommuteBalancer (Bobingabout's Commute Balancer)
    • housingoptimize (a mod.io listing of Housing Optimize)
    -

    Disable the other mod in the Mods menu and restart. Only one housing mod should be on.

    @@ -119,13 +118,13 @@

    Find your symptom

    Reading the line: Pass 34: 345 adults, 104 homes, 167 workplaces; 5394 route queries over 183 ticks; 4 move cycles applied (1 rejected, 2 stale), 0 disconnected commutes repaired, route cost saved 717.

    • adults / homes / workplaces: how many the pass considered.
    • -
    • move cycles applied: groups of beavers that swapped beds around. Zero is the correct answer when the colony is already as good as it can be. A second pass on an optimized colony changes nothing.
    • -
    • rejected: the fresh route check threw a proposed cycle away, because a beaver would end up unable to reach work, or the cycle didn't save at least half a route-cost unit. The route costs it found are remembered (and checked again when they come due), so the same cycle isn't proposed again every day.
    • -
    • stale: someone in the cycle changed home or job, died, or a home couldn't take them, between the snapshot and the moment of applying. Small numbers are normal. These beavers are reconsidered in the next pass.
    • -
    • disconnected commutes repaired: moved beavers whose old home couldn't reach their workplace and whose new home can. A cut-off beaver that was moved but still can't reach work isn't counted.
    • -
    • route cost saved: the net drop in route cost across the beavers that moved. Repaired commutes aren't included, since they had no route before.
    • +
    • move cycles applied: groups of beavers who swapped beds. Zero is normal once the colony is as good as it can be.
    • +
    • rejected: cycles the fresh route check threw away, because a beaver would lose its route to work or the cycle saved too little. The costs it found are remembered, so the same cycle isn't proposed every day.
    • +
    • stale: cycles skipped because something changed during the pass: a beaver's home or job, a death, or a home that could no longer take them. Small numbers are normal; those beavers are reconsidered the next day.
    • +
    • disconnected commutes repaired: beavers who couldn't reach work from their old home and can from the new one.
    • +
    • route cost saved: how much shorter the movers' walks got in total. Repaired commutes aren't counted, since they had no route before.
    -

    Persistent zeros on a colony that clearly needs help usually mean the beavers aren't eligible: they have no assigned workplace, the workplace is disabled or in another district, or their homes are paused, blocked or switched off by automation. Those beavers are left alone by design.

    +

    Zeros on a colony that clearly needs help usually mean the beavers aren't eligible. They have no job, or their homes are paused, blocked or switched off by automation, and those are left alone by design.

    @@ -134,11 +133,11 @@

    Find your symptom

    • Beds are limited. The mod minimizes the total. Someone has to live farther away, and it may be the beaver you're watching.
    • -
    • Route cost isn't distance. The mod uses the game's route cost, so stairs and ziplines can make a home that looks close actually costly, or a far one cheap.
    • -
    • Commute means home to assigned workplace. A beaver that wanders off to haul goods or a different job site isn't measured by that.
    • +
    • Route cost isn't distance. Stairs and ziplines can make a home that looks close costly, or a far one cheap.
    • +
    • Commute means home to assigned workplace. Trips to haul goods or visit other buildings don't count.
    • Timing. New jobs, new homes and births show up in the next pass.
    • -
    • Vacant beds aren't used. Every home keeps its number of adults, and empty beds are left for the game and for babies. See the FAQ.
    • -
    • Candidate homes are limited to the 32 nearest by block distance in each workplace's district, plus a re-check of anything farther. A home far away by straight line but close by zipline could be missed.
    • +
    • Empty beds aren't used. They're left for the game and for babies (why).
    • +
    • Only nearby homes are priced. Each workplace checks its 32 nearest homes; farther ones are estimated. A far home made cheap by a zipline could be missed.
    @@ -146,29 +145,30 @@

    Find your symptom

    Everyone moved at once, or parents ended up away from their children
    -

    Expected on the first pass of a badly housed colony: the best arrangement can differ from the current one for most adults. Children never move, so a child can end up in a home with different adults than before. Every home still has the same number of adults, so babies and breeding capacity are untouched. Later passes move only a few beavers. If you dislike the first result, load a backup save and don't install the mod.

    +

    That's expected on the first pass of a badly housed colony. Children never move, so a child may end up living with different adults; breeding is untouched. Later passes move only a few beavers.

    +

    If you dislike the result, load your backup and remove the mod.

    The game hitches when a pass starts or finishes
    -

    The pass is split into steps with per-tick budgets (32 route queries per tick on a colony of a few hundred beavers; a large colony's pass does up to 128, and more solver work per tick, so that it usually ends within the daytime), but two moments do their work in a single tick: taking the snapshot when a pass starts, and applying the moves when it ends. On a large colony either could cause a brief blip. Frame-time impact hasn't been measured; for scale, a pass on a live colony of about 350 adults, 104 homes and 167 workplaces used about 5,350 route queries over about 183 ticks, with no problems reported.

    -

    If you see a real stutter, please report it with your colony size and the pass line from the log. Until it's fixed you can disable the mod.

    +

    Most of a pass is spread over many ticks, but two moments happen in a single tick: taking the snapshot when a pass starts, and applying the moves when it ends. On a large colony either could cause a brief blip.

    +

    Frame-time impact hasn't been measured. If you see a real stutter, report it with your colony size and the pass line; until it's fixed, you can disable the mod.

    The log says Pass abandoned until the next day
    -

    An unexpected error stopped the pass. It is contained: no beavers are left half-moved, the game keeps running, and the mod tries again the next day. Copy the full message, which includes the error and where it happened, and report it. That is a bug we want to hear about.

    +

    An error stopped the pass. No beaver is left half-moved, the game keeps running, and the mod tries again the next day. It's a bug: copy the full message and report it.

    The log says A move cycle failed and was rolled back
    -

    The game refused one of the assignments in a cycle. The mod put every beaver in that cycle back in its original home, so nothing is lost. If it happens repeatedly, report it with the message.

    +

    The game refused one of the moves in a cycle, so every beaver in it went back to its old home. Nothing is lost. If it keeps happening, report it with the message.

    @@ -182,25 +182,31 @@

    Find your symptom

    Multiplayer: the game desynced, or players see different homes
    -
      -
    • Every player must install the same version of the mod and run the same game version. If only some players have the mod, or the versions differ, the games will disagree about where beavers live.
    • -
    • Restart the session from the host's save with everyone on the same version.
    • -
    • It has been used in one live hosted co-op session (about 11,000 ticks and 15 passes) with no desync reported by the host, so a desync would be a new finding. If it happens, please report it: include every player's Player.log from the session and say when it happened relative to a Pass line.
    • -
    +
      +
    1. Check that every player has the same mod version and game version. If only some players have the mod, or versions differ, the games will disagree about where beavers live.
    2. +
    3. Restart the session from the host's save.
    4. +
    5. If it happens again, report it with every player's Player.log, and say when it happened relative to a Pass line.
    6. +
    +

    One live co-op session, on the code the stable release started from, showed no desync. This release hasn't been played live by two players yet, so a report helps.

    It stopped working after a Timberborn update
    -

    The mod is built against Timberborn 1.1.2.4. A game update can change the parts it relies on. Look in the log for an error mentioning OptimizedLocalHousing, disable the mod until a matching release is available, and check the releases page.

    +

    The mod is built against Timberborn 1.1.2.4, and a game update can change the parts it relies on.

    +
      +
    1. Look in the log for an error mentioning OptimizedLocalHousing.
    2. +
    3. Disable the mod until a matching release is out.
    4. +
    5. Check the releases page.
    6. +
    I want to undo what it did
    -

    Disabling or deleting the mod stops further changes but doesn't move anyone back. To undo the moves already made, load a save from before you installed it. That is why you should try it on a copy first.

    +

    Load a save from before you installed it. Disabling the mod stops further moves, but doesn't move anyone back.

    From 71d1f419ea66135420ddf228b3b60ec6d38617d2 Mon Sep 17 00:00:00 2001 From: Kyler Ramsey Date: Thu, 24 Sep 2026 01:37:08 -0700 Subject: [PATCH 2/2] Troubleshooting: symptoms with log text in their title read again details.q summary is a two-column grid (text, then the 24px arrow). A summary that mixed text and became several grid items, so the log text landed in the arrow's column, one character per line, on seven of the eleven symptoms (live on main too). Each such summary's content is wrapped in one , like the plain-text summaries; no CSS change. Co-Authored-By: Claude Opus 5.5 --- docs/troubleshooting.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/troubleshooting.html b/docs/troubleshooting.html index 66b7337..3ffb142 100644 --- a/docs/troubleshooting.html +++ b/docs/troubleshooting.html @@ -78,7 +78,7 @@

    Find your symptom

    - It's enabled, but there is no [OptimizedLocalHousing] line in the log + It's enabled, but there is no [OptimizedLocalHousing] line in the log
    1. Make sure you're reading the right session. The log is overwritten at each launch; the previous one is Player-prev.log.
    2. @@ -89,7 +89,7 @@

      Find your symptom

    - It says loaded. but I never see a Pass line + It says loaded. but I never see a Pass line
    1. Unpause and let the game run. A pass takes about 150 to 200 ticks on a colony of a few hundred beavers: roughly 90 seconds to two minutes at normal speed.
    2. @@ -101,7 +101,7 @@

      Find your symptom

    - The log says Disabled because another housing assignment mod is enabled + The log says Disabled because another housing assignment mod is enabled

    Disable the other housing mod in the Mods menu and restart. Two housing mods would keep undoing each other's moves. The message ends with the ID of the mod it found:

      @@ -113,7 +113,7 @@

      Find your symptom

    - The pass line says 0 move cycles applied, or the numbers look strange + The pass line says 0 move cycles applied, or the numbers look strange

    Reading the line: Pass 34: 345 adults, 104 homes, 167 workplaces; 5394 route queries over 183 ticks; 4 move cycles applied (1 rejected, 2 stale), 0 disconnected commutes repaired, route cost saved 717.

      @@ -159,21 +159,21 @@

      Find your symptom

    - The log says Pass abandoned until the next day + The log says Pass abandoned until the next day

    An error stopped the pass. No beaver is left half-moved, the game keeps running, and the mod tries again the next day. It's a bug: copy the full message and report it.

    - The log says A move cycle failed and was rolled back + The log says A move cycle failed and was rolled back

    The game refused one of the moves in a cycle, so every beaver in it went back to its old home. Nothing is lost. If it keeps happening, report it with the message.

    - The log says Saved state ignored + The log says Saved state ignored

    The mod couldn't read its own data from the save. It starts fresh, at no cost to your colony.