Bot Battle is an exciting multiplayer project where you can program your own tank and compete against other tanks. The core of this project is that everyone can define their tank's logic themselves – using WebAssembly. The tanks can move around the map, shoot, avoid obstacles, and collect items.
The backend is built using C# .NET 8 and utilizes Garnet for the server infrastructure. The frontend is implemented with Svelte, a modern web framework for fast and performant web applications.
In the Samples folder, you'll also find example agents implemented in Rust and C#. These agents demonstrate how to develop your tank's logic with WebAssembly.
- Customizable Tank Control: Program the logic of your tank! Decide when it turns, moves, shoots, or how it reacts to its environment.
- Environment Interaction: Your tank can respond to various things on the map, such as obstacles, items, or enemy tanks.
- WebAssembly Extism Integration: Use WebAssembly to run your tank's logic in a performant environment. Each tank is controlled by its own WebAssembly instance. https://extism.org/
- Backend with C# and Garnet: The backend is built with C# .NET 8 and uses Garnet to provide smooth gameplay and fast response times.
- Frontend with Svelte: The game's user interface is built using Svelte, allowing for fast and efficient interactions.
- Sample Agents: In the
samplesfolder, you'll find example implementations of a Rust and C# agent to help you get started with developing WebAssembly-based tank control. - Multiplayer Support: Compete against other players to see whose tank logic works best.
The frontend is built with Svelte. To run it locally, follow these steps:
-
Clone the repository:
git clone https://github.com/aridminds/bot-battle.git cd bot-battle/frontend -
Install the necessary dependencies:
npm install
-
Start the local server:
npm run dev
-
Open your browser and go to
http://localhost:3000to start the game.
The backend uses C# .NET 8 and Garnet. To run it locally, follow these steps:
-
Navigate to the backend folder:
cd ../backend -
Ensure you have .NET 8 installed, then run the project:
dotnet run
-
The backend server will now run on
http://localhost:5000.
- Node.js (version 14 or higher)
- npm (or yarn)
- .NET 8 SDK
- A browser that supports WebAssembly (e.g., Chrome, Firefox)
-
Create Your Tank: Each player can program their own tank by providing a WebAssembly module that controls the tank's behavior.
-
React to the Environment: Your tank can respond to events like incoming bullets, obstacles (such as trees or walls), and other tanks. Use this information to adapt your tank's logic.
-
Strategy and Combat: Test your logic on the map! Use items, avoid obstacles, and eliminate other tanks to win.
The core logic of your tank is controlled by WebAssembly. Here are the basic steps to program your own tank:
-
Create a WebAssembly Module: Write your code in a language like Rust, C, C++, or AssemblyScript and compile it to WebAssembly.
-
Interact with the Map: Your tank has access to information about its environment, such as the position of obstacles or the presence of items.
-
Control Functions: Your WebAssembly module should include functions that define how the tank moves, turns, and shoots.
In the Samples folder, you'll find example agents in Rust and C#, which can serve as a starting point for developing your tank's control logic.
Example (Rust):
#[plugin_fn]
pub fn calculate_action(arena: AgentRequest) -> FnResult<String> {
//Rotate
let action = Rotate {
direction: Direction::North
};
let response = AgentRotateResponse { action };
Ok(serde_json::to_string(&response).unwrap())
}We welcome contributions from other developers! Whether you want to add new features, fix bugs, or improve the project, you're welcome to participate.
- Fork this repository
- Create a new branch (
git checkout -b feature/new-feature) - Implement your changes
- Submit a pull request
- Add more maps
- Mobile optimization
- Player leaderboards
- More items and obstacles
This project is licensed under the MIT License.