LittleWarGame / API / AI Documentation

home
getTypeFieldValue
getGroundDistance
getCurrentGameTimeInSec
getMyPlayerNumber
getMyTeamNumber
getTeamNumber
positionIsPathable
getMapWidth
getMapHeight
getCurrentSupply
getMaxSupply
getUpgradeLevel
getArrayOfPlayerNumbers
getStartLocationForPlayerNumber
getUnits
getBuildings
order
getGold
chatMsg
playerIsAlive
getCommandFromCommandName
getHeightLevel
getRandomNumber
fieldIsRamp

home

This page is here to provide explainations of the available API functions for custom AI and example use cases. Feel free to contact me (glaba) if you run into any issues. Navigate using the left hand panel.

getTypeFieldValue(typeName, fieldName)

getGroundDistance(fromX, fromY, toX, toY)

Gets the length of the path from point (fromX, fromY) to point (toX, toY).

getCurrentGameTimeInSec

Gets game time as a number.

getMyPlayerNumber

Gets player id.

getMyTeamNumber

Gets team id.

getTeamNumber(playerNr)

Gets team id for player id 'playerNr'.

positionIsPathable(x, y)

If the specified coordinates are walkable. (This does NOT ensure a direct route to the tile).

getMapWidth

Gets the map width in tiles.

getMapHeight

Gets the map height in tiles.

getCurrentSupply

Returns a number for the current supply.

getMaxSupply

Returns a number for the player's maximum supply.

getUpgradeLevel(upgName)

Returns the upgrade level for the upgrade, or null if no upgrade was found with that name.

getArrayOfPlayerNumbers

Gets an array of player IDs.

getStartLocationForPlayerNumber(nr)

Gets an object with the start location of the player in the form {x, y}

getUnits(filter)

Gets all units you can see, that pass the filter. Filter accepts the following parameters; { type, notOfType, player, team, order, enemyOf } Returns an array.

getBuildings(filter)

Gets all buildings you have seen that pass the filter. Filter accepts the following parameters; { type, notOfType, player, team, order, onlyFinished, enemyOf } Returns an array.

order(order, units, o, shift)

Set's the unit's order to the order. Units needs to be an array. Shift allows you to chain commands as if the shift key was pressed. TODO: what is 'o' ?
getCenterOfUnits(units)
Returns an object with the center of a unit group in the form {x, y}.

getGold

Returns a number for player's gold.

chatMsg(text)

Submits a chat message to be sent.

playerIsAlive(nr)

Returns a boolean (True/False) for if the player is alive.

getCommandFromCommandName(name)

Returns the command (Not sure what format) for the command name. If no command is found, returns null.

getHeightLevel(x, y)

Returns a number representing the height value at that point.

getRandomNumber(min, max)

Returns a random number.

fieldIsRamp(x, y)

Retuns a boolean (True/False) for if the specified point is a ramp tile.