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
WorldRegion
One of the 42 regions on the map.
static final int LAST_ID = 42; // # of existing regions
final int id; // 1-based final WorldContinent worldContinent; // the continent containing this region
final String mapName; // e.g. "Peru"
static
WorldRegion forId(
int
id)
Return the WorldRegion with the given id.
List<WorldRegion> getNeighbours()
enum
WorldContinent
One of the 6 continents on the map,
static final int LAST_ID = 6; // # of existing continents
final int id; // 1-based final int reward; // # of extra armies/turn if you hold this continent final String mapName; // e.g. "Europe"
static
WorldContinent forId(
int
id)
Return the WorldContinent with the given id.
List<WorldRegion> getRegions()
Return a list of all regions in this continent.
enum
Phase {
STARTING_REGIONS,
PLACE_ARMIES, ATTACK_TRANSFER
};
class
Region
WorldRegion getWorldRegion();
String mapName();
Continent getContinent(); int getOwner(); // who currently owns this region int getArmies(); // how many armies are here ArrayList<Region> getNeighbors();
class
Continent
WorldContinent getWorldContinent();
int getArmiesReward(); int owner(); // who currently owns this continent ArrayList<Region> getRegions(); // all regions of this continent
class
GameMap
ArrayList<Region> getRegions()
//
all regions in the world
Region region(WorldRegion region)
ArrayList<Continent>
getContinents()
// all continents
in the world
int numberRegionsOwned(int player)
int numberArmiesOwned(int player)
ArrayList<Region>
ownedRegionsByPlayer(int player)
class
GameState
GameState()
Return a new game.
GameState clone()
Return a copy of the game state that can be used as a forward model.
GameMap getMap()
Region getRegion(
int
id)
int
getRoundNumber()
Phase getPhase()
int me()
// the player whose turn it is to move
int opp()
// the other player
boolean
isDone()
int
winningPlayer()
int armiesPerTurn(int player)
List<Region> getPickableRegions()
interface Action
A set of commands that form a player's turn and
can be applied to a GameState
.
void
apply(GameState state)
class ChooseAction implements Action
A command to choose a starting region.
ChooseAction(Region region)
class PlaceArmiesMove
A command to place armies at the beginning of a turn.
PlaceArmiesMove(Region region, int armies)
class PlaceArmiesAction implements Action
A set of placement commands.
PlaceArmiesAction(List<PlaceArmiesMove>
commands)
class AttackTransferMove
A command to move or attack.
AttackTransferMove(Region from, Region to, int armies)
class AttackTransferAction implements Action
A set of movement commands.
MoveAction(List<AttackTransferMove>
commands)
interface Bot
Your bot should implement this interface.
void init(long timeoutMillis)
Called once before any other methods are called.
Your bot must respond to this request and all subsequent requests
within timeoutMillis
milliseconds.
WorldRegion
chooseRegion(
GameState
state
)
Called to select a starting region at the beginning of the game.
List<PlaceArmiesMove>
placeArmies(
GameState
state
)
Called to ask where you want to place your armies at the beginning of each round.
List<AttackTransferMove>
moveArmies(
GameState
state
)
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)