266 Commits

Author SHA1 Message Date
Tom di Mino
e653c8d306 feat(economy): wire economy system into simulation tick loop
- EconomyState added to SimulationStates
- Economy tick runs BEFORE manufacturing (per original game order)
- Support drift applied to GameWorld popularity fields per tick
- Collection rate and garrison requirement events emitted on change
- Garrison events suppressed when unchanged (avoids 525K/run flood)
- 3 construction sites updated: playtest main, 2 simulation test helpers

351 tests passing, economy events visible in playtest JSONL.
Eval score regression expected — eval_game_quality.py denominators need
adjustment to filter economy/AI volume from ratio calculations (Phase 1.3).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 23:01:38 -04:00
Tom di Mino
e91b830d27 feat(economy): implement per-system economy tick loop (P1 critical gap)
New economy.rs module — the single biggest parity gap from the community
disassembly cross-reference. Implements the per-system economy tick from
FUN_005073d0 with:

- Popular support drift formula (GNPRTB 7686-7688, 7732-7737):
  military presence suppresses dissent, support drifts away from
  controlling faction when below threshold with no friendly fleet
- Collection rate calculation (GNPRTB 7763): inversely proportional
  to popular support — higher support = lower taxation
- Garrison requirement (GNPRTB 7761-7762): troops needed to prevent
  uprising, Empire core systems need half the garrison
- EconomyState with per-system resource tracking
- 11 unit tests covering drift, suppression, collection, garrison

351 tests passing, zero failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 22:48:06 -04:00
Tom di Mino
d6e677aa6f feat: Knesset Ereshkigal Phase 0+1 — effect algebra + P0 formula fixes
Phase 0: Open Souls functional programming foundation
- New effects.rs: 45-variant GameEffect enum with EffectPhase ordering,
  monoidal composition (combine_effects), filtering, and invertibility
  for autoresearch rollback. 7 unit tests.
- New telemetry constants: 12 EVT_* + 2 SYS_* (economy, repair) in
  game_events.rs. Uniqueness test now covers all 39 constants.

Phase 1.1: P0 mission formula corrections (community disassembly cross-ref)
- Sabotage: (espionage + combat) / 2 instead of raw espionage
- InciteUprising: subtracts counter-intelligence espionage rating
- Abduction: subtracts target character's combat defense
- Assassination: subtracts target character's combat defense
- Recruitment: uses target character's loyalty as resistance
- compute_table_input() gains target_character parameter
- MissionOutcome gains Serialize + Deserialize derives
- 5 new unit tests verifying each corrected formula

340 tests passing, zero warnings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 22:34:39 -04:00
Tom di Mino
6a56be9df1 fix(combat): thread difficulty_index through 2 missed bombardment calls
Reviewer caught hardcoded difficulty=2 in AI-vs-AI bombardment path
(simulation.rs:327) and interactive post-ground-combat bombardment
(main.rs:659). Both now use world.difficulty_index.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 23:30:10 -04:00
Tom di Mino
e311016b85 fix(combat): resolve all 10 Knesset Ma'at review findings
Shield absorption: replaced f64 double-truncation with single i64 integer
division to eliminate rounding loss. recall_fighters: added
originally_launched parameter to preserve grounded (never-launched)
squadrons. Difficulty: added GameWorld.difficulty_index field, threaded
through all combat/bombardment calls (was hardcoded to 2). TroopClassDef:
added deduplicated eprintln! warning when class data missing. Tactical
view: fighter damage now absorbs shields first (consistent with
auto-resolve), weapon type uses actual CapitalShipClass stats instead of
hull_max bracket. Removed dead code (ButtonSprite::disabled,
atk_class_defense fetch). Replaced deprecated Frame::none() with
Frame::NONE.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 23:28:08 -04:00
Tom di Mino
8c42aa9c8e docs: add 10 review findings to 100% parity plan
Wave 1+3 marked DONE with checkboxes. 10 review findings from
code reviewer + silent failure hunter added as tracked register.
1 HIGH already FIXED (event screen keyboard blocking).
9 remaining: shield rounding, fighter recall loss, hardcoded
difficulty, TroopClassDef fallback, tactical view inconsistencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:28:22 -04:00
Tom di Mino
c4895e79f4 feat: Knesset Ma'at Wave 1+3 — combat formulas + UI assets + review fixes
Wave 1 — Combat Formula Parity (3 Opus agents):
- Shield absorption phase (Phase 4): pending damage pipeline,
  shield recharge, ion 2x multiplier, overflow to hull (+8 tests)
- Fighter combat: launch from carriers (capacity-gated), per-weapon
  dogfight with maneuverability, recall capped to surviving carriers (+6 tests)
- Ground combat: per-unit resolution with TroopClassDef (attack/defense),
  facility defense bonus, difficulty modifiers wired throughout (+6 tests)

Wave 3 — UI Asset Integration (2 Sonnet agents):
- Cockpit BMP button sprites (9 buttons, 3-state from COMMON.DLL)
- Event screen overlay (61 STRATEGY.DLL BMPs, 5s timer, click-dismiss)
- Tactical HUD panels + weapon gauge from TACTICAL.DLL
- GOKRES mini-icons in fleet panel detail view

