...

Package stumped

import "joueur/games/stumped"
Overview
Index

Overview ▾

Package stumped contains all the interfaces and AI that are required to represent and play Stumped.

Stumped Game Info ▾

Gather branches and build up your lodge as beavers fight to survive.

More Info

The full game rules for Stumped can be found on GitHub.

Additional materials, such as the story and game template can be found on GitHub as well.

Variables

TileDirections are all the direction strings that Tile's neighbors can be in.

var TileDirections = [...]string{"North", "South", "East", "West"}

func PlayerName

func PlayerName() string

PlayerName should return the string name of your Player in games it plays.

type AI

AI is your personal AI implimentation.

type AI struct {
    base.AIImpl
}

func (*AI) Ended

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) Game

func (ai *AI) Game() Game

Game returns the instance of the Game this AI is currently playing.

func (*AI) GameUpdated

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) Player

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) RunTurn

func (ai *AI) RunTurn() bool

RunTurn this is called every time it is this AI.player's turn.

func (*AI) Start

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.

type Beaver

Beaver is a beaver in the game.

type Beaver interface {
    // Parent interfaces
    GameObject

    // Actions is the number of actions remaining for the Beaver this
    // turn.
    Actions() int64

    // Branches is the amount of branches this Beaver is holding.
    Branches() int64

    // Food is the amount of food this Beaver is holding.
    Food() int64

    // Health is how much health this Beaver has left.
    Health() int64

    // Job is the Job this Beaver was recruited to do.
    Job() Job

    // Moves is how many moves this Beaver has left this turn.
    Moves() int64

    // Owner is the Player that owns and can control this Beaver.
    Owner() Player

    // Recruited is true if the Beaver has finished being recruited
    // and can do things, False otherwise.
    Recruited() bool

    // Tile is the Tile this Beaver is on.
    //
    // Value can be returned as a nil pointer.
    Tile() Tile

    // TurnsDistracted is number of turns this Beaver is distracted
    // for (0 means not distracted).
    TurnsDistracted() int64

    // Attack attacks another adjacent beaver.
    Attack(Beaver) bool

    // BuildLodge builds a lodge on the Beavers current Tile.
    BuildLodge() bool

    // Drop drops some of the given resource on the beaver's Tile.
    Drop(Tile, string, int64) bool

    // Harvest harvests the branches or food from a Spawner on an
    // adjacent Tile.
    Harvest(Spawner) bool

    // Move moves this Beaver from its current Tile to an adjacent
    // Tile.
    Move(Tile) bool

    // Pickup picks up some branches or food on the beaver's tile.
    Pickup(Tile, string, int64) bool
}

type Game

Game is gather branches and build up your lodge as beavers fight to survive.

type Game interface {
    // Parent interfaces
    base.Game

    // Beavers is every Beaver in the game.
    Beavers() []Beaver

    // 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

    // FreeBeaversCount is when a Player has less Beavers than this
    // number, then recruiting other Beavers is free.
    FreeBeaversCount() 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

    // Jobs is all the Jobs that Beavers can have in the game.
    Jobs() []Job

    // LodgeCostConstant is constant number used to calculate what it
    // costs to spawn a new lodge.
    LodgeCostConstant() float64

    // LodgesToWin is how many lodges must be owned by a Player at
    // once to win the game.
    LodgesToWin() 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

    // Session is a unique identifier for the game instance that is
    // being played.
    Session() string

    // Spawner is every Spawner in the game.
    Spawner() []Spawner

    // SpawnerHarvestConstant is constant number used to calculate how
    // many branches/food Beavers harvest from Spawners.
    SpawnerHarvestConstant() float64

    // SpawnerTypes is all the types of Spawners in the game.
    SpawnerTypes() []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

    // GetTileAt returns the Tile at a give position (x, y).
    GetTileAt(int64, int64) Tile
}

type GameObject

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)
}

type Job

Job is information about a beaver's job.

type Job interface {
    // Parent interfaces
    GameObject

    // Actions is the number of actions this Job can make per turn.
    Actions() int64

    // CarryLimit is how many combined resources a beaver with this
    // Job can hold at once.
    CarryLimit() int64

    // Chopping is scalar for how many branches this Job harvests at
    // once.
    Chopping() int64

    // Cost is how much food this Job costs to recruit.
    Cost() int64

    // Damage is the amount of damage this Job does per attack.
    Damage() int64

    // DistractionPower is how many turns a beaver attacked by this
    // Job is distracted by.
    DistractionPower() int64

    // Health is the amount of starting health this Job has.
    Health() int64

    // Moves is the number of moves this Job can make per turn.
    Moves() int64

    // Munching is scalar for how much food this Job harvests at once.
    Munching() int64

    // Title is the Job title.
    Title() string

    // Recruit recruits a Beaver of this Job to a lodge.
    Recruit(Tile) Beaver
}

type Player

Player is a player in this game. Every AI controls one player.

type Player interface {
    // Parent interfaces
    GameObject

    // Beavers is the array of Beavers owned by this Player.
    Beavers() []Beaver

    // BranchesToBuildLodge is how many branches are required to build
    // a lodge for this Player.
    BranchesToBuildLodge() int64

    // ClientType is what type of client this is, e.g. 'Python',
    // 'JavaScript', or some other language. For potential data mining
    // purposes.
    ClientType() string

    // Lodges is an array of Tiles that contain lodges owned by this
    // player.
    Lodges() []Tile

    // 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

    // 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
}

type Spawner

Spawner is a resource spawner that generates branches or food.

type Spawner interface {
    // Parent interfaces
    GameObject

    // HasBeenHarvested is true if this Spawner has been harvested
    // this turn, and it will not heal at the end of the turn, false
    // otherwise.
    HasBeenHarvested() bool

    // Health is how much health this Spawner has, which is used to
    // calculate how much of its resource can be harvested.
    Health() int64

    // Tile is the Tile this Spawner is on.
    Tile() Tile

    // Type is what type of resource this is ('food' or 'branches').
    //
    // Literal Values: "food" or "branches"
    Type() string
}

type Tile

Tile is a Tile in the game that makes up the 2D map grid.

type Tile interface {
    // Parent interfaces
    GameObject

    // Beaver is the Beaver on this Tile if present, otherwise nil.
    //
    // Value can be returned as a nil pointer.
    Beaver() Beaver

    // Branches is the number of branches dropped on this Tile.
    Branches() int64

    // FlowDirection is the cardinal direction water is flowing on
    // this Tile ('North', 'East', 'South', 'West').
    //
    // Literal Values: "North", "East", "South", "West", or ""
    FlowDirection() string

    // Food is the number of food dropped on this Tile.
    Food() int64

    // LodgeOwner is the owner of the Beaver lodge on this Tile, if
    // present, otherwise nil.
    //
    // Value can be returned as a nil pointer.
    LodgeOwner() Player

    // Spawner is the resource Spawner on this Tile if present,
    // otherwise nil.
    //
    // Value can be returned as a nil pointer.
    Spawner() Spawner

    // 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

    // Type is what type of Tile this is, either 'water' or 'land'.
    //
    // Literal Values: "land" or "water"
    Type() string

    // 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
}