Documentation
¶
Index ¶
Constants ¶
const WinThreshold = 6
WinThreshold is the number of captures needed to win
Variables ¶
var ( DirE = Hex{1, 0} DirW = Hex{-1, 0} DirNE = Hex{1, -1} DirSW = Hex{-1, 1} DirNW = Hex{0, -1} DirSE = Hex{0, 1} AllDirections = []Hex{DirE, DirW, DirNE, DirSW, DirNW, DirSE} )
Direction constants for the 6 hex directions
var ( ErrInvalidMarbleCount = errors.New("must move 1, 2, or 3 marbles") ErrNotYourMarble = errors.New("can only move your own marbles") ErrNotCollinear = errors.New("marbles must be adjacent and collinear") ErrInvalidDirection = errors.New("invalid direction") ErrMoveBlocked = errors.New("move is blocked") ErrCannotPush = errors.New("cannot push: no numerical superiority") ErrGameOver = errors.New("game is over") ErrPushBlocked = errors.New("push blocked: no space behind opponent marbles") )
Functions ¶
Types ¶
type Board ¶
Board represents the Abalone hex board Valid cells satisfy |q| <= 4, |r| <= 4, |q+r| <= 4 (61 cells total)
type Game ¶
type Game struct {
Board *Board
Turn Cell // Black or White
CapturedBlack int // black marbles pushed off (white's score)
CapturedWhite int // white marbles pushed off (black's score)
Winner Cell // Empty if game ongoing
}
Game holds the full game state
func (*Game) CheckWinner ¶
func (g *Game) CheckWinner()
CheckWinner updates the Winner field if someone has won