Game Engine Rules (AI Training)
-
I decided to try some Claude code. Trying to make sure I have all the rules for the map Triplea revised. I am trying to get a better ai for the community on the map revised. I have like 1000 games trained but the rules were wrong. I just need another pair of eyes on my rules to make sure they are 100% right. # Colossus Rules Implementation Audit. If you have coded before would you mind looking at this to map sure this is right?
Updated: # Colossus Rules Implementation Audit
This document provides a comprehensive audit of all game rules implemented in the Colossus Axis & Allies engine.
Legend:
Verified - Rule implemented correctly with test coverage
️ Untested - Rule implemented but lacks dedicated tests
Bug - Known issue with implementation
1. Unit Properties
File: unit.rs
Unit Cost Attack Defense Movement Notes Status Infantry 3 1 2 1 Transport cost: 2
VerifiedArtillery 4 2 2 1 Transport cost: 3, supports infantry
VerifiedArmour 5 3 3 2 Transport cost: 3, can blitz
VerifiedAA Gun 5 0 0 1 Transport cost: 3, special AA fire
VerifiedFighter 10 3 4 4 Carrier cost: 1, +2 with Long Range
VerifiedBomber 15 4 1 6 SBR capable, +2 with Long Range
VerifiedSubmarine 8 2 2 2 First strike, submerge
VerifiedDestroyer 12 3 3 2 Negates sub abilities
VerifiedTransport 8 0 1* 2 Capacity: 5 points
VerifiedCarrier 16 1 3 2 Holds 2 fighters
VerifiedBattleship 24 4 4 2 2 hit points, shore bombard
VerifiedFactory 15 0 0 0 Production building
Verified*Transport defense is configurable (0 or 1 via
config.transport_defense)Transport Capacity (Point-Based)
Files: unit.rs:98-99, generation_fixed.rs
Unit Transport Cost Infantry 2 points Artillery 3 points Armour 3 points AA Gun 3 points Total transport capacity: 5 points
Valid loadouts:
- 2 Infantry (4 points)

- 1 Infantry + 1 Artillery/Armour/AA (5 points)

- 1 Artillery/Armour/AA only (3 points)

