Python Bot API for Robocode Tank Royale
Project description
Robocode Tank Royale - Python Bot API
Build the best - destroy the rest!
The Python Bot API for Robocode Tank Royale - the next evolution of the classic Robocode programming game where you code virtual tanks to battle against each other in a virtual arena.
About Robocode Tank Royale
Robocode is a programming game where the goal is to code a bot in the form of a virtual tank to compete against other bots in a virtual battle arena. The player is the programmer of a bot, who will have no direct influence on the game. Instead, you must write a program with the logic for the brain of the bot containing instructions about how it should behave during battles.
Tank Royale is the next generation of Robocode that supports:
- Network-based battles via WebSocket connections
- Multiple programming languages and platforms
- Real-time battles with multiple bots
Installation
Install the Python Bot API using pip:
pip install robocode-tank-royale
Requirements
- Python 3.10 or higher
- WebSocket support (automatically handled by dependencies)
Quick Start
Check out the complete MyFirstBot example on GitHub:
Or start with this minimal example you can run right away:
import asyncio
from robocode_tank_royale.bot_api.bot import Bot
from robocode_tank_royale.bot_api.events import ScannedBotEvent, HitByBulletEvent
class MyFirstBot(Bot):
async def run(self) -> None:
while self.is_running():
await self.forward(100)
await self.turn_gun_left(360)
await self.back(100)
await self.turn_gun_left(360)
async def on_scanned_bot(self, e: ScannedBotEvent) -> None:
del e
await self.fire(1)
async def on_hit_by_bullet(self, e: HitByBulletEvent) -> None:
bearing = self.calc_bearing(e.bullet.direction)
await self.turn_right(90 - bearing)
async def main() -> None:
bot = MyFirstBot()
await bot.start()
if __name__ == "__main__":
asyncio.run(main())
How to run:
- Install and start the Robocode Tank Royale GUI from the releases page (it starts the game server).
- Save the code above as MyFirstBot.py and run:
python MyFirstBot.py - In the GUI, add your bot process and start a battle.
Configuration
By default, the bot looks for a <ClassName>.json file with bot information. If not found, it falls back to environment
variables.
- SERVER_URL: WebSocket URL of the server (default: ws://localhost:7654 if not set)
- SERVER_SECRET: Optional. Only set this if the server requires a secret; otherwise leave it unset.
- Required when no config file is used: BOT_NAME, BOT_VERSION, BOT_AUTHORS
- Optional: BOT_DESCRIPTION, BOT_HOMEPAGE, BOT_COUNTRY_CODES, BOT_GAME_TYPES, BOT_PLATFORM, BOT_PROG_LANG, BOT_INITIAL_POS
Features
The Python Bot API provides:
- Full Bot Control: Move your tank, rotate gun and radar, fire bullets
- Event Handling: Respond to hits, bot scanned, bullet impacts, and more
- Battle Information: Access to battle state, opponent positions, and game rules
- Debugging Support: Built-in debugging and logging capabilities
- Modern Python: Type hints and modern Python features supported
Getting Started
-
Install the package:
pip install robocode-tank-royale -
Download Robocode Tank Royale: Get the game GUI and server from the official releases
-
Create your bot: Download and study MyFirstBot.py or check the documentation
-
Run battles: Start the GUI, add your bot, and watch the battles unfold!
Documentation & Resources
- 📖 Official Documentation: robocode-dev.github.io/tank-royale
- 🚀 Getting Started: Tutorial
- 🤖 My First Bot: Create Your First Bot
- 📚 API Reference: Python API Documentation
- 🤖 Sample Bots: Python Examples
- 💾 Source Code: GitHub Repository
Supported Platforms
Robocode Tank Royale runs on:
- Windows
- macOS
- Linux
The Python Bot API works with Python 3.10+ on all supported platforms.
Community & Support
- GitHub Issues: Report bugs and request features
- Discussions: Community discussions and help
- Contributing: Check out our Contributing Guide
Development Status
🚧 Work in Progress: The Python Bot API is currently under active development. Features and APIs may change before the stable release.
License
Licensed under the Apache License 2.0
Copyright
Copyright © 2022 Flemming N. Larsen
Ready to build the best tank and destroy the rest? Start coding your bot today! 🚀🎯
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robocode_tank_royale-0.35.0-py3-none-any.whl.
File metadata
- Download URL: robocode_tank_royale-0.35.0-py3-none-any.whl
- Upload date:
- Size: 137.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d43fdbab4d8a3adbf9e8c4d84b2d67c14d22bee0a29c88d37f7605737e6378cd
|
|
| MD5 |
db2f3ca20388b4e47660561c7e1f09c8
|
|
| BLAKE2b-256 |
6561fe964c7992ea5b5677722bbf5777ff5474811aea1646f320ed6261d1b055
|