Warlight API
All fields and methods listed below are public
unless noted otherwise.
Player numbers are as follows: 0 = neutral, 1 =
player 1, 2 = player 2, etc.
== package engine ==
interface
Agent
An agent that plays Warlight.
	- void
	init(long
	timeoutMillis)
- 
	Called once before any other methods are called. Your agent
	must respond to this request and all subsequent requests within
	timeoutMillismilliseconds.
- 
	Move getMove(Game game)
- 
	Called to retrieve the agent's next move from the given game state.
- 
	void terminate()
- 
	Called once after all other
	interaction with the agent is complete.
abstract
class AgentBase implements Agent
A convenience class for creating agents.
	- abstract List<AttackTransfer>
	attackTransfer(Game
	game)
- 
	Called to ask where you would like to move and/or attack in this
	round.
- 
	abstract Region chooseRegion(Game game)
- 
	Called to select a starting region at the beginning of the game.
- 
	abstract List<PlaceArmies> placeArmies(Game game)
- 
	Called to ask where you want to place your
	armies at the beginning of each round.
== package game ==
class Continent
One of the continents on the map.
	- int
	getId()
- 
	The ID of this continent.
	Every continent
	has a unique integer ID in the range from 0 to (N – 1),
	where N is the total number of continents.
- 
	String getName()
- 
	The name of this continent.
- 
	int getReward()
- 
	The number of extra
	armies per turn that you will receive if you hold this continent.
- 
	List<Region> getRegions()
- 
	Return a list of all
	regions in this continent.
class Game
A game of Warlight in progress.
	- Game(GameConfig config)
- 
	Create a new game. configspecifies configuration
	options for the game, or can be null for default options.
- 
	int
	armiesPerTurn(int
	player)
- 
	Return the number of armies that the given player receives each
	turn.
- 
	Game clone()
- 
	Return an exact copy of the game state that can be used as a forward
	model.
- 
	int
	currentPlayer()
- 
	Return the player
	whose turn it is to move.
- 
	int
	getArmies(Region region)
- 
	Return the number of armies that are currently in the given region.
- 
	Continent getContinent(int
	id)
- 
	Return the continent with the given id.
- 
	List<Continent> getContinents()
- 
	Return a list of all continents in the world.
- 
	int
	getOwner(Continent continent)
- 
	Return the player who currently owns the given
	continent, i.e. holds all of its regions. If there is no such
	player, the method returns 0.
- 
	int
	getOwner(Region region)
- 
	Return the player who currently owns the given region.
- 
	Phase getPhase()
- 
	Return the current game phase such as
	PLACE_ARMIES or ATTACK_TRANSFER.
- 
	ArrayList<Region> getPickableRegions()
- 
	Return the regions that are available for
	selection in the STARTING_REGIONS phase (which occurs only when
	Warlight is run with the -manual option).
- 
	Region
	getRegion(int
	id)
- 
	Return the Region with the given id.
- 
	List<Region> getRegions()
- 
	Return a list of all regions in the world.
- 
	int
	getRoundNumber()
- 
	Return the current round number. The first
	round is numbered 1.
- 
	int getScore(int
	player)
- 
	Assuming that the game is complete, return the given player's score.
	 If there are N players, the winning player has score (N – 1), the
	player who finishes second has score (N – 2), and so on down to 0.
- 
	boolean isDone()
- 
	Return true if the game is complete.
- 
	public void
	move(Move move)
- 
	Apply a move to the game state.
- 
	public void
	move(Move move, boolean
	mostLikely)
- 
	Apply a move to the game state. If mostLikely is true, then the most
	likely outcome will
	always occur instead of the usual stochastic result.
- 
	int
	numberArmiesOwned(int
	player)
- 
	Return the number of armies that the given player owns.
- 
	int numPlayers()
- 
	Return the number of players in the game (not including the neutral
	player 0).
- 
	int
	numberRegionsOwned(int
	player)
- 
	Return the number of regions that the given player owns.
- 
	int
	numContinents()
- 
	Return the number of continents
	that exist in the world.
- 
	int numRegions()
- 
	Return the number of regions that exist in the world.
- 
	ArrayList<Region> regionsOwnedBy(int
	player)
- 
	Return a list of all regions owned by the given player.
- 
	int
	winningPlayer()
- 
	Assuming that the game is complete, return the
	number of the player who has won the game.
enum Phase
A phase of the game. Possible values include
	- STARTING_REGIONS
- 
	An initial phase in which players choose their starting territories.
	(This phase will only ever occur if Warlight is invoked with the
	-manual option, which enables manual territory distribution.)
- 
	PLACE_ARMIES
- 
	The phase in which a player decides where to place armies at the
	beginning of their turn.
- 
	ATTACK_TRANSFER
- 
	The phase in which a player decides where to attack with or transfer
	armies.
class Region
One of the
territories on the
map.
	- Continent getContinent()
- 
	The continent containing this region.
- 
	int getId()
- 
	The ID of this region.
	Every region
	has a unique integer ID in the range from 0 to (N – 1), where N is
	the total number of regions.
- 
	String getName()
- 
	The name of this region.
- 
	List<Region> getNeighbors()
- 
	A list of this region's neighbors.
==
package game.move ==
class AttackTransfer
A single
attack or transfer.
	- Region fromRegion;
- 
	The region to attack or transfer from.
- 
	Region toRegion;
- 
	The region to attack or transfer to.
- 
	int armies;
- 
	The number of armies with which to attack or transfer.
- 
	AttackTransfer(Region from, Region to, int
	armies)
- 
	Create a single attack or transfer
	between regions.
class AttackTransferMove extends Move
A move containing a set of attacks/transfers.
	- AttackTransferMove(List<AttackTransfer>
	commands)
- 
	Create a move to attack/transfer armies.
class ChooseRegion extends Move
A move
that chooses a starting region. This move type is used only if
Warlight is started with the -manual option.
	- Region region;
- 
	The Region in this move.
- 
	ChooseRegion(Region region)
- 
	Create a move that chooses the given region.
abstract class Move
A player's move. In each turn, a player makes one
move to place armies, followed by a second move that
attacks and transfers armies.
class PlaceArmies
A single
army placement.
	- Region region;
- 
	The Region in this placement.
- 
	int armies;
- 
	The number of armies in this placement.
- 
	PlaceArmies(Region region, int
	armies)
- 
	Create an army placement on a single region.
class PlaceArmiesMove extends Move
A move containing a set of placements.
	- PlaceArmiesMove(List<PlaceArmies>
	commands)
- 
	Create a move to place armies.