Review fixes:
- Event screen now blocks all keyboard shortcuts while active (HIGH finding)
- Cleared bad waifu2x upscales; proper PBRify pipeline planned

Docs: v0.19.0, 328 tests, CLAUDE.md split into table format,
upscale ExecPlan (6 phases, 4 tools, 2,231 BMPs)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:24:57 -04:00
Tom di Mino
7cb635cd4d feat(combat): implement ground combat formula with class stats and difficulty modifiers
Replace the simplified strength-ratio ground combat with per-unit resolution
using attack_strength/defense_strength from TROOPSD.DAT (TroopClassDef).
Defense facilities grant a defense bonus to defending troops. Wire difficulty
parameter (GNPRTB) into both ground and space combat damage scaling.

- Add TroopClassDef struct and troop_classes HashMap to GameWorld
- Load troop class data from TROOPSD.DAT during data loading
- Rewrite resolve_ground: per-unit resolution with class-based combat stats
- Add defense facility bonus spread across defending troops
- Wire difficulty parameter into resolve_ground (new param) and resolve_space
  (existing _difficulty param now used in phase_hull_damage)
- Add GNPRTB_COMBAT_DIFFICULTY_MODIFIER constant (param 0x1400)
- Add 6 unit tests: class stats, facility bonus, difficulty scaling (ground
  and space), fallback behavior, large asymmetric battle
- Update all call sites (main.rs, simulation.rs) with difficulty parameter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 17:16:07 -04:00
Tom di Mino
56f382b43b feat(combat): implement fighter combat subsystem — launch, dogfight, attack, recall
Replace placeholder fighter combat mechanics with proper subsystem:

- Fighter launch: squadrons deploy from carriers gated by fighter_capacity
  of alive capital ships (compute_carrier_capacity + launch_fighters)
- Fighter-vs-capital: per-class weapon-type attack strengths (turbolaser,
  ion cannon, laser cannon) with shield absorption, replacing /10 placeholder
- Fighter dogfight: attack_strength + maneuverability/2 weighted combat power
  determines loss ratios, replacing flat 0.3 factor approximation
- Fighter recall: surviving squadrons return capped to post-combat carrier
  capacity (carriers destroyed mid-phase lose their fighters)
- 6 unit tests: maneuverability advantage, attack_strength damage, carrier
  capacity limiting, recall after carrier destruction, no-fighter skip,
  asymmetric engagement

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:40:45 -04:00
Tom di Mino
317280efce feat(combat): implement fighter combat subsystem — launch, dogfight, attack, recall
Replace placeholder fighter combat mechanics with proper subsystem:

- Fighter launch: squadrons deploy from carriers gated by fighter_capacity
  of alive capital ships (compute_carrier_capacity + launch_fighters)
- Fighter-vs-capital: per-class weapon-type attack strengths (turbolaser,
  ion cannon, laser cannon) with shield absorption, replacing /10 placeholder
- Fighter dogfight: attack_strength + maneuverability/2 weighted combat power
  determines loss ratios, replacing flat 0.3 factor approximation
- Fighter recall: surviving squadrons return capped to post-combat carrier
  capacity (carriers destroyed mid-phase lose their fighters)
- 6 unit tests: maneuverability advantage, attack_strength damage, carrier
  capacity limiting, recall after carrier destruction, no-fighter skip,
  asymmetric engagement

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:40:12 -04:00
Tom di Mino
a4c2367e9c feat(render): wire TACTICAL.DLL HUD BMPs and GOKRES.DLL mini-icons
Tactical HUD (tactical_view.rs):
- Task force info panels (IDs 1001/1002) displayed as BMP overlays in a
  top-left floating HUD window; attacker vs defender sides use distinct
  faction-colored panel sprites.
- Weapon recharge gauge (IDs 1206-1210) animated at 4 ticks/step, shown
  in the bottom combat panel during the Combat phase.
- Hull/shield display panel (ID 1302) shown as BMP background in the
  selected-ship info side panel, above the hull/shield stat rows.

Fleet panel mini-icons (panels/fleets.rs):
- Added BmpCache parameter to draw_fleets(); updated main.rs call site.
- GOKRES.DLL 61x25 mini-icons rendered inline with each capital ship and
  fighter squadron entry in the expanded fleet detail view.
- Uses dat_id.raw() + 17000 offset to map ship/fighter DatIds into the
  18000-18999 GOKRES resource range; missing icons fall through silently.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:38:43 -04:00
Tom di Mino
eaaae95743 docs: 100% parity plan + 3 gap analysis reports
Unified 4-wave plan to reach Core 100% | UI 100% | Combat 100%:
- Wave 1: Combat formulas (shields, per-arc weapons, fighters, ground) ~600 LOC
- Wave 2: AI dispatch validators + troop deployment + core polish ~800 LOC
- Wave 3: BMP integration (2,231 assets) + waifu2x upscaling ~800 LOC
- Wave 4: Advisor BIN RE + GOKRES diagrams + validation ~1,500 LOC

