Here are the most important classes, fields and methods in the Warlight API. For more details, read the Javadoc and/or look at the source code.
All fields and methods listed below are public unless noted otherwise.
Player numbers are as follows: 0 = neutral, 1 = player 1, 2 = player 2.
enum
Region
One of the 42 regions on the map.
final Continent continent; // the continent containing this region
final String mapName; // e.g. "Peru"
List<Region> getNeighbours()
enum
Continent
One of the 7 continents on the map,
final int reward; // # of extra armies/turn if you hold this continent final String mapName; // e.g. "Europe"
Set<Region> getRegions()
Return a list of all regions in this continent.
enum
Phase {
STARTING_REGIONS,
PLACE_ARMIES, ATTACK_TRANSFER
};
class
RegionState
final Region region; int owner; // who currently owns this region int armies; // how many armies are here RegionState[] neighbours;
class
ContinentState
final Continent continent; int owner; // who currently owns this continent Map<Region, RegionState> regions; // all regions of this continent and their states
class
PlayerState
int player; // which player this object describes Map<Region, RegionState> regions; // all regions this player owns Map<Continent, ContinentState> continents; // all continents this player owns int totalArmies; // total armies the player has in all controlled regions int placeArmies; // number of armies this player can place per round
class
GameState
RegionState[] regions; // WARNING: 1-based array; [0] is null ContinentState[] continents; // WARNING: 1-based array; [0] is null PlayerState[] players; // player state for each player (0 = neutral, 1 = player 1, 2 = player 2) int me; // the player whose turn it is to move int opp; // the other player
GameState()
Return a new game.
GameState clone()
Return a copy of the game state that can be used as a forward model.
int
getRoundNumber()
Phase getPhase()
List<Region> getPickableRegions()
boolean
isDone()
int
winningPlayer()
interface Action
A set of commands that form a player's turn and can be applied to
a GameState
.
void
apply(GameState state)
class ChooseCommand implements Action
A command to choose a starting region.
Region region;
ChooseCommand(Region region)
class PlaceCommand
A command to place armies at the beginning of a turn.
Region region;
int armies;
PlaceCommand(Region region, int armies)
class PlaceAction implements Action
A set of placement commands.
List<PlaceCommand>
commands
;
PlaceAction(List<PlaceCommand>
commands)
class MoveCommand
A command to move or attack.
Region from, to;
int armies;
MoveCommand(Region from, Region to, int armies)
class MoveAction implements Action
A set of movement commands.
List<MoveCommand>
commands
;
MoveAction(List<MoveCommand>
commands)
class PlaceMoveAction implements Action
An action containing placement and movement commands that can be applied all at once.
List<PlaceCommand>
placeCommands
;
List<MoveCommand>
moveCommands
;
PlaceMoveAction(List<PlaceCommand>
placeCommands, List<MoveCommand> moveCommands)
abstract class GameBot
Implement your bot as a subclass of this class.
protected GameState state;
abstract
ChooseCommand chooseRegion(List<Region> choosable,
long
timeout)
Called to select a starting region at the beginning of the game.
abstract
List<PlaceCommand> placeArmies(
long
timeout)
Called to ask where you want to place your armies at the beginning of each round.
abstract
List<MoveCommand> moveArmies(
long
timeout)
Called to ask where you would like to move and/or attack in this round.
class FightAttackersResults
double
getAttackersWinChance(
int
attackers,
int
defenders)
Return the probability that the attackers will win the given battle.
double
getDefendersWinChance(
int
attackers,
int
defenders)
double
getExpectedAttackersDeaths(
int
attackers,
int
defenders)
Return the expected number of attackers that will die in the given attack, averaged across cases where the attack succeeds and also cases where it fails.
double
getExpectedDefendersDeaths(
int
attackers,
int
defenders)