Documentation ¶
Index ¶
- Constants
- func AllMoves(board *Board, color Color, previousMove Move, previousMover *Piece, ...) map[Position]bool
- type Board
- type Color
- type Game
- func (game *Game) BlackKing() *Piece
- func (game *Game) BlackPieces() map[PieceType]uint8
- func (game *Game) BoardString() string
- func (game *Game) GameOver() bool
- func (game *Game) GetBoard() *Board
- func (game *Game) GetSerializableBoard() SerializableBoard
- func (game *Game) MarshalBinary() (data []byte, err error)
- func (game *Game) Move(moveRequest MoveRequest) error
- func (game *Game) OnlyKing(color Color) bool
- func (game *Game) PointAdvantage(color Color) int8
- func (game *Game) PositionHistory() map[string]uint8
- func (game *Game) PreviousMove() Move
- func (game *Game) PreviousMover() *Piece
- func (game *Game) Result() GameResult
- func (game *Game) SetGameResult(winner Color, draw bool)
- func (game *Game) Turn() Color
- func (game *Game) TurnsSinceCaptureOrPawnMove() uint8
- func (game *Game) WhiteKing() *Piece
- func (game *Game) WhitePieces() map[PieceType]uint8
- type GameResult
- type Move
- type MoveRequest
- type Piece
- func (piece *Piece) ClientString() string
- func (piece *Piece) File() uint8
- func (piece *Piece) IsMoveValid(board *Board, move Move, previousMove Move, previousMover *Piece, king *Piece, ...) bool
- func (piece *Piece) MarshalBinary(board *Board, previousMove Move, previousMover *Piece, king *Piece) (data []byte, err error)
- func (piece *Piece) Moves(board *Board, previousMove Move, previousMover *Piece, allThreatened bool, ...) []Position
- func (piece *Piece) Rank() uint8
- func (piece *Piece) String() string
- func (piece *Piece) StringSimple() string
- func (piece *Piece) ValidMoves(board *Board, previousMove Move, previousMover *Piece, allThreatened bool, ...) []Move
- func (piece *Piece) Value() int8
- type PieceType
- type Position
- type SerializableBoard
Constants ¶
const ( // Black is one of the two chess colors Black = Color(iota) // White is one of the two chess colors White = Color(iota) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game is a struct representing a chess game
func NewCustomGame ¶
func NewCustomGame(serializableBoard SerializableBoard, blackKing Piece, whiteKing Piece, positionHistory map[string]uint8, blackPieces map[PieceType]uint8, whitePieces map[PieceType]uint8, turn Color, gameOver bool, result GameResult, previousMove Move, previousMover Piece, turnsSinceCaptureOrPawnMove uint8) *Game
NewCustomGame create a new custom game
func (*Game) BlackPieces ¶
BlackPieces get the game's black pieces
func (*Game) BoardString ¶
BoardString get the board's string
func (*Game) GetSerializableBoard ¶
func (game *Game) GetSerializableBoard() SerializableBoard
GetSerializableBoard get the game's board
func (*Game) MarshalBinary ¶
MarshalBinary represent the game as a byte array
func (*Game) PointAdvantage ¶
PointAdvantage get the color's point advantage
func (*Game) PositionHistory ¶
PositionHistory get the game's position history
func (*Game) PreviousMove ¶
PreviousMove get the game's previous move
func (*Game) PreviousMover ¶
PreviousMover get the game's previous mover
func (*Game) SetGameResult ¶
SetGameResult set the game's result
func (*Game) TurnsSinceCaptureOrPawnMove ¶
TurnsSinceCaptureOrPawnMove get the game's number of turns since a capture or pawn move
func (*Game) WhitePieces ¶
WhitePieces get the game's white pieces
type GameResult ¶
GameResult is a struct representing the result of a game
type MoveRequest ¶
MoveRequest is a move request that can be applied to a game
func (MoveRequest) String ¶
func (mr MoveRequest) String() string
type Piece ¶
Piece a chess piece
func (*Piece) ClientString ¶
ClientString return the piece's client string
func (*Piece) IsMoveValid ¶
func (piece *Piece) IsMoveValid( board *Board, move Move, previousMove Move, previousMover *Piece, king *Piece, promoteTo *PieceType, ) bool
IsMoveValid determines whether a move is valid
func (*Piece) MarshalBinary ¶
func (piece *Piece) MarshalBinary( board *Board, previousMove Move, previousMover *Piece, king *Piece, ) (data []byte, err error)
MarshalBinary return the piece's representation as a byte array
func (*Piece) Moves ¶
func (piece *Piece) Moves( board *Board, previousMove Move, previousMover *Piece, allThreatened bool, king *Piece, ) []Position
Moves get all the valid moves or all the threatening moves for a piece
func (*Piece) StringSimple ¶
StringSimple return the piece's simple string representation
type Position ¶
type Position struct {
File, Rank uint8
}
Position is a struct representing a chess piece's position
type SerializableBoard ¶
type SerializableBoard []Piece
SerializableBoard is a chess board of pieces that can be serialized