Lua Client Documentation

Anarchy Documentaion

Game

Two player grid based game where each player tries to burn down the other player's buildings. Let it burn!

Attributes
  • number mapHeight

    The width of the entire map along the vertical (y) axis.

  • number baseBribesPerTurn

    How many bribes players get at the beginning of their turn, not counting their burned down Buildings.

  • number mapWidth

    The width of the entire map along the horizontal (x) axis.

  • Forecast currentForecast

    The current Forecast, which will be applied at the end of the turn.

  • table<Building> buildings

    All the buildings in the game.

  • Player currentPlayer

    The player whose turn it is currently. That player can send commands. Other players cannot.

  • number currentTurn

    The current turn number, starting at 0 for the first player's turn

  • table<Forecast> forecasts

    All the forecasts in the game, indexed by turn number.

  • table<string, GameObject> gameObjects

    A mapping of every game object's ID to the actual game object. Primarily used by the server and client to easily refer to the game objects via ID.

  • number maxFire

    The maximum amount of fire value for any Building.

  • number maxForecastnumberensity

    The maximum amount of numberensity value for any Forecast.

  • number maxTurns

    The maximum number of turns before the game will automatically end.

    Defaults to: 100

  • Forecast nextForecast

    The next Forecast, which will be applied at the end of your opponent's turn. This is also the Forecast WeatherStations can control this turn.

  • table<Player> players

    List of all the players in the game.

  • string session

    A unique identifier for the game instance that is being played.

AI

The AI competitors will add logic to this AI so its functions return valid and smart values.