3 gap analysis reports from parallel explorers:
- Core: 24 gaps, 1,400 LOC (9 systems)
- Combat: 11 gaps, 1,330 LOC (5 categories)
- UI: 13 categories, 3,500 LOC (87% BMPs unused)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 14:27:06 -04:00
Tom di Mino
1516e9e61f feat: Knesset Kothar final parity — seeding M5-M8, ship fields, droid advisor, HD assets, reviews
Knesset Kothar swarm (5 daborot, 9 tasks):

Resheph (Opus): Seeding M5-M8 complete
- M5: Support/popularity initialization from SDPRTB 7682-7685 + GNPRTB 7764-7765
- M6: Energy/raw materials + procedural facility generation from SYFCCRTB/SYFCRMTB
- M7: Maintenance-budget common unit seeding from SDPRTB 5168-5170
- M8: Integration wiring (GameSetup → SeedOptions → loader)
- Fixed garrison DatIds: Alliance 0x10000002, Empire 0x10000008 (per TheArchitect2018)
- Rim exclusion verified correct against seed.js Section 10
- Seeding parity: COMPLETE

Shapash: 25 ship class DAT fields promoted
- CapitalShipClass: 14 new fields (attack, weapons, tractor, interdiction, shields)
- FighterClass: 11 new fields (shields, engines, maneuverability, weapons)
- All wired from DAT parsers with #[serde(default)]

Pidray (Opus): Droid Advisor system (Phase 2.3)
- advisor.rs: 420 LOC, 7 tests, priority message queue, frame cycling animation
- C-3PO/R2-D2 (Alliance) or Imperial protocol droid (Empire)
- 6 trigger functions wired to game events

Anat: Polish triad
- DEF-004: WASM right-click fallback (held-frames heuristic)
- Ghidra site: requirements.txt with mkdocs-material[imaging]
- 32 HD upscaled assets via waifu2x (cockpit, buttons, portraits)

Review fixes:
- SDPRTB.DAT + SYFCCRTB/SYFCRMTB added to WASM optional file list
- Garrison DatId validation guard added
- Legacy fallback paths documented (Yavin collapse when 3-system model unavailable)

Docs: v0.18.0, 308 tests, seeding COMPLETE, advisor.rs in architecture

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 13:45:56 -04:00
Tom di Mino
8893165568 M8: Wire GameSetup choices through to seeding + regression pass
Complete the integration wiring so player choices actually affect
initial galaxy state:

- rebellion-app: GameSetupAction::StartGame now builds SeedOptions
  from the UI's galaxy_size, difficulty, and faction, then reloads
  the world via load_game_data_with_options. Each new game gets a
  fresh random seed and difficulty-aware seeding.

- rebellion-playtest: Uses SeedOptions with the CLI --seed value
  for deterministic headless runs. Ensures playtest results are
  reproducible and reflect the full M5-M7 pipeline.

Full regression: 308 tests pass (220 core + 50 data + 35 render-setup
+ 3 doc-tests), 0 failures. cargo check clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 08:33:03 -04:00
Tom di Mino
84cee5d8d7 M7: Maintenance-budget common unit seeding + low-support garrisons
Implement the budget-driven force generation loop and garrison pass
matching the original 1998 game:

- seed_maintenance_budget_units: Computes existing maintenance per
  faction, applies SDPRTB 5168/5169/5170 budget percentage (varies by
  galaxy size and difficulty), then rolls random unit bundles from
  CMUNEMTB (Empire) or CMUNALTB (Alliance) and deploys them to random
  owned systems until budget exhausted. Ships create new fleets, troops
  go to system ground inventory.

- seed_low_support_garrisons: For controlled systems with support below
  GNPRTB 7761 threshold (60), adds ceil((threshold-support)/10) troops
  using GNPRTB 7762 divisor to prevent immediate uprisings.

- Helper functions: compute_faction_maintenance (sums fleet ship +
  fighter + troop costs), compute_bundle_maintenance (costs a single
  seed table group), deploy_bundle_to_system (creates fleet/troops).

3 new tests: maintenance_budget_seeding_spends_without_overshoot,
low_support_systems_get_garrison_troops, budget_differs_by_galaxy_size.
All 17 seed tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 08:29:57 -04:00
Tom di Mino
dae2892082 feat(combat): promote 15 DAT fields to CapitalShipClass and FighterClass
Promotes all remaining combat-relevant fields from CAPSHPSD.DAT and
FIGHTSD.DAT into their world struct counterparts. Previously both
structs were missing per-weapon attack strengths, ranges, interdiction
fields, tractor beams, and fighter movement/evasion stats that the
7-phase combat pipeline needs for full parity.

CapitalShipClass gains 14 new fields: overall_attack_strength,
weapon_recharge_rate, per-type attack strengths (turbolaser/ion/laser),
per-type ranges, tractor_beam_power, tractor_beam_range,
gravity_well_projector, interdiction_strength, uprising_defense,
hyperdrive_if_damaged. All wired from dat.* in rebellion-data/src/lib.rs.

