Documentation ¶
Index ¶
- Variables
- func NewBoard(size common.Size, pieces []common.Piece) common.PieceStoragedeprecated
- func Perft(generator PerftMoveGenerator, storage common.PieceStorage, color common.Color, ...) int
- type Colordeprecated
- type Kinddeprecated
- type Movedeprecated
- type MoveGenerator
- type PerftHandler
- type PerftMoveGenerator
- type Piecedeprecated
- type PieceStoragedeprecated
- type Positiondeprecated
- type Sizedeprecated
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Deprecated: use common.ErrKingCapture instead. ErrKingCapture = common.ErrKingCapture )
...
Functions ¶
func NewBoard
deprecated
NewBoard ...
Deprecated: use boards.NewSliceBoard instead.
func Perft ¶
func Perft( generator PerftMoveGenerator, storage common.PieceStorage, color common.Color, deep int, handler PerftHandler, ) int
Perft ...
Types ¶
type Kind
deprecated
Kind ...
Deprecated: use common.Kind instead.
const ( // Deprecated: use common.King instead. King Kind = common.King // Deprecated: use common.Queen instead. Queen Kind = common.Queen // Deprecated: use common.Rook instead. Rook Kind = common.Rook // Deprecated: use common.Bishop instead. Bishop Kind = common.Bishop // Deprecated: use common.Knight instead. Knight Kind = common.Knight // Deprecated: use common.Pawn instead. Pawn Kind = common.Pawn )
...
type Move
deprecated
type MoveGenerator ¶
type MoveGenerator struct{}
MoveGenerator ...
func (MoveGenerator) MovesForColor ¶
func (generator MoveGenerator) MovesForColor( storage common.PieceStorage, color common.Color, ) ([]common.Move, error)
MovesForColor ...
It doesn't guarantee an order of returned moves.
It doesn't take into account possible checks and can generate such moves.
It returns an error only on a king capture.
Example ¶
package main import ( "fmt" "sort" models "github.com/thewizardplusplus/go-chess-models" "github.com/thewizardplusplus/go-chess-models/boards" "github.com/thewizardplusplus/go-chess-models/common" "github.com/thewizardplusplus/go-chess-models/pieces" ) func main() { board := boards.NewMapBoard(common.Size{Width: 5, Height: 5}, []common.Piece{ pieces.NewRook(common.Black, common.Position{File: 2, Rank: 2}), pieces.NewKnight(common.White, common.Position{File: 3, Rank: 3}), pieces.NewPawn(common.White, common.Position{File: 4, Rank: 3}), }) var generator models.MoveGenerator moves, _ := generator.MovesForColor(board, common.White) // sorting only by the final point will be sufficient for the reproducibility // of this example sort.Slice(moves, func(i int, j int) bool { a, b := moves[i].Finish, moves[j].Finish if a.File == b.File { return a.Rank < b.Rank } return a.File < b.File }) for _, move := range moves { fmt.Printf("%+v\n", move) } }
Output: {Start:{File:3 Rank:3} Finish:{File:1 Rank:2}} {Start:{File:3 Rank:3} Finish:{File:1 Rank:4}} {Start:{File:3 Rank:3} Finish:{File:2 Rank:1}} {Start:{File:3 Rank:3} Finish:{File:4 Rank:1}} {Start:{File:4 Rank:3} Finish:{File:4 Rank:4}}
func (MoveGenerator) MovesForPosition ¶
func (generator MoveGenerator) MovesForPosition( storage common.PieceStorage, position common.Position, ) ([]common.Move, error)
MovesForPosition ...
It doesn't take into account possible checks and can generate such moves.
It returns an error only on a king capture.
type PerftMoveGenerator ¶
type PerftMoveGenerator interface { MovesForColor(storage common.PieceStorage, color common.Color) ( []common.Move, error, ) }
PerftMoveGenerator ...
type Piece
deprecated
type PieceStorage
deprecated
type PieceStorage = common.PieceStorage
PieceStorage ...
Deprecated: use common.PieceStorage instead.
type Position
deprecated
type Size
deprecated
Click to show internal directories.
Click to hide internal directories.