This game is a simplified version of the classic board game Stratego, where a human player faces off against an AI opponent. The game features strategic piece placement, tactical movement, and hidden ranks, with AI utilizing genetic algorithms for board setup and rule-based heuristics for gameplay.
The objective is to capture the opponent’s flag while defending your own. This project blends strategy and AI to create an engaging and challenging experience for players.
- The game is played between two players: Red and Blue.
- Each player has 16 pieces arranged on an 8x8 grid at the start of the game.
- Pieces include various ranks such as Spy, Bombs, Soldiers, and Generals.
- At the start of the game, all pieces are placed face-down.
- Only the player knows the ranks of their own pieces, while the opponent remains unaware until combat occurs.
- When two opposing pieces occupy the same square, their ranks are revealed.
- The piece with the higher rank wins, while the losing piece is removed from the board.
- Capture the opponent's Flag or eliminate all their movable pieces.
- Capturing the Flag results in an immediate victory, while eliminating all pieces leaves the opponent without options.
- Players alternate turns to move their pieces.
- Most pieces can move one square vertically or horizontally.
- Each piece has a rank dictating its combat power.
- Ranks range from the Spy (lowest) to the Marshal (highest).
- During combat, the higher-ranked piece wins.
- Stationary pieces that destroy any opposing piece attempting to move into their square.
- Miners are the only pieces capable of defusing bombs.
- The primary target for the opponent.
- Stationary and hidden until captured.
- The Spy can defeat the Marshal but loses to all other ranks.
- The Miner is the only piece capable of defusing Bombs.
- The human player manually positions their 16 pieces on their half of the board.
- The goal is to create a balanced defensive and offensive strategy.
- The AI uses a Genetic Algorithm (GA) to determine its initial setup.
- The algorithm optimizes for factors such as:
- Piece safety.
- Board coverage.
- Attack potential.
The human player manually places their 16 pieces on their half of the board, focusing on a balance of offensive and defensive strategies.
The AI’s piece placement is handled by a Genetic Algorithm (GA) that optimizes for:
- Protecting critical pieces like the Flag.
- Creating a balance between offense and defense.
- Maximizing board coverage and minimizing vulnerabilities.
The human player takes turns moving pieces, aiming to:
- Capture opponent pieces.
- Protect their Flag.
- Predict and counter AI moves.
The AI employs Rule-Based Heuristics for gameplay, with strategies such as:
- Strategic Movements: Prioritizing piece safety and targeting opponent pieces.
- Combat Strategy: Leveraging ranks for efficiency (e.g., using the Spy against the Marshal).
- Piece-Specific Logic: Miners defuse bombs, while Scouts explore the board.
These govern the AI’s real-time decision-making:
- Decision-Making Framework: Predefined rules mimic expert strategies.
- Quick Tactical Responses: The AI reacts dynamically to threats and opportunities.
- Key Strategies:
- Piece Interaction Rules: Example: Spy targeting Marshal.
- Positional Heuristics: High-value pieces are defended while Scouts probe enemy defenses.
- Dynamic Playstyle: Switching between offensive and defensive modes.
Used for optimizing initial piece placement:
- Generating Diverse Setups: Random configurations are generated.
- Fitness Evaluation: Evaluates metrics like piece safety and defensive strength.
- Selection and Mutation: High-performing setups are selected and enhanced.
The AI combines:
- Genetic Algorithm for static optimization (initial setup).
- Rule-Based Heuristics for dynamic decision-making during gameplay.
- Python 3.12
- Pygame: For game development and rendering.
-
Clone the repository:
git clone https://github.com/<your-github-username>/AI-Stratego-Battle-Your-Opponent.git cd AI-Stratego-Battle-Your-Opponent
-
Install the dependencies:
pip install pygame
-
Run the game:
python main.py