`sots_turn` loads a save through the engine's own reader, walks the published phase order of all three turn drivers, runs what we hold, prints what we do not, and writes the result back through the engine's own writer. The phase catalog carries all 32 + 12 + 37 phases whether or not they are implemented, so an unimplemented phase is a named no-op that appears in the run log rather than a silent absence. 14 of the 44 turn-driver phases are modelled, 7 commit anything, 2 of the 37 tail phases are modelled. Modelled but NOT committed is a first-class state. A phase whose formula we hold and whose inputs we do not is evaluated, reported, and left unwritten unless --commit-blocked is passed. That distinction was earned: committing phase 31's player-status restore regressed two leaves that had agreed with the oracle before the turn, because the phase writes 1 and the file carries 4. Measured against the game's own post-turn saves, leaves localised by state_checksum.py with coverage proved by re-serialisation: turn1-state -> turn2-state 209 -> 204 diverging, closed 5, regressed 0 turn2-state -> turn3-state 108 -> 103 diverging, closed 5, regressed 0 Two tests: app_catalog (the tables stay complete and nothing claims to be verified against a live game) and app_turn (11 saves driven; an untouched load re-serialises byte-identically, a turn leaves the file re-readable, and no blocked or stub phase writes anything). Skips cleanly without SOTS_SAVES_DIR. ctest 38/38, clean-room OK. src/shim untouched. docs/S-standalone.md has the full gap list. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ARBgSooAfokKUy6wKUKEyZ
36 lines
3 KiB
Markdown
36 lines
3 KiB
Markdown
# sots-engine
|
|
|
|
A from-scratch, functional reimplementation of the engine behind **Sword of the Stars (2006)**.
|
|
Not a byte-for-byte decompilation: behavior-equivalent code, built up one verified piece at a time
|
|
(OpenRCT2-style) until the tree can build the whole application on its own.
|
|
|
|
**Bring your own game.** This repository contains engine code only. Game data, assets, saves, and
|
|
the original binaries are never included; tests and tools read an owner-supplied copy via
|
|
`$SOTS_DATA_DIR`. See `CONTRIBUTING.md` for the clean-room rules.
|
|
|
|
## Status
|
|
Phase 2. **M0 done** — the shim frontend (`src/shim/`, a proxy `binkw32.dll` the original game
|
|
loads) builds, deploys, hooks, and logs from a real game launch. Engine code accrues under
|
|
`src/mars/` and `src/game/`; each module is oracle-verified against the owner's game data before merge:
|
|
- `mars/parse` — brace-block + `.effect` readers (1,531/1,531 files agree with the reference)
|
|
- `mars/text` — flat key/value tables, id manifests, CSV (64/64 files agree)
|
|
- `game/sim` — strategic formulas (economy, research, colonies, movement) as pure functions; 356 hand-computed checks
|
|
- `mars/vfs` — `.gob` (ZIP) archive reader + loose-file override; entry counts and bytes verified against `unzip`
|
|
- `mars/stream` — the game's self-describing save/serialization format (reader, writer, typed shapes) + gzip; three real saves round-trip byte-identical
|
|
- `mars/rng` — MT19937 with save-state load/store; layout confirmed against real saves, draw mappings read off the binary (`docs/mars-rng.md`)
|
|
- `game/data` — typed catalogs (weapons, ship sections, turrets, id registries, tech tree, strings) with cross-reference checks; 229k values agree with the reference
|
|
- `game/design` — ship-design assembly/fit/tech-gating rules and derived stats; validates all 127 stock designs from real saves
|
|
- `app` — **the standalone**: `sots_turn` loads a save, runs one strategic turn over the published phase order of all three turn drivers, and writes a save. 14 of the 44 turn-driver phases are modelled; every phase that is not appears in the run log as a named no-op. How far it is from the byte-match, and what stands in the way, is in `docs/S-standalone.md`
|
|
|
|
Build: `cmake --preset host && cmake --build --preset host && ctest --preset host` (Linux);
|
|
`tools/sync-build.sh` cross-builds the shim on the lab box and stages it for deployment.
|
|
|
|
## Layout (grows with the work)
|
|
- `src/shim/` — binkw32 proxy + hooks + old-vs-new compare harness (frontend #1)
|
|
- `src/mars/`, `src/game/` — the engine and game reimplementation (accruing)
|
|
- `src/app/` — the standalone turn driver (frontend #2): load a save, run a turn, write a save
|
|
- `include/generated/sots_addresses.h` — binary facts (RVAs/prototypes), generated from the RE repo
|
|
- `tests/` — host tests; real-data tests skip unless `$SOTS_DATA_DIR` is set
|
|
- `tools/` — build (MinGW i686 cross) and deploy scripts
|
|
|
|
Planning, findings, and verification evidence are tracked in the private RE repo (`sots-re`).
|