Research toward Stronghold Crusader AIs that adapt on their own - reacting to the live game state instead of following a fixed build plan.
The current bot and offline framework are organized together in src/selfaware/,
with separate packages for game access, live orchestration, macro, micro,
strategy, learning and telemetry. Start with the repository map,
agent handoff, architecture, and
engineering acceptance details. Task status is maintained in
the authoritative backlog.
The strategy design develops the next behavior ideas: sustained aggression, layered defense, phased castles, technology choices and explicit state/decision gates, with linked implementation work.
With uv 0.12.9 installed, run from a fresh checkout:
uv sync --locked --extra dev
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run selfaware doctor --offline
uv run selfaware replay tests/fixtures/legacy_sample.jsonlThe package supports Python 3.11+; CI covers Windows/Linux with Python 3.11 and
3.14. Offline checks require no game installation. uv build builds the package.
Use --extra legacy for the old tools' Python libraries and --extra audit for
Lua audit probes. Dependency resolution is recorded in uv.lock.
The existing Rust game DLL is in crates/samurai-kern, including its explicit 32-bit Windows build command. It is compiled by Windows CI.
The new BotRuntime currently operates on recorded observations. The current
live bot is selfaware.runtime.live.erstes_spiel; its policies and external
game requirements are preserved. Launch existing modules with uv run selfaware run <name> [arguments], or uv run python -m <module>. uv run selfaware modules
lists all 184 relocated module names. Missing external
VillageStudio files and known connector defects are documented in the backlog;
a green offline check does not establish live-game readiness.
This repository collects the reverse-engineering handbook behind that goal: memory addresses, data structures and measured in-game behaviour for Stronghold Crusader / Crusader Extreme under UCP3.
- Wissensstand.md - the handbook: what is known about the AI build lists, units, tiles and walls, and the runtime. Every fact carries a confidence mark (proven / measured / read-from-code / assumed).
Early research. Assumptions are labelled and must not be relied on.
Jeder Rechner (Laptop, Desktop-PC, jede Sitzung) committet und pusht nach jeder
echten Partie, spaetestens vor dem Eintrag im docs/research/Wissensregister.md:
- Die Mitschrift
data/research/<name>_konsole.txt. Ihre ersten Zeilen sindCODE-KENNUNG ...undSTART-BEFEHL Instanz N: uv run python -m selfaware.runtime.live.erstes_spiel ...(schreibterstes_spiel.pyselbst). Wer nicht uebererstes_spiel.pystartet, schreibt den vollstaendigen Aufruf von Hand als erste Zeile. - Alles, was die Partie neu angelegt hat und zum Nachspielen noetig ist:
data/research/start_<karte>*.json/.txt,data/research/eroeffnung_plan_<karte>.json,data/research/baeume_*,data/research/rohstoffe_*, Saat-Dateien. - Das Lageprotokoll
data/research/lage_<stempel>_i<n>.jsonl.gz, wenn es kleiner als 50 MB ist; sonst im Register vermerken, auf welchem Rechner es liegt. - Die Umgebung, wenn sie anders ist als zuletzt notiert: Karte, Gegner-KI
und deren Plugin-Fassung, Instanz, geaenderte
ucp-config.yml-Stellen und die Pruefsumme derucp/villagestudio/logik.lua. Aendert sich dielogik.lua, kommt die neue Fassung als Kopie nachbridge/snapshots/.
Die Registerzeile einer Partie nennt den Dateinamen ihrer Mitschrift. Ohne diese Dateien kann kein anderer Rechner einen Lauf nachspielen oder auswerten (17.10.: der Laptop musste Karte und Schalter von 1017a-g raten).