Functions
  • boolean runTurn(
      )

      This is called every time the AI is asked to respond with a command during their turn

      Returns boolean

      represents if you want to end your turn. true means end the turn, false means to keep your turn going and re-call runTurn()

    Building
    Parent Classes:

    A basic building. It does nothing besides burn down. Other Buildings inherit from this class.

    Attributes
    • boolean isHeadquarters

      true if this is the Headquarters of the owning player, false otherwise. Burning this down wins the game for the other Player.

    • boolean bribed

      when true this building has already been bribed this turn and cannot be bribed again this turn.

    • Player owner

      The player that owns this building. If it burns down (health reaches 0) that player gets an additional bribe(s).

    • Building buildingNorth

      The Building directly to the north of this building, or null if not present.

    • Building buildingEast

      The Building directly to the east of this building, or null if not present.

    • Building buildingSouth

      The Building directly to the south of this building, or null if not present.

    • Building buildingWest

      The Building directly to the west of this building, or null if not present.

    • number fire

      How much fire is currently burning the building, and thus how much damage it will take at the end of its owner's turn. 0 means no fire.

    • string gameObjectName

      Inherited from GameObject.gameObjectName

      String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

    • number health

      How much health this building currently has. When this reaches 0 the Building has been burned down

    • string id

      Inherited from GameObject.id

      A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

    • table<string> logs

      Inherited from GameObject.logs

      Any strings logged will be stored here when this game object logs the strings. numberended for debugging.

    • number x

      The location of the Building along the x-axis

    • number y

      The location of the Building along the y-axis

    Functions
    • void log(
      • string message
      )

      Inherited from GameObject.log

      adds a message to this game object's log. numberended for debugging purposes.

      Arguments
      • string message

        A string to add to this GameObject's log. numberended for debugging.

      Returns void

    FireDepartment
    Parent Classes:

    Can put out fires completely.

    Attributes
    • string gameObjectName

      Inherited from GameObject.gameObjectName

      String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

    • number fireExtinguished

      The amount of fire removed from a building when bribed to extinguish a building.

    • Building buildingEast

      Inherited from Building.buildingEast

      The Building directly to the east of this building, or null if not present.

    • Building buildingNorth

      Inherited from Building.buildingNorth

      The Building directly to the north of this building, or null if not present.

    • Building buildingSouth

      Inherited from Building.buildingSouth

      The Building directly to the south of this building, or null if not present.

    • Building buildingWest

      Inherited from Building.buildingWest

      The Building directly to the west of this building, or null if not present.

    • number fire

      Inherited from Building.fire

      How much fire is currently burning the building, and thus how much damage it will take at the end of its owner's turn. 0 means no fire.

    • boolean bribed

      Inherited from Building.bribed

      when true this building has already been bribed this turn and cannot be bribed again this turn.

    • number health

      Inherited from Building.health

      How much health this building currently has. When this reaches 0 the Building has been burned down

    • string id

      Inherited from GameObject.id

      A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

    • boolean isHeadquarters

      Inherited from Building.isHeadquarters

      true if this is the Headquarters of the owning player, false otherwise. Burning this down wins the game for the other Player.

    • table<string> logs

      Inherited from GameObject.logs

      Any strings logged will be stored here when this game object logs the strings. numberended for debugging.

    • Player owner

      Inherited from Building.owner

      The player that owns this building. If it burns down (health reaches 0) that player gets an additional bribe(s).

    • number x

      Inherited from Building.x

      The location of the Building along the x-axis

    • number y

      Inherited from Building.y

      The location of the Building along the y-axis

    Functions
    • boolean extinguish(
      • Building building
      )

      Bribes this FireDepartment to extinguish the some of the fire in a building.

      Arguments
      • Building building

        The Building you want to extinguish.

      Returns boolean

      true if the bribe worked, false otherwise

    • void log(
      • string message
      )

      Inherited from GameObject.log

      adds a message to this game object's log. numberended for debugging purposes.

      Arguments
      • string message

        A string to add to this GameObject's log. numberended for debugging.

      Returns void

    Forecast
    Parent Classes:

    The weather effect that will be applied at the end of a turn, which causes fires to spread.

    Attributes
    • Player controllingPlayer

      The Player that can use WeatherStations to control this Forecast when its the nextForecast.

    • string direction

      The direction the wind will blow fires in. Can be 'north', 'east', 'south', or 'west'

    • string gameObjectName

      Inherited from GameObject.gameObjectName

      String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

    • string id

      Inherited from GameObject.id

      A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

    • number numberensity

      How much of a Building's fire that can be blown in the direction of this Forecast. Fire is duplicated (copied), not moved (transfered).

    • table<string> logs

      Inherited from GameObject.logs

      Any strings logged will be stored here when this game object logs the strings. numberended for debugging.

    Functions
    • void log(
      • string message
      )

      Inherited from GameObject.log

      adds a message to this game object's log. numberended for debugging purposes.

      Arguments
      • string message

        A string to add to this GameObject's log. numberended for debugging.

      Returns void

    GameObject

    An object in the game. The most basic class that all game classes should inherit from automatically.

    Attributes
    • string gameObjectName

      String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

    • string id

      A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

    • table<string> logs

      Any strings logged will be stored here when this game object logs the strings. numberended for debugging.

    Functions
    • void log(
      • string message
      )

      adds a message to this game object's log. numberended for debugging purposes.

      Arguments
      • string message

        A string to add to this GameObject's log. numberended for debugging.

      Returns void

    Player
    Parent Classes:

    A player in this game. Every AI controls one player.

    Attributes
    • string reasonLost

      the reason why the player lost the game

    • number bribesRemaining

      How many bribes this player has remaining to use during their turn. Each action a Building does costs 1 bribe. Any unused bribes are lost at the end of the player's turn.

    • string reasonWon

      the reason why the player won the game

    • string clientType

      What type of client this is, e.g. 'Python', 'JavaScript', or some other language. For potential data mining purposes.

    • table<Building> buildings

      All the buildings owned by this player.

    • float timeRemaining

      The amount of time (in ns) remaining for this AI to send commands.

    • table<string> logs

      Inherited from GameObject.logs

      Any strings logged will be stored here when this game object logs the strings. numberended for debugging.

    • string id

      Inherited from GameObject.id

      A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

    • string gameObjectName

      Inherited from GameObject.gameObjectName

      String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

    • Warehouse headquarters

      The Warehouse that serves as this player's headquarters and has extra health. If this gets destroyed they lose.

    • table<FireDepartment> fireDepartments

      All the FireDepartments owned by this player.

    • boolean lost

      if the player lost the game or not

      Defaults to: false

    • string name

      The name of the player

      Defaults to: "Anonymous"

    • Player otherPlayer

      this player's opponent in the game.

    • table<PoliceDepartment> policeDepartments

      All the PoliceDepartments owned by this player.

    • table<Warehouse> warehouses

      All the warehouses owned by this player. Includes the Headquarters.

    • table<WeatherStation> weatherStations

      All the WeatherStations owned by this player.

    • boolean won

      if the player won the game or not

      Defaults to: false

    Functions
    • void log(
      • string message
      )

      Inherited from GameObject.log

      adds a message to this game object's log. numberended for debugging purposes.

      Arguments
      • string message

        A string to add to this GameObject's log. numberended for debugging.

      Returns void

    PoliceDepartment
    Parent Classes:

    Used to keep cities under control and raid Warehouses.

    Attributes
    • number health

      Inherited from Building.health

      How much health this building currently has. When this reaches 0 the Building has been burned down

    • boolean bribed

      Inherited from Building.bribed

      when true this building has already been bribed this turn and cannot be bribed again this turn.

    • string id

      Inherited from GameObject.id

      A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

    • Building buildingNorth

      Inherited from Building.buildingNorth

      The Building directly to the north of this building, or null if not present.

    • Building buildingEast

      Inherited from Building.buildingEast

      The Building directly to the east of this building, or null if not present.

    • Building buildingSouth

      Inherited from Building.buildingSouth

      The Building directly to the south of this building, or null if not present.

    • Building buildingWest

      Inherited from Building.buildingWest

      The Building directly to the west of this building, or null if not present.

    • number fire

      Inherited from Building.fire

      How much fire is currently burning the building, and thus how much damage it will take at the end of its owner's turn. 0 means no fire.

    • string gameObjectName

      Inherited from GameObject.gameObjectName

      String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

    • boolean isHeadquarters

      Inherited from Building.isHeadquarters

      true if this is the Headquarters of the owning player, false otherwise. Burning this down wins the game for the other Player.

    • table<string> logs

      Inherited from GameObject.logs

      Any strings logged will be stored here when this game object logs the strings. numberended for debugging.

    • Player owner

      Inherited from Building.owner

      The player that owns this building. If it burns down (health reaches 0) that player gets an additional bribe(s).

    • number x

      Inherited from Building.x

      The location of the Building along the x-axis

    • number y

      Inherited from Building.y

      The location of the Building along the y-axis

    Functions
    • void log(
      • string message
      )

      Inherited from GameObject.log

      adds a message to this game object's log. numberended for debugging purposes.

      Arguments
      • string message

        A string to add to this GameObject's log. numberended for debugging.

      Returns void

    • number raid(
      • Warehouse warehouse
      )

      Bribe the police to raid a Warehouse, dealing damage equal based on the Warehouse's current exposure, and then resetting it to 0.

      Arguments
      • Warehouse warehouse

        The warehouse you want to raid.

      Returns number

      The amount of damage dealt to the warehouse, or -1 if there was an error.

    Warehouse
    Parent Classes:

    A typical abandoned warehouse... that anarchists hang out in and can be bribed to burn down Buildings.

    Attributes
    • string gameObjectName

      Inherited from GameObject.gameObjectName

      String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

    • number exposure

      How exposed the anarchists in this warehouse are to PoliceDepartments. Raises when bribed to ignite buildings, and drops each turn if not bribed.

    • boolean bribed

      Inherited from Building.bribed

      when true this building has already been bribed this turn and cannot be bribed again this turn.

    • Building buildingEast

      Inherited from Building.buildingEast

      The Building directly to the east of this building, or null if not present.

    • Building buildingNorth

      Inherited from Building.buildingNorth

      The Building directly to the north of this building, or null if not present.

    • Building buildingSouth

      Inherited from Building.buildingSouth

      The Building directly to the south of this building, or null if not present.

    • Building buildingWest

      Inherited from Building.buildingWest

      The Building directly to the west of this building, or null if not present.

    • number fire

      Inherited from Building.fire

      How much fire is currently burning the building, and thus how much damage it will take at the end of its owner's turn. 0 means no fire.

    • number fireAdded

      The amount of fire added to buildings when bribed to ignite a building. Headquarters add more fire than normal Warehouses.

    • number health

      Inherited from Building.health

      How much health this building currently has. When this reaches 0 the Building has been burned down

    • string id

      Inherited from GameObject.id

      A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

    • boolean isHeadquarters

      Inherited from Building.isHeadquarters

      true if this is the Headquarters of the owning player, false otherwise. Burning this down wins the game for the other Player.

    • table<string> logs

      Inherited from GameObject.logs

      Any strings logged will be stored here when this game object logs the strings. numberended for debugging.

    • Player owner

      Inherited from Building.owner

      The player that owns this building. If it burns down (health reaches 0) that player gets an additional bribe(s).

    • number x

      Inherited from Building.x

      The location of the Building along the x-axis

    • number y

      Inherited from Building.y

      The location of the Building along the y-axis

    Functions
    • number ignite(
      • Building building
      )

      Bribes the Warehouse to light a Building on fire. This adds this building's fireAdded to their fire, and then this building's exposure is increased based on the Manhatten distance between the two buildings.

      Arguments
      • Building building

        The Building you want to light on fire.

      Returns number

      The exposure added to this Building's exposure. -1 is returned if there was an error.

    • void log(
      • string message
      )

      Inherited from GameObject.log

      adds a message to this game object's log. numberended for debugging purposes.

      Arguments
      • string message

        A string to add to this GameObject's log. numberended for debugging.

      Returns void

    WeatherStation
    Parent Classes:

    Can be bribed to change the next Forecast in some way.

    Attributes
    • number health

      Inherited from Building.health

      How much health this building currently has. When this reaches 0 the Building has been burned down

    • boolean bribed

      Inherited from Building.bribed

      when true this building has already been bribed this turn and cannot be bribed again this turn.

    • string id

      Inherited from GameObject.id

      A unique id for each instance of a GameObject or a sub class. Used for client and server communication. Should never change value after being set.

    • Building buildingNorth

      Inherited from Building.buildingNorth

      The Building directly to the north of this building, or null if not present.

    • Building buildingEast

      Inherited from Building.buildingEast

      The Building directly to the east of this building, or null if not present.

    • Building buildingSouth

      Inherited from Building.buildingSouth

      The Building directly to the south of this building, or null if not present.

    • Building buildingWest

      Inherited from Building.buildingWest

      The Building directly to the west of this building, or null if not present.

    • number fire

      Inherited from Building.fire

      How much fire is currently burning the building, and thus how much damage it will take at the end of its owner's turn. 0 means no fire.

    • string gameObjectName

      Inherited from GameObject.gameObjectName

      String representing the top level Class that this game object is an instance of. Used for reflection to create new instances on clients, but exposed for convenience should AIs want this data.

    • boolean isHeadquarters

      Inherited from Building.isHeadquarters

      true if this is the Headquarters of the owning player, false otherwise. Burning this down wins the game for the other Player.

    • table<string> logs

      Inherited from GameObject.logs

      Any strings logged will be stored here when this game object logs the strings. numberended for debugging.

    • Player owner

      Inherited from Building.owner

      The player that owns this building. If it burns down (health reaches 0) that player gets an additional bribe(s).

    • number x

      Inherited from Building.x

      The location of the Building along the x-axis

    • number y

      Inherited from Building.y

      The location of the Building along the y-axis

    Functions
    • boolean numberensify(
      • boolean negative
      )

      Bribe the weathermen to numberensity the next Forecast by 1 or -1

      Arguments
      • boolean negative

        By default the numberensity will be increased by 1, setting this to true decreases the numberensity by 1.

        Defaults to: false

      Returns boolean

      true if the numberensity was changed, false otherwise

    • void log(
      • string message
      )

      Inherited from GameObject.log

      adds a message to this game object's log. numberended for debugging purposes.

      Arguments
      • string message

        A string to add to this GameObject's log. numberended for debugging.

      Returns void

    • boolean rotate(
      • boolean counterclockwise
      )

      Bribe the weathermen to change the direction of the next Forecast by rotating it clockwise or counterclockwise.

      Arguments
      • boolean counterclockwise

        By default the direction will be rotated clockwise. If you set this to true we will rotate the forecast counterclockwise instead.

        Defaults to: false

      Returns boolean

      true if the rotation worked, false otherwise.