Programming a Bot
The programming of a bot is simple.
First, you download a template in the language you like to use; you can find the different templates here:
Bot templates
The different templates are more or less similar
A spacebattlez bot works receiving and sending JSON data.
In each of the template, you will find a method called GameUpdate, which take a GameState as parameter.
This is the main method of each bot; GameUpdate is called one time for each tick, containing a GameState object that holds info about everything in the battle zone.
Output of the method should be a list of FleetCommands to send.
Input |
Output |
public class GameState
{
public List<Bot> Bots { get; set; }
public List<Planet> Planets { get; set; }
public List<Fleet> Fleets { get; set; }
}
|
public class FleetCommand
{
public int SourcePlanetId { get; set; }
public int DestinationPlanetId { get; set; }
public int NumberOfUnits { get; set; }
}
|
The classes used in the input data:
|
|
public class Bot
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Planet
{
public int Id { get; set; }
public int OwnerId { get; set; }
public Position Position { get; set; }
public int NumberOfShips { get; set; }
public int GrowthRate { get; set; }
}
public class Fleet
{
public int Id { get; set; }
public int OwnerId { get; set; }
public int NumberOfShips { get; set; }
public int TicksToDestination { get; set; }
public int DestinationPlanetId { get; set; }
public int SourcePlanetId { get; set; }
public Position Position { get; set; }
}
public class Position
{
public int X { get; set; }
public int Y { get; set; }
}
|
|