Improving AI through patterns and simple prediction#9
Improving AI through patterns and simple prediction#9DvaMishkiLapa wants to merge 2 commits intoregular-dev:masterfrom
Conversation
|
@DvaMishkiLapa, thanks for your commitment! I've played against Hard & Developer bots with your changes and I've noticed two things:
However, there are several issues with your implementation. Some of the systems you implemented don't work as you described. To make them work, I applied some fixes but I'm not sure they affect bot behaviour as intended. And now to more serious stuff. Also, I printed out
In my attempt at fixing the first problem I used a timer giving enough time to make a full (or at least half) circle until Problem 1 fix proposal for The second problem exists because your algorithm doesn't take X coordinate wrapping into account. When the plane crosses screen border, the difference between two point sequences becomes too big and that messes up all calculations. Problem 2 fix proposal for Also, I'm a bit confused with I won't say how the bots behave with my fixes because I'm not sure it's still the intended way of calculating things. I had to lower |
Thinking about PR #8, I tried to solve a strange problem and improve the overall behavior of the AI.
I wouldn't say I achieved everything I wanted, but the bots started shooting better and no longer circle around the player if he flies in circles all the time.
In addition, it's now really interesting to watch two bots play.
This doesn't solve the issue of the strange "low-speed-to-back" tactic of the plane, but I didn't try to solve it.
I tried to describe what I did in more detail. But I suspect that there is a more elegant way to do it, as this is my first time doing this :D
Description of changes
Core Components
1. Pattern Recognition System
Detects when opponents are stuck in predictable patterns and responds appropriately.
Key Features:
include/ai_patterns.hpp(lines 37-47) -AiPatternTrackerstructureHow Circular Pattern Detection Works:
2. Pattern Breaking Strategy
Prevents infinite circular pursuit loops by forcing AI to change course.
Breaking Conditions:
src/ai_patterns.cpp(lines 130-174) -shouldBreakCircularPattern()methodBreaking Mechanism:
src/ai_stuff.cpp(lines 940-1041) - Pattern breaking implementation3. Enhanced Combat with Movement Prediction
AI uses enhanced shooting logic with movement prediction for better accuracy in all combat situations.
Key Behaviors:
src/ai_stuff.cpp(lines 98-161) -shouldShootWithPrediction()function4. Personality System
Gives each bot unique behavioral characteristics and tactical preferences.
Core Parameters:
Personality Types:
src/ai_patterns.cpp(lines 177-227) -updateBasedOnDifficulty()method5. Tactical Strategy System
Adapts AI behavior based on personality and tactical situation.
Strategy Selection Logic:
Defensive Strategy (when to use):
Defensive Behavior:
src/ai_patterns.cpp(lines 248-266) -shouldUseDefensiveStrategy()methodAggressive Strategy (when to use):
Aggressive Behavior:
src/ai_patterns.cpp(lines 229-266) -shouldUseAggressiveStrategy()methodsrc/ai_stuff.cpp(lines 1087-1100) - Aggressive behavior implementation6. Enhanced Aiming System
Improves shooting accuracy based on personality.
src/ai_patterns.cpp(lines 268-272)How it works:
src/ai_patterns.cpp(lines 268-275) -getModifiedAimCone()methodDifficulty Levels and Behavior
EASY
MEDIUM
HARD
DEVELOPER
New Behavior Patterns
The system introduces five distinct behavior patterns that make the AI feel more intelligent and unpredictable:
1. Adaptive Pursuit
2. Tactical Positioning
3. Dynamic Avoidance
4. Targeted Pursuit
5. Intelligent Pattern Breaking
Technical Implementation
Data Structures
include/ai_patterns.hpp(lines 37-57) -AiPatternTrackerstructureinclude/ai_patterns.hpp(lines 60-79) -AiPersonalitystructureNew Constants
What
circularPatternThresholdregulates:circularPatternThreshold * 2.0f= maximum allowed varianceWhat
stalePursuitThresholdregulates:mPursuitTimerstalePursuitThreshold→ pattern is considered staleisStalePursuit(): Detects stale pursuit stateshouldBreakCircularPattern(): UsesstalePursuitThreshold * 0.5ffor breaking decisionsWhat
movementPredictionTimeregulates:movementPredictionTimeseconds ahead