Documentation
¶
Index ¶
- Constants
- Variables
- func About() string
- func FmtDummy()
- func GenAttackSquares(sq Square, normFunc func(Square, Square) (Delta, bool)) ([]Square, Bitboard)
- func Mix32Uint64AndUint32(v64 uint64, v32 uint32) uint32
- func PieceMaterialTablesString() string
- func SearchMagic(sq Square, sqs []Square, deltas []Delta, tries int) (int, uint64, bool, int)
- func SlidingAttack(sq Square, deltas []Delta, occup Bitboard) (Bitboard, []Square)
- func Uint32ToByteSlice(v uint32) []byte
- func Uint64ToByteSlice(v uint64) []byte
- type Accum
- type AlphaBetaInfo
- type Bitboard
- func BackwardFill(col Color, bb Bitboard) Bitboard
- func BackwardSpan(col Color, bb Bitboard) Bitboard
- func BishopMobility(kind MoveKind, sq Square, occupUs, occupThem Bitboard) Bitboard
- func East(bb Bitboard) Bitboard
- func FileBb(file int) Bitboard
- func Fill(bb Bitboard) Bitboard
- func ForwardFill(col Color, bb Bitboard) Bitboard
- func ForwardSpan(col Color, bb Bitboard) Bitboard
- func JumpAttack(sq Square, deltas []Delta) Bitboard
- func KingMobility(kind MoveKind, sq Square, occupUs, occupThem Bitboard) Bitboard
- func KnightMobility(kind MoveKind, sq Square, occupUs, occupThem Bitboard) Bitboard
- func LancerMobility(kind MoveKind, ld int, sq Square, occupUs, occupThem Bitboard) Bitboard
- func North(bb Bitboard) Bitboard
- func NorthFill(bb Bitboard) Bitboard
- func NorthSpan(bb Bitboard) Bitboard
- func QueenMobility(kind MoveKind, sq Square, occupUs, occupThem Bitboard) Bitboard
- func RankBb(rank int) Bitboard
- func RookMobility(kind MoveKind, sq Square, occupUs, occupThem Bitboard) Bitboard
- func South(bb Bitboard) Bitboard
- func SouthFill(bb Bitboard) Bitboard
- func SouthSpan(bb Bitboard) Bitboard
- func Translate(sqs []Square, occup uint64) Bitboard
- func West(bb Bitboard) Bitboard
- type CastlingRight
- type CastlingRights
- type Color
- type ColorCastlingRights
- type ColorPawnInfo
- type Delta
- type Figure
- type File
- type KingInfo
- type MagicSquare
- type Magics
- type Move
- type MoveBuff
- type MoveBuffItem
- type MoveKind
- type MoveType
- type MultiPvInfo
- type MultiPvInfos
- type PawnInfo
- type PawnInfoItem
- type Piece
- func (p Piece) Color() Color
- func (p Piece) ColorInverse() Piece
- func (p Piece) FenSymbol() string
- func (p Piece) Figure() Figure
- func (p Piece) IsLancer() bool
- func (l Piece) LancerDirection() int
- func (p Piece) PrettySymbol() string
- func (p Piece) SanLetter() string
- func (p Piece) SanSymbol() string
- func (p Piece) String() string
- func (p Piece) UCI() string
- type PieceMaterialTable
- type PosMoveEntry
- type PosMoveHash
- type Position
- func (pos *Position) AlphaBeta(maxDepth int) Score
- func (pos *Position) AlphaBetaRec(abi AlphaBetaInfo) Score
- func (pos Position) CheckTime() float32
- func (pos *Position) ClearPosMoveTable()
- func (pos *Position) ClearPvTable()
- func (pos *Position) Current() *State
- func (pos *Position) ExecCommand(command string)
- func (pos Position) GameEnd(ply int) (bool, Score)
- func (pos Position) GetPv(maxDepth int) []Move
- func (pos Position) GetPvRec(depthRemaining int, pvSoFar []Move) []Move
- func (pos *Position) Init(variant Variant)
- func (pos Position) IsMateInN() bool
- func (pos Position) Line() string
- func (pos Position) Log(content string)
- func (pos Position) Nps() float32
- func (pos *Position) ParseFen(fen string)
- func (pos *Position) Perf(depth int)
- func (pos *Position) PerfRec(remDepth int)
- func (pos *Position) Pop()
- func (pos Position) PrettyPrintString() string
- func (pos *Position) Print()
- func (pos *Position) PrintBestMove(pv []Move)
- func (pos *Position) Push(move Move)
- func (pos *Position) PushUci(uci string)
- func (pos Position) PvUCI() string
- func (pos *Position) Reset()
- func (pos *Position) Search(maxDepth int)
- func (pos Position) SearchRoot() *State
- func (pos Position) Time() float32
- func (pos Position) TimeMs() int
- func (pos Position) Zobrist() uint64
- type PvEntry
- type PvHash
- type Rank
- type Score
- type Square
- type StackBuff
- type StackBuffEntry
- type State
- func (st State) AddDeltaToSquare(sq Square, delta Delta) (Square, bool)
- func (st State) AppendMove(moves *[]Move, move Move, jailColor Color)
- func (st *State) CalculateOccupancyAndMaterial()
- func (st State) CastlingRank(color Color) Rank
- func (st State) CastlingTargetSquares(color Color, side int) [2]Square
- func (st State) GenBitboardMoves(sq Square, mobility Bitboard, jailColor Color) []Move
- func (st State) GenLancerMoves(color Color, sq Square, mobility Bitboard, keepDir bool, lancerDir int, ...) []Move
- func (st *State) GenMoveBuff()
- func (st State) GenPawnMoves(kind MoveKind, color Color, sq Square, occupUs, occupThem Bitboard, ...) []Move
- func (st State) GenSentryMoves(kind MoveKind, color Color, sq Square, occupUs, occupThem Bitboard, ...) []Move
- func (st State) GenerateMoves() []Move
- func (st *State) GetZobrist() uint64
- func (st State) HasLegalMove() bool
- func (st *State) Init(variant Variant)
- func (st *State) InitStack(nmp bool, pvTable *PvHash, ignoreMoves []Move)
- func (st State) IsCapture(move Move) bool
- func (st State) IsCastlingPartner(fig Figure) bool
- func (st State) IsChecked(color Color) bool
- func (st State) IsCheckedSansExplosion(color Color) bool
- func (st State) IsCheckedThem() bool
- func (st State) IsCheckedUs() bool
- func (st State) IsSquareJailedForColor(sq Square, color Color) bool
- func (st State) KingsAdjacent() bool
- func (st State) LegalMoves(stopAtFirst bool) []Move
- func (st State) LostCastlingDeductionBalance(phase float32) Score
- func (st State) LostCastlingDeductionForColor(color Color, phase float32) Score
- func (st State) LostCastlingDeductionPOV(phase float32) Score
- func (st *State) MakeMove(move Move)
- func (st State) MaterialPOV() Accum
- func (st State) MobilityBalance() Accum
- func (st State) MobilityForColor(color Color) Accum
- func (st State) MobilityForPieceAtSquare(p Piece, sq Square) Accum
- func (st State) MobilityPOV() Accum
- func (st State) MoveLAN(move Move) string
- func (st *State) MoveToSan(move Move) string
- func (st State) MoveToSanBatch(move Move) string
- func (st State) OccupThem() Bitboard
- func (st State) OccupUs() Bitboard
- func (st *State) ParseCastlingRights(crs string)
- func (st *State) ParseDisabledMove(dms string)
- func (st *State) ParseEpSquare(epsqs string)
- func (st *State) ParseFen(fen string) error
- func (st *State) ParseFullmoveNumber(fmns string)
- func (st *State) ParseHalfmoveClock(hmcs string)
- func (st *State) ParsePlacementString(ps string) error
- func (st *State) ParseTurnString(ts string)
- func (st State) Phase() float32
- func (st State) PieceAtSquare(sq Square) Piece
- func (st *State) PopStack(pos *Position) Move
- func (st *State) PopStackBuff() (StackBuffEntry, bool)
- func (st *State) PopulateCastlingRights(crs CastlingRights) CastlingRights
- func (st State) PrettyPlacementString() string
- func (st State) PrettyPrintString() string
- func (st State) PromotionFigures() []Figure
- func (st State) Pslms(kind MoveKind) []Move
- func (st State) PslmsForColor(kind MoveKind, color Color) []Move
- func (st State) PslmsForPieceAtSquare(kind MoveKind, p Piece, sq Square, occupUs, occupThem Bitboard, ...) []Move
- func (st *State) Put(p Piece, sq Square)
- func (st *State) Remove(sq Square)
- func (st State) ReportFen() string
- func (st *State) Reset()
- func (st State) Score() Score
- func (st *State) SetCastlingAbility(newCastlingRighs CastlingRights)
- func (st *State) SetEpSquare(epsq Square)
- func (st *State) SetSideToMove(color Color)
- func (st *State) SetStackBuff(pos *Position, moves []Move)
- func (st *State) UciToMove(uci string) (Move, bool)
- func (st *State) UpdateMaterialBalance()
- type Tokenizer
- func (t *Tokenizer) GetCastlingRights() CastlingRights
- func (t *Tokenizer) GetColor() Color
- func (t *Tokenizer) GetFenPiece() []Piece
- func (t *Tokenizer) GetInt() int
- func (t *Tokenizer) GetSquare() Square
- func (t *Tokenizer) GetToken() (string, bool)
- func (t *Tokenizer) GetTokensUpTo(upTo string) []string
- func (t *Tokenizer) Init(content string)
- type TranspositionTableEntry
- type Variant
- type VariantInfo
- type Wizard
Constants ¶
const ( Normal = MoveType(iota) Promotion SentryPush Castling Null )
const ( PopNull = iota GenAll PopAll GenDone )
stack phases
const ( NoMove = MoveKind(iota) Quiet Violent )
const ( NoFigure = Figure(0) Pawn = Figure(1) Knight = Figure(2) Bishop = Figure(3) Rook = Figure(4) Queen = Figure(5) King = Figure(6) Lancer = Figure(7) LancerN = Figure(8) LancerNE = Figure(9) LancerE = Figure(10) LancerSE = Figure(11) LancerS = Figure(12) LancerSW = Figure(13) LancerW = Figure(14) LancerNW = Figure(15) Sentry = Figure(16) Jailer = Figure(17) FigureArraySize = int(iota) )
const ( NoPiece = Piece(0) DummyPiece = Piece(1) BlackPawn = Piece(2) WhitePawn = Piece(3) BlackKnight = Piece(4) WhiteKnight = Piece(5) BlackBishop = Piece(6) WhiteBishop = Piece(7) BlackRook = Piece(8) WhiteRook = Piece(9) BlackQueen = Piece(10) WhiteQueen = Piece(11) BlackKing = Piece(12) WhiteKing = Piece(13) BlackLancer = Piece(14) WhiteLancer = Piece(15) BlackLancerN = Piece(16) WhiteLancerN = Piece(17) BlackLancerNE = Piece(18) WhiteLancerNE = Piece(19) BlackLancerE = Piece(20) WhiteLancerE = Piece(21) BlackLancerSE = Piece(22) WhiteLancerSE = Piece(23) BlackLancerS = Piece(24) WhiteLancerS = Piece(25) BlackLancerSW = Piece(26) WhiteLancerSW = Piece(27) BlackLancerW = Piece(28) WhiteLancerW = Piece(29) BlackLancerNW = Piece(30) WhiteLancerNW = Piece(31) BlackSentry = Piece(32) WhiteSentry = Piece(33) BlackJailer = Piece(34) WhiteJailer = Piece(35) )
const ( Black = Color(iota) White NoColor ColorArraySize = int(iota) )
const ( SquareA1 = Square(0) SquareB1 = Square(1) SquareC1 = Square(2) SquareD1 = Square(3) SquareE1 = Square(4) SquareF1 = Square(5) SquareG1 = Square(6) SquareH1 = Square(7) SquareA2 = Square(8) SquareB2 = Square(9) SquareC2 = Square(10) SquareD2 = Square(11) SquareE2 = Square(12) SquareF2 = Square(13) SquareG2 = Square(14) SquareH2 = Square(15) SquareA3 = Square(16) SquareB3 = Square(17) SquareC3 = Square(18) SquareD3 = Square(19) SquareE3 = Square(20) SquareF3 = Square(21) SquareG3 = Square(22) SquareH3 = Square(23) SquareA4 = Square(24) SquareB4 = Square(25) SquareC4 = Square(26) SquareD4 = Square(27) SquareE4 = Square(28) SquareF4 = Square(29) SquareG4 = Square(30) SquareH4 = Square(31) SquareA5 = Square(32) SquareB5 = Square(33) SquareC5 = Square(34) SquareD5 = Square(35) SquareE5 = Square(36) SquareF5 = Square(37) SquareG5 = Square(38) SquareH5 = Square(39) SquareA6 = Square(40) SquareB6 = Square(41) SquareC6 = Square(42) SquareD6 = Square(43) SquareE6 = Square(44) SquareF6 = Square(45) SquareG6 = Square(46) SquareH6 = Square(47) SquareA7 = Square(48) SquareB7 = Square(49) SquareC7 = Square(50) SquareD7 = Square(51) SquareE7 = Square(52) SquareF7 = Square(53) SquareG7 = Square(54) SquareH7 = Square(55) SquareA8 = Square(56) SquareB8 = Square(57) SquareC8 = Square(58) SquareD8 = Square(59) SquareE8 = Square(60) SquareF8 = Square(61) SquareG8 = Square(62) SquareH8 = Square(63) )
const ( Rank1 = Rank(0) Rank2 = Rank(1) Rank3 = Rank(2) Rank4 = Rank(3) Rank5 = Rank(4) Rank6 = Rank(5) Rank7 = Rank(6) Rank8 = Rank(7) )
const ( FileA = File(0) FileB = File(1) FileC = File(2) FileD = File(3) FileE = File(4) FileF = File(5) FileG = File(6) FileH = File(7) )
const ( VariantStandard = Variant(iota) VariantEightPiece VariantAtomic )
const ( CastlingSideKing = iota CastlingSideQueen )
const ( CastleWhiteKingIndex = iota CastleWhiteQueenIndex CastleBlackKingIndex CastleBlackQueenIndex )
const ( LANCER_DIRECTION_N = iota LANCER_DIRECTION_NE LANCER_DIRECTION_E LANCER_DIRECTION_SE LANCER_DIRECTION_S LANCER_DIRECTION_SW LANCER_DIRECTION_W LANCER_DIRECTION_NW )
const ATTACK_MULTIPLIER = 25
const BISHOP_WIZARD_INDEX = 0
const BOARD_AREA = NUM_RANKS * NUM_FILES
const COLOR_MASK = White
const CastleArraySize = 4
const ColorMaxValue = NoColor
const ColorMinValue = 0
const FILE_MASK = (1 << FILE_STORAGE_SIZE_IN_BITS) - 1
const FILE_SHIFT_IN_BITS = 0
const FILE_STORAGE_SIZE_IN_BITS = 3
const FROM_SQUARE_SHIFT = 0 // 0
const FigureMaxValue = Jailer
const FigureMinValue = Pawn
const INFINITE_DEPTH = int8(SEARCH_MAX_DEPTH + 1)
const INFINITE_SCORE = Score(20000)
const INITIAL_MATERIAL = 2 * 4220
const LANCER_DIRECTION_MASK = 0b111
const LAST_FILE = NUM_FILES - 1
const LAST_RANK = NUM_RANKS - 1
const LOST_CASTLING_DEDUCTION = 50
const LancerMaxValue = LancerNW
const LancerMinValue = LancerN
const MATE_SCORE = Score(10000)
const MAX_MULTIPV = 20
const MAX_PV_MOVES = 4
const MAX_SCORE = 9000
const MAX_STATES = SEARCH_MAX_DEPTH + 1
const MIN_REDUCE_LIMIT = 8
const MOBILITY_MULTIPLIER = 10
const MOVE_TYPE_MASK = (1 << MOVE_TYPE_STORAGE_SIZE_IN_BITS) - 1
const MOVE_TYPE_SHIFT = PROMOTION_PIECE_SHIFT + PIECE_STORAGE_SIZE_IN_BITS // 24
const MOVE_TYPE_STORAGE_SIZE_IN_BITS = 8
const NUM_FILES = 8
const NUM_LANCER_DIRECTIONS = 8
const NUM_RANKS = 8
const NullMove = Move(Null) << MOVE_TYPE_SHIFT
const PIECE_MASK = (1 << PIECE_STORAGE_SIZE_IN_BITS) - 1
const PIECE_STORAGE_SIZE_IN_BITS = 6
const POS_MOVE_HASH_KEY_SIZE_IN_BITS = 25
const POS_MOVE_HASH_MASK = PV_HASH_SIZE - 1
const POS_MOVE_HASH_SIZE = 1 << PV_HASH_KEY_SIZE_IN_BITS
const PROMOTION_PIECE_SHIFT = PROMOTION_SQUARE_SHIFT + SQUARE_STORAGE_SIZE_IN_BITS // 18
const PROMOTION_SQUARE_SHIFT = TO_SQUARE_SHIFT + SQUARE_STORAGE_SIZE_IN_BITS // 12
const PV_HASH_KEY_SIZE_IN_BITS = 20
const PV_HASH_MASK = PV_HASH_SIZE - 1
const PV_HASH_SIZE = 1 << PV_HASH_KEY_SIZE_IN_BITS
const PieceArraySize = PieceMaxValue - PieceMinValue + 1
const PieceMaxValue = WhiteJailer
const PieceMinValue = BlackPawn
const RANK_MASK = ((1 << RANK_STORAGE_SIZE_IN_BITS) - 1) << RANK_SHIFT_IN_BITS
const RANK_SHIFT_IN_BITS = FILE_STORAGE_SIZE_IN_BITS
const RANK_STORAGE_SIZE_IN_BITS = 3
const ROOK_WIZARD_INDEX = 1
const SEARCH_MAX_DEPTH = 100
const SQUARE_MASK = (1 << SQUARE_STORAGE_SIZE_IN_BITS) - 1
const SQUARE_STORAGE_SIZE_IN_BITS = RANK_STORAGE_SIZE_IN_BITS + FILE_STORAGE_SIZE_IN_BITS
const SquareMaxValue = SquareH8
const SquareMinValue = SquareA1
const TO_SQUARE_SHIFT = SQUARE_STORAGE_SIZE_IN_BITS // 6
Variables ¶
var BISHOP_DELTAS = []Delta{{1, 1}, {1, -1}, {-1, 1}, {-1, -1}}
var BISHOP_MAGICS = Magics{ {SquareA1, 7, 0x00400a4182001490, []Bitboard{}}, {SquareB1, 7, 0x0010008829000c00, []Bitboard{}}, {SquareC1, 7, 0x0044008180080000, []Bitboard{}}, {SquareD1, 7, 0x0094220020000400, []Bitboard{}}, {SquareE1, 7, 0x000048d600000100, []Bitboard{}}, {SquareF1, 7, 0x0004300082601280, []Bitboard{}}, {SquareG1, 7, 0x0044002208600801, []Bitboard{}}, {SquareH1, 7, 0x0040602206d64000, []Bitboard{}}, {SquareA2, 7, 0x0080461220884010, []Bitboard{}}, {SquareB2, 7, 0x0044201800848010, []Bitboard{}}, {SquareC2, 7, 0x0000404084224800, []Bitboard{}}, {SquareD2, 7, 0x00008802c0400184, []Bitboard{}}, {SquareE2, 7, 0x0000009040004002, []Bitboard{}}, {SquareF2, 7, 0x000081c202240021, []Bitboard{}}, {SquareG2, 7, 0x0001320082011000, []Bitboard{}}, {SquareH2, 7, 0x000002e024020080, []Bitboard{}}, {SquareA3, 7, 0x000102024c100440, []Bitboard{}}, {SquareB3, 7, 0x0001044210020200, []Bitboard{}}, {SquareC3, 7, 0x0008040400c40008, []Bitboard{}}, {SquareD3, 8, 0x0000800042004800, []Bitboard{}}, {SquareE3, 8, 0x0001000020080048, []Bitboard{}}, {SquareF3, 8, 0x0000510028004800, []Bitboard{}}, {SquareG3, 7, 0x000a000020806100, []Bitboard{}}, {SquareH3, 7, 0x000020008c028480, []Bitboard{}}, {SquareA4, 7, 0x0004040402018680, []Bitboard{}}, {SquareB4, 7, 0x0009010020380110, []Bitboard{}}, {SquareC4, 8, 0x0000100318004150, []Bitboard{}}, {SquareD4, 12, 0x0004081404060002, []Bitboard{}}, {SquareE4, 10, 0x0000108002100400, []Bitboard{}}, {SquareF4, 9, 0x0008008020082000, []Bitboard{}}, {SquareG4, 7, 0x00080a4000804440, []Bitboard{}}, {SquareH4, 7, 0x0002402042148100, []Bitboard{}}, {SquareA5, 7, 0x02009040e0080200, []Bitboard{}}, {SquareB5, 7, 0x0002010090040808, []Bitboard{}}, {SquareC5, 9, 0x0000080041220040, []Bitboard{}}, {SquareD5, 11, 0x0000022604040100, []Bitboard{}}, {SquareE5, 10, 0x0002004010080200, []Bitboard{}}, {SquareF5, 8, 0x0008120020411000, []Bitboard{}}, {SquareG5, 7, 0x000081c202240021, []Bitboard{}}, {SquareH5, 7, 0x000a022048002201, []Bitboard{}}, {SquareA6, 7, 0x0001648a10084840, []Bitboard{}}, {SquareB6, 7, 0x0000842100802000, []Bitboard{}}, {SquareC6, 8, 0x0201010020804200, []Bitboard{}}, {SquareD6, 8, 0x0000002458000400, []Bitboard{}}, {SquareE6, 7, 0x0000400091000200, []Bitboard{}}, {SquareF6, 7, 0x0040080801200040, []Bitboard{}}, {SquareG6, 7, 0x0003100502000a40, []Bitboard{}}, {SquareH6, 7, 0x000102024c100440, []Bitboard{}}, {SquareA7, 7, 0x0201008043202000, []Bitboard{}}, {SquareB7, 7, 0x00080c1414040000, []Bitboard{}}, {SquareC7, 7, 0x0282009040424800, []Bitboard{}}, {SquareD7, 7, 0x0084400050120000, []Bitboard{}}, {SquareE7, 7, 0x0000001002408000, []Bitboard{}}, {SquareF7, 7, 0x0000042480604000, []Bitboard{}}, {SquareG7, 7, 0x0070228302640200, []Bitboard{}}, {SquareH7, 7, 0x0011080300308084, []Bitboard{}}, {SquareA8, 7, 0x0000440085272000, []Bitboard{}}, {SquareB8, 7, 0x02b0010012018200, []Bitboard{}}, {SquareC8, 7, 0x0200000080802114, []Bitboard{}}, {SquareD8, 7, 0x0011080300308084, []Bitboard{}}, {SquareE8, 7, 0x0002090404008205, []Bitboard{}}, {SquareF8, 7, 0x0020081001101121, []Bitboard{}}, {SquareG8, 7, 0x0200090d00884010, []Bitboard{}}, {SquareH8, 7, 0x00400a4182001490, []Bitboard{}}, }
var BISHOP_VALUE = Accum{300, 320}
var BishopAttack [BOARD_AREA]Bitboard
var CENTER_PAWN_VALUE = Accum{150, 120}
var ColorFigure [2][18]Piece
ColorFigure constructs a Piece from Color and Figure
var ColorOf [36]Color
ColorOf tells the color of a Piece
var FigureOf [36]Figure
var FileLetterOf = [NUM_FILES]string{"a", "b", "c", "d", "e", "f", "g", "h"}
var FileOf [BOARD_AREA]File
FileOf tells the file of a square
var JAILER_VALUE = Accum{400, 420}
var JailerAdjacent [BOARD_AREA]Bitboard
var KING_DELTAS = append(BISHOP_DELTAS, ROOK_DELTAS...)
var KNIGHT_CLOSE_TO_EDGE_DEDUCTION = Accum{25, 25}
var KNIGHT_DELTAS = []Delta{{1, 2}, {1, -2}, {-1, 2}, {-1, -2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}}
var KNIGHT_ON_EDGE_DEDUCTION = Accum{50, 50}
var KNIGHT_VALUE = Accum{300, 300}
var KingArea [BOARD_AREA]Bitboard
var KingAttack [BOARD_AREA]Bitboard
var KnightAttack [BOARD_AREA]Bitboard
var LANCER_DELTAS = []Delta{{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}}
var LANCER_FACING_OUT_VALUE = Accum{0, 0}
var LANCER_HOME_BONUS = Accum{200, 0}
var LANCER_VALUE = Accum{700, 720}
var LancerAttack [BOARD_AREA][NUM_LANCER_DIRECTIONS]Bitboard
var PAWN_VALUE = Accum{100, 120}
var PawnDir = []Rank{-1, 1}
var PawnInfos [BOARD_AREA]ColorPawnInfo
var PawnStartRank = []Rank{6, 1}
var PieceMaterialTables [PieceArraySize + 2]PieceMaterialTable
var PromotionRank = []Rank{0, 7}
var QUEEN_VALUE = Accum{900, 920}
var QueenAttack [BOARD_AREA]Bitboard
var ROOK_DELTAS = []Delta{{1, 0}, {-1, 0}, {0, 1}, {0, -1}}
var ROOK_MAGICS = Magics{ {SquareA1, 14, 0x0004220080104000, []Bitboard{}}, {SquareB1, 14, 0x0018004240681000, []Bitboard{}}, {SquareC1, 14, 0x0030000205102000, []Bitboard{}}, {SquareD1, 14, 0x0200020110208a00, []Bitboard{}}, {SquareE1, 13, 0x0200080401008200, []Bitboard{}}, {SquareF1, 13, 0x0200080401008200, []Bitboard{}}, {SquareG1, 13, 0x0200042060510200, []Bitboard{}}, {SquareH1, 14, 0x0010005080281100, []Bitboard{}}, {SquareA2, 13, 0x0000f00021081400, []Bitboard{}}, {SquareB2, 13, 0x0000020408401000, []Bitboard{}}, {SquareC2, 13, 0x0000900220009000, []Bitboard{}}, {SquareD2, 13, 0x0000400140041200, []Bitboard{}}, {SquareE2, 14, 0x0000080100480340, []Bitboard{}}, {SquareF2, 14, 0x0000040100402210, []Bitboard{}}, {SquareG2, 12, 0x0054000080420328, []Bitboard{}}, {SquareH2, 14, 0x00840800900200c8, []Bitboard{}}, {SquareA3, 13, 0x0000580600148000, []Bitboard{}}, {SquareB3, 13, 0x0000810200085000, []Bitboard{}}, {SquareC3, 13, 0x0000341002100080, []Bitboard{}}, {SquareD3, 13, 0x0000011000104080, []Bitboard{}}, {SquareE3, 13, 0x0000230001000098, []Bitboard{}}, {SquareF3, 14, 0x0000010400002100, []Bitboard{}}, {SquareG3, 14, 0x0001084011000080, []Bitboard{}}, {SquareH3, 13, 0x0000081000400100, []Bitboard{}}, {SquareA4, 13, 0x0001480804001000, []Bitboard{}}, {SquareB4, 14, 0x0000040110000200, []Bitboard{}}, {SquareC4, 13, 0x0000089061000200, []Bitboard{}}, {SquareD4, 13, 0x0000100500024100, []Bitboard{}}, {SquareE4, 14, 0x0000044200004a00, []Bitboard{}}, {SquareF4, 13, 0x0000005200018108, []Bitboard{}}, {SquareG4, 12, 0x0000009400004118, []Bitboard{}}, {SquareH4, 13, 0x0000002030080280, []Bitboard{}}, {SquareA5, 13, 0x0000081100288000, []Bitboard{}}, {SquareB5, 14, 0x0000024200890880, []Bitboard{}}, {SquareC5, 13, 0x0208841042000200, []Bitboard{}}, {SquareD5, 14, 0x0090018802000120, []Bitboard{}}, {SquareE5, 13, 0x0000230001000098, []Bitboard{}}, {SquareF5, 13, 0x000002283000c020, []Bitboard{}}, {SquareG5, 12, 0x0001004204000288, []Bitboard{}}, {SquareH5, 13, 0x0200014002a40010, []Bitboard{}}, {SquareA6, 12, 0x00009080c02a8000, []Bitboard{}}, {SquareB6, 13, 0x0001080090080200, []Bitboard{}}, {SquareC6, 13, 0x0000040e00a02000, []Bitboard{}}, {SquareD6, 13, 0x00002c1201000400, []Bitboard{}}, {SquareE6, 13, 0x00000218400a1800, []Bitboard{}}, {SquareF6, 13, 0x0000040080010400, []Bitboard{}}, {SquareG6, 13, 0x0000010120408004, []Bitboard{}}, {SquareH6, 13, 0x0000004000220802, []Bitboard{}}, {SquareA7, 12, 0x0000832600442a00, []Bitboard{}}, {SquareB7, 13, 0x00004081041a1200, []Bitboard{}}, {SquareC7, 13, 0x000c702008c00200, []Bitboard{}}, {SquareD7, 12, 0x0000200851040200, []Bitboard{}}, {SquareE7, 13, 0x0000100140880200, []Bitboard{}}, {SquareF7, 12, 0x0200080401008200, []Bitboard{}}, {SquareG7, 11, 0x0000020800815400, []Bitboard{}}, {SquareH7, 13, 0x0000001842400320, []Bitboard{}}, {SquareA8, 13, 0x0000c060218a0012, []Bitboard{}}, {SquareB8, 13, 0x0002000480406152, []Bitboard{}}, {SquareC8, 13, 0x00000402080940a2, []Bitboard{}}, {SquareD8, 13, 0x0000020201181022, []Bitboard{}}, {SquareE8, 14, 0x0008012050008402, []Bitboard{}}, {SquareF8, 14, 0x00000081120000aa, []Bitboard{}}, {SquareG8, 12, 0x0000044201080084, []Bitboard{}}, {SquareH8, 13, 0x0000008031004022, []Bitboard{}}, }
var ROOK_VALUE = Accum{500, 520}
var Rand = rand.New(rand.NewSource(1))
var RankFile [NUM_RANKS][NUM_FILES]Square
RankFile constructs a square from rank and file
var RankLetterOf = [NUM_RANKS]string{"1", "2", "3", "4", "5", "6", "7", "8"}
var RankOf [BOARD_AREA]Rank
RankOf tells the rank of a square
var RookAttack [BOARD_AREA]Bitboard
var SEMI_CENTER_PAWN_VALUE = Accum{125, 120}
var SENTRY_VALUE = Accum{320, 320}
var SymbolOf = [18]string{
".",
"p",
"n",
"b",
"r",
"q",
"k",
"l",
"ln",
"lne",
"le",
"lse",
"ls",
"lsw",
"lw",
"lnw",
"s",
"j",
}
SymbolOf tells the symbol of a Figure
var SymbolToPiece = map[string]Piece{ "p": BlackPawn, "P": WhitePawn, "n": BlackKnight, "N": WhiteKnight, "b": BlackBishop, "B": WhiteBishop, "r": BlackRook, "R": WhiteRook, "q": BlackQueen, "Q": WhiteQueen, "k": BlackKing, "K": WhiteKing, "l": BlackLancer, "L": WhiteLancer, "ln": BlackLancerN, "Ln": WhiteLancerN, "lne": BlackLancerNE, "Lne": WhiteLancerNE, "le": BlackLancerE, "Le": WhiteLancerE, "lse": BlackLancerSE, "Lse": WhiteLancerSE, "ls": BlackLancerS, "Ls": WhiteLancerS, "lsw": BlackLancerSW, "Lsw": WhiteLancerSW, "lw": BlackLancerW, "Lw": WhiteLancerW, "lnw": BlackLancerNW, "Lnw": WhiteLancerNW, "s": BlackSentry, "S": WhiteSentry, "j": BlackJailer, "J": WhiteJailer, }
SymbolToPiece tells Piece for a FEN symbol
var TotalMagicEntries int = 0
var UCIOf [BOARD_AREA]string
var UCIToSquare map[string]Square
var VARIANT_NAMES = make([]string, len(VariantInfos))
var VariantInfos = []VariantInfo{
{
StartFen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
DisplayName: "Standard",
},
{
StartFen: "jlsesqkbnr/pppppppp/8/8/8/8/PPPPPPPP/JLneSQKBNR w KQkq - 0 1 -",
DisplayName: "Eightpiece",
},
{
StartFen: "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
DisplayName: "Atomic",
},
}
var Wizards = []Wizard{ { Name: "bishop", Deltas: BISHOP_DELTAS, Tries: 50000, Magics: BISHOP_MAGICS, }, { Name: "rook", Deltas: ROOK_DELTAS, Tries: 50000, Magics: ROOK_MAGICS, }, }
Functions ¶
func GenAttackSquares ¶
func Mix32Uint64AndUint32 ¶
https://github.com/spaolacci/murmur3/blob/539464a789e9b9f01bc857458ffe2c5c1a2ed382/murmur32.go#L106
func PieceMaterialTablesString ¶
func PieceMaterialTablesString() string
func SearchMagic ¶
func SlidingAttack ¶
func Uint32ToByteSlice ¶
Types ¶
type Accum ¶
type AlphaBetaInfo ¶
type Bitboard ¶
type Bitboard uint64
Bitboard is a set representing the 8x8 chess board squares
const ( BbEmpty Bitboard = 0x0000000000000000 BbFull Bitboard = 0xffffffffffffffff BbBorder Bitboard = 0xff818181818181ff BbPawnStartRank Bitboard = 0x00ff00000000ff00 BbPawnStartRankBlack Bitboard = 0x00ff000000000000 BbPawnStartRankWhite Bitboard = 0x000000000000ff00 BbPawnDoubleRank Bitboard = 0x000000ffff000000 BbBlackSquares Bitboard = 0xaa55aa55aa55aa55 BbWhiteSquares Bitboard = 0x55aa55aa55aa55aa )
useful bitboards
func BackwardFill ¶
BackwardFill computes forward fill wrt color
func BackwardSpan ¶
BackwardSpan computes backward span wrt color
func BishopMobility ¶
func ForwardFill ¶
ForwardFill computes forward fill wrt color.
func ForwardSpan ¶
ForwardSpan computes forward span wrt color.
func JumpAttack ¶
func KingMobility ¶
func KnightMobility ¶
func LancerMobility ¶
func QueenMobility ¶
func RookMobility ¶
func (Bitboard) AsSquare ¶
AsSquare returns the occupied square if the bitboard has a single piece if the board has more then one piece the result is undefined https://golang.org/pkg/math/bits/#TrailingZeros64
func (Bitboard) Count ¶
count returns the number of squares set in bb https://golang.org/pkg/math/bits/#OnesCount64
type CastlingRight ¶
type CastlingRights ¶
type CastlingRights [2]ColorCastlingRights
func (CastlingRights) String ¶
func (crs CastlingRights) String() string
CastlingRights.String() reports castling rights in fen format
type ColorCastlingRights ¶
type ColorCastlingRights [2]CastlingRight
func (ColorCastlingRights) CanCastle ¶
func (ccr ColorCastlingRights) CanCastle() bool
type ColorPawnInfo ¶
type ColorPawnInfo [2]PawnInfo
type Delta ¶
type Delta struct {
// contains filtered or unexported fields
}
Delta is a square vector
func NormalizedBishopDirection ¶
NormalizedBishopDirection tells the normalized bishop direction from fromSq to toSq returns true in the second return parameter if such a direction exists, false otherwise
func NormalizedRookDirection ¶
NormalizedRookDirection tells the normalized rook direction from fromSq to toSq returns true in the second return parameter if such a direction exists, false otherwise
type MagicSquare ¶
func (MagicSquare) Key ¶
func (msq MagicSquare) Key(occup Bitboard) uint64
func (MagicSquare) String ¶
func (msq MagicSquare) String() string
type Magics ¶
type Magics [BOARD_AREA]MagicSquare
type Move ¶
type Move uint32
func MakeMoveFT ¶
func MakeMoveFTC ¶
func MakeMoveFTP ¶
func (Move) PromotionPiece ¶
func (Move) PromotionSquare ¶
type MultiPvInfo ¶
type MultiPvInfo struct { Index int Depth int Time int Nodes int Nps float32 Score Score Pv []Move PvUCI string }
func (MultiPvInfo) String ¶
func (mpi MultiPvInfo) String() string
type MultiPvInfos ¶
type MultiPvInfos [MAX_MULTIPV]MultiPvInfo
type PawnInfo ¶
type PawnInfo struct { Dir Rank Pushes []PawnInfoItem Captures []PawnInfoItem PushOneSq Square CheckEps []Square }
type PawnInfoItem ¶
type Piece ¶
type Piece int
func MakeLancer ¶
func (Piece) ColorInverse ¶
ColorInverse tells the color inverse of a piece
func (Piece) LancerDirection ¶
func (Piece) PrettySymbol ¶
PrettySymbol tells the pretty print symbol of a Piece
type PieceMaterialTable ¶
type PieceMaterialTable [BOARD_AREA]Accum
func (*PieceMaterialTable) Fill ¶
func (mt *PieceMaterialTable) Fill(accum Accum)
func (PieceMaterialTable) POV ¶
func (mt PieceMaterialTable) POV(color Color) PieceMaterialTable
POV returns material table from point of view of color
func (PieceMaterialTable) String ¶
func (pmt PieceMaterialTable) String() string
type PosMoveEntry ¶
type PosMoveHash ¶
type PosMoveHash struct {
Entries [POS_MOVE_HASH_SIZE]PosMoveEntry
}
var PosMoveTable PosMoveHash
func (*PosMoveHash) Get ¶
func (pmh *PosMoveHash) Get(zobrist uint64, move Move) (uint32, PosMoveEntry)
func (*PosMoveHash) Set ¶
func (pmh *PosMoveHash) Set(zobrist uint64, move Move, pme PosMoveEntry)
type Position ¶
type Position struct { States [MAX_STATES]State StatePtr int SearchRootPtr int MaxStatePtr int Nodes int SearchStopped bool NullMovePruning bool NullMovePruningMinDepth int NullMoveDepthReduction int StackReduction bool AspirationWindow bool PvTable *PvHash PosMoveTable *PosMoveHash LastRootPvScore Score LastGoodPv []Move Start time.Time CheckPoint time.Time Depth int Verbose bool IgnoreRootMoves []Move PruningAgressivity int PruningReduction int MultiPV int MultiPvInfos MultiPvInfos OldMultiPvInfos MultiPvInfos MultiPvIndex int LogFilePath string }
func (*Position) AlphaBetaRec ¶
func (pos *Position) AlphaBetaRec(abi AlphaBetaInfo) Score
func (*Position) ClearPosMoveTable ¶
func (pos *Position) ClearPosMoveTable()
func (*Position) ClearPvTable ¶
func (pos *Position) ClearPvTable()
func (*Position) ExecCommand ¶
func (Position) PrettyPrintString ¶
func (*Position) PrintBestMove ¶
func (Position) SearchRoot ¶
type Square ¶
type Square uint
type StackBuff ¶
type StackBuff []StackBuffEntry
type StackBuffEntry ¶
type State ¶
type State struct { Variant Variant Pieces [NUM_RANKS][NUM_FILES]Piece Turn Color CastlingRights CastlingRights EpSquare Square HalfmoveClock int FullmoveNumber int HasDisabledMove bool DisableFromSquare Square DisableToSquare Square ByFigure [FigureArraySize]Bitboard ByLancer Bitboard ByColor [ColorArraySize]Bitboard Ply int Move Move MoveBuff MoveBuff Material [ColorArraySize]Accum Zobrist uint64 KingInfos [ColorArraySize]KingInfo StackPhase int StackBuff StackBuff StackPvMoves [MAX_PV_MOVES]Move StackReduceFrom int StackReduceDepth int StackReduceFactor int LostCastlingForColor [ColorArraySize]bool StackIgnoreMoves []Move }
State records the state of a position
func (State) AddDeltaToSquare ¶
func (*State) CalculateOccupancyAndMaterial ¶
func (st *State) CalculateOccupancyAndMaterial()
func (State) CastlingRank ¶
func (State) CastlingTargetSquares ¶
func (State) GenBitboardMoves ¶
func (State) GenLancerMoves ¶
func (*State) GenMoveBuff ¶
func (st *State) GenMoveBuff()
func (State) GenPawnMoves ¶
func (State) GenSentryMoves ¶
func (State) GenerateMoves ¶
func (*State) GetZobrist ¶
Zobrist returns the zobrist key of the position, never returns 0
func (State) HasLegalMove ¶
func (State) IsCastlingPartner ¶
func (State) IsCheckedSansExplosion ¶
func (State) IsCheckedThem ¶
func (State) IsCheckedUs ¶
func (State) IsSquareJailedForColor ¶
func (State) KingsAdjacent ¶
func (State) LegalMoves ¶
func (State) LostCastlingDeductionBalance ¶
func (State) LostCastlingDeductionForColor ¶
func (State) LostCastlingDeductionPOV ¶
func (State) MaterialPOV ¶
func (State) MobilityBalance ¶
func (State) MobilityForColor ¶
func (State) MobilityForPieceAtSquare ¶
func (State) MobilityPOV ¶
func (State) MoveToSanBatch ¶
func (*State) ParseCastlingRights ¶
func (*State) ParseDisabledMove ¶
func (*State) ParseEpSquare ¶
func (*State) ParseFullmoveNumber ¶
func (*State) ParseHalfmoveClock ¶
func (*State) ParsePlacementString ¶
ParsePlacementString parses a placement string and sets pieces accordingly returns an error if there are not enough pieces to fill the board liberal otherwise
func (*State) ParseTurnString ¶
func (State) PieceAtSquare ¶
func (*State) PopStackBuff ¶
func (st *State) PopStackBuff() (StackBuffEntry, bool)
func (*State) PopulateCastlingRights ¶
func (st *State) PopulateCastlingRights(crs CastlingRights) CastlingRights
PopulateCastlingRights determines castling rights information based on piece placement also does sanity check
func (State) PrettyPlacementString ¶
PrettyPlacementString returns the pretty string representation of the board
func (State) PrettyPrintString ¶
PrettyPrintString returns the state pretty print string
func (State) PromotionFigures ¶
func (State) PslmsForPieceAtSquare ¶
func (*State) SetCastlingAbility ¶
func (st *State) SetCastlingAbility(newCastlingRighs CastlingRights)
SetCastlingAbility sets the side to move, correctly updating the Zobrist key
func (*State) SetEpSquare ¶
SetEnpassantSquare sets the en passant square correctly updating the Zobrist key
func (*State) SetSideToMove ¶
SetSideToMove sets the side to move, correctly updating the Zobrist key
func (*State) SetStackBuff ¶
func (*State) UpdateMaterialBalance ¶
func (st *State) UpdateMaterialBalance()
type Tokenizer ¶
type Tokenizer struct {
Content string
}
func (*Tokenizer) GetCastlingRights ¶
func (t *Tokenizer) GetCastlingRights() CastlingRights