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) GotCaptured( checker Checker, )
GotCaptured this is called whenever your checker gets captured (during an opponent's turn).
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.
Checker is a checker on the game board.
type Checker interface { // Parent interfaces GameObject // Kinged is if the checker has been kinged and can move // backwards. Kinged() bool // Owner is the player that controls this Checker. Owner() Player // X is the x coordinate of the checker. X() int64 // Y is the y coordinate of the checker. Y() int64 // IsMine returns if the checker is owned by your player or not. IsMine() bool // Move moves the checker from its current location to the given // (x, y). Move(int64, int64) Checker }
Game is the simple version of American Checkers. An 8x8 board with 12 checkers on each side that must move diagonally to the opposing side until kinged.
type Game interface { // Parent interfaces base.Game // BoardHeight is the height of the board for the Y component of a // checker. BoardHeight() int64 // BoardWidth is the width of the board for X component of a // checker. BoardWidth() int64 // CheckerMoved is the checker that last moved and must be moved // because only one checker can move during each players turn. // // Value can be returned as a nil pointer. CheckerMoved() Checker // CheckerMovedJumped is if the last checker that moved jumped, // meaning it can move again. CheckerMovedJumped() bool // Checkers is all the checkers currently in the game. Checkers() []Checker // 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 // 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 // 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 // TimeAddedPerTurn is the amount of time (in nano-seconds) added // after each player performs a turn. TimeAddedPerTurn() float64 }
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) }
Player is a player in this game. Every AI controls one player.
type Player interface { // Parent interfaces GameObject // Checkers is all the checkers currently in the game owned by // this player. Checkers() []Checker // 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 // 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 // YDirection is the direction your checkers must go along the // y-axis until kinged. YDirection() int64 }