FighterClass gains 11 new fields: research_order, research_difficulty,
torpedoes_range, shield_strength, sub_light_engine, maneuverability,
detection, uprising_defense, fore weapon arcs (turbolaser/ion/laser),
per-type attack strengths. All wired from dat.* in rebellion-data/src/lib.rs.

Default impls added for both structs to keep test helpers concise.
Six test files updated to use ..Default::default() struct rest syntax.
302 tests pass, zero warnings introduced.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-25 08:19:19 -04:00
Tom di Mino
a51600e089 feat: Droid Advisor system (Phase 2.3) — animated faction advisors
Add animated droid advisor system with C-3PO/R2-D2 (Alliance) and
Imperial protocol droid (Empire) sprites from ALSPRITE/EMSPRITE DLLs.

- advisor.rs: AdvisorState with priority queue, frame cycling animation,
  lazy BMP loading from ref-ui/07-droid-advisors/, 7 unit tests
- Faction-specific dialogue for 6 trigger types: game start greeting,
  mission results, combat outcomes, uprisings, Death Star events,
  manufacturing completion
- Priority preemption (Critical > High > Normal > Low) with timed display
- Floating egui window anchored bottom-right with translucent background
- Wired into main.rs simulation loop at all relevant event points

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 08:18:50 -04:00
Tom di Mino
0153a42503 M6: Energy/raw materials + procedural facility generation
Implement per-system economy and facility generation matching the
original 1998 game:

- initialize_energy_and_raw_materials: Core systems get energy from
  GNPRTB 7721+rand(7722), raw from 7723+rand(7724), capped at 15
  and raw<=energy. Rim uses 7725+rand(7726)+rand(7727). Unpopulated
  systems get 0.

- generate_procedural_facilities: For each energy slot, roll mine vs
  non-mine using GNPRTB 7766 (core mult=4) / 7767 (rim mult=2).
  Non-mines picked via weighted random from SYFCCRTB (core) or
  SYFCRMTB (rim) tables with cumulative weight selection.

- Refactored assign_control_buckets to return a ControlBucket map
  so initialize_support can correctly classify strong vs weak systems
  without re-deriving bucket assignments.

- Fixed section 8b in lib.rs to skip systems with explicit control
  from the seed pipeline (prevents post-hoc override of M5 buckets).

- Loads SYFCCRTB.DAT and SYFCRMTB.DAT (Pattern 2 tables) via the
  existing dat-dumper SyfcTableFile parser.

2 new tests: energy_and_raw_materials_respect_param_ranges,
procedural_facilities_placed_at_populated_systems. All 14 pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:14:55 -04:00
Tom di Mino
8eae36b040 M5: Support/popularity initialization from SDPRTB/GNPRTB params
Implement procedural control bucket assignment, population state, and
support value initialization matching the original 1998 game:

- assign_control_buckets: Classify core systems, compute strong/weak
  bucket counts from SDPRTB 7680/7681, subtract Coruscant from Empire
  strong, shuffle and drain buckets into Alliance/Empire/neutral control.

- initialize_population: Set is_populated from GNPRTB 7730 (core: 100%)
  and 7731 (rim: 31%). Special systems already marked by M3.

- initialize_support: Map original 0-100 support into dual f32 popularity:
  core controlled strong (60+rand(30)), weak (20+rand(30)),
  neutral (41-59 via GNPRTB 7764=18), rim populated (50+rand(7765)),
  unpopulated (50). No system starts at (0.0, 0.0) anymore.

Also fixes CapitalShipClass/FighterClass constructors in lib.rs to
include extended combat stat fields added by Shapash (defaulting to 0).

3 new tests: support_ranges_match_original_rules,
core_bucket_counts_follow_sdprtb_percentages,
populated_systems_follow_gnprtb_rules. All 12 seed tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 23:04:18 -04:00
Tom di Mino
c4491d5fd5 docs: Knesset Kothar plan + CLAUDE.md audit + seeding.md
Knesset Kothar — Final Parity Sprint plan: 5 daborot (Resheph,
Shapash, Anat, Pidray, Yarikh) covering all 9 remaining tasks.
Seeding chain M5-M8 on critical path (Opus), ship class fields,
WASM QA, HD upscaling, droid advisor, and verification phase.

CLAUDE.md audit: cleaned stale limitations, added reports, added
seeding.md agent doc reference, updated frontmatter.

New: agent_docs/seeding.md — 3-system model, SeedOptions, 9 seed
tables, parity status.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 22:53:09 -04:00
Tom di Mino
f28e753d9e docs: CLAUDE.md audit + new seeding.md + architecture refresh
CLAUDE.md audit (claude-md-manager):
- Removed 3 stale known limitations (already fixed)
- Added 2 current limitations (seeding ~50%, droid advisor)
- Added Knesset Demiurge + Sassuratu + seeding audit to Reports
- Added seeding.md reference to agent docs section
- Updated frontmatter date

New: agent_docs/seeding.md — game seeding pipeline documentation:
  3-system model, character stat rolling, named placement, 9 seed
  tables, SeedOptions, parity status (~50%), M5-M8 remaining items

Architecture refresh:
- Added bmp_cache.rs, cockpit.rs, tactical_view.rs, ground_combat.rs
  to render module listing
