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.
BroodMother is the Spider Queen. She alone can spawn Spiderlings for each Player, and if she dies the owner loses.
type BroodMother interface { // Parent interfaces Spider // Eggs is how many eggs the BroodMother has to spawn Spiderlings // this turn. Eggs() int64 // Health is how much health this BroodMother has left. When it // reaches 0, she dies and her owner loses. Health() int64 // Consume consumes a Spiderling of the same owner to regain some // eggs to spawn more Spiderlings. Consume(Spiderling) bool // Spawn spawns a new Spiderling on the same Nest as this // BroodMother, consuming an egg. Spawn(string) Spiderling }
Cutter is a Spiderling that can cut existing Webs.
type Cutter interface { // Parent interfaces Spiderling // CuttingWeb is the Web that this Cutter is trying to cut. Nil if // not cutting. // // Value can be returned as a nil pointer. CuttingWeb() Web // Cut cuts a web, destroying it, and any Spiderlings on it. Cut(Web) bool }
Game is there's an infestation of enemy spiders challenging your queen BroodMother spider! Protect her and attack the other BroodMother in this turn based, node based, game.
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 // CutSpeed is the speed at which Cutters work to do cut Webs. CutSpeed() int64 // EggsScalar is constant used to calculate how many eggs // BroodMothers get on their owner's turns. EggsScalar() float64 // 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 // InitialWebStrength is the starting strength for Webs. InitialWebStrength() int64 // MaxTurns is the maximum number of turns before the game will // automatically end. MaxTurns() int64 // MaxWebStrength is the maximum strength a web can be // strengthened to. MaxWebStrength() int64 // MovementSpeed is the speed at which Spiderlings move on Webs. MovementSpeed() int64 // Nests is every Nest in the game. Nests() []Nest // 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 // SpitSpeed is the speed at which Spitters work to spit new Webs. SpitSpeed() int64 // TimeAddedPerTurn is the amount of time (in nano-seconds) added // after each player performs a turn. TimeAddedPerTurn() float64 // WeavePower is how much web strength is added or removed from // Webs when they are weaved. WeavePower() int64 // WeaveSpeed is the speed at which Weavers work to do strengthens // and weakens on Webs. WeaveSpeed() int64 // Webs is every Web in the game. Webs() []Web }
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) }
Nest is a location (node) connected to other Nests via Webs (edges) in the game that Spiders can converge on, regardless of owner.
type Nest interface { // Parent interfaces GameObject // ControllingPlayer is the Player that 'controls' this Nest as // they have the most Spiders on this nest. // // Value can be returned as a nil pointer. ControllingPlayer() Player // Spiders is all the Spiders currently located on this Nest. Spiders() []Spider // Webs is webs that connect to this Nest. Webs() []Web // X is the X coordinate of the Nest. Used for distance // calculations. X() int64 // Y is the Y coordinate of the Nest. Used for distance // calculations. Y() int64 }
Player is a player in this game. Every AI controls one player.
type Player interface { // Parent interfaces GameObject // BroodMother is this player's BroodMother. If it dies they lose // the game. BroodMother() BroodMother // ClientType is what type of client this is, e.g. 'Python', // 'JavaScript', or some other language. For potential data mining // purposes. ClientType() string // Lost is if the player lost the game or not. Lost() bool // MaxSpiderlings is the max number of Spiderlings players can // spawn. MaxSpiderlings() int64 // Name is the name of the player. Name() string // NumberOfNestsControlled is the number of nests this player // controls. NumberOfNestsControlled() int64 // 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 // Spiders is all the Spiders owned by this player. Spiders() []Spider // TimeRemaining is the amount of time (in ns) remaining for this // AI to send commands. TimeRemaining() float64 // Won is if the player won the game or not. Won() bool }
Spider is a Spider in the game. The most basic unit.
type Spider interface { // Parent interfaces GameObject // IsDead is if this Spider is dead and has been removed from the // game. IsDead() bool // Nest is the Nest that this Spider is currently on. Nil when // moving on a Web. // // Value can be returned as a nil pointer. Nest() Nest // Owner is the Player that owns this Spider, and can command it. Owner() Player }
Spiderling is a Spider spawned by the BroodMother.
type Spiderling interface { // Parent interfaces Spider // Busy is when empty string this Spiderling is not busy, and can // act. Otherwise a string representing what it is busy with, e.g. // 'Moving', 'Attacking'. // // Literal Values: "", "Moving", "Attacking", "Strengthening", // "Weakening", "Cutting", or "Spitting" Busy() string // MovingOnWeb is the Web this Spiderling is using to move. Nil if // it is not moving. // // Value can be returned as a nil pointer. MovingOnWeb() Web // MovingToNest is the Nest this Spiderling is moving to. Nil if // it is not moving. // // Value can be returned as a nil pointer. MovingToNest() Nest // NumberOfCoworkers is the number of Spiderlings busy with the // same work this Spiderling is doing, speeding up the task. NumberOfCoworkers() int64 // WorkRemaining is how much work needs to be done for this // Spiderling to finish being busy. See docs for the Work formula. WorkRemaining() float64 // Attack attacks another Spiderling. Attack(Spiderling) bool // Move starts moving the Spiderling across a Web to another Nest. Move(Web) bool }
Spitter is a Spiderling that creates and spits new Webs from the Nest it is on to another Nest, connecting them.
type Spitter interface { // Parent interfaces Spiderling // SpittingWebToNest is the Nest that this Spitter is creating a // Web to spit at, thus connecting them. Nil if not spitting. // // Value can be returned as a nil pointer. SpittingWebToNest() Nest // Spit creates and spits a new Web from the Nest the Spitter is // on to another Nest, connecting them. Spit(Nest) bool }
Weaver is a Spiderling that can alter existing Webs by weaving to add or remove silk from the Webs, thus altering its strength.
type Weaver interface { // Parent interfaces Spiderling // StrengtheningWeb is the Web that this Weaver is strengthening. // Nil if not strengthening. // // Value can be returned as a nil pointer. StrengtheningWeb() Web // WeakeningWeb is the Web that this Weaver is weakening. Nil if // not weakening. // // Value can be returned as a nil pointer. WeakeningWeb() Web // Strengthen weaves more silk into an existing Web to strengthen // it. Strengthen(Web) bool // Weaken weaves more silk into an existing Web to strengthen it. Weaken(Web) bool }
Web is a connection (edge) to a Nest (node) in the game that Spiders can converge on (regardless of owner). Spiders can travel in either direction on Webs.
type Web interface { // Parent interfaces GameObject // Length is how long this Web is, i.e., the distance between its // nestA and nestB. Length() float64 // Load is how much weight this Web currently has on it, which is // the sum of all its Spiderlings weight. Load() int64 // NestA is the first Nest this Web is connected to. // // Value can be returned as a nil pointer. NestA() Nest // NestB is the second Nest this Web is connected to. // // Value can be returned as a nil pointer. NestB() Nest // Spiderlings is all the Spiderlings currently moving along this // Web. Spiderlings() []Spiderling // Strength is how much weight this Web can take before snapping // and destroying itself and all the Spiders on it. Strength() int64 }