A C# simulation environment for testing AI strategies in a Bedwars-style game, inspired by the popular Minecraft minigame. This project implements a custom game engine with different AI agent strategies competing against each other.
This simulation models a Bedwars game where players start on their home islands, gather resources, build bridges to other islands, upgrade their equipment, and attempt to destroy other players' beds. Once a player's bed is destroyed, they cannot respawn when eliminated. The last player standing wins.
- Bed Islands: Home bases for players with resource generators (iron and gold)
- Diamond Islands: Generate diamond resources
- Emerald Islands: Generate emerald resources
- Iron: Basic resource, generated fastest
- Gold: Intermediate resource, generated at a moderate rate
- Diamond: Advanced resource, generated slowly
- Emerald: Premium resource, generated most slowly
- Weapons: Stone, Iron, and Diamond swords
- Tools: Wooden, Iron, and Diamond pickaxes
- Defensive Blocks: Wool, Endstone, Obsidian
- Consumables: Golden Apple (heals the player)
- Bridges: Players must build bridges to travel between islands
- Combat: Players can engage in combat to eliminate opponents
- Bed Breaking: Destroying an opponent's bed prevents them from respawning
- Resource Collection: Players automatically collect resources from islands they occupy
The simulation includes four different AI strategies:
- Optimal Player (Red): Uses sophisticated minimax decision making with alpha-beta pruning to make intelligent decisions
- Aggressive Player (Blue): Focuses on combat and bed destruction, often at the expense of resource gathering
- Resource Player (Green): Prioritizes resource collection and upgrades before engaging in combat
- Defensive Player (Yellow): Builds strong defenses and plays conservatively
-
Core Game Logic:
-
AIsland.cs: Base class for all islands -
BedIsland.cs,DiamondIsland.cs,EmeraldIsland.cs: Specific island types -
Connection.cs: Represents bridges between islands -
GameEngine.cs: Manages game simulation -
GameState.cs: Stores the current state of the game -
Generator.cs: Handles resource generation -
Player.cs: Base player class -
Inventory.cs: Player inventory management -
AI Logic:
-
BedwarsAIAgent.cs: Main AI decision-making engine using minimax -
Strategy-specific player classes in
Program.cs -
Items and Commands:
-
Various item classes (sword, pickaxe, etc.)
-
Command classes for actions (move, combat, buy, etc.)
- Compile the project using a C# compiler (.NET Core compatible)
- Run the executable to start the simulation
- The program will run multiple simulations and output statistics about which AI strategy performs best
dotnet build
dotnet run