- Added save.rs to data module listing
- Updated seeds.rs LOC (545 → ~1200) and test count (0 → 8)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 22:41:16 -04:00
Tom di Mino
d861687418 docs: update roadmap + CLAUDE.md for seeding M1-M4 + QA fix status
Seeding parity: M1-M4 complete (5 of 8 gaps fixed). Character stat
rolling, named character placement, 3-system model, Alliance HQ
randomization, System struct extended. 3 gaps remain (popularity init,
control buckets, maintenance budget).

293 tests. All 5 QA defects addressed (3 fixed, 1 needs manual test,
1 deferred).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 22:34:28 -04:00
Tom di Mino
a9d238b2fa fix: save/load panel wired + cockpit viewport mouse clamping
Save/Load panel:
- Added show_save_load flag + S keyboard shortcut
- Cockpit SaveLoad button now toggles panel directly
- draw_save_load() called in Galaxy egui block (10 slots, save/load/delete)

Cockpit viewport mouse clamping (DEF-003):
- Added viewport field to GalaxyMapState (x, y, width, height)
- draw_galaxy_map() now checks mouse is within viewport before processing
  input — clicks/hovers in cockpit chrome area are ignored
- main.rs passes CockpitViewport bounds to map_state each frame

QA defect inventory updated: DEF-001, DEF-002, DEF-003 all FIXED.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 22:30:39 -04:00
Tom di Mino
9adddea1cf fix: faction selection clickable + unified panel mutual exclusion
P1-DEF-001: Rewrite faction_button() from allocate_ui+interact to
allocate_exact_size with Sense::click — cards now register clicks.

P1-DEF-002: Replace 9 per-panel mutual exclusion blocks (90 LOC)
with toggle_panel! macro (20 LOC). All 9 panels now clear each
other uniformly — B/D/L properly close O/F/M/N/T/J and vice versa.

Also: shorten COMMON.DLL entry in Ghidra docs to match table style.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 21:55:18 -04:00
Tom di Mino
58cc8788a3 feat(seeds): 3-system model + character stat rolling + named placement (M3-M4)
Replace proximity-based fleet spread with the original game's explicit 3-system
seeding model: Coruscant (Empire HQ), Yavin (Alliance base), and a random rim
system as the Rebel HQ. CMUNHQTB and FACLHQTB now route to the separate Rebel
HQ instead of collapsing onto Yavin. Empire fleet (CMUNEFTB) goes only to
Coruscant instead of spreading across 10 proximity-based systems.

Roll character stats from SkillPair{base, variance} using deterministic RNG at
game start, matching the original setup_character() behavior. Place named
characters: Luke/Leia/Han/Wedge/Chewie/Dodonna at Yavin, Mon Mothma at Rebel
HQ, Palpatine/Vader at Coruscant.

8 new tests covering special system roles, fleet routing, deterministic HQ
selection, character placement, and stat rolling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 21:49:13 -04:00
Tom di Mino
b4ff67a062 docs(ghidra-site): correct COMMON.DLL status from unknown to analyzed
Update index.md to reflect completed COMMON.DLL analysis: pure resource
container (321 BMPs: UI buttons, panel chrome, main menu backgrounds,
cockpit speed-control buttons; 5 WAVs), zero game logic, no decompilation
needed. Correct the false "DirectPlay networking" claim — DirectPlay lives
in REBEXE.EXE at 0x5a0000–0x5b0000. Note cockpit buttons are now
implemented using COMMON.DLL assets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 17:55:04 -04:00
Tom di Mino
bf11f23dd6 docs: Codex ExecPlan for game seeding parity — 8 milestones
Thread seeding inputs → extend System struct → special-system
pipeline → character stat rolling + placement → procedural control
buckets + support init → energy/raw materials/facilities →
maintenance-budget common unit seeding → integration tests.

Key discovery: apply_seeds() runs before GNPRTB.DAT loads — must
fix load ordering. SDPRTB.DAT needs first-class runtime type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 12:51:06 -04:00
Tom di Mino
df68873480 docs: game seeding parity audit — 12% match, 56 gaps identified
Audit against TheArchitect2018's initial_game_seeding_logic wiki
reveals our apply_seeds() only covers DAT seed table dispatch.
Missing: character stat rolling + placement, support/popularity
initialization, procedural galaxy generation (political control
buckets from GNPRTB 7680/7681), energy/raw materials fields,
maintenance-budget common unit seeding, Alliance HQ randomization,
difficulty/galaxy size affecting seeds.

Roadmap updated with prioritized gap list. Full audit report in
.subdaimon-output/seeding-parity-audit.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 12:38:50 -04:00
Tom di Mino
c2616ed93a docs: Knesset Sassuratu plan — visual QA + UI parity + SEO/GEO
5 daborot, 47 test scenarios, ~4h wall-clock:
- Boreret (Inspector): agent-browser QA of all 19 panels in WASM
- Rophe (Healer): fix panel mutual exclusion, viewport clamping, save/load
- Yashar (Straightener): close remaining non-combat UI parity gaps
- Sopher (Scribe): SEO/GEO for Ghidra docu site (OG tags, robots.txt, FAQ)
- Mashbir (Verifier): re-test all 47 scenarios + cargo test + WASM build

