Navigation

    TripleA Logo

    TripleA Forum

    • Register
    • Login
    • Search
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags

    Game Engine Rules (AI Training)

    Development
    2
    3
    45
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Kindwind
      Kindwind last edited by

      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

      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 ✅ Verified
      Artillery 4 2 2 1 Transport cost: 3, supports infantry ✅ Verified
      Armour 5 3 3 2 Transport cost: 3, can blitz ✅ Verified
      AA Gun 5 0 0 1 Transport cost: 3, special AA fire ✅ Verified
      Fighter 10 3 4 4 Carrier cost: 1, +2 with Long Range ✅ Verified
      Bomber 15 4 1 6 SBR capable, +2 with Long Range ✅ Verified
      Submarine 8 2 2 2 First strike, submerge ✅ Verified
      Destroyer 12 3 3 2 Negates sub abilities ✅ Verified
      Transport 8 0 1* 2 Capacity: 5 points ✅ Verified
      Carrier 16 1 3 2 Holds 2 fighters ✅ Verified
      Battleship 24 4 4 2 2 hit points, shore bombard ✅ Verified
      Factory 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) ✅ Verified
      2. TechActivation Roll tech dice, gain technology ✅ Verified
      3. Purchase Buy units (placed at end of turn) ✅ Verified
      4. CombatMove Move units to attack ✅ Verified
      5. Battle Resolve all combat ✅ Verified
      6. NonCombatMove Move remaining units ✅ Verified
      7. Place Place purchased units ✅ Verified
      8. EndTurn Collect income, repair units ✅ Verified

      Player Order

      1. Russians → 2. Germans → 3. British → 4. Japanese → 5. Americans

      File: phase.rs:15-28 ✅ Verified

      Bid 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 ✅ Verified
      Ships can attack adjacent sea zones gen_combat_moves ✅ Verified
      Aircraft can attack within movement range gen_combat_moves ✅ Verified
      AA guns CANNOT move during combat Excluded from combat move gen ✅ Verified
      AA guns CANNOT load on transports gen_transport_loads_combat_dedup ✅ Verified
      Transports can load infantry/artillery/armour gen_transport_loads_combat_dedup ✅ Verified
      Amphibious assaults from transports gen_amphibious_assaults ✅ Verified

      Test Coverage: generation_fixed.rs:745-923 ✅ Verified

      3.2 Non-Combat Move Phase

      File: generation_fixed.rs

      Rule Implementation Status
      Units move to friendly territories gen_noncombat_moves ✅ Verified
      AA guns CAN move during NCM gen_noncombat_moves ✅ Verified
      AA guns CAN load on transports gen_transport_loads_dedup ✅ Verified
      Aircraft must land with valid capacity validation/aircraft.rs ✅ Verified
      Transports can unload cargo gen_transport_unloads ✅ Verified

      Test Coverage: generation_fixed.rs:871-923 ✅ Verified

      3.3 Blitzing

      File: validation/movement.rs:130-153

      Rule Description Status
      Only armour can blitz Movement 2 required ✅ Verified
      Must pass through EMPTY enemy territory No enemy units present ✅ Verified
      Cannot blitz through defended territory can_blitz function ✅ Verified
      Territory captured during blitz Ownership changes ✅ Verified
      AA guns block blitzing can_blitz check ✅ Verified

      Test Coverage: movement.rs:295-433 ✅ Verified

      3.4 Canal Restrictions

      File: generation_fixed.rs:611-634

      Canal Required Territories Status
      Suez Canal Egypt ✅ Verified
      Panama Canal Panama, Central America ✅ Verified

      Ships cannot pass through canals unless controlling player owns required territories.

      Implementation: can_pass_canal function ✅ Verified

      3.5 Aircraft Landing

      File: validation/aircraft.rs

      Rule Description Status
      Fighters land on friendly territory can_land function ✅ Verified
      Fighters land on carriers has_carrier_capacity ✅ Verified
      Carrier capacity: 2 fighters Per carrier ✅ Verified
      Bombers land on friendly territory only Cannot use carriers ✅ Verified
      Must have movement remaining remaining_movement ✅ Verified
      Long Range Air: +2 movement Technology bonus ✅ Verified

      Test Coverage: aircraft.rs:163-217 ✅ Verified


      4. Combat Rules

      4.1 Battle Resolution

      File: combat/resolve.rs

      Phase Description Status
      1. AA Fire AA guns fire at attacking aircraft ✅ Verified
      2. Submarine First Strike Subs attack before regular combat ✅ Verified
      3. Regular Combat Alternating fire rounds ✅ Verified
      4. Retreat Attacker may retreat ✅ Verified

      4.2 AA Fire

      File: combat/resolve.rs, combat/dice.rs:29-37

      Rule Description Status
      Hits on 1 1/6 chance per aircraft ✅ Verified
      One shot per aircraft Max hits = aircraft count ✅ Verified
      Low Luck AA Guaranteed hits for 6+ aircraft ✅ Verified
      Choose casualties (optional) config.choose_aa_casualties ✅ Verified
      Always-on AA (flyover) config.always_on_aa ✅ Verified

      Test Coverage: resolve.rs:665-681, apply.rs:822-980 ✅ Verified

      4.3 Submarine Combat

      File: combat/resolve.rs

      Rule Description Status
      First strike Submarines fire first ✅ Verified
      Casualties don't return fire Unless destroyer present ✅ Verified
      Destroyer negates first strike has_destroyer check ✅ Verified
      Submerge option config.submersible_subs ✅ Verified
      Super Subs tech: Attack 3 Technology bonus ✅ Verified
      Super Subs defense bonus config.super_sub_defense_bonus ✅ Verified
      Defending subs fire back config.defending_subs_fire_back ✅ Verified

      Test Coverage: resolve.rs:634-642, submarines.rs:42-139 ✅ Verified

      4.4 Artillery Support

      File: combat/resolve.rs

      Rule Description Status
      1:1 support ratio Each artillery supports 1 infantry ✅ Verified
      Supported infantry attack at 2 Instead of 1 ✅ Verified

      Test Coverage: resolve.rs:613-621 ✅ Verified

      4.5 Two-Hit Battleships

      File: combat/resolve.rs

      Rule Description Status
      Battleships take 2 hits config.two_hit_battleship ✅ Verified
      Damaged state tracked state.damaged_battleships ✅ Verified
      Repair at end of turn config.units_repair_hits_end_turn ✅ Verified
      Repair at start of turn config.units_repair_hits_start_turn ✅ Verified

      Test Coverage: resolve.rs:684-709 ✅ Verified

      4.6 Transport Defense

      File: combat/resolve.rs

      Setting Behavior Status
      transport_defense = 0 Defenseless transports ✅ Verified
      transport_defense = 1 Transports defend at 1 ✅ Verified
      Combat unit check Transports count as combat when defending ✅ Verified

      Test Coverage: resolve.rs:711-784 ✅ Verified


      5. Strategic Bombing

      File: combat/bombing.rs

      Rule Description Status
      Bombers attack factories resolve_bombing_raid ✅ Verified
      AA fires at bombers Before damage ✅ Verified
      Damage = 1d6 per bomber Standard ✅ Verified
      Heavy Bombers: 2d6 With technology ✅ Verified
      LHTR Heavy: Best of 2d6 config.lhtr_heavy_bombers ✅ Verified
      Low Luck: 4 IPC per bomber config.low_luck_bombing ✅ Verified
      Low Luck Heavy: 7 IPC Per bomber ✅ Verified
      Territory turn limit config.territory_turn_limit ✅ Verified
      Factory damage tracked state.factory_damage ✅ Verified
      Repair costs 1 IPC per point repair_factory ✅ Verified

      Test 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 ✅ Verified
      No income if capital captured state.capital_captured check ✅ Verified
      Income collected at end of turn collect_income ✅ Verified

      Test Coverage: income.rs:54-77 ✅ Verified

      6.2 Capital Capture

      File: game/capital.rs

      Rule Description Status
      Captor steals all IPCs handle_capital_capture ✅ Verified
      Victim loses income ability capital_captured flag ✅ Verified
      Liberation restores income check_capital_liberation ✅ Verified
      IPCs not returned on liberation Intended behavior ✅ Verified

      Test Coverage: capital.rs:101-144 ✅ Verified

      6.3 Unit Purchase

      Files: generation_fixed.rs, action_space.rs

      Rule Description Status
      Purchase during Purchase phase Phase check ✅ Verified
      Units placed during Place phase Deferred placement ✅ Verified
      Factory required for placement Factory presence check ✅ Verified
      Cannot use enemy factory Ownership check ✅ Verified
      Sea units placed in adjacent sea zone Naval placement ✅ Verified
      Factory damage reduces production effective_production ✅ Verified

      Test Coverage: generation_fixed.rs:996-1124 ✅ Verified


      7. Victory Conditions

      File: game/victory.rs

      Victory Type Cities Needed Status
      Projection of Power 9 VCs ✅ Verified
      Honorable Surrender 10 VCs ✅ Verified
      Total Victory 12 VCs ✅ Verified

      Implementation:

      • check_victory - Main victory check
      • count_victory_cities - Count per alliance
      • check_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 ✅ Verified
      Rockets AA guns can SBR ✅ Verified
      Super Subs Submarines attack at 3 ✅ Verified
      Long Range Air Aircraft +2 movement ✅ Verified
      Industrial Tech Units cost 1 less ✅ Verified
      Heavy Bombers 2d6 bombing damage ✅ Verified

      Test Coverage: resolve.rs:814-1056 ✅ Verified (All technologies)

      Tech Research

      Rule Description Status
      Cost: 5 IPCs per die config.tech_cost_per_die ✅ Verified
      Success on 6 roll_tech ✅ Verified
      Low Luck: N dice = N/6 chance Guaranteed at 6 dice ✅ Verified

      Test 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 ✅ Verified
      AA Fire hits = floor(aircraft/6) + roll ✅ Verified
      Tech 6 dice = guaranteed, else roll ≤ N ✅ Verified
      Bombing 4 IPC per normal, 7 per heavy ✅ Verified

      Configuration:

      • config.low_luck - Combat
      • config.low_luck_aa - AA fire
      • config.low_luck_tech - Technology
      • config.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_luck true ✅ Verified
      low_luck_aa true ✅ Verified
      low_luck_tech true ✅ Verified
      low_luck_bombing true ✅ Verified
      always_on_aa true ✅ Verified
      roll_aa_individually true ✅ Verified
      choose_aa_casualties true ✅ Verified
      kamikaze_airplanes false ✅ Verified
      territory_turn_limit true ✅ Verified

      Technology Options

      Option Default (TRAINING) Status
      technology_enabled false ✅ Verified
      tech_cost_per_die 5 ✅ Verified
      lhtr_heavy_bombers true ✅ Verified
      heavy_bomber_dice_rolls 2 ✅ Verified
      super_sub_defense_bonus 0 ✅ Verified

      Unit Options

      Option Default (TRAINING) Status
      two_hit_battleship true ✅ Verified
      units_repair_hits_end_turn true ✅ Verified
      units_repair_hits_start_turn false ✅ Verified
      submersible_subs true ✅ Verified
      defending_subs_fire_back true ✅ Verified
      transport_defense 1 ✅ Verified
      produce_fighters_on_carriers true ✅ Verified
      move_existing_fighters_to_new_carriers true ✅ Verified
      lhtr_carrier_production false ✅ Verified
      allied_air_dependents true ✅ Verified

      Movement Options

      Option Default (TRAINING) Status
      neutrals_are_impassable true ✅ Verified
      neutrals_are_blitzable false ✅ Verified
      sub_control_sea_zone_restricted false ✅ Verified

      Victory Options

      Option Default (TRAINING) Status
      victory_type TotalVictory (12 VCs) ✅ Verified

      Test 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 20 0 0 20
      Combat Rules 23 0 0 23
      Economic Rules 9 0 0 9
      Victory 3 0 0 3
      Technology 7 0 0 7
      Configuration 29 0 0 29
      TOTAL 111 0 0 111

      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_dedup excluding AA guns
      Transport loading not generated during NCM Added gen_transport_loads_dedup to gen_noncombat_moves

      Test Cases Added:

      1. test_aa_gun_cannot_load_during_combat_move
      2. test_aa_gun_can_load_during_noncombat_move
      3. test_infantry_can_load_during_combat_move
      4. test_artillery_can_load_during_combat_move
      5. test_aa_gun_can_unload_during_noncombat_move
      6. test_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_destroyer
      • test_subs_cannot_submerge_with_enemy_destroyer
      • test_sub_attack_power_normal
      • test_sub_attack_power_super_subs
      • test_first_strike_checks_correct_enemy
      • test_resolve_battle_with_defending_subs_fire_back
      • test_resolve_battle_without_defending_subs_fire_back
      • test_submersible_subs_first_strike_enabled

      Technology Effects (resolve.rs😞

      • test_jet_power_increases_fighter_attack
      • test_jet_power_increases_fighter_defense
      • test_jet_power_only_affects_fighters
      • test_super_subs_increases_attack

      Movement/Blitz (movement.rs😞

      • test_blitz_through_empty_enemy_territory
      • test_blitz_blocked_by_any_enemy_unit
      • test_blitz_blocked_by_aa_gun
      • test_blitz_tracker_records_correctly
      • test_only_armour_can_blitz_movement_check
      • test_blitz_path_length_validation

      Factory Placement (generation_fixed.rs):

      • test_placement_requires_factory
      • test_placement_with_factory
      • test_sea_unit_placement_requires_adjacent_sea_zone
      • test_cannot_place_in_enemy_factory

      Technologies - Rockets & Industrial Tech (resolve.rs😞

      • test_rockets_tech_defined
      • test_rockets_tech_can_be_granted
      • test_rockets_allows_aa_sbr
      • test_industrial_tech_defined
      • test_industrial_tech_can_be_granted
      • test_industrial_tech_reduces_unit_cost
      • test_industrial_tech_all_unit_types

      Config Options (game_options.rs):

      • test_kamikaze_airplanes_default_training
      • test_kamikaze_airplanes_default_tournament
      • test_kamikaze_airplanes_can_be_enabled
      • test_produce_fighters_on_carriers_enabled
      • test_produce_fighters_on_carriers_all_presets
      • test_move_existing_fighters_to_new_carriers_enabled
      • test_move_existing_fighters_to_new_carriers_all_presets
      • test_lhtr_carrier_production_disabled_by_default
      • test_lhtr_carrier_production_all_presets
      • test_lhtr_carrier_production_can_be_enabled
      • test_allied_air_dependents_enabled
      • test_allied_air_dependents_all_presets
      • test_allied_air_dependents_can_be_disabled
      • test_neutrals_are_blitzable_disabled_by_default
      • test_neutrals_are_blitzable_all_presets
      • test_neutrals_are_blitzable_can_be_enabled
      • test_neutrals_impassable_takes_precedence
      • test_sub_control_sea_zone_restricted_disabled_by_default
      • test_sub_control_sea_zone_restricted_all_presets
      • test_sub_control_sea_zone_restricted_can_be_enabled
      • test_sub_control_affects_transport_passage

      Last updated: 2026-01

      TheDog 1 Reply Last reply Reply Quote 4
      • TheDog
        TheDog @Kindwind last edited by

        @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?

        Kindwind 1 Reply Last reply Reply Quote 1
        • Kindwind
          Kindwind @TheDog last edited by

          @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!

          1 Reply Last reply Reply Quote 2
          • 1 / 1
          • First post
            Last post
          Copyright © 2016-2018 TripleA-Devs | Powered by NodeBB Forums