Test Coverage: unit.rs:182-198
Verified
2. Turn Sequence
File: phase.rs
Turn Order
Phase Description Status 1. Tech Purchase technology dice (5 IPCs each)
Verified2. TechActivation Roll tech dice, gain technology
Verified3. Purchase Buy units (placed at end of turn)
Verified4. CombatMove Move units to attack
Verified5. Battle Resolve all combat
Verified6. NonCombatMove Move remaining units
Verified7. Place Place purchased units
Verified8. EndTurn Collect income, repair units
VerifiedPlayer Order
- Russians → 2. Germans → 3. British → 4. Japanese → 5. Americans
File: phase.rs:15-28
VerifiedBid Phases (Pre-Game)
Phase Description RussiansBid Place Russian bid units GermansBid Place German bid units BritishBid Place British bid units JapaneseBid Place Japanese bid units AmericansBid Place American bid units File: phase.rs, game_options.rs:184-204
Verified
3. Movement Rules
3.1 Combat Move Phase
File: generation_fixed.rs
Rule Implementation Status Land units can attack adjacent territories gen_combat_moves
VerifiedShips can attack adjacent sea zones gen_combat_moves
VerifiedAircraft can attack within movement range gen_combat_moves
VerifiedAA guns CANNOT move during combat if unit_type == UnitType::AaGun { continue; }
VerifiedAA guns CANNOT load on transports during combat gen_transport_loads_combat_dedup
VerifiedTransports can load infantry/artillery/armour gen_transport_loads_combat_dedup
VerifiedAmphibious assaults from transports gen_amphibious_assaults
VerifiedBombers CAN attack sea zones Must have valid landing spot for return
VerifiedTest Coverage: generation_fixed.rs:745-923
Verified3.2 Non-Combat Move Phase
File: generation_fixed.rs
Rule Implementation Status Units move to friendly territories gen_noncombat_moves
VerifiedAA guns CAN move during NCM gen_noncombat_moves
VerifiedAA guns CAN load on transports gen_transport_loads_dedup
VerifiedAircraft must land with valid capacity validation/aircraft.rs
VerifiedTransports can unload cargo gen_transport_unloads
VerifiedBombers CANNOT land in sea zones if unit_type == UnitType::Bomber && to_terr.is_water { continue; }
VerifiedTest Coverage: generation_fixed.rs:871-923
Verified3.3 Blitzing
File: validation/movement.rs:130-153
Rule Description Status Only armour can blitz Movement 2 required
VerifiedMust pass through EMPTY enemy territory No enemy units present
VerifiedCannot blitz through defended territory can_blitzfunction
VerifiedTerritory captured during blitz Ownership changes
VerifiedAA guns block blitzing can_blitzcheck
VerifiedTest Coverage: movement.rs:295-433
Verified3.4 Canal Restrictions
File: generation_fixed.rs:611-634
Canal Required Territories Status Suez Canal Egypt
VerifiedPanama Canal Panama, Central America
VerifiedShips cannot pass through canals unless controlling player owns required territories.
Implementation:
can_pass_canalfunction
Verified3.5 Aircraft Landing
File: validation/aircraft.rs
Rule Description Status Fighters land on friendly territory can_landfunction
VerifiedFighters land on carriers has_carrier_capacity
VerifiedCarrier capacity: 2 fighters Per carrier
VerifiedBombers land on friendly territory only Cannot use carriers
VerifiedMust have movement remaining remaining_movement
VerifiedLong Range Air: +2 movement Technology bonus
VerifiedTest Coverage: aircraft.rs:163-217
Verified3.6 Movement Tracking
Files: fixed.rs, apply.rs, undo.rs, generation_fixed.rs
Rule Description Status Units move once per phase units_moved_counttracking array
VerifiedWalk-then-load blocked (Combat Move) Load tracks unit at source territory
VerifiedUnload-then-walk blocked (both phases) Unload tracks unit at destination
VerifiedNCM bridging allowed Load NOT tracked in Non-Combat Move
VerifiedMCTS apply/unapply works unrecord_units_moved()restores state
VerifiedPhase transition clears tracking clear_movement_tracking()on phase change
VerifiedImplementation:
units_moved_count[player][territory][unit_type]- Tracks how many units moved FROM each territoryremaining_movement[player][territory][unit_type]- For multi-space movers (future use)record_units_moved()- Called inapply_unit_move(),apply_load()(CM only),apply_unload()unrecord_units_moved()- Called inunapply_move()for MCTS backtrackingunits_available_to_move()- Returns present count minus already moved countclear_movement_tracking()- Called when leaving CombatMove or NonCombatMove phase
Movement Tracking Matrix:
Function Combat Move Non-Combat Move Track Location Reason apply_unit_move()
Track
TrackDESTINATION Unit can't move again after arriving apply_load()
Track
No trackSOURCE CM: prevents walk-then-load; NCM: allows bridging apply_unload()
Track
TrackDESTINATION Unit can't move after unloading Note: Tracking at destination for
apply_unit_move()is correct because the unit is physically removed from the source territory. Tracking the arriving unit at its destination prevents it from moving further.State Size Impact: Increased from 16KB to 32KB to accommodate tracking arrays.
Test Coverage: battle_test.rs
Verified
4. Combat Rules
4.1 Battle Resolution
File: combat/resolve.rs
Phase Description Status 1. AA Fire AA guns fire at attacking aircraft
Verified2. Submarine First Strike Subs attack before regular combat
Verified3. Regular Combat Alternating fire rounds
Verified4. Retreat Attacker may retreat
Verified4.1.1 Territory Capture
File: combat/resolve.rs
Rule Description Status Territory ownership transfers Winner takes control
VerifiedAA guns are CAPTURED, not destroyed capture_aa_guns()transfers ownership
VerifiedAA guns do not participate in combat Non-combatant, defense = 0
VerifiedAA guns not selected as casualties Excluded from casualty selection
VerifiedAllied AA guns NOT captured Only enemy AA guns transfer
VerifiedImplementation:
capture_aa_guns()called when attacker wins battle- Iterates through all enemy players (skips self and allies)
- Transfers AA gun ownership from old owner to new owner
- Updates unit counts and territory masks
- Called after bombardment victory AND after regular combat victory
Test Coverage:
test_aa_gun_captured_when_territory_falls,test_aa_gun_not_in_casualty_list,test_multiple_aa_guns_all_captured
Verified4.1.2 Shore Bombardment
Files: battle.rs, resolve.rs, bombardment.rs
Rule Description Status Battleships bombard in amphibious assaults Fire BEFORE AA fire
VerifiedOne shot per battleship Attack value 4
VerifiedOnly from adjacent sea zones Must have transport AND battleship
VerifiedCasualties applied before combat Hits remove defenders immediately
VerifiedNot in land-only attacks Only amphibious assaults
VerifiedLow Luck bombardment 4/6 = 0.66 guaranteed hits per battleship
VerifiedImplementation:
get_amphibious_info()- Detects amphibious assault by checking for transports in adjacent sea zonesresolve_bombardment_multi()- Fires all battleships from identified sea zones- Called at start of
resolve_battle()before AA fire - Can end battle early if bombardment kills all defenders
Test Coverage: battle_test.rs
Verified4.2 AA Fire
File: combat/resolve.rs, combat/dice.rs:29-37
Rule Description Status Hits on 1 1/6 chance per aircraft
VerifiedOne shot per aircraft Max hits = aircraft count
VerifiedLow Luck AA Guaranteed hits for 6+ aircraft
VerifiedChoose casualties (optional) config.choose_aa_casualties
VerifiedAlways-on AA (flyover) config.always_on_aa
VerifiedTest Coverage: resolve.rs:665-681, apply.rs:822-980
Verified4.3 Submarine Combat
File: combat/resolve.rs
Rule Description Status First strike Submarines fire first
VerifiedCasualties don't return fire Unless destroyer present
VerifiedDestroyer negates first strike has_destroyercheck
VerifiedSubmerge option config.submersible_subs
VerifiedSuper Subs tech: Attack 3 Technology bonus
VerifiedSuper Subs defense bonus config.super_sub_defense_bonus
VerifiedDefending subs fire back config.defending_subs_fire_back
VerifiedAir cannot hit subs without destroyer air_can_hit_subs()check
VerifiedSubs cannot hit aircraft get_sub_targetable_units()excludes aircraft
VerifiedAir vs Sub stalemate Battle ends if only air vs only subs
VerifiedImplementation (Fixed 2026-01):
air_can_hit_subs()- Returns true only if attacker has destroyer in territoryget_air_targetable_units()- Filters subs from targets when no destroyer presentget_sub_targetable_units()- Excludes fighters and bombers from sub targetsis_air_sub_stalemate()- Detects deadlock when only air vs only subs- Stalemate check runs BEFORE each combat round
- If stalemate detected, battle ends with no winner
Test Coverage:
test_air_cannot_hit_subs_without_destroyer,test_air_can_hit_subs_with_destroyer,test_sub_hits_cannot_kill_aircraft,test_is_air_sub_stalemate_detection
Verified4.4 Artillery Support
File: combat/resolve.rs
Rule Description Status 1:1 support ratio Each artillery supports 1 infantry
VerifiedSupported infantry attack at 2 Instead of 1
VerifiedTest Coverage: resolve.rs:613-621
Verified4.5 Two-Hit Battleships
File: combat/resolve.rs
Rule Description Status Battleships take 2 hits config.two_hit_battleship
VerifiedDamaged state tracked state.damaged_battleships
VerifiedRepair at end of turn config.units_repair_hits_end_turn
VerifiedRepair at start of turn config.units_repair_hits_start_turn
VerifiedTest Coverage: resolve.rs:684-709
Verified4.6 Transport Defense
File: combat/resolve.rs
Setting Behavior Status transport_defense = 0Defenseless transports
Verifiedtransport_defense = 1Transports defend at 1
VerifiedCombat unit check Transports count as combat when defending
VerifiedTest Coverage: resolve.rs:711-784
Verified
5. Strategic Bombing
File: combat/bombing.rs
Rule Description Status Bombers attack factories resolve_bombing_raid
VerifiedAA fires at bombers Before damage
VerifiedDamage = 1d6 per bomber Standard
VerifiedHeavy Bombers: 2d6 With technology
VerifiedLHTR Heavy: Best of 2d6 config.lhtr_heavy_bombers
VerifiedLow Luck: 4 IPC per bomber config.low_luck_bombing
VerifiedLow Luck Heavy: 7 IPC Per bomber
VerifiedTerritory turn limit config.territory_turn_limit
VerifiedFactory damage tracked state.factory_damage
VerifiedRepair costs 1 IPC per point repair_factory
VerifiedTest Coverage: bombing.rs:152-260
Verified
6. Economic Rules
6.1 Income Collection
File: game/income.rs
Rule Description Status Income = sum of controlled territory production calculate_income
VerifiedNo income if capital captured state.capital_capturedcheck
VerifiedIncome collected at end of turn collect_income
VerifiedTest Coverage: income.rs:54-77
Verified6.2 Capital Capture
File: game/capital.rs
Rule Description Status Captor steals all IPCs handle_capital_capture
VerifiedVictim loses income ability capital_capturedflag
VerifiedLiberation restores income check_capital_liberation
VerifiedIPCs not returned on liberation Intended behavior
VerifiedTest Coverage: capital.rs:101-144
Verified6.3 Unit Purchase
Files: generation_fixed.rs, action_space.rs
Rule Description Status Purchase during Purchase phase Phase check
VerifiedUnits placed during Place phase Deferred placement
VerifiedFactory required for placement Factory presence check
VerifiedCannot use enemy factory Ownership check
VerifiedSea units placed in adjacent sea zone Naval placement
VerifiedFactory damage reduces production effective_production
VerifiedTest Coverage: generation_fixed.rs:996-1124
Verified
7. Victory Conditions
File: game/victory.rs
Victory Type Cities Needed Status Projection of Power 9 VCs
VerifiedHonorable Surrender 10 VCs
VerifiedTotal Victory 12 VCs
VerifiedImplementation:
check_victory- Main victory checkcount_victory_cities- Count per alliancecheck_capitals- Alternative capital-based victory
Test Coverage: victory.rs:106-126
Verified
8. Technology System
File: types/phase.rs, combat/dice.rs
Available Technologies
Technology Effect Status Jet Power Fighters attack/defend +1
VerifiedRockets AA guns can SBR
VerifiedSuper Subs Submarines attack at 3
VerifiedLong Range Air Aircraft +2 movement
VerifiedIndustrial Tech Units cost 1 less
VerifiedHeavy Bombers 2d6 bombing damage
VerifiedTest Coverage: resolve.rs:814-1056
Verified (All technologies)Tech Research
Rule Description Status Cost: 5 IPCs per die config.tech_cost_per_die
VerifiedSuccess on 6 roll_tech
VerifiedLow Luck: N dice = N/6 chance Guaranteed at 6 dice
VerifiedTest Coverage: dice.rs:129-140
Verified
9. Low Luck System
File: combat/dice.rs
Type Formula Status Combat hits = floor(power/6) + roll for remainder
VerifiedAA Fire hits = floor(aircraft/6) + roll
VerifiedTech 6 dice = guaranteed, else roll ≤ N
VerifiedBombing 4 IPC per normal, 7 per heavy
VerifiedConfiguration:
config.low_luck- Combatconfig.low_luck_aa- AA fireconfig.low_luck_tech- Technologyconfig.low_luck_bombing- Strategic bombing
Test Coverage: dice.rs:91-162
Verified
10. Configuration Options
File: config/game_options.rs
Combat Options
Option Default (TRAINING) Status low_lucktrue
Verifiedlow_luck_aatrue
Verifiedlow_luck_techtrue
Verifiedlow_luck_bombingtrue
Verifiedalways_on_aatrue
Verifiedroll_aa_individuallytrue
Verifiedchoose_aa_casualtiestrue
Verifiedkamikaze_airplanesfalse
Verifiedterritory_turn_limittrue
VerifiedTechnology Options
Option Default (TRAINING) Status technology_enabledfalse
Verifiedtech_cost_per_die5
Verifiedlhtr_heavy_bomberstrue
Verifiedheavy_bomber_dice_rolls2
Verifiedsuper_sub_defense_bonus0
VerifiedUnit Options
Option Default (TRAINING) Status two_hit_battleshiptrue
Verifiedunits_repair_hits_end_turntrue
Verifiedunits_repair_hits_start_turnfalse
Verifiedsubmersible_substrue
Verifieddefending_subs_fire_backtrue
Verifiedtransport_defense1
Verifiedproduce_fighters_on_carrierstrue
Verifiedmove_existing_fighters_to_new_carrierstrue
Verifiedlhtr_carrier_productionfalse
Verifiedallied_air_dependentstrue
VerifiedMovement Options
Option Default (TRAINING) Status neutrals_are_impassabletrue
Verifiedneutrals_are_blitzablefalse
Verifiedsub_control_sea_zone_restrictedfalse
VerifiedVictory Options
Option Default (TRAINING) Status victory_typeTotalVictory (12 VCs)
VerifiedTest Coverage: game_options.rs:544-848
Verified
11. Presets
File: config/game_options.rs
Preset Description Key Differences TRAINING Your preferred settings Low Luck ON, 12 VCs, German bid 9 TOURNAMENT Competitive play Low Luck ON, 9 VCs, no bids CASUAL Standard dice Low Luck OFF, 9 VCs TRIPLEA_DEFAULT Matches TripleA Low Luck OFF, no LHTR
Summary Statistics
Category Verified Untested Bugs Total Unit Properties 12 0 0 12 Turn Sequence 8 0 0 8 Movement Rules 21 0 0 21 Combat Rules 27 0 0 27 Economic Rules 9 0 0 9 Victory 3 0 0 3 Technology 7 0 0 7 Configuration 29 0 0 29 TOTAL 116 0 0 116 Coverage: 100% verified, 0% untested, 0% bugs
Known Fixed Issues
AA Gun Transport Rules (Fixed 2024-12)
Files Modified: generation_fixed.rs
Bug Fix AA guns could load during Combat Move Created gen_transport_loads_combat_dedupexcluding AA gunsTransport loading not generated during NCM Added gen_transport_loads_deduptogen_noncombat_movesTest Cases Added:
test_aa_gun_cannot_load_during_combat_movetest_aa_gun_can_load_during_noncombat_movetest_infantry_can_load_during_combat_movetest_artillery_can_load_during_combat_movetest_aa_gun_can_unload_during_noncombat_movetest_aa_gun_can_amphibious_assault
Test Coverage Expansion (2026-01)
Added comprehensive tests for previously untested rules:
Combat Rules (submarines.rs, resolve.rs

test_subs_can_submerge_no_destroyertest_subs_cannot_submerge_with_enemy_destroyertest_sub_attack_power_normaltest_sub_attack_power_super_substest_first_strike_checks_correct_enemytest_resolve_battle_with_defending_subs_fire_backtest_resolve_battle_without_defending_subs_fire_backtest_submersible_subs_first_strike_enabled
Technology Effects (resolve.rs

test_jet_power_increases_fighter_attacktest_jet_power_increases_fighter_defensetest_jet_power_only_affects_fighterstest_super_subs_increases_attack
Movement/Blitz (movement.rs

test_blitz_through_empty_enemy_territorytest_blitz_blocked_by_any_enemy_unittest_blitz_blocked_by_aa_guntest_blitz_tracker_records_correctlytest_only_armour_can_blitz_movement_checktest_blitz_path_length_validation
Factory Placement (generation_fixed.rs):
test_placement_requires_factorytest_placement_with_factorytest_sea_unit_placement_requires_adjacent_sea_zonetest_cannot_place_in_enemy_factory
Technologies - Rockets & Industrial Tech (resolve.rs

test_rockets_tech_definedtest_rockets_tech_can_be_grantedtest_rockets_allows_aa_sbrtest_industrial_tech_definedtest_industrial_tech_can_be_grantedtest_industrial_tech_reduces_unit_costtest_industrial_tech_all_unit_types
Config Options (game_options.rs):
test_kamikaze_airplanes_default_trainingtest_kamikaze_airplanes_default_tournamenttest_kamikaze_airplanes_can_be_enabledtest_produce_fighters_on_carriers_enabledtest_produce_fighters_on_carriers_all_presetstest_move_existing_fighters_to_new_carriers_enabledtest_move_existing_fighters_to_new_carriers_all_presetstest_lhtr_carrier_production_disabled_by_defaulttest_lhtr_carrier_production_all_presetstest_lhtr_carrier_production_can_be_enabledtest_allied_air_dependents_enabledtest_allied_air_dependents_all_presetstest_allied_air_dependents_can_be_disabledtest_neutrals_are_blitzable_disabled_by_defaulttest_neutrals_are_blitzable_all_presetstest_neutrals_are_blitzable_can_be_enabledtest_neutrals_impassable_takes_precedencetest_sub_control_sea_zone_restricted_disabled_by_defaulttest_sub_control_sea_zone_restricted_all_presetstest_sub_control_sea_zone_restricted_can_be_enabledtest_sub_control_affects_transport_passage
Last updated: 2026-01
Movement Rules Overhaul (Fixed 2026-01)
Files Modified:
Bug Description Fix AA guns could move in Combat Move AA guns have movement=1, weren't excluded Added if unit_type == UnitType::AaGun { continue; }ingen_combat_moves()Bombers could land in sea zones (NCM) No explicit check for bomber sea landing Added if unit_type == UnitType::Bomber && to_terr.is_water { continue; }ingen_noncombat_moves()AA guns destroyed on capture AA guns vanished when territory fell Added capture_aa_guns()to transfer ownership to attackerMovement tracking not used Units could move unlimited times Added units_moved_counttracking - see Section 3.6Note: Bombers CAN move to sea zones during Combat Move (to attack ships). The fix only prevents landing in sea zones during Non-Combat Move.
Test Cases Added:
test_aa_gun_cannot_move_during_combat_movetest_aa_gun_can_move_during_noncombattest_bomber_cannot_move_to_sea_zone_ncmtest_aa_gun_captured_when_territory_fallstest_aa_gun_not_in_casualty_listtest_multiple_aa_guns_all_captured
Impact: These bugs meant the AI was learning invalid strategies during training. Training should be restarted from scratch after these fixes.
Shore Bombardment Implementation (Added 2026-01)
Files Modified:
- battle.rs - Added
get_amphibious_info()helper - resolve.rs - Added bombardment logic before AA fire
- bombardment.rs -
resolve_bombardment_multi()function
Feature Description Detection get_amphibious_info()checks for transports in adjacent sea zonesFiring Battleships fire at attack value 4 (Low Luck: 4/6 = 0.66 hits each) Timing Fires BEFORE AA fire, casualties applied immediately Multi-zone Supports battleships from multiple adjacent sea zones Early victory Can end battle if bombardment kills all defenders Rule Details:
- Only battleships can bombard (WW2v2 has no cruisers)
- One bombardment shot per battleship per battle
- Bombardment only happens in amphibious assaults (requires transport unloading)
- Defender selects casualties from bombardment hits
Test Cases (tests/battle_test.rs):
test_bombardment_in_amphibious_assault- Bombardment fires during amphibious assaulttest_no_bombardment_without_amphibious- No bombardment for land-only attackstest_multiple_battleships_bombard- Multiple battleships all firetest_bombardment_before_aa_fire- Bombardment happens before AA fire in battle sequence
Movement Tracking Implementation (Added 2026-01)
Files Modified:
- fixed.rs - Added
units_moved_countandremaining_movementarrays - apply.rs - Track in apply functions, untrack in unapply
- undo.rs - Added movement tracking fields to UndoInfo
- generation_fixed.rs - Use
units_available_to_move()for move generation
Issue Description Fix Units could move multiple times No tracking of which units moved Added units_moved_countarrayWalk-then-load exploit Infantry walk to coast, then load same turn Track load at source (Combat Move only) Unload-then-walk exploit Tank unload from transport, then walk inland Track unload at destination (both phases) MCTS state corruption Movement not restored on unapply Added unrecord_units_moved()in unapplyNCM bridging broken Bridging requires load→sail→unload in one phase Don't track load in Non-Combat Move State Size Impact: Increased from 16KB to 32KB to accommodate tracking arrays.
MCTS Compatibility:
apply_move()records movement inUndoInfounapply_move()callsunrecord_units_moved()to restore state- Phase transitions call
clear_movement_tracking()to reset arrays
Test Cases (tests/battle_test.rs):
test_movement_tracking_basic- Basic record_units_moved functionalitytest_unit_move_tracks_movement- Unit moves are tracked at destinationtest_mcts_apply_unapply_preserves_movement- MCTS cycle restores movement statetest_phase_transition_clears_tracking- Tracking cleared on phase changetest_clear_movement_tracking_directly- Direct clear function workstest_moved_units_not_in_move_generation- Moved units excluded from legal movestest_unload_tracks_at_destination- Unloaded units tracked at destinationtest_full_combat_round_with_tracking- Full battle with trackingtest_aa_gun_cannot_combat_move- AA guns excluded from Combat Movetest_aa_gun_can_noncombat_move- AA guns can move in Non-Combat Movetest_bomber_cannot_land_in_sea_zone_ncm- Bombers can't land in sea zones
Production Limit Implementation (Fixed 2026-01)
Files Modified:
- fixed.rs - Added
units_placed_countarray and helper methods - apply.rs - Track placements in
apply_place(), untrack inunapply_move() - undo.rs - Added
placement_territoryandplacement_countto UndoInfo - generation_fixed.rs - Use
remaining_production_capacity()ingen_placements()
Rule Description Status Production = territory IPC Max units placeable = territory production value
VerifiedFactory damage reduces capacity Effective limit = production - damage
VerifiedTracking per territory units_placed_count[territory]tracks placements
VerifiedReset at end of turn clear_placement_tracking()on phase transition
VerifiedImplementation:
remaining_production_capacity(territory, production)- Returns available capacityrecord_units_placed(territory, count)- Increments placement countunrecord_units_placed(territory, count)- Decrements for MCTS unapplyclear_placement_tracking()- Resets all counts (called when leaving Place phase)
Bug Fixed:
Previously,gen_placements()retrievedlet _production = map.territory(tid).production;but NEVER USED IT. This allowed unlimited unit placement at any factory, breaking game balance.Test Cases:
test_production_limited_by_territory_ipc- Placement capped at territory IPCtest_production_reduced_by_factory_damage- Damage reduces capacitytest_no_placement_at_capacity- No placements when at capacitytest_remaining_production_capacity_helper- Helper function works correctly
Air vs Submarine Rules Implementation (Fixed 2026-01)
Files Modified:
- resolve.rs - Added stalemate detection and target filtering
Rule Description Status Air cannot hit subs without destroyer air_can_hit_subs()check in combat
VerifiedSubs cannot hit aircraft Sub hits filtered to exclude fighters/bombers
VerifiedStalemate detection Battle ends if only air vs only subs (no destroyer)
VerifiedImplementation:
has_only_subs()- Checks if player only has submarines remaininghas_only_air_no_destroyer()- Checks if player has only air and no destroyeris_air_sub_stalemate()- Detects when combat cannot continueget_air_targetable_units()- Filters subs from air targets when no destroyerget_sub_targetable_units()- Excludes aircraft from sub targets
Bug Fixed:
Theair_can_hit_subs()function insubmarines.rsexisted but was NEVER CALLED in combat resolution. This meant aircraft could always hit submarines regardless of destroyer presence.Test Cases:
test_air_cannot_hit_subs_without_destroyer- Stalemate when only air vs substest_air_can_hit_subs_with_destroyer- Normal combat with destroyertest_sub_hits_cannot_kill_aircraft- Sub hits go to non-aircrafttest_has_only_subs_helper- Helper function workstest_has_only_air_no_destroyer_helper- Helper function workstest_is_air_sub_stalemate_detection- Stalemate detection workstest_get_air_targetable_units_filters_subs- Target filtering workstest_get_sub_targetable_units_excludes_aircraft- Aircraft excluded from sub targets
Canal Blocking Tests (Added 2026-01)
Files Modified:
- generation_fixed.rs - Added canal blocking test cases
Rule Description Status Suez Canal blocking Ships cannot pass Suez if enemy controls Anglo Egypt OR Trans-Jordan
VerifiedPanama Canal blocking Ships cannot pass Panama if enemy controls Panama
VerifiedBoth territories required Suez requires control of BOTH Anglo Egypt AND Trans-Jordan
VerifiedAllied canal access Allied ships can use canals controlled by friendly powers
VerifiedImplementation:
can_pass_canal()in generation_fixed.rs already implemented correctly- Tests added to verify canal blocking works as expected
Test Cases:
test_suez_canal_blocked_without_control- British ships blocked when Germans control Sueztest_suez_canal_open_with_control- British ships pass when British control Sueztest_panama_canal_blocked_without_control- Japanese ships blocked when Allies control Panamatest_panama_canal_open_with_control- American ships pass when Americans control Panamatest_suez_requires_both_territories- Suez blocked if only one territory controlledtest_allied_can_use_friendly_canal- British can use American-controlled Panama
Amphibious Retreat Rules Implementation (Fixed 2026-01)
Files Modified:
- fixed.rs - Added
amphibious_assault_territoriestracking mask - apply.rs - Mark amphibious assaults, restrict retreat to aircraft
- undo.rs - Added
amphibious_territoryandamphibious_territory_markedfields - generation_fixed.rs - Only generate retreat moves if aircraft present in amphibious battles
Rule Description Status Ground units cannot retreat from amphibious Infantry, artillery, armour stay and fight to death
VerifiedAircraft can retreat from amphibious Fighters and bombers can retreat to friendly territory
VerifiedPure amphibious ground has no retreat If only ground units in amphibious, no retreat moves generated
VerifiedNon-amphibious full retreat All units can retreat from non-amphibious battles
VerifiedImplementation:
amphibious_assault_territories: TerritoryMask- Tracks which territories have amphibious landings- Set when
apply_amphibious()is called during Combat Move phase - Cleared when leaving Battle phase
gen_battle_moves()- Only generates retreat if attacker has aircraft in amphibious battlesapply_retreat()- Only moves aircraft in amphibious battles, ground units stay
Bug Fixed:
Previously, all units could retreat from any battle. In amphibious assaults, ground units that landed from transports are committed to the battle and cannot retreat. Only aircraft (which flew in separately) can retreat.Test Cases:
test_amphibious_assault_no_retreat_without_air- No retreat moves when only ground unitstest_amphibious_assault_air_can_retreat- Retreat available when aircraft presenttest_non_amphibious_all_units_can_retreat- All units can retreat in land battlestest_amphibious_retreat_only_moves_aircraft- Only aircraft move when retreating from amphibious
Submarine Submerge Implementation (Fixed 2026-01)
Files Modified:
- mod.rs - Added
MOVE_SUBMERGEconstant andMove::submerge()constructor - fixed.rs - Added
submerged_substracking array and helper methods - undo.rs - Added
submerge_territory,submerge_player,submerge_count,submerge_occurredfields - apply.rs - Added
apply_submerge()and undo logic - generation_fixed.rs - Generate submerge option in
gen_battle_moves() - battle.rs - Restore submerged subs after battle ends
Rule Description Status Submerge option available Subs can submerge if no enemy destroyer present
VerifiedDestroyer blocks submerge Enemy destroyer prevents submerge option
VerifiedSubmerged subs leave combat Submerged subs don't participate in remaining rounds
VerifiedSubmerged subs survive Submerged subs remain in territory after battle
VerifiedPlayer choice Player can choose to submerge OR continue (stalemate)
VerifiedImplementation:
submerged_subs: [[u8; MAX_TERRITORIES]; Player::COUNT]- Tracks submerged subs per player per territorysubmerge_subs()- Moves subs from active units to submerged trackingrestore_submerged_subs()- Restores subs to active units after battle endsunsubmerge_subs()- For MCTS unapplygen_battle_moves()- Generates submerge option when subs present and no enemy destroyer- After
resolve_battle(),restore_submerged_subs()is called for all players
Bug Fixed:
Thesubs_can_submerge()function existed but was never used in the game. Submarines couldn't choose to submerge to escape combat. Now the player can choose between:- Submerge - Subs escape and remain in territory after battle
- Pass (continue) - Battle continues (with stalemate detection if only air vs subs)
Test Cases:
test_submerge_option_available_without_destroyer- Submerge move generated when no destroyertest_submerge_option_blocked_by_destroyer- No submerge option when enemy has destroyertest_submerge_removes_subs_from_combat- Subs move to submerged trackingtest_submerged_subs_restored_after_battle- Subs restored to active units post-battletest_submerge_vs_stalemate_gives_choice- Player has choice: submerge or continue to stalemate
-
@kindwind
Looks impressive!
Is the PU value of a territory taken into account?The built-in AI targets Capital and Victory Cities (vc), it looks like you cater for those. It also targets factories does the above?
-
@thedog What the neural network CAN SEE (encoded in the 48-channel tensor):
Feature
Channel
How Encoded
Territory PU values
25
Production value normalized (0-1, max 10)
Victory Cities
26
Binary flag
Capitals
28
Binary flag
Factories
30
Binary "has factory" flag
Factory damage
29
Damage level normalized
So the network sees all this information, but here's the philosophical difference from TripleA's built-in AI:
TripleA's AI: Has explicit targeting heuristics ("prioritize capitals → VCs → factories → high-PU territories")
COLOSSUS: Has NO explicit targeting. It must discover through self-play that these things matter based on:
Win condition: Victory City count (9/10/12 VCs) or capital capture
Reward shaping: IPC advantage as a tie-breaker (which reflects total controlled PU)
The theory is that after enough training games, the network should learn:
"Capturing Moscow gives me all their IPCs" → value capitals
"Controlling more VCs wins games" → value VCs
"High-PU territories increase my IPC advantage" → value territory production
"Factories let me place units there" → value factories (implicitly)
The question is: Has training progressed far enough for this learning to emerge? Or does it need explicit reward shaping for intermediate strategic objectives?So it's an alpha go style. Should work used low luck instead of pure dice.
It may not work out however!
-
@kindwind said in Game Engine Rules (AI Training):
Or does it need explicit reward shaping for intermediate strategic objectives?
TripleAs AI needs help to be better, in 1941 Global Command Decision (GCD) there are 82 Capital territories/TT and Sea Zones/SZ. A few Capitals are in the middle of the Pacific. I have used these excess Capitals to tell the AI what is important to the player.
Also SZ have PU values, usually 1, but SZ that are part of a canal have 2PU, so the AI values these more.
So does your AI value what the player values?
-
@thedog For right now I am doing the revised map. I will take on other maps later. Hopefully from my current project I can upgrade to something like a universal game engine for triplea that handles all the maps. That's a lot of work. The project is much simpler. Get an AI like alpha go for revised. Make sure it's right. Then expand. The AI can figure out how I build this and then make me a script for the universal engine from all the tirplea game boards. Remember, I don't code. I am just guy who can think is all. This is all AI and some wits. LOL. This will take months to do.
-
@kindwind Why don't you try the Minimap scenario? It uses a simplified version of the Revised rules with a small, simple map.
-
@rogercooper had no idea that was a thing. I just started to work with code using AI. I just build everything that I thought I would have needed. My AI uses an alpha go style MCST. That's all I know really.
-
@kindwind If you want to try a neural net AI for TripleA, you would need to modify TripleA to support repeated self-play. For example of programs that support repeated self-play checkout Ludii & Chess Arena.
Supporting repeated self-play would be project of moderate difficulty in Java. (TripleA already supports self-play). You would need to learn Java (Vibe coding doesn't cut it).. Repeated self-play would also be useful for balancing mods.
I don't know how well a neural net would play TripleA. The number of possible moves in Go is a most 361, far fewer than the number of possible moves in a TripleA game. An effort to get a neural net to play a 2-player Risk variant did not go well.
One advantage is that TripleA already has heuristic AI's that could be used to train a neural net.