3 pre-identified bugs + dynamic defect inventory from QA.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 09:07:24 -04:00
Tom di Mino
4f81307a17 fix: critical review findings from Knesset Demiurge swarm + docs v0.17.0
Review fixes (3 agents, 10 findings addressed):
- Player-involvement combat detection simplified from 4-clause OR
  (always true for inter-faction battles) to correct == comparison
- Retreated ships now survive: added `retreated` flag to TacticalShip,
  apply_tactical_results skips retreated ships instead of destroying them
- Ground combat results now applied: losing side's troops removed from
  system based on winner (attacker/defender), troops deleted from world
- Rebel Alliance starbird set as Ghidra site favicon + logo

CLAUDE.md updated to v0.17.0:
  Core 95% | UI 92% | Combat 85% | Overall ~90%
  284 tests, BMP cache, cockpit chrome, tactical combat, audio, portraits

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 08:52:31 -04:00
Tom di Mino
87f33a2778 docs: set Rebel Alliance starbird as favicon and logo for Ghidra site
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 08:22:09 -04:00
Tom di Mino
1e140c6883 fix: address review findings in bombardment/DS/loyalty panels
Critical fixes:
- FireDeathStar now calls DeathStarSystem::fire() for precondition
  validation (guards: not already destroyed, not self-destruction,
  Death Star fleet present) instead of raw mutation
- OrderBombardment guards against stale fleet/system keys before
  calling resolve_bombardment (prevents SlotMap index panic)
- Bombardment popularity reduction capped at 0.25 per strike and
  uses clamp(0.0, 1.0) for consistency with all other mutation sites
- Bombardment difficulty changed from hardcoded 3 to 2 (medium)
  with TODO for actual game difficulty threading

High fixes:
- MoveDeathStar checks for existing transit order before issuing
  new one — refuses with message instead of silently overwriting
- partial_cmp().unwrap() replaced with unwrap_or(Equal) in loyalty
  and death_star panels to prevent NaN panics

Medium fixes:
- Destroyed systems filtered from loyalty dashboard
- TODOs added for VictoryState update and entity cleanup on DS fire

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 23:31:12 -04:00
Tom di Mino
5a4444b999 docs: add Phase 4.4-4.6 panels to all docs, audit fixes
- CLAUDE.md: 6 → 9 player control panels (add bombardment, Death Star, loyalty)
- roadmap.md: move Phase 4.4-4.6 from Remaining to Completed
- architecture.md: add bombardment.rs, death_star.rs, loyalty.rs to render module tree

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 23:28:19 -04:00
Tom di Mino
dd8a826339 feat: bombardment, Death Star, and loyalty panels (Phase 4.4-4.6)
Bombardment panel (B key): select fleet with capital ships, view
ship class breakdown, damage forecast against enemy system, FIRE button
that resolves bombardment via BombardmentSystem and reduces enemy
popularity.

Death Star panel (D key): Empire view shows construction progress bar,
operational status, superlaser targeting with FIRE button, nearby system
list for movement orders. Alliance view shows threat intelligence and
sabotage guidance.

Loyalty dashboard (L key): per-system loyalty view sorted by danger
level (uprisings first, then lowest loyalty). Summary counts for
uprising/at-risk/stable. Dual popularity bars per system. Character
betrayal risk section showing low-loyalty officers.

New PanelAction variants: OrderBombardment, FireDeathStar, MoveDeathStar.
All wired in apply_panel_action with message log entries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 23:23:07 -04:00
Tom di Mino
9e3877dfcd docs: update architecture, roadmap, and CLAUDE.md for v0.16.0
- CLAUDE.md: bump to v0.16.0, UI 85%, add context menus + fleet editor
- architecture.md: add new render modules (theme, main_menu, game_setup,
  research, jedi, context menus), update rendering architecture section
  with all 13 draw functions and context menu input behavior
- roadmap.md: add UI Rebuild section tracking 11 completed phases and
  remaining work items

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 23:02:44 -04:00
Tom di Mino
b213273136 feat: context menus + fleet editor with review fixes (Phase 3.3-3.4, 4.3)
System context menu (right-click system): faction control, popularity
snapshot, garrison summary, quick actions (View Details, Send Diplomat,
Send Spy, Move Fleet Here).

Fleet context menu (right-click fleet diamond): composition, commander,
transit status, View in Fleet Panel button. Fleet hover detection added
to fleet_movement.rs for both stationary diamonds and transit dots.

Fleet composition editor (F panel): assign/remove officers with
current_fleet tracking, merge fleets at same location with full asset
transfer (ships, fighters, characters, Death Star flag).

