...

Package chess

import "joueur/games/chess"
Overview
Index

Overview ▾

Package chess contains all the interfaces and AI that are required to represent and play Chess.

Chess Game Info ▾

The traditional 8x8 chess board with pieces.

More Info

The full game rules for Chess 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) MakeMove

func (ai *AI) MakeMove() string

MakeMove this is called every time it is this AI.player's turn to make a move.

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

Game is the traditional 8x8 chess board with pieces.

type Game interface {
    // Parent interfaces
    base.Game

    // Fen is forsyth-Edwards Notation (fen), a notation that
    // describes the game board state.
    Fen() string

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

    // History is the array of [known] moves that have occurred in the
    // game, in Universal Chess Interface (UCI) format. The first
    // element is the first move, with the last element being the most
    // recent.
    History() []string

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

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

    // Color is the color (side) of this player. Either 'white' or
    // 'black', with the 'white' player having the first move.
    //
    // Literal Values: "black" or "white"
    Color() string

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