瀏覽代碼

Delete game/systems/ai_system/IMPROVEMENTS.md

Adam Djellouli 2 月之前
父節點
當前提交
31f9f614bf
共有 1 個文件被更改,包括 0 次插入151 次删除
  1. 0 151
      game/systems/ai_system/IMPROVEMENTS.md

+ 0 - 151
game/systems/ai_system/IMPROVEMENTS.md

@@ -1,151 +0,0 @@
-# AI System Improvements - Implementation Summary
-
-## Files Created (11 new files)
-
-### Core Infrastructure
-1. **ai_command_filter.{h,cpp}** - Command deduplication system
-2. **ai_tactical.{h,cpp}** - Tactical combat utilities (focus fire, engagement assessment)
-
-### Behaviors
-3. **behaviors/retreat_behavior.{h,cpp}** - Intelligent retreat for damaged units
-
-## Files Modified (15 files)
-
-### Core AI System
-- **ai_system.{h,cpp}** - Integrated command filter, retreat behavior
-- **ai_types.h** - Added unit ownership tracking, composition metrics, ContactSnapshot health/type
-- **ai_utils.h** - Added claimUnits(), releaseUnits(), cleanupDeadUnits()
-- **ai_reasoner.cpp** - Added hysteresis to state machine, enhanced context tracking
-- **ai_snapshot_builder.cpp** - Populate ContactSnapshot with health/type info
-
-### Behaviors (Enhanced)
-- **behaviors/attack_behavior.{h,cpp}** - Focus fire, engagement rules, target persistence
-- **behaviors/defend_behavior.cpp** - Unit claiming, tactical targeting
-- **behaviors/gather_behavior.cpp** - Unit claiming integration
-- **behaviors/production_behavior.{h,cpp}** - Dynamic unit composition strategy
-
-### Build System
-- **CMakeLists.txt** - Added new source files
-
-## Key Features Implemented
-
-### 1. Command Deduplication (Fixes Jitter)
-- **Problem**: Units received redundant commands every 1-2 seconds
-- **Solution**: AICommandFilter tracks recent commands with 3s cooldown
-- **Impact**: Smooth unit movement, no more stop/start behavior
-
-### 2. Unit Ownership Tracking (Fixes Conflicts)
-- **Problem**: Multiple behaviors commanded same units simultaneously
-- **Solution**: Priority-based claiming system with lock duration
-- **Mechanics**:
-  - Behaviors call `claimUnits()` before issuing commands
-  - Higher priority can steal units after lock expires
-  - Dead units auto-cleaned from assignments
-- **Impact**: No more conflicting orders, predictable behavior
-
-### 3. State Machine Hysteresis (Fixes Flipping)
-- **Problem**: Rapid state switches at threshold boundaries
-- **Solution**: Enter/exit thresholds with gaps
-  - Retreat: Enter 25%, Exit 55% (+30% gap)
-  - Defend: Enter 40%, Exit 65% (+25% gap)
-  - Min state duration: 3 seconds
-- **Impact**: Stable decisions, no more indecision loops
-
-### 4. Focus Fire & Tactical Targeting
-- **Problem**: Units spread damage, picked random targets
-- **Solution**: TacticalUtils::selectFocusFireTarget() with scoring:
-  - Target persistence (+10 points) - don't switch constantly
-  - Low health bonus (+8-20 points) - finish wounded enemies
-  - Unit type priority (archers > melee > workers)
-  - Isolation bonus (+6 points) - vulnerable targets
-  - Distance penalty - prefer closer targets
-- **Impact**: Efficient damage concentration, faster kills
-
-### 5. Engagement Assessment (Fixes Suicide Attacks)
-- **Problem**: AI attacked regardless of force ratio
-- **Solution**: TacticalUtils::assessEngagement()
-  - Calculates force ratio (friendlies/enemies weighted by health)
-  - Confidence level: 0.0 = terrible odds, 1.0 = overwhelming
-  - Min ratio thresholds: 0.7 attacking, 0.9 defending
-- **Impact**: AI won't commit to unwinnable fights
-
-### 6. Intelligent Retreat Behavior
-- **Priority**: Critical (overrides everything)
-- **Triggers**:
-  - Units below 35% health (critical)
-  - Units below 50% health AND engaged in combat
-- **Action**: Pull back to base in formation
-- **Impact**: Preserves army, allows healing/regrouping
-
-### 7. Dynamic Production Strategy
-- **Old**: Alternated archer/swordsman blindly
-- **New**: Composition based on game phase
-  - Early (< 5 units): 70% melee (tanking)
-  - Mid (5-12 units): 50/50 balanced
-  - Late (12+ units): 60% ranged (DPS)
-  - Override: Melee when under threat
-- **Impact**: Better army composition for different scenarios
-
-### 8. Enhanced Context Tracking
-**New Metrics**:
-- `meleeCount` / `rangedCount` - Army composition
-- `damagedUnitsCount` - Units below 50% health
-- `visibleEnemyCount` - Total visible enemies
-- `enemyBuildingsCount` - Enemy structures
-- `averageEnemyDistance` - Threat proximity
-
-**Usage**: Enables smarter decision-making
-
-## Behavior Priority Order (Updated)
-
-1. **Critical**: RetreatBehavior - Save damaged units
-2. **Critical**: DefendBehavior - Protect base
-3. **High**: ProductionBehavior - Build army (concurrent)
-4. **Normal**: AttackBehavior - Offensive operations
-5. **Low**: GatherBehavior - Rally idle units
-
-## Performance Impact
-
-- **Command Filter**: O(n) per update, < 100 history entries
-- **Unit Claiming**: O(1) hash map lookups
-- **Tactical Scoring**: O(enemies × attackers) worst case
-- **Memory**: +~2KB per AI (tracking structures)
-
-## Testing Checklist
-
-- [x] Units don't jitter when idle
-- [x] No rapid state flipping
-- [x] Attack focuses single target until dead/switching needed
-- [x] AI retreats when outnumbered (doesn't suicide)
-- [x] Damaged units pull back instead of staying in combat
-- [x] Production builds balanced armies
-- [x] DefendBehavior doesn't conflict with AttackBehavior
-- [x] GatherBehavior gets overridden by higher priority tasks
-
-## Compilation
-
-All files compile cleanly. New dependencies:
-- ai_command_filter.cpp
-- ai_tactical.cpp
-- retreat_behavior.cpp
-
-## Recent Improvements
-
-### 9. Ranged Unit Combat Behavior (Archers)
-- **Problem**: Archers continued walking into melee range even when enemies were in firing range
-- **Solution**: Enhanced CombatSystem to detect ranged units and stop movement when within attack range
-- **Implementation**:
-  - Ranged units stop all movement when any enemy is within range, regardless of movement reason
-  - Works for archers moving to defend, attack, or any other command
-  - Maintain optimal firing distance (85% of max range) when approaching targets during chase
-  - Hold position instead of continuing movement when enemies enter effective range
-  - Prevents ranged units from walking into melee combat unnecessarily
-- **Impact**: Archers now engage from safe distance in all scenarios, maintain tactical advantage
-
-## Next Steps (Optional Enhancements)
-
-1. **Advanced Kiting Behavior** - Ranged units actively retreat when enemies close distance
-2. **Squad System** - Group units into persistent squads
-3. **Threat Map** - Track enemy positions over time
-4. **Difficulty Levels** - Configurable reaction times, mistakes
-5. **Economic Strategy** - Resource management, expansion timing