Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultGameStateColour() uint8
- func LSB(x uint64) int
- func NLSB(x *uint64, i int) int
- func Perft()
- type GameState
- type Iterator
- type Move
- func (m *Move) ButterflyIndex() uint16
- func (m *Move) Equal(a *Move) bool
- func (m *Move) Flags() uint16
- func (m *Move) From() uint16
- func (m *Move) GetMove() uint16
- func (m *Move) HasCapture() bool
- func (m *Move) HasPromotion() bool
- func (m *Move) HasSpecial1() bool
- func (m *Move) IsBishopPromoCapture() bool
- func (m *Move) IsBishopPromotion() bool
- func (m *Move) IsCheck() bool
- func (m *Move) IsDoublePawnPush() bool
- func (m *Move) IsEPCapture() bool
- func (m *Move) IsKingCastle() bool
- func (m *Move) IsKnightPromoCapture() bool
- func (m *Move) IsKnightPromotion() bool
- func (m *Move) IsQueenCastle() bool
- func (m *Move) IsQueenPromoCapture() bool
- func (m *Move) IsQueenPromotion() bool
- func (m *Move) IsQuietMoves() bool
- func (m *Move) IsRookPromoCapture() bool
- func (m *Move) IsRookPromotion() bool
- func (m *Move) Not(a *Move) bool
- func (m *Move) SetFlags(flags uint16)
- func (m *Move) SetFrom(from uint16)
- func (m *Move) SetMove(move uint16)
- func (m *Move) SetMoveFromInstance(m2 *Move)
- func (m *Move) SetTo(to uint16)
- func (m *Move) String() string
- func (m *Move) To() uint16
- type MoveGen
- func (mg *MoveGen) AddMove(move uint16)
- func (mg *MoveGen) Clear()
- func (mg *MoveGen) CreateIterator() *MoveGenIterator
- func (mg *MoveGen) GenerateKnightMoves() uint64
- func (mg *MoveGen) GenerateMoves()
- func (mg *MoveGen) GeneratePawnMoves() uint64
- func (mg *MoveGen) GetMove(index uint) uint16
- func (mg *MoveGen) SetMove(move uint16, index int)
- func (mg *MoveGen) SetState(st *GameState)
- func (mg *MoveGen) Size() uint
- type MoveGenIterator
Constants ¶
const BBishop uint64 = 2594073385365405696
BBishop black bishops
const BKing uint64 = 576460752303423488
BKing black king
const BKnight uint64 = 4755801206503243776
BKnight black knight
const BPawn uint64 = 71776119061217280
BPawn black pawn
BPieces all the black pieces concated
const BQueen uint64 = 1152921504606846976
BQueen black queen
const BRook uint64 = 9295429630892703744
BRook black rooks
const FlagCapture uint16 = 16384 // 0b0100000000000000
FlagCapture capture bit
const FlagPromotion uint16 = 32768 // 0b1000000000000000
FlagPromotion promotion bit
const FlagSpecial0 uint16 = 4096 // 0b0001000000000000
FlagSpecial0 special2 bit
const FlagSpecial1 uint16 = 8192 // 0b0010000000000000
FlagSpecial1 special1 bit
const MaxMoves = 256
MaxMoves per round
const RangeFlag uint16 = 61440 // 0b1111000000000000
RangeFlag bit range of all bit positions used for flags
const RangeFrom uint16 = 4032 // 0b0000111111000000
RangeFrom bit range which holds the From position as a uint8 position
const RangeTo uint16 = 63 // 0b0000000000111111
RangeTo bit range which holds the To position as a uint8 position
const WBishop uint64 = 36
WBishop white bishops
const WKing uint64 = 8
WKing white king
const WKnight uint64 = 66
WKnight white knights
const WPawn uint64 = 65280
WPawn white pawns
WPieces all the white pieces concated
const WQueen uint64 = 16
WQueen white queen
const WRook uint64 = 129
WRook white rooks
Variables ¶
var KnightMoves = [64]uint64{
0x20400, 0x50800, 0xa1100, 0x142200, 0x284400, 0x508800, 0xa01000, 0x402000,
0x2040004, 0x5080008, 0xa110011, 0x14220022, 0x28440044, 0x50880088, 0xa0100010, 0x40200020,
0x204000402, 0x508000805, 0xa1100110a, 0x1422002214, 0x2844004428, 0x5088008850, 0xa0100010a0, 0x4020002040,
0x20400040200, 0x50800080500, 0xa1100110a00, 0x142200221400, 0x284400442800, 0x508800885000, 0xa0100010a000, 0x402000204000,
0x2040004020000, 0x5080008050000, 0xa1100110a0000, 0x14220022140000, 0x28440044280000, 0x50880088500000, 0xa0100010a00000, 0x40200020400000,
0x204000402000000, 0x508000805000000, 0xa1100110a000000, 0x1422002214000000, 0x2844004428000000, 0x5088008850000000, 0xa0100010a0000000, 0x4020002040000000,
0x400040200000000, 0x800080500000000, 0x1100110a00000000, 0x2200221400000000, 0x4400442800000000, 0x8800885000000000, 0x100010a000000000, 0x2000204000000000,
0x4020000000000, 0x8050000000000, 0x110a0000000000, 0x22140000000000, 0x44280000000000, 0x88500000000000, 0x10a00000000000, 0x20400000000000,
}
Functions ¶
func DefaultGameStateColour ¶
func DefaultGameStateColour() uint8
Types ¶
type GameState ¶
type GameState struct {
// contains filtered or unexported fields
}
func NewGameState ¶
func NewGameState() *GameState
func (*GameState) BasicOutput ¶
BasicOutput uses letters to indicate pieces
func (*GameState) PrettyOutput ¶
PrettyOutput uses unicodes to indicate pieces
type Move ¶
type Move struct {
// contains filtered or unexported fields
}
Move is used to hold a move and manipulate or extract data from it
func NewMoveDetail ¶
NewMoveDetail creates a new encoded move based on primitive values
func (*Move) IsBishopPromoCapture ¶
IsBishopPromoCapture ...
func (*Move) IsKnightPromoCapture ¶
IsKnightPromoCapture ...
func (*Move) IsQueenPromoCapture ¶
IsQueenPromoCapture ...
func (*Move) SetMoveFromInstance ¶
SetMoveFromInstance ...
type MoveGen ¶
type MoveGen struct {
// contains filtered or unexported fields
}
MoveGen chess move generator
func NewMoveGenByState ¶
NewMoveGenByState creates a new movegen instance using the following state
func (*MoveGen) CreateIterator ¶
func (mg *MoveGen) CreateIterator() *MoveGenIterator
CreateIterator Iterator pattern
func (*MoveGen) GenerateKnightMoves ¶
GenerateKnightMoves ...
func (*MoveGen) GenerateMoves ¶
func (mg *MoveGen) GenerateMoves()
GenerateMoves generates all the moves for an active player
func (*MoveGen) GeneratePawnMoves ¶
type MoveGenIterator ¶
type MoveGenIterator struct {
// contains filtered or unexported fields
}
MoveGenIterator chess move generator
func NewMoveGenIterator ¶
func NewMoveGenIterator(i, size uint, mg *MoveGen) *MoveGenIterator
NewMoveGenIterator Creates an iterator for MoveGen
func (*MoveGenIterator) Begin ¶
func (it *MoveGenIterator) Begin() uint
Begin [iterator] return the first element
func (*MoveGenIterator) End ¶
func (it *MoveGenIterator) End() uint
End [iterator] return the element after the last
func (*MoveGenIterator) GetIndex ¶
func (it *MoveGenIterator) GetIndex() uint
GetIndex returns the current iterator index (progress)
func (*MoveGenIterator) GetMove ¶
func (it *MoveGenIterator) GetMove() uint16
GetMove explicit to MoveGen and returns an encoded chess move
func (*MoveGenIterator) Good ¶
func (it *MoveGenIterator) Good() bool
Good checks if the iteration is within bounds
func (*MoveGenIterator) Next ¶
func (it *MoveGenIterator) Next() uint
Next [iterator] get the next index