TileDirections are all the direction strings that Tile's neighbors can be in.
var TileDirections = [...]string{"North", "South", "East", "West"}
func PlayerName() string
PlayerName should return the string name of your Player in games it plays.
AI is your personal AI implimentation.
type AI struct { base.AIImpl }
func (ai *AI) Ended(won bool, reason string)
Ended is called when the game ends, you can clean up your data and dump files here if need be.
func (ai *AI) Game() Game
Game returns the instance of the Game this AI is currently playing.
func (ai *AI) GameUpdated()
GameUpdated is called every time the game's state updates, so if you are tracking anything you can update it here.
func (ai *AI) Player() Player
Player returns the instance of the Player this AI is represented by in the game this AI is playing.
func (ai *AI) RunTurn() bool
RunTurn this is called every time it is this AI.player's turn.
func (ai *AI) Start()
Start is called once the game starts and your AI has a Player and Game. You can initialize your AI struct here.
Game is send hordes of the undead at your opponent while defending yourself against theirs to win.
type Game interface { // Parent interfaces base.Game // CurrentPlayer is the player whose turn it is currently. That // player can send commands. Other players cannot. CurrentPlayer() Player // CurrentTurn is the current turn number, starting at 0 for the // first player's turn. CurrentTurn() int64 // GameObjects is 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. GameObjects() map[string]GameObject // GoldIncomePerUnit is the amount of gold income per turn per // unit in a mine. GoldIncomePerUnit() int64 // IslandIncomePerUnit is the amount of gold income per turn per // unit in the island mine. IslandIncomePerUnit() int64 // ManaIncomePerUnit is the Amount of gold income per turn per // unit fishing on the river side. ManaIncomePerUnit() int64 // MapHeight is the number of Tiles in the map along the y // (vertical) axis. MapHeight() int64 // MapWidth is the number of Tiles in the map along the x // (horizontal) axis. MapWidth() int64 // MaxTurns is the maximum number of turns before the game will // automatically end. MaxTurns() int64 // Players is array of all the players in the game. Players() []Player // RiverPhase is the amount of turns it takes between the river // changing phases. RiverPhase() int64 // Session is a unique identifier for the game instance that is // being played. Session() string // Tiles is all the tiles in the map, stored in Row-major order. // Use `x + y * mapWidth` to access the correct index. Tiles() []Tile // TimeAddedPerTurn is the amount of time (in nano-seconds) added // after each player performs a turn. TimeAddedPerTurn() float64 // TowerJobs is an array of every tower type / job. TowerJobs() []TowerJob // Towers is every Tower in the game. Towers() []Tower // UnitJobs is an array of every unit type / job. UnitJobs() []UnitJob // Units is every Unit in the game. Units() []Unit // GetTileAt returns the Tile at a give position (x, y). GetTileAt(int64, int64) Tile }
GameObject is an object in the game. The most basic class that all game classes should inherit from automatically.
type GameObject interface { // Parent interfaces base.GameObject // Logs is any strings logged will be stored here. Intended for // debugging. Logs() []string // Log adds a message to this GameObject's logs. Intended for your // own debugging purposes, as strings stored here are saved in the // gamelog. Log(string) }
Player is a player in this game. Every AI controls one player.
type Player interface { // Parent interfaces GameObject // ClientType is what type of client this is, e.g. 'Python', // 'JavaScript', or some other language. For potential data mining // purposes. ClientType() string // Gold is the amount of gold this Player has. Gold() int64 // Health is the amount of health remaining for this player's main // unit. Health() int64 // HomeBase is the tile that the home base is located on. HomeBase() []Tile // Lost is if the player lost the game or not. Lost() bool // Mana is the amount of mana this player has. Mana() int64 // Name is the name of the player. Name() string // Opponent is this player's opponent in the game. Opponent() Player // ReasonLost is the reason why the player lost the game. ReasonLost() string // ReasonWon is the reason why the player won the game. ReasonWon() string // Side is all tiles that this player can build on and move // workers on. Side() []Tile // TimeRemaining is the amount of time (in ns) remaining for this // AI to send commands. TimeRemaining() float64 // Towers is every Tower owned by this player. Towers() []Tower // Units is every Unit owned by this Player. Units() []Unit // Won is if the player won the game or not. Won() bool }
Tile is a Tile in the game that makes up the 2D map grid.
type Tile interface { // Parent interfaces GameObject // Corpses is the amount of corpses on this tile. Corpses() int64 // IsCastle is whether or not the tile is a castle tile. IsCastle() bool // IsGoldMine is whether or not the tile is considered to be a // gold mine or not. IsGoldMine() bool // IsGrass is whether or not the tile is considered grass or not // (Workers can walk on grass). IsGrass() bool // IsIslandGoldMine is whether or not the tile is considered to be // the island gold mine or not. IsIslandGoldMine() bool // IsPath is whether or not the tile is considered a path or not // (Units can walk on paths). IsPath() bool // IsRiver is whether or not the tile is considered a river or // not. IsRiver() bool // IsTower is whether or not the tile is considered a tower or // not. IsTower() bool // IsUnitSpawn is whether or not the tile is the unit spawn. IsUnitSpawn() bool // IsWall is whether or not the tile can be moved on by workers. IsWall() bool // IsWorkerSpawn is whether or not the tile is the worker spawn. IsWorkerSpawn() bool // NumGhouls is the amount of Ghouls on this tile. NumGhouls() int64 // NumHounds is the amount of Hounds on this tile. NumHounds() int64 // NumZombies is the amount of Zombies on this tile. NumZombies() int64 // Owner is which player owns this tile, only applies to grass // tiles for workers, NULL otherwise. // // Value can be returned as a nil pointer. Owner() Player // TileEast is the Tile to the 'East' of this one (x+1, y). Nil if // out of bounds of the map. // // Value can be returned as a nil pointer. TileEast() Tile // TileNorth is the Tile to the 'North' of this one (x, y-1). Nil // if out of bounds of the map. // // Value can be returned as a nil pointer. TileNorth() Tile // TileSouth is the Tile to the 'South' of this one (x, y+1). Nil // if out of bounds of the map. // // Value can be returned as a nil pointer. TileSouth() Tile // TileWest is the Tile to the 'West' of this one (x-1, y). Nil if // out of bounds of the map. // // Value can be returned as a nil pointer. TileWest() Tile // Tower is the Tower on this Tile if present, otherwise nil. // // Value can be returned as a nil pointer. Tower() Tower // Unit is the Unit on this Tile if present, otherwise nil. // // Value can be returned as a nil pointer. Unit() Unit // X is the x (horizontal) position of this Tile. X() int64 // Y is the y (vertical) position of this Tile. Y() int64 // Res resurrect the corpses on this tile into Zombies. Res(int64) bool // SpawnUnit spawns a fighting unit on the correct tile. SpawnUnit(string) bool // SpawnWorker spawns a worker on the correct tile. SpawnWorker() bool // GetNeighbors returns an array of the neighbors of this Tile. GetNeighbors() []Tile // IsPathable returns if the Tile is pathable for FindPath IsPathable() bool // HasNeighbor checks if this Tile has a specific neighboring Tile. HasNeighbor(Tile) bool }
Tower is a tower in the game. Used to combat enemy waves.
type Tower interface { // Parent interfaces GameObject // Attacked is whether this tower has attacked this turn or not. Attacked() bool // Cooldown is how many turns are left before it can fire again. Cooldown() int64 // Health is how much remaining health this tower has. Health() int64 // Job is what type of tower this is (it's job). Job() TowerJob // Owner is the player that built / owns this tower. // // Value can be returned as a nil pointer. Owner() Player // Tile is the Tile this Tower is on. Tile() Tile // Attack attacks an enemy unit on an tile within it's range. Attack(Tile) bool }
TowerJob is information about a tower's job/type.
type TowerJob interface { // Parent interfaces GameObject // AllUnits is whether this tower type hits all of the units on a // tile (true) or one at a time (false). AllUnits() bool // Damage is the amount of damage this type does per attack. Damage() int64 // GoldCost is how much does this type cost in gold. GoldCost() int64 // Health is the amount of starting health this type has. Health() int64 // ManaCost is how much does this type cost in mana. ManaCost() int64 // Range is the number of tiles this type can attack from. Range() int64 // Title is the type title. 'arrow', 'aoe', 'balarraya', // 'cleansing', or 'castle'. // // Literal Values: "arrow", "aoe", "ballista", "cleansing", or // "castle" Title() string // TurnsBetweenAttacks is how many turns have to take place // between this type's attacks. TurnsBetweenAttacks() int64 }
Unit is a unit in the game. May be a worker, zombie, ghoul, hound, abomination, wraith or horseman.
type Unit interface { // Parent interfaces GameObject // Acted is whether or not this Unit has performed its action this // turn (attack or build). Acted() bool // Health is the remaining health of a unit. Health() int64 // Job is the type of unit this is. Job() UnitJob // Moves is the number of moves this unit has left this turn. Moves() int64 // Owner is the Player that owns and can control this Unit. // // Value can be returned as a nil pointer. Owner() Player // Tile is the Tile this Unit is on. // // Value can be returned as a nil pointer. Tile() Tile // Attack attacks an enemy tower on an adjacent tile. Attack(Tile) bool // Build unit, if it is a worker, builds a tower on the tile it is // on, only workers can do this. Build(string) bool // Fish stops adjacent to a river tile and begins fishing for // mana. Fish(Tile) bool // Mine enters a mine and is put to work gathering resources. Mine(Tile) bool // Move moves this Unit from its current Tile to an adjacent Tile. Move(Tile) bool }
UnitJob is information about a unit's job/type.
type UnitJob interface { // Parent interfaces GameObject // Damage is the amount of damage this type does per attack. Damage() int64 // GoldCost is how much does this type cost in gold. GoldCost() int64 // Health is the amount of starting health this type has. Health() int64 // ManaCost is how much does this type cost in mana. ManaCost() int64 // Moves is the number of moves this type can make per turn. Moves() int64 // PerTile is how many of this type of unit can take up one tile. PerTile() int64 // Range is amount of tiles away this type has to be in order to // be effective. Range() int64 // Title is the type title. 'worker', 'zombie', 'ghoul', 'hound', // 'abomination', 'wraith' or 'horseman'. // // Literal Values: "worker", "zombie", "ghoul", "hound", // "abomination", "wraith", or "horseman" Title() string }