Documentation
¶
Index ¶
- Constants
- func Perft(g Game, depth int) int
- type Action
- type Board
- type Color
- type Game
- func (g Game) Clone() Game
- func (g Game) DoAction(a Action) Game
- func (g Game) King(c color) Piece
- func (g Game) PieceAt(xy XY) Piece
- func (g Game) Pieces(c color) []Piece
- func (g Game) PositionHistory() []uint64
- func (g Game) String() string
- func (g Game) ToBoard() Board
- func (g Game) ToFEN() string
- func (g Game) Turn() color
- func (g Game) WithPositionHistory(history []uint64) Game
- type GameStep
- type Piece
- type PieceType
- type XY
Constants ¶
const ( PieceNone = iota PieceQueen PieceKing PieceBishop PieceKnight PieceRook PiecePawn )
const ( ColorBlack = iota ColorWhite )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct {
FromPiece Piece
ToXY XY
IsCapture bool
IsResign bool
IsDraw bool
IsPromotion bool
IsEnPassantCapture bool
IsCastle bool
IsKingsideCastle bool
IsQueensideCastle bool
PromotionPieceType PieceType
CapturedPiece Piece
}
func (Action) DebugString ¶
type Color ¶
type Color = color
Color is the exported name for the color of a player or piece (e.g. core.ColorWhite).
type Game ¶
type Game struct {
CanWhiteCastle bool
CanWhiteKingsideCastle bool
CanWhiteQueensideCastle bool
CanBlackCastle bool
CanBlackKingsideCastle bool
CanBlackQueensideCastle bool
HalfMoveClock int
FullMoveNumber int
IsLastMoveEnPassant bool
EnPassantTargetSquare XY
MoveNumber int
IsCheck bool
IsDoubleCheck bool
IsDiscoverCheck bool
IsCheckmate bool
IsStalemate bool
IsDraw bool
CanClaimDraw bool
IsGameOver bool
GameOverWinner color
InCheckBy []Piece
Actions []Action
// contains filtered or unexported fields
}
func NewDefaultGame ¶
func NewDefaultGame() Game
func NewGameFromBoard ¶
func NewGameFromFEN ¶
func (Game) DoAction ¶
doAction executes the given action on the given game. It assumes that the game is in a state where this action can be executed. It assumes that the action is fully-correctly created and it's valid. It fully updates the game context. This is an expensive method (due to having to check for check and checkmate), so use only if needed.
func (Game) PieceAt ¶
PieceAt returns the piece at the given square, or the zero Piece (PieceNone) if empty.
func (Game) PositionHistory ¶
PositionHistory returns the Zobrist hashes of the positions reached since the last irreversible move, most recent last. It can be persisted and restored via WithPositionHistory to detect repetitions across stateless API calls.
func (Game) WithPositionHistory ¶
WithPositionHistory returns a copy of the game whose position history is the given hashes (as returned by PositionHistory of a previous game), and with draw flags recalculated accordingly. The current position is appended if it isn't already the last entry, so both "history up to and including this position" and "history of prior positions" are accepted.
type GameStep ¶
type PieceType ¶
type PieceType int