...

Package stardash

import "joueur/games/stardash"
Overview
Index

Overview ▾

Package stardash contains all the interfaces and AI that are required to represent and play Stardash.

Stardash Game Info ▾

Collect of the most of the rarest mineral orbiting around the sun and out-compete your competitor.

More Info

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

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

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 Body

Body is a celestial body located within the game.

type Body interface {
    // Parent interfaces
    GameObject

    // Amount is the amount of material the object has, or energy if
    // it is a planet.
    Amount() int64

    // BodyType is the type of celestial body it is. Either 'planet',
    // 'asteroid', or 'sun'.
    //
    // Literal Values: "planet", "asteroid", or "sun"
    BodyType() string

    // MaterialType is the type of material the celestial body has.
    // Either 'none', 'genarium', 'rarium', 'legendarium', or
    // 'mythicite'.
    //
    // Literal Values: "none", "genarium", "rarium", "legendarium", or
    // "mythicite"
    MaterialType() string

    // Owner is the Player that owns and can control this Body.
    //
    // Value can be returned as a nil pointer.
    Owner() Player

    // Radius is the radius of the circle that this body takes up.
    Radius() float64

    // X is the x value this celestial body is on.
    X() float64

    // Y is the y value this celestial body is on.
    Y() float64

    // NextX the x value of this body a number of turns from now.
    // (0-how many you want).
    NextX(int64) int64

    // NextY the x value of this body a number of turns from now.
    // (0-how many you want).
    NextY(int64) int64

    // Spawn spawn a unit on some value of this celestial body.
    Spawn(float64, float64, string) bool
}

type Game

Game is collect of the most of the rarest mineral orbiting around the sun and out-compete your competitor.

type Game interface {
    // Parent interfaces
    base.Game

    // Bodies is all the celestial bodies in the game. The first two
    // are planets and the third is the sun. The fourth is the VP
    // asteroid. Everything else is normal asteroids.
    Bodies() []Body

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

    // DashCost is the cost of dashing.
    DashCost() int64

    // DashDistance is the distance traveled each turn by dashing.
    DashDistance() 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

    // GenariumValue is the value of every unit of genarium.
    GenariumValue() float64

    // Jobs is an array of all jobs. The first element is corvette,
    // second is missileboat, third is martyr, fourth is transport,
    // and fifth is miner.
    Jobs() []Job

    // LegendariumValue is the value of every unit of legendarium.
    LegendariumValue() float64

    // MaxAsteroid is the highest amount of material, that can be in a
    // asteroid.
    MaxAsteroid() int64

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

    // MinAsteroid is the smallest amount of material, that can be in
    // a asteroid.
    MinAsteroid() int64

    // MiningSpeed is the rate at which miners grab minerals from
    // asteroids.
    MiningSpeed() int64

    // MythiciteAmount is the amount of mythicite that spawns at the
    // start of the game.
    MythiciteAmount() float64

    // OrbitsProtected is the number of orbit updates you cannot mine
    // the mithicite asteroid.
    OrbitsProtected() int64

    // OreRarityGenarium is the rarity modifier of the most common
    // ore. This controls how much spawns.
    OreRarityGenarium() float64

    // OreRarityLegendarium is the rarity modifier of the rarest ore.
    // This controls how much spawns.
    OreRarityLegendarium() float64

    // OreRarityRarium is the rarity modifier of the second rarest
    // ore. This controls how much spawns.
    OreRarityRarium() float64

    // PlanetEnergyCap is the amount of energy a planet can hold at
    // once.
    PlanetEnergyCap() int64

    // PlanetRechargeRate is the amount of energy the planets restore
    // each round.
    PlanetRechargeRate() int64

    // Players is array of all the players in the game.
    Players() []Player

    // ProjectileRadius is the standard size of ships.
    ProjectileRadius() int64

    // ProjectileSpeed is the amount of distance missiles travel
    // through space.
    ProjectileSpeed() int64

    // Projectiles is every projectile in the game.
    Projectiles() []Projectile

    // RariumValue is the value of every unit of rarium.
    RariumValue() float64

    // RegenerateRate is the regeneration rate of asteroids.
    RegenerateRate() float64

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

    // ShipRadius is the standard size of ships.
    ShipRadius() int64

    // SizeX is the size of the map in the X direction.
    SizeX() int64

    // SizeY is the size of the map in the Y direction.
    SizeY() int64

    // TimeAddedPerTurn is the amount of time (in nano-seconds) added
    // after each player performs a turn.
    TimeAddedPerTurn() float64

    // TurnsToOrbit is the number of turns it takes for a asteroid to
    // orbit the sun. (Asteroids move after each players turn).
    TurnsToOrbit() int64

    // Units is every Unit in the game.
    Units() []Unit
}

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 unit's job.

