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 convert as many humans to as you can to survive in this post- apocalyptic wasteland.
type Game interface {
// Parent interfaces
base.Game
// CatEnergyMult is the multiplier for the amount of energy
// regenerated when resting in a shelter with the cat overlord.
CatEnergyMult() float64
// 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
// HarvestCooldown is the amount of turns it takes for a Tile that
// was just harvested to grow food again.
HarvestCooldown() int64
// Jobs is all the Jobs that Units can have in the game.
Jobs() []Job
// LowerHarvestAmount is the amount that the harvest rate is
// lowered each season.
LowerHarvestAmount() 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
// MonumentCostMult is the multiplier for the cost of actions when
// performing them in range of a monument. Does not effect pickup
// cost.
MonumentCostMult() float64
// MonumentMaterials is the number of materials in a monument.
MonumentMaterials() int64
// NeutralMaterials is the number of materials in a neutral
// Structure.
NeutralMaterials() int64
// Players is array of all the players in the game.
Players() []Player
// Session is a unique identifier for the game instance that is
// being played.
Session() string
// ShelterMaterials is the number of materials in a shelter.
ShelterMaterials() int64
// StartingFood is the amount of food Players start with.
StartingFood() int64
// StarvingEnergyMult is the multiplier for the amount of energy
// regenerated when resting while starving.
StarvingEnergyMult() float64
// Structures is every Structure in the game.
Structures() []Structure
// 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
// TurnsBetweenHarvests is after a food tile is harvested, the
// number of turns before it can be harvested again.
TurnsBetweenHarvests() int64
// TurnsToCreateHuman is the number of turns between fresh humans
// being spawned on the road.
TurnsToCreateHuman() int64
// TurnsToLowerHarvest is the number of turns before the harvest
// rate is lowered (length of each season basically).
TurnsToLowerHarvest() int64
// Units is every Unit in the game.
Units() []Unit
// WallMaterials is the number of materials in a wall.
WallMaterials() int64
// 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)
}
Job is information about a Unit's job.
type Job interface {
// Parent interfaces
GameObject
// ActionCost is the amount of energy this Job normally uses to
// perform its actions.
ActionCost() float64
// CarryLimit is how many combined resources a Unit with this Job
// can hold at once.
CarryLimit() int64
// Moves is the number of moves this Job can make per turn.
Moves() int64
// RegenRate is the amount of energy normally regenerated when
// resting at a shelter.
RegenRate() float64
// Title is the Job title.
//
// Literal Values: "fresh human", "cat overlord", "soldier",
// "gatherer", "builder", or "missionary"
Title() string
// Upkeep is the amount of food per turn this Unit consumes. If
// there isn't enough food for every Unit, all Units become
// starved and do not consume food.
Upkeep() int64
}
Player is a player in this game. Every AI controls one player.
type Player interface {
// Parent interfaces
GameObject
// Cat is the overlord cat Unit owned by this Player.
Cat() Unit
// ClientType is what type of client this is, e.g. 'Python',
// 'JavaScript', or some other language. For potential data mining
// purposes.
ClientType() string
// Food is the amount of food owned by this player.
Food() int64
// Lost is if the player lost the game or not.
Lost() bool
// 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
// Structures is every Structure owned by this Player.
Structures() []Structure
// TimeRemaining is the amount of time (in ns) remaining for this
// AI to send commands.
TimeRemaining() float64
// Units is every Unit owned by this Player.
Units() []Unit
// Upkeep is the total upkeep of every Unit owned by this Player.
// If there isn't enough food for every Unit, all Units become
// starved and do not consume food.
Upkeep() int64
// Won is if the player won the game or not.
Won() bool
}
Structure is a structure on a Tile.
type Structure interface {
// Parent interfaces
GameObject
// EffectRadius is the range of this Structure's effect. For
// example, a radius of 1 means this Structure affects a 3x3
// square centered on this Structure.
EffectRadius() int64
// Materials is the number of materials in this Structure. Once
// this number reaches 0, this Structure is destroyed.
Materials() int64
// Owner is the owner of this Structure if any, otherwise nil.
//
// Value can be returned as a nil pointer.
Owner() Player
// Tile is the Tile this Structure is on.
//
// Value can be returned as a nil pointer.
Tile() Tile
// Type is the type of Structure this is ('shelter', 'monument',
// 'wall', 'road', 'neutral').
//
// Literal Values: "neutral", "shelter", "monument", "wall", or
// "road"
Type() string
}
Tile is a Tile in the game that makes up the 2D map grid.
type Tile interface {
// Parent interfaces
GameObject
// Food is the number of food dropped on this Tile.
Food() int64
// HarvestRate is the amount of food that can be harvested from
// this Tile per turn.
HarvestRate() int64
// Materials is the number of materials dropped on this Tile.
Materials() int64
// Structure is the Structure on this Tile if present, otherwise
// nil.
//
// Value can be returned as a nil pointer.
Structure() Structure
// 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
// TurnsToHarvest is the amount of turns before this resource can
// be harvested.
TurnsToHarvest() int64
// 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
// 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
}
Unit is a unit in the game.
type Unit interface {
// Parent interfaces
GameObject
// Acted is whether this Unit has performed its action this turn.
Acted() bool
// Energy is the amount of energy this Unit has (from 0.0 to
// 100.0).
Energy() float64
// Food is the amount of food this Unit is holding.
Food() int64
// Job is the Job this Unit was recruited to do.
Job() Job
// Materials is the amount of materials this Unit is holding.
Materials() int64
// MovementTarget is the tile this Unit is moving to. This only
// applies to neutral fresh humans spawned on the road. Otherwise,
// the tile this Unit is on.
//
// Value can be returned as a nil pointer.
MovementTarget() Tile
// Moves is how many moves this Unit has left this turn.
Moves() int64
// Owner is the Player that owns and can control this Unit, or nil
// if the Unit is neutral.
//
// Value can be returned as a nil pointer.
Owner() Player
// Squad is the Units in the same squad as this Unit. Units in the
// same squad attack and defend together.
Squad() []Unit
// Starving is whether this Unit is starving. Starving Units
// regenerate energy at half the rate they normally would while
// resting.
Starving() bool
// Tile is the Tile this Unit is on.
//
// Value can be returned as a nil pointer.
Tile() Tile
// TurnsToDie is the number of turns before this Unit dies. This
// only applies to neutral fresh humans created from combat.
// Otherwise, 0.
TurnsToDie() int64
// Attack attacks an adjacent Tile. Costs an action for each Unit
// in this Unit's squad. Units in the squad without an action
// don't participate in combat. Units in combat cannot move
// afterwards. Attacking structures will not give materials.
Attack(Tile) bool
// ChangeJob changes this Unit's Job. Must be at max energy (100)
// to change Jobs.
ChangeJob(string) bool
// Construct constructs a Structure on an adjacent Tile.
Construct(Tile, string) bool
// Convert converts an adjacent Unit to your side.
Convert(Tile) bool
// Deconstruct removes materials from an adjacent Tile's
// Structure. You cannot deconstruct friendly structures (see
// `Unit.attack`).
Deconstruct(Tile) bool
// Drop drops some of the given resource on or adjacent to the
// Unit's Tile. Does not count as an action.
Drop(Tile, string, int64) bool
// Harvest harvests the food on an adjacent Tile.
Harvest(Tile) bool
// Move moves this Unit from its current Tile to an adjacent Tile.
Move(Tile) bool
// Pickup picks up some materials or food on or adjacent to the
// Unit's Tile. Does not count as an action.
Pickup(Tile, string, int64) bool
// Rest regenerates energy. Must be in range of a friendly shelter
// to rest. Costs an action. Units cannot move after resting.
Rest() bool
}