bots/
│── base_bot.py # Abstract base class for all bots
│── bot_factory.py # Factory class for creating different types of bots
│── simple_bots.py # Collection of basic bot implementations
└── strategy_bot.py # Advanced strategic bot implementation
| Bot Type | Class Name | Description | Strategy |
|---|---|---|---|
| Smart Strategy | SmartStrategyBot |
Advanced bot using pathfinding and line of sight | Uses BFS for navigation, maintains optimal distance |
| Random | RandomBot |
Basic bot with random actions | Random movement and shooting |
| Aggressive | AggressiveBot |
Pursuit-focused bot | Directly chases and shoots at enemies |
| Defensive | DefensiveBot |
Buff zone control bot | Moves to buff zones and shoots from safety |
| Dodge | DodgeBot |
Evasion-focused bot | Actively dodges bullets and enemy tanks |
Abstract base class that all bots inherit from.
| Method | Parameters | Description |
|---|---|---|
get_action |
None | Returns [rotation, movement, shoot] action array |
find_nearest_opponent |
None | Locates closest enemy tank |
Actions are represented as a list of 3 integers:
- Rotation:
[0: Left, 1: None, 2: Right] - Movement:
[0: Backward, 1: None, 2: Forward] - Shooting:
[0: No, 1: Yes]
The BotFactory class manages bot creation and registration.
BOT_TYPES = {
'smart': SmartStrategyBot,
'random': RandomBot,
'aggressive': AggressiveBot,
'defensive': DefensiveBot,
'dodge': DodgeBot
}# Create a bot instance
bot = BotFactory.create_bot(bot_type='aggressive', tank=tank_instance)Advanced bot using pathfinding and tactical positioning.
- BFS pathfinding for navigation
- Line of sight checking
- Optimal distance maintenance
- State machine: searching, aiming, shooting
| State | Description |
|---|---|
| searching | Looking for opponents |
| aiming | Rotating to face target |
| shooting | Firing at target in range |
Basic bot with randomized behavior.
- Random action generation
- Action delay for smoother movement
- Simple state tracking
Pursuit-focused combat bot.
- Direct target pursuit
- Aggressive shooting
- Close-range combat
- Minimal retreat behavior
aim_threshold: 10° (forgiving aim for constant shooting)move_threshold: 45° (wide angle for movement)min_distance: 0.5 grid cells (close combat range)
Strategic bot focusing on buff zone control.
- Buff zone positioning
- Safe distance maintenance
- Precise shooting
- Defensive positioning
| State | Description |
|---|---|
| moving_to_buff | Seeking nearest buff zone |
| shooting | Engaging enemies from buff zone |
| searching | Looking for targets |
Evasion-focused survival bot.
- Threat detection (tanks and bullets)
- Wall-aware dodging
- Perpendicular movement to threats
- Continuous threat assessment
detection_radius: 4 grid cellsmin_dodge_angle: 45°max_dodge_angle: 120°dodge_duration: 10 frameswall_check_distance: 1.5 grid cells
The bot_arena.py script enables bot vs bot matches.
- Bot vs Bot matches
- Score tracking
- Round management
- Manual reset support (R key)
python bot_arena.py --bot1 aggressive --bot2 defensive- Initialize environment and bots
- Process bot actions each frame
- Track tank destruction
- Update scores
- Reset for next round
- Continue until window closed
state: Current bot state/behaviorstuck_timer: Tracks potential stuck conditionstarget: Current target (if any)
aim_threshold: Accuracy requirement for shootingmove_threshold: Angle tolerance for movementspeed: Movement velocity
tank: Reference to controlled tankenemy_tanks: List of opponent tankstarget_position: Desired position (if applicable)