type Job interface {
    // Parent interfaces
    GameObject

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

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

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

    // Moves is the distance this job can move per turn.
    Moves() int64

    // Range is the distance at which this job can effect things.
    Range() int64

    // Shield is the reserve the martyr use to protect allies.
    Shield() int64

    // Title is the Job title. 'corvette', 'missileboat', 'martyr',
    // 'transport', or 'miner'. (in this order from 0-4).
    //
    // Literal Values: "corvette", "missileboat", "martyr",
    // "transport", or "miner"
    Title() string

    // UnitCost is how much money it costs to spawn a unit.
    UnitCost() int64
}

type Player

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

    // HomeBase is the home base of the player.
    HomeBase() Body

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

    // Money is the amount of money this Player has.
    Money() int64

    // Name is the name of the player.
    Name() string

    // Opponent is this player's opponent in the game.
    Opponent() Player

    // Projectiles is every Projectile owned by this Player. The
    // earlier in the array the older they are.
    Projectiles() []Projectile

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

    // Units is every Unit owned by this Player. The earlier in the
    // array the older they are.
    Units() []Unit

    // VictoryPoints is the number of victory points the player has.
    VictoryPoints() int64

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

type Projectile

Projectile is tracks any projectiles moving through space.

type Projectile interface {
    // Parent interfaces
    GameObject

    // Energy is the remaining health of the projectile.
    Energy() int64

    // Fuel is the amount of remaining distance the projectile can
    // move.
    Fuel() int64

    // Owner is the Player that owns and can control this Projectile.
    //
    // Value can be returned as a nil pointer.
    Owner() Player

    // Target is the unit that is being attacked by this projectile.
    Target() Unit

    // X is the x value this projectile is on.
    X() float64

    // Y is the y value this projectile is on.
    Y() float64
}

type Unit

Unit is a unit in the game. May be a corvette, missleboat, martyr, transport, miner.

type Unit interface {
    // Parent interfaces
    GameObject

    // Acted is whether or not this Unit has performed its action this
    // turn.
    Acted() bool

    // DashX is the x value this unit is dashing to.
    DashX() float64

    // DashY is the y value this unit is dashing to.
    DashY() float64

    // Energy is the remaining health of the unit.
    Energy() int64

    // Genarium is the amount of Genarium ore carried by this unit. (0
    // to job carry capacity - other carried items).
    Genarium() int64

    // IsBusy is tracks whether or not the ship is dashing or Mining.
    // If true, it cannot do anything else.
    IsBusy() bool

    // Job is the Job this Unit has.
    Job() Job

    // Legendarium is the amount of Legendarium ore carried by this
    // unit. (0 to job carry capacity - other carried items).
    Legendarium() int64

    // Moves is the distance this unit can still move.
    Moves() float64

    // Mythicite is the amount of Mythicite carried by this unit. (0
    // to job carry capacity - other carried items).
    Mythicite() int64

    // Owner is the Player that owns and can control this Unit.
    //
    // Value can be returned as a nil pointer.
    Owner() Player

    // Protector is the martyr ship that is currently shielding this
    // ship if any.
    //
    // Value can be returned as a nil pointer.
    Protector() Unit

    // Rarium is the amount of Rarium carried by this unit. (0 to job
    // carry capacity - other carried items).
    Rarium() int64

    // Shield is the shield that a martyr ship has.
    Shield() int64

    // X is the x value this unit is on.
    X() float64

    // Y is the y value this unit is on.
    Y() float64

    // Attack attacks the specified unit.
    Attack(Unit) bool

    // Dash causes the unit to dash towards the designated
    // destination.
    Dash(float64, float64) bool

    // Mine allows a miner to mine a asteroid.
    Mine(Body) bool

    // Move moves this Unit from its current location to the new
    // location specified.
    Move(float64, float64) bool

    // Safe tells you if your ship can move to that location from were
    // it is without clipping the sun.
    Safe(float64, float64) bool

    // Shootdown attacks the specified projectile.
    Shootdown(Projectile) bool

    // Transfer grab materials from a friendly unit. Doesn't use a
    // action.
    Transfer(Unit, int64, string) bool
}