Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 2.89 KB

README.md

File metadata and controls

51 lines (38 loc) · 2.89 KB

Badger Brawl tutorial: your first bot

Badger Brawl is a real-time strategy game where you don't click: you write a program (a bot) that plays for you over a REST API. This tutorial takes you from nothing to a bot that mines ore, builds a Barracks, trains an army and destroys the house bot sitter. You watch every step in the spectator page in your browser.

Every code example comes in two languages, C# and Python, which do exactly the same thing. Pick one and stick with it.

You need:

  • the .NET 10 SDK, to run the game server;
  • for your bot, either the same .NET 10 SDK (for C#) or Python 3.10 or newer. Both versions use only the built-in libraries, so there's nothing to install from NuGet or pip;
  • a terminal: bash, Git Bash or PowerShell all work;
  • about an hour.

You don't need to know anything about REST APIs or game bots yet. If you can write a for loop and a function in C# or Python, you're ready.

Pages

  1. Start the server and look around: run the game, watch two house bots play.
  2. Talk to the API by hand: register, start a match and give orders with curl or PowerShell.
  3. Your first bot: the loop: a program that follows a match tick by tick.
  4. Put your workers to work: mine ore and train more workers.
  5. Build and train: pick a build site, build a Barracks, train soldiers, handle errors.
  6. Attack and win: march on the enemy base and read the result.
  7. Where next: ideas for making your bot stronger.

Each page adds one idea to the bot. The finished code for every step, in both languages, is in code/:

C# Python Page What it adds
step1_loop.cs step1_loop.py 3 Register, create a match, follow it tick by tick
step2_economy.cs step2_economy.py 4 Workers mine; the Command Center trains more
step3_army.cs step3_army.py 5 Build a Barracks, train soldiers, report errors
step4_attack.cs step4_attack.py 6 Attack. This bot beats sitter

Each C# file is a .NET 10 file-based app: a single .cs file that you run with dotnet run step1_loop.cs, with no project file. Each Python file runs with python step1_loop.py.

Other docs you'll want later:

  • Bot guide: the complete API and rules reference (every command, error code and stat).
  • Getting started: other ways to set up and run NetRTS.
  • How it works: what happens inside the server.

Start: Start the server and look around →