@@ -38,17 +38,45 @@ pip install robocode-tank-royale
3838
3939Check out the complete ** MyFirstBot** example on GitHub:
4040
41- ** 📁 [ MyFirstBot.py] ( https://github.com/robocode-dev/tank-royale/blob/master/sample-bots/python/MyFirstBot/MyFirstBot.py )
42- **
43-
44- This sample bot demonstrates:
45-
46- - Basic movement (forward/backward)
47- - Gun rotation and targeting
48- - Event handling (scanned bot, hit by bullet)
49- - Async/await programming pattern
41+ ** 📁 MyFirstBot.py** : https://github.com/robocode-dev/tank-royale/blob/main/sample-bots/python/MyFirstBot/MyFirstBot.py
42+
43+ Or start with this minimal example you can run right away:
44+
45+ ``` python
46+ import asyncio
47+ from robocode_tank_royale.bot_api.bot import Bot
48+ from robocode_tank_royale.bot_api.bot_info import BotInfo
49+ from robocode_tank_royale.bot_api.events import ScannedBotEvent
50+
51+ class MyFirstBot (Bot ):
52+ async def run (self ) -> None :
53+ # Main loop: move and keep the radar/gun scanning
54+ while self .is_running():
55+ self .set_forward(100 )
56+ self .set_turn_gun_right(20 )
57+ await self .go()
58+
59+ async def on_scanned_bot (self , e : ScannedBotEvent) -> None :
60+ # Fire small bullets when the gun is cool
61+ if self .get_gun_heat() == 0 :
62+ await self .fire(1.5 )
63+
64+ if __name__ == " __main__" :
65+ # Provide bot metadata via BotInfo so no env vars are required
66+ info = BotInfo(
67+ name = " MyFirstBot" ,
68+ version = " 1.0" ,
69+ authors = [" Your Name" ],
70+ description = " A simple starter bot written in Python" ,
71+ )
72+ # Default server URL in the GUI is ws://localhost:7654
73+ asyncio.run(MyFirstBot(bot_info = info, server_url = " ws://localhost:7654" ).start())
74+ ```
5075
51- The bot moves in a seesaw motion, spins its gun to scan for enemies, and fires when it spots another bot.
76+ How to run:
77+ - Install and start the Robocode Tank Royale GUI from the releases page (it starts the game server).
78+ - Save the code above as MyFirstBot.py and run: ` python MyFirstBot.py `
79+ - In the GUI, add your bot process and start a battle.
5280
5381## Features
5482
@@ -76,12 +104,10 @@ The Python Bot API provides:
76104## Documentation & Resources
77105
78106- ** 📖 Official Documentation** : [ robocode-dev.github.io/tank-royale] ( https://robocode-dev.github.io/tank-royale/ )
79- - ** 🚀 Getting Started Guide
80- ** : [ Getting Started Tutorial] ( https://robocode-dev.github.io/tank-royale/tutorial/getting-started )
81- - ** 🤖 My First Bot Tutorial
82- ** : [ Create Your First Bot] ( https://robocode-dev.github.io/tank-royale/tutorial/my-first-bot.html )
107+ - 🚀 Getting Started: [ Tutorial] ( https://robocode-dev.github.io/tank-royale/tutorial/getting-started.html )
108+ - 🤖 My First Bot: [ Create Your First Bot] ( https://robocode-dev.github.io/tank-royale/tutorial/my-first-bot.html )
83109- ** 📚 API Reference** : [ Python API Documentation] ( https://robocode-dev.github.io/tank-royale/api/apis.html )
84- - ** 🤖 Sample Bots** : [ Python Examples] ( https://github.com/robocode-dev/tank-royale/tree/master /sample-bots/python )
110+ - ** 🤖 Sample Bots** : [ Python Examples] ( https://github.com/robocode-dev/tank-royale/tree/main /sample-bots/python )
85111- ** 💾 Source Code** : [ GitHub Repository] ( https://github.com/robocode-dev/tank-royale/tree/main/bot-api/python )
86112
87113## Supported Platforms
@@ -108,7 +134,7 @@ the stable release.
108134
109135## License
110136
111- Licensed under the [ Apache License 2.0] ( https://github.com/robocode-dev/tank-royale/blob/master /LICENSE )
137+ Licensed under the [ Apache License 2.0] ( https://github.com/robocode-dev/tank-royale/blob/main /LICENSE )
112138
113139## Copyright
114140
0 commit comments