...

Package coreminer

import "joueur/games/coreminer"
Overview
Index

Overview ▾

Package coreminer contains all the interfaces and AI that are required to represent and play Coreminer.

Coreminer Game Info ▾

Mine resources to obtain more value than your opponent.

More Info

The full game rules for Coreminer 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 Bomb

Bomb is a Bomb in the game.

type Bomb interface {
    // Parent interfaces
    GameObject

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

    // Timer is the number of turns before this Bomb explodes. One
    // means it will explode after the current turn.
    Timer() int64
}

type Game

Game is mine resources to obtain more value than your opponent.

type Game interface {
    // Parent interfaces
    base.Game

    // BombPrice is the monetary price of a bomb when bought or sold.
    BombPrice() int64

    // BombSize is the amount of cargo space taken up by a Bomb.
    BombSize() int64

    // Bombs is every Bomb in the game.
    Bombs() []Bomb

    // BuildingMaterialPrice is the monetary price of building
    // materials when bought.
    BuildingMaterialPrice() int64

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

    // DirtPrice is the monetary price of dirt when bought or sold.
    DirtPrice() int64

    // FallDamage is the amount of damage taken per Tile fallen.
    FallDamage() int64

    // FallWeightDamage is the amount of extra damage taken for
    // falling while carrying a large amount of cargo.
    FallWeightDamage() 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

    // LadderCost is the amount of building material required to build
    // a ladder.
    LadderCost() int64

    // LadderHealth is the amount of mining power needed to remove a
    // ladder from a Tile.
    LadderHealth() int64

    // LargeCargoSize is the amount deemed as a large amount of cargo.
    LargeCargoSize() int64

    // LargeMaterialSize is the amount deemed as a large amount of
    // material.
    LargeMaterialSize() 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

    // MaxShielding is the maximum amount of shielding possible on a
    // Tile.
    MaxShielding() int64

    // MaxTurns is the maximum number of turns before the game will
    // automatically end.
    MaxTurns() int64

    // MaxUpgradeLevel is the highest upgrade level allowed on a
    // Miner.
    MaxUpgradeLevel() int64

    // Miners is every Miner in the game.
    Miners() []Miner

    // OrePrice is the amount of money awarded when ore is dumped in
    // the base and sold.
    OrePrice() int64

    // OreValue is the amount of value awarded when ore is dumped in
    // the base and sold.
    OreValue() 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

    // ShieldCost is the amount of building material required to
    // shield a Tile.
    ShieldCost() int64

    // ShieldHealth is the amount of mining power needed to remove one
    // unit of shielding off a Tile.
    ShieldHealth() int64

    // SpawnPrice is the monetary price of spawning a Miner.
    SpawnPrice() int64

    // SuffocationDamage is the amount of damage taken when
    // suffocating inside a filled Tile.
    SuffocationDamage() int64

    // SuffocationWeightDamage is the amount of extra damage taken for
    // suffocating under a large amount of material.
    SuffocationWeightDamage() int64

    // SupportCost is the amount of building material required to
    // build a support.
    SupportCost() int64

    // SupportHealth is the amount of mining power needed to remove a
    // support from a Tile.
    SupportHealth() int64

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

    // UpgradePrice is the cost to upgrade a Miner.
    UpgradePrice() int64

    // Upgrades is every Upgrade for a Miner in the game.
    Upgrades() []Upgrade

    // VictoryAmount is the amount of victory points (value) required
    // to win.
    VictoryAmount() int64

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

Miner is a Miner in the game.

type Miner interface {
    // Parent interfaces
    GameObject

    // Bombs is the number of bombs being carried by this Miner.
    Bombs() int64

    // BuildingMaterials is the number of building materials carried
    // by this Miner.
    BuildingMaterials() int64

    // CurrentUpgrade is the Upgrade this Miner is on.
    CurrentUpgrade() Upgrade

    // Dirt is the amount of dirt carried by this Miner.
    Dirt() int64

    // Health is the remaining health of this Miner.
    Health() int64

    // MiningPower is the remaining mining power this Miner has this
    // turn.
    MiningPower() int64

    // Moves is the number of moves this Miner has left this turn.
    Moves() int64

    // Ore is the amount of ore carried by this Miner.
    Ore() int64

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

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

    // UpgradeLevel is the upgrade level of this Miner. Starts at 0.
    UpgradeLevel() int64

    // Build builds a support, shield, or ladder on Miner's Tile, or
    // an adjacent Tile.
    Build(Tile, string) bool

    // Buy purchase a resource from the Player's base or hopper.
    Buy(string, int64) bool

    // Dump dumps materials from cargo to an adjacent Tile. If the
    // Tile is a base or a hopper Tile, materials are sold instead of
    // placed.
    Dump(Tile, string, int64) bool

    // Mine mines the Tile the Miner is on or an adjacent Tile.
    Mine(Tile, int64) bool

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

    // Transfer transfers a resource from the one Miner to another.
    Transfer(Miner, string, int64) bool

    // Upgrade upgrade this Miner by installing an upgrade module.
    Upgrade() bool
}

type Player

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

type Player interface {
    // Parent interfaces
    GameObject

    // BaseTile is the Tile this Player's base is on.
    BaseTile() Tile

    // Bombs is every Bomb owned by this Player.
    Bombs() []Bomb

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

    // HopperTiles is the Tiles this Player's hoppers are on.
    HopperTiles() []Tile

    // Lost is if the player lost the game or not.
    Lost() bool

    // Miners is every Miner owned by this Player.
    Miners() []Miner

    // Money is the amount of money this Player currently has.
    Money() 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

    // TimeRemaining is the amount of time (in ns) remaining for this
    // AI to send commands.
    TimeRemaining() float64

    // Value is the amount of value (victory points) this Player has
    // gained.
    Value() int64

    // Won is if the player won the game or not.
    Won() bool

    // SpawnMiner spawns a Miner on this Player's base Tile.
    SpawnMiner() bool
}

type Tile

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

type Tile interface {
    // Parent interfaces
    GameObject

    // Bombs is an array of Bombs on this Tile.
    Bombs() []Bomb

    // Dirt is the amount of dirt on this Tile.
    Dirt() int64

    // IsBase is whether or not the Tile is a base Tile.
    IsBase() bool

    // IsFalling is whether or not this Tile is about to fall after
    // this turn.
    IsFalling() bool

    // IsHopper is whether or not a hopper is on this Tile.
    IsHopper() bool

    // IsLadder is whether or not a ladder is built on this Tile.
    IsLadder() bool

    // IsSupport is whether or not a support is built on this Tile.
    IsSupport() bool

    // Miners is an array of the Miners on this Tile.
    Miners() []Miner

    // Ore is the amount of ore on this Tile.
    Ore() int64

    // Owner is the owner of this Tile, or undefined if owned by no-
    // one.
    //
    // Value can be returned as a nil pointer.
    Owner() Player

    // Shielding is the amount of shielding on this Tile.
    Shielding() int64

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

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

type Upgrade

Upgrade is information about a Miner's Upgrade module.

type Upgrade interface {
    // Parent interfaces
    GameObject

    // CargoCapacity is the amount of cargo capacity this Upgrade has.
    CargoCapacity() int64

    // Health is the maximum amount of health this Upgrade has.
    Health() int64

    // MiningPower is the amount of mining power this Upgrade has per
    // turn.
    MiningPower() int64

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

    // Title is the Upgrade title.
    Title() string
}