Review fixes (3 agents):
- Fixed right_click_start consumed before fleet hover check could read it
- Fixed "Issue Move Order" sending fleet to its own location (removed)
- Added in-transit guard for fleet merge (UI filter + handler guard)
- Added existence guard preventing silent data loss on stale merge
- Added movement_state.cancel(fleet_b) to prevent ghost transit dots
- Added character.current_fleet updates on assign/remove/merge
- Removed dead pending_assign field from FleetsState

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 23:00:39 -04:00
Tom di Mino
a72a60f3bd feat: system + fleet right-click context menus (Phase 3.3-3.4)
Right-click a system on the galaxy map to see faction control, popularity
snapshot, garrison summary, and quick action buttons (View Details, Send
Diplomat, Send Spy, Move Fleet Here). Right-click a fleet diamond to see
composition, commander, transit status, and fleet actions.

Fleet hover detection added to fleet_movement.rs (checks both stationary
diamonds and in-transit dots). Short right-click (no drag) triggers menu;
right-drag still pans the camera. Left-click or Close dismisses menus.

New PanelAction variants: OpenMissionTo, InitiateFleetMove (wired with
TODO stubs for full panel pre-selection integration).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 22:52:13 -04:00
Tom di Mino
a441409c8e feat: character detail view overhaul (Phase 4.8)
Complete rewrite of draw_character_detail() in officers.rs:

40a — Themed header: faction-colored name, status badges (CAPTIVE,
ON MISSION, MANDATORY), Force tier badge, role flags
40b — Skill bars: egui::ProgressBar replacing manual painter rects,
themed colors (green ≥75, gold ≥45, orange ≥20, dim <20)
40c — Location section: current system from fleet lookup, fleet info,
mission status, unassigned indicator
40d — Force progression: tier label with color, XP progress bar toward
next tier, detection risk percentage, sensitivity for latent

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 19:11:53 -04:00
Tom di Mino
577fe0d105 feat: expanded system detail panel (Phase 4.7)
Replace bare text counts with rich strategic display:
- Color-coded system name by controlling faction
- HQ and Destroyed badges
- Popularity bars with Alliance blue / Empire red fill
- Control status label (Neutral/Alliance/Empire/Contested/Uprising)
- Fleet roster: ship counts by class, fighter squadrons, Death Star flag, commanders
- Ground forces: Alliance vs Empire regiment counts
- Facilities: defense, shipyard, production counts
- Scrollable panel for systems with many assets

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 17:54:19 -04:00
Tom di Mino
c2cda9e12b feat: Research Panel + Jedi Training Panel (Phase 4.1-4.2)
Research Panel (panels/research.rs, 228 LOC):
- 3 tech tree tabs (Ship/Troop/Facility) with current level display
- Active project progress bar with ticks remaining
- Eligible character list filtered by faction + skill
- Assign character → DispatchResearch PanelAction
- Cancel research button

Jedi Training Panel (panels/jedi.rs, 214 LOC):
- Force-sensitive character roster sorted by tier
- XP progress bars (Aware→Training, Training→Experienced)
- Detection risk display per tier
- Start/Stop training buttons
- Faction-aware (Jedi vs Sith labels)

Wiring:
- T key toggles Research panel, J key toggles Jedi panel
- Mutually exclusive with other left panels
- PanelActions: DispatchResearch, CancelResearch, StartJediTraining, StopJediTraining
- Actions logged to message log

280 tests pass, 0 failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 17:41:11 -04:00
Tom di Mino
c5bd46f87f fix: address review findings in AI docs
- Fix validator count: 19 (not 18) in FUN_00508250 pseudocode
- Add omitted initial dispatch call in FUN_0052e970 annotated snippet
- Clarify FUN_0052e970 returns true by default (bVar4 = true at init)
- Fix budget comparison comment (consumed vs remaining)
- Update behavior analysis: FUN_0052e970 is "binary capacity check"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 15:50:59 -04:00
Tom di Mino
3888ffb4f8 docs: add decompiled function archives to Ghidra site + dispatch validator plan
- AI functions archive: 39 C files (29KB) — core pipeline, validators, handlers
- Full archive: 5,159 C files (936KB) — complete REBEXE.EXE decompilation
- Download links added to AI Functions page on mkdocs site
- Codex-generated ExecPlan for porting 14 dispatch validators to Rust

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 14:45:26 -04:00
Tom di Mino
74c6dc16e4 feat: resolve all AI parity guesses — 23 functions decompiled via GhidraMCP
Ghidra RE session decompiled 23 functions via HTTP bridge, resolving every
"BY DESIGN" guess in the AI system:

- FUN_0052e970: NOT a scoring function — binary capacity check. Our 4-factor
  weighted model (weakness × proximity × deconfliction × freshness) is
  strictly superior to the original.
- FUN_00506ea0: Faction-specific evaluator pointer (Alliance +0xc4, Empire
  +0xc8 on global struct). Different deployment budgets per faction.
- FUN_004927c0: AI triggered by event 0x1f0 (every game-day). Our
  AI_TICK_INTERVAL=7 is intentional performance throttle.
- FUN_00508250: All 18 validator sub-functions decoded (4 implemented,
  14 remaining capacity/composition checks).
- FUN_00520580: 2-field struct setter, not transit calculator.

Mission probability formulas ported from TheArchitect2018 wiki:
- Diplomacy: (enemy_pop - our_pop) + diplomacy_rating
- Recruitment: leadership - resistance
- Subdue: (enemy_pop - our_pop) + diplomacy
- DS Sabotage: (espionage + combat) / 2

