Deception Game API Documentation - notruilin/DeceptionGame GitHub Wiki

This documentation contains details of the scripting API that the game provides to support your AI agent development.

Actions

Before each turn, you need to create an Actions class which includes all actions the shuttle will take sequentially in this turn.

Public Functions

CollectAt Collects pickup(s) from position(s)
MoveTo Moves to position(s)
DepositAt Deposits a specified colored counter at the position, sets delay optionally
DepositIndexAt Deposits a specified indexed counter at the position, sets delay optionally
GetDepositPos Returns a list of positions that have been added deposit commands in this actions as well as all other shuttles' actions.
GetCollectPos Returns a list of positions that have been added collect commands in this actions as well as all other shuttles' actions.
TurnOverCounterInBagByIndex Turns over the counter with the given index
CollectFromBoard Collects a counter from the board
GetPickupColor Returns how many red, yellow and blue counters are carried according to the Actions
GetPickupColorBagPos Returns the color of counter on each bag position

GameManager

GameManager holds the states of the game, includes generators, anchors, deposit records and block records.

Variables

generators The GameObjects of all generators
parkingPos The parking position of all generators, shuttle needs to move to the parking position before collect
anchorPositions The positions of the centre of anchors
deposited The deposit status of each grid
blocked The block status of each grid

GeneratorManager

Every generator corresponds to a GeneratorManager which controls pickups' generation.

Variables

regenerateDelay The delay before regenerating a pickup after collecting

Public Functions

GetPickupsInGn Returns a list of GameObjects of all pickups in the generator
GetRedPickupsNumber Returns the number of red pickups in the generator
GetPickupsInGnColor Returns the color of the pickup at the given position

AIAgent

Every shuttle instance attaches an AIAgent and an AIBehaviour. AIAgent is where you define your own agent.

Public Functions

Start Called on the frame when a script is enabled
MakeDecision Called before each AI's turn

AIBehavior

AIBehavior includes AI's properties such as information about carrying counters.

Variables

turnOverDelay Turns over the counters how many seconds when the shuttle collides with them

Public Functions

GetCarryColor Returns the number of each counter
GetBagCounterColor Returns the color of each counter in the shuttle's bag

GameParameters

GameParameters control the parameters of the game, includes the size of the board, the number of the shuttles, the minimal distance between two anchors, the number of counters in each generator and so on. If you make selections in the "Options" menu, it will cover the values in GameParameters.

Variables

shuttleNum The number of the shuttles
gridSize The default size of the board
minAnchorDis The minimal distance between two anchors
counterNumInGenerator The number of counters in each generator
carryLimit The number of counters each shuttle can carry
anchorCount The number of anchors
randomAnchor The positions of the anchors are random or default
timeLimitForAI The time limit for AI

Functions

SetCustomAnchorPos Edit this function to set customized anchor positions
InitializeColorProportion Edit this function to initialize the proportions of each colored counter in the generators
SetColorProportion Sets the proportions of each colored counter in the generators during the game

Methods

Contains several general methods and algorithms that may help you develop your agent.

Public Functions

RandomPosition Returns a random position from the list
IsOnAnAnchor Checks if the position is on an anchor
IsOnBoard Checks if the position is valid on the board
IsEmptyGrid Checks if the position is empty grid
IsAdjGrid Checks if two positions are adjacent
FindGenerator Returns the generator ID which the parking position belongs
OnPickup Returns the generator ID if the position has a pickup
OnCounter Returns the counter's color at position
TileExist Checks if the position hasn't been blocked
FindEmptyNeighbor Returns some empty grids around the given list of positions
PickupColorInPos Returns how many red, yellow and blue counters can be picked up if collect according to the given list
MostRedGenerator Returns the generator ID which has the most number of red pickups
SearchClosestAnchor Returns the Anchor with the shortest linear distance except positions in the given list
RandomAnchor Returns a random Anchor except positions in the given list
TransAnchorPositionInGrid Returns a valid grid position according to the given anchor's center
PickupsPosInGn Returns num pickups' positions in the given generator
FindPathInGrid Returns a BFS path from start to end according to the board
RemoveDepositedAndAnchor Removes all deposited grids and anchors in the given list