New AI Functions page added to mkdocs Ghidra documentation site.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 14:39:44 -04:00
Tom di Mino
1bc59c2abb feat: game UI Phase 1 — main menu, game setup, theme, TEXTSTRA extraction
- GameMode state machine (MainMenu → GameSetup → Galaxy) in main.rs
- Star Wars egui theme: dark space bg, gold/amber accents, faction colors
- Liberation Sans font (metrically identical to original Arial, SIL OFL)
- Main menu screen: title, New Game / Load Game / Quit
- Game setup screen: galaxy size, difficulty, faction selection
- TEXTSTRA.DLL --extract-strings flag for dat-dumper (1,347 entity names)
- WASM string table integration: textstra.json → set_string_table() → real names
- build-wasm.sh wired to extract strings automatically
- Removed faction_select.rs (replaced by game_setup.rs)
- 280 tests pass, zero errors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 11:59:21 -04:00
Tom di Mino
362118a492 docs: complete game flow reference — 1,334 lines, every screen from launch to victory
23 sections covering every screen, panel, button, and interaction in the
original Star Wars Rebellion (1998). Compiled from Prima Strategy Guide,
game manual, GameFAQs, Steam guides, PCGamingWiki, and community sources.

Covers: pre-game flow, new game setup, opening briefing, cockpit interface,
galaxy map (2 zoom levels), system view (3 tabs), droid advisors, 8 command
buttons, character/fleet/manufacturing/research/mission management, encyclopedia,
space combat (auto + 3D tactical), ground combat, bombardment, GenCore shields,
event popups, save/load, options, victory/defeat, audio architecture.

Plus: screen transition map, keyboard shortcuts, galaxy structure appendix,
key numerical constants (Jedi thresholds, bounty hunter probabilities, etc.).

Foundation document for the complete game UI rebuild plan.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 22:49:49 -04:00
Tom di Mino
f9b1022b7d plan: complete game UI rebuild — 39 tasks, 8 phases, ~7,430 LOC
Comprehensive plan covering every screen from launch to victory:
- Phase 1: Main menu & game setup (pre-game flow)
- Phase 2: Cockpit interface (faction chrome, droid advisors, theme)
- Phase 3: Galaxy map (facility icons, context menus, blockade indicators)
- Phase 4: Player control panels (research, jedi, fleet editor, bombardment,
  Death Star, loyalty dashboard, expanded detail views)
- Phase 5: Tactical combat (2D arena, ship placement, real-time phased combat,
  HUD, targeting, ground combat, results modal)
- Phase 6: Audio (soundtrack, voice lines, SFX, WASM WebAudio)
- Phase 7: Encyclopedia & visuals (entity portraits, event screens, tech tree)
- Phase 8: Save/load & polish (localStorage, help overlay, HD upscaling)

2,441 BMPs + 285 WAVs + 15 videos extracted, zero currently rendered.
Parity target: Core 95% | UI 95% | Combat 90% | Overall ~90%

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 22:46:35 -04:00
Tom di Mino
bda8ceef61 feat: WASM browser build — game runs in the browser for the first time
The game now loads and renders in the browser via WebAssembly:
- WASM file cache: set_file_cache() pre-loads DAT bytes, read_dat_file()
  reads from cache instead of filesystem, file_available() checks cache
- Loading screen: shows "Loading... (X/Y)" with progress bar while
  fetching 51 DAT files via macroquad::file::load_file() HTTP fetch
- gl.js updated from miniquad 0.4.8 (fixes version mismatch)
- RNG seed: uses macroquad::time::get_time() on WASM (SystemTime panics)
- build-wasm.sh: copies DAT files to web/data/base/, generates placeholder
  textstra.json (real string extraction is next task)

Galaxy map, faction select, all panels, status bar, message log all working.
Entity names show fallback format ("System 12345") until TEXTSTRA extraction.
283 native tests still pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 22:33:25 -04:00
Tom di Mino
af668c9e25 docs: COMMON.DLL analysis — pure resource container, no game logic
98.8% resource section (321 BMPs + 5 WAVs), zero exports, 7 CRT
functions. Corrects prior claims about DirectPlay networking.
REBEXE.EXE loads it at runtime as module ID 8 via LoadLibraryA.
No Ghidra decompilation needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 18:33:48 -04:00
Tom di Mino
29de3a6dd4 feat: autoresearch run 001 — baseline 0.54 → best 0.65 (+19%)
20 iterations × 3 seeds × 5000 ticks. 2 accepted mutations:
- distance_scale 2 → 3 (slower transit = more strategic depth)
- mfg_target 50 → 55 (higher manufacturing expectation)

Key finding: parameter space is narrow. Most mutations to AI tick
interval, diplomacy threshold, or transit time cause degenerate
(zero-combat) games. The default config is near a local optimum.

Phase F complete — all 6 AI parity phases (A–F) now DONE.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 17:57:00 -04:00
Tom di Mino
3ce72c0ec1 fix: constrain dark Tanit by height to match light mode size
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 14:01:18 -04:00