chessEngine

package
v0.0.0-...-d1c4c0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CheckmateScore int16 = 10000

	DrawishPositionScaleFactor int16 = 16
)
View Source
const (
	MinimumExpectedPliesLeft                 = 10
	AverageExpectedPliesLeft                 = 40
	MinimumMoveTimeAllocation                = 100
	AverageAdjustMoveTime                    = 150
	MoveAllocatedTimeOfRemainingTimeFraction = 8
)
View Source
const (
	DefaultTableSize = 64 * 1024 * 1024
	EntriesPerIndex  = 2
	EntrySize        = 16

	UpperBoundEntryType uint8 = 1
	LowerBoundEntryType uint8 = 2
	ExactEntryType      uint8 = 3

	MateThreshold = 9000
)
View Source
const (
	NumOfKillerMoves                                   = 2
	MaximumNumberOfPlies                               = 1024
	EssentialMovesOffset                        uint16 = math.MaxUint16 - 256
	PvMoveScore                                 uint16 = 65
	KillerMoveFirstSlotScore                    uint16 = 10
	KillerMoveSecondSlotScore                   uint16 = 20
	CounterMoveScore                            uint16 = 5
	HistoryHeuristicScoreUpperBound                    = int32(EssentialMovesOffset - 30)
	AspirationWindowOffset                      int16  = 35
	AspirationWindowMissTimeExtensionLowerBound        = 6
	StaticNullMovePruningPenalty                int16  = 85
	NullMovePruningDepthLimit                   int8   = 2
	RazoringDepthUpperBound                     int8   = 2
	FutilityPruningDepthUpperBound              int8   = 8
	InternalIterativeDeepeningDepthLowerBound   int8   = 4
	InternalIterativeDeepeningReductionAmount   int8   = 2
	LateMovePruningDepthUpperBound              int8   = 5
	FutilityPruningLegalMovesLowerBound         int    = 1
	SingularExtensionDepthLowerBound            int8   = 4
	SingularMoveExtensionPenalty                int16  = 125
	SignularMoveExtensionAmount                 int8   = 1
	LateMoveReductionLegalMoveLowerBound        int    = 4
	LateMoveReductionDepthLowerBound            int8   = 3
)
View Source
const (
	PawnPhaseIncrement   int16 = 0
	KnightPhaseIncrement int16 = 1
	BishopPhaseIncrement int16 = 1
	RookPhaseIncrement   int16 = 2
	QueenPhaseIncrement  int16 = 4
	TotalPhaseIncrement  int16 = PawnPhaseIncrement*16 + KnightPhaseIncrement*4 + BishopPhaseIncrement*4 + RookPhaseIncrement*4 + QueenPhaseIncrement*2
)
View Source
const (
	MidGameIsolatedPawnPenalty int16 = 17
	EndGameIsolatedPawnPenalty int16 = 6
	MidGameDoubledPawnPenalty  int16 = 1
	EndGameDoubledPawnPenalty  int16 = 16

	MidGameKnightOnOutpostBonus int16 = 27
	EndGameKnightOnOutpostBonus int16 = 18
	MidGameBishopOnOutpostBonus int16 = 10
	EndGameBishopOnOutpostBonus int16 = 14
	MidGameBishopPairBonus      int16 = 22
	EndgameBishopPairBonus      int16 = 30

	EndGameBonusForRookOrQueenOnSeventhRank int16 = 23
	MidGameRookOnOpenFileBonus              int16 = 23

	MidGameTempoBonus int16 = 14
)
View Source
const (
	CaptureMoveType   uint8 = 0
	CastleMoveType    uint8 = 1
	PromotionMoveType uint8 = 2
	QuietMoveType     uint8 = 3

	PromotionToKnight uint8 = 0
	PromotionToBishop uint8 = 1
	PromotionToRook   uint8 = 2
	PromotionToQueen  uint8 = 3

	EnPassant uint8 = 1

	MoveTypeMask   = 0xc0000000
	MoveInfoMask   = 0x30000000
	FromSquareMask = 0x0fc00000
	ToSquareMask   = 0x003f0000
	ScoreMask      = 0x0000ffff
	NoScoreMask    = 0xffff0000

	MoveTypeOffset   = 30
	MoveInfoOffset   = 28
	FromSquareOffset = 22
	ToSquareOffset   = 16

	NullMove Move = 0
)
View Source
const (
	WhiteKingSideCastlingSquaresMask  = 0x600000000000000
	WhiteQueenSideCastlingSquaresMask = 0x7000000000000000
	BlackKingSideCastlingSquaresMask  = 0x6
	BlackQueenSideCastlingSquaresMask = 0x70
)
View Source
const (
	Black     uint8 = 0
	White     uint8 = 1
	NoneColor uint8 = 2

	Pawn     uint8 = 0
	Knight   uint8 = 1
	Bishop   uint8 = 2
	Rook     uint8 = 3
	Queen    uint8 = 4
	King     uint8 = 5
	NoneType uint8 = 6

	White_Kingside_Castle_Right  uint8 = 0b00001000
	White_Queenside_Castle_Right uint8 = 0b00000100
	Black_Kingside_Castle_Right  uint8 = 0b00000010
	Black_Queenside_Castle_Right uint8 = 0b00000001

	A1, B1, C1, D1, E1, F1, G1, H1 = 0, 1, 2, 3, 4, 5, 6, 7
	A2, B2, C2, D2, E2, F2, G2, H2 = 8, 9, 10, 11, 12, 13, 14, 15
	A3, B3, C3, D3, E3, F3, G3, H3 = 16, 17, 18, 19, 20, 21, 22, 23
	A4, B4, C4, D4, E4, F4, G4, H4 = 24, 25, 26, 27, 28, 29, 30, 31
	A5, B5, C5, D5, E5, F5, G5, H5 = 32, 33, 34, 35, 36, 37, 38, 39
	A6, B6, C6, D6, E6, F6, G6, H6 = 40, 41, 42, 43, 44, 45, 46, 47
	A7, B7, C7, D7, E7, F7, G7, H7 = 48, 49, 50, 51, 52, 53, 54, 55
	A8, B8, C8, D8, E8, F8, G8, H8 = 56, 57, 58, 59, 60, 61, 62, 63

	NoneSquare       = 64
	FENStartPosition = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 0"
)
View Source
const (
	FileA = 0
	FileB = 1
	FileC = 2
	FileD = 3
	FileE = 4
	FileF = 5
	FileG = 6
	FileH = 7

	Rank1 = 0
	Rank2 = 1
	Rank3 = 2
	Rank4 = 3
	Rank5 = 4
	Rank6 = 5
	Rank7 = 6
	Rank8 = 7

	NorthOffset = 8
	SouthOffset = 8
	EastOffset  = 1
	WestOffset  = 1
)
View Source
const (
	EngineName   = "GoFish"
	Author       = "Ahmad & Yazan"
	InfiniteTime = -1
	NoValue      = 0
	MaxDepth     = 100
)
View Source
const (
	MaxPerftDepth = 6
)
View Source
const MovesCapacity = 1024
View Source
const (
	NoEnPassantOnAnyFile uint8 = 8
)

Variables

View Source
var AntiDiagonalMasks = [15]Bitboard{
	0x1,
	0x102,
	0x10204,
	0x1020408,
	0x102040810,
	0x10204081020,
	0x1020408102040,
	0x102040810204080,
	0x204081020408000,
	0x408102040800000,
	0x810204080000000,
	0x1020408000000000,
	0x2040800000000000,
	0x4080000000000000,
	0x8000000000000000,
}
View Source
var BishopMagicPackages [64]MagicPackage
View Source
var BitboardForSquare = [65]Bitboard{
	0x8000000000000000, 0x4000000000000000, 0x2000000000000000, 0x1000000000000000,
	0x0800000000000000, 0x0400000000000000, 0x0200000000000000, 0x0100000000000000,
	0x0080000000000000, 0x0040000000000000, 0x0020000000000000, 0x0010000000000000,
	0x0008000000000000, 0x0004000000000000, 0x0002000000000000, 0x0001000000000000,
	0x0000800000000000, 0x0000400000000000, 0x0000200000000000, 0x0000100000000000,
	0x0000080000000000, 0x0000040000000000, 0x0000020000000000, 0x0000010000000000,
	0x0000008000000000, 0x0000004000000000, 0x0000002000000000, 0x0000001000000000,
	0x0000000800000000, 0x0000000400000000, 0x0000000200000000, 0x0000000100000000,
	0x0000000080000000, 0x0000000040000000, 0x0000000020000000, 0x0000000010000000,
	0x0000000008000000, 0x0000000004000000, 0x0000000002000000, 0x0000000001000000,
	0x0000000000800000, 0x0000000000400000, 0x0000000000200000, 0x0000000000100000,
	0x0000000000080000, 0x0000000000040000, 0x0000000000020000, 0x0000000000010000,
	0x0000000000008000, 0x0000000000004000, 0x0000000000002000, 0x0000000000001000,
	0x0000000000000800, 0x0000000000000400, 0x0000000000000200, 0x0000000000000100,
	0x0000000000000080, 0x0000000000000040, 0x0000000000000020, 0x0000000000000010,
	0x0000000000000008, 0x0000000000000004, 0x0000000000000002, 0x0000000000000001,
	0x0000000000000000,
}
View Source
var BoardRanksNormalAndFlipped = [2][8]uint8{
	{Rank8, Rank7, Rank6, Rank5, Rank4, Rank3, Rank2, Rank1},
	{Rank1, Rank2, Rank3, Rank4, Rank5, Rank6, Rank7, Rank8},
}
View Source
var BoardSquaresNormalAndFlipped [2][64]int = [2][64]int{
	{
		0, 1, 2, 3, 4, 5, 6, 7,
		8, 9, 10, 11, 12, 13, 14, 15,
		16, 17, 18, 19, 20, 21, 22, 23,
		24, 25, 26, 27, 28, 29, 30, 31,
		32, 33, 34, 35, 36, 37, 38, 39,
		40, 41, 42, 43, 44, 45, 46, 47,
		48, 49, 50, 51, 52, 53, 54, 55,
		56, 57, 58, 59, 60, 61, 62, 63,
	},

	{
		56, 57, 58, 59, 60, 61, 62, 63,
		48, 49, 50, 51, 52, 53, 54, 55,
		40, 41, 42, 43, 44, 45, 46, 47,
		32, 33, 34, 35, 36, 37, 38, 39,
		24, 25, 26, 27, 28, 29, 30, 31,
		16, 17, 18, 19, 20, 21, 22, 23,
		8, 9, 10, 11, 12, 13, 14, 15,
		0, 1, 2, 3, 4, 5, 6, 7,
	},
}
View Source
var CharToPiece = map[byte]Piece{
	'P': {Pawn, White},
	'N': {Knight, White},
	'B': {Bishop, White},
	'R': {Rook, White},
	'Q': {Queen, White},
	'K': {King, White},
	'p': {Pawn, Black},
	'n': {Knight, Black},
	'b': {Bishop, Black},
	'r': {Rook, Black},
	'q': {Queen, Black},
	'k': {King, Black},
}
View Source
var CheckDoublePawnOnSquareMask [2][64]Bitboard
View Source
var CheckForIsolatedPawnOnFileMasks [8]Bitboard
View Source
var CheckOutpostOnSquareMask [2][64]Bitboard
View Source
var CheckPassedPawnOnSquareMask [2][64]Bitboard
View Source
var ClearFileMasks = [8]Bitboard{}
View Source
var ClearRankMasks = [8]Bitboard{}
View Source
var ComputedBishopMoves = [64][512]Bitboard{}
View Source
var ComputedKingMoves = [64]Bitboard{}
View Source
var ComputedKnightMoves = [64]Bitboard{}
View Source
var ComputedPawnAdvances = [2][64]Bitboard{}
View Source
var ComputedPawnCaptures = [2][64]Bitboard{}
View Source
var ComputedRookMoves = [64][4096]Bitboard{}

look at slider_moves.go to understand the sizes 4096 and 512 for slider pieces, i.e. rook and bishop

View Source
var EndGameMobilityScoresPerPiece = [5]int16{0, 2, 3, 2, 6}
View Source
var EndGamePassedPawnSquareTables = [64]int16{
	0, 0, 0, 0, 0, 0, 0, 0,
	77, 74, 63, 53, 59, 60, 72, 77,
	91, 83, 66, 40, 30, 61, 67, 84,
	55, 52, 42, 35, 30, 34, 56, 52,
	29, 26, 21, 18, 17, 19, 34, 30,
	8, 6, 5, 1, 1, -1, 14, 7,
	2, 3, -4, 0, -2, -1, 7, 6,
	0, 0, 0, 0, 0, 0, 0, 0,
}
View Source
var EndGamePieceSquareTables = [6][64]int16{
	{

		0, 0, 0, 0, 0, 0, 0, 0,
		77, 74, 63, 53, 59, 60, 72, 77,
		17, 11, 11, 11, 11, -6, 14, 8,
		-3, -14, -18, -31, -29, -25, -20, -18,
		-12, -14, -24, -31, -29, -28, -27, -28,
		-22, -20, -25, -20, -21, -24, -34, -34,
		-16, -22, -11, -19, -13, -23, -32, -34,
		0, 0, 0, 0, 0, 0, 0, 0,
	},
	{

		-36, -16, -7, -14, -4, -20, -20, -29,
		-17, 2, -7, 14, 2, -7, -9, -19,
		-13, -7, 14, 12, 4, 6, 0, -13,
		-5, 8, 24, 18, 22, 15, 11, -4,
		-3, 4, 20, 30, 22, 25, 15, -2,
		-7, 1, 3, 19, 10, -2, -4, -4,
		-10, -2, -1, 0, 6, -8, -3, -13,
		-12, -28, -8, 1, -5, -12, -27, -12,
	},
	{

		-9, -5, -9, -5, -2, -4, -5, -8,
		0, 2, 8, -7, 1, 0, -2, -8,
		8, 0, 0, 1, 0, 1, 5, 6,
		0, 7, 7, 8, 3, 5, 2, 6,
		-1, 0, 12, 8, 0, 6, 0, -5,
		0, 0, 3, 6, 8, -1, 0, -1,
		-6, -12, -7, 0, 0, -8, -9, -13,
		-11, 0, -6, 0, -3, -4, -5, -9,
	},
	{

		8, 9, 11, 13, 13, 12, 13, 9,
		3, 5, 1, 0, -1, 0, 6, 2,
		9, 5, 7, 2, 2, 1, 0, 0,
		3, 3, 6, 0, 0, 0, 0, 4,
		5, 4, 9, 0, -3, -2, -6, -2,
		0, 0, -6, -5, -9, -14, -7, -12,
		-2, -5, -1, -7, -9, -11, -13, -1,
		-7, -3, 0, -8, -13, -12, -4, -24,
	},
	{

		-12, 4, 8, 4, 10, 9, 3, 6,
		-17, -7, -1, 7, 3, 6, 1, 0,
		-5, -1, -4, 12, 14, 20, 12, 14,
		-2, 2, 2, 9, 13, 7, 18, 22,
		-9, 3, 1, 15, 5, 10, 12, 10,
		-6, -20, 0, -15, 0, -1, 10, 7,
		-6, -14, -31, -27, -19, -12, -11, -4,
		-12, -22, -19, -30, -8, -13, -6, -15,
	},
	{

		-15, -11, -11, -6, -2, 3, 4, -9,
		-9, 14, 11, 13, 13, 28, 19, 1,
		-1, 18, 19, 15, 16, 35, 34, 4,
		-12, 14, 21, 25, 19, 25, 18, -5,
		-23, -6, 14, 21, 20, 18, 5, -16,
		-21, -6, 5, 13, 15, 9, -2, -12,
		-27, -10, 2, 9, 9, 1, -12, -26,
		-43, -34, -20, -5, -26, -9, -35, -55,
	},
}
View Source
var EndGamePieceValues = [6]int16{106, 244, 268, 478, 886}
View Source
var FutilityBoosts = [9]int16{0, 100, 160, 220, 280, 340, 400, 460, 520}
View Source
var InnerRingAttackScorePerPiece = [5]int16{0, 3, 4, 3, 2}
View Source
var KingSafetyZonesOnSquareMask [64]KingSafetyZone
View Source
var LateMovePruningLegalMoveLowerBounds = [6]int{0, 8, 12, 16, 20, 24}
View Source
var LateMoveReductions = [MaxDepth + 1][100]int8{}
View Source
var MainDiagonalMasks = [15]Bitboard{
	0x80,
	0x8040,
	0x804020,
	0x80402010,
	0x8040201008,
	0x804020100804,
	0x80402010080402,
	0x8040201008040201,
	0x4020100804020100,
	0x2010080402010000,
	0x1008040201000000,
	0x804020100000000,
	0x402010000000000,
	0x201000000000000,
	0x100000000000000,
}
View Source
var MidGameMobilityScoresPerPiece = [5]int16{0, 5, 3, 3, 0}
View Source
var MidGamePassedPawnSquareTables = [64]int16{
	0, 0, 0, 0, 0, 0, 0, 0,
	45, 52, 42, 43, 28, 34, 19, 9,
	48, 43, 43, 30, 24, 31, 12, 2,
	28, 17, 13, 10, 10, 19, 6, 1,
	14, 0, -9, -7, -13, -7, 9, 16,
	5, 3, -3, -14, -3, 10, 13, 19,
	8, 9, 2, -8, -3, 8, 16, 9,
	0, 0, 0, 0, 0, 0, 0, 0,
}
View Source
var MidGamePieceSquareTables = [6][64]int16{
	{

		0, 0, 0, 0, 0, 0, 0, 0,
		45, 52, 42, 43, 28, 34, 19, 9,
		-14, -3, 7, 14, 35, 50, 15, -6,
		-27, -6, -8, 13, 16, 4, -3, -25,
		-32, -28, -7, 5, 7, -1, -15, -30,
		-29, -25, -12, -12, -1, -5, 6, -17,
		-34, -23, -27, -18, -14, 10, 13, -22,
		0, 0, 0, 0, 0, 0, 0, 0,
	},
	{

		-43, -11, -8, -5, 1, -20, -4, -22,
		-31, -22, 19, 7, 5, 13, -8, -11,
		-21, 21, 8, 16, 36, 33, 19, 6,
		-6, 2, 0, 23, 8, 27, 4, 14,
		-3, 10, 12, 8, 16, 10, 19, 1,
		-19, -4, 3, 7, 22, 12, 15, -11,
		-21, -20, -9, 8, 9, 11, -5, 0,
		-19, -13, -20, -14, -2, 3, -11, -8,
	},
	{

		-13, 0, -17, -8, -7, -5, -2, -3,
		-21, 0, -16, -10, 4, 1, -6, -41,
		-23, 6, 10, 8, 8, 26, 0, -10,
		-15, -4, 2, 22, 9, 10, -1, -16,
		0, 10, -2, 15, 17, -7, -1, 13,
		-2, 16, 13, 0, 5, 16, 14, 0,
		8, 11, 12, 3, 11, 23, 27, 3,
		-26, 3, -3, -1, 10, -5, -7, -15,
	},
	{

		3, 1, 0, 7, 7, -1, 0, 0,
		-6, -9, 7, 7, 7, 5, -4, -1,
		-12, 11, 0, 17, -2, 12, 23, -1,
		-17, -9, 4, 0, 3, 15, -1, -2,
		-24, -16, -16, -4, -1, -14, 2, -20,
		-30, -15, -6, -3, 0, 2, 2, -15,
		-25, -6, -6, 5, 8, 6, 8, -46,
		-3, 1, 6, 15, 17, 14, -13, -2,
	},
	{

		-10, 0, 0, 0, 10, 9, 5, 7,
		-19, -35, -5, 2, -9, 7, 1, 15,
		-10, -7, -4, -9, 15, 29, 24, 22,
		-14, -14, -15, -11, -1, -5, 3, -6,
		-8, -20, -8, -5, -4, -2, 2, -2,
		-13, 5, 2, 1, -1, 8, 4, 2,
		-20, 0, 10, 16, 16, 16, -6, 6,
		-3, -1, 7, 19, 5, -10, -9, -17,
	},
	{

		-3, 0, 2, 0, 0, 0, 1, -1,
		1, 4, 0, 7, 4, 2, 3, -2,
		2, 4, 7, 4, 4, 14, 12, 0,
		0, 2, 6, 0, 0, 2, 6, -9,
		-8, 5, 0, -8, -10, -10, -9, -23,
		-3, 5, 1, -8, -12, -12, 8, -24,
		6, 13, 0, -40, -23, -1, 25, 19,
		-28, 29, 17, -53, 2, -25, 34, 15,
	},
}
View Source
var MidGamePieceValues = [6]int16{84, 333, 346, 441, 921}
View Source
var MvvLvaScores [7][6]uint16 = [7][6]uint16{
	{15, 14, 13, 12, 11, 10},
	{25, 24, 23, 22, 21, 20},
	{35, 34, 33, 32, 31, 30},
	{45, 44, 43, 42, 41, 40},
	{55, 54, 53, 52, 51, 50},
	{0, 0, 0, 0, 0, 0},
	{0, 0, 0, 0, 0, 0},
}
View Source
var OuterRingAttackScorePerPiece = [5]int16{0, 1, 0, 1, 1}
View Source
var PieceTypeToChar = map[uint8]rune{
	Pawn:     'p',
	Knight:   'n',
	Bishop:   'b',
	Rook:     'r',
	Queen:    'q',
	King:     'k',
	NoneType: '.',
}
View Source
var RandomNumberGeneratorSeeds [8]uint64 = [8]uint64{728, 10316, 55013, 32803, 12281, 15100, 16645, 255}
View Source
var RookMagicPackages [64]MagicPackage
View Source
var SemiOpenFileBesideKingPenalty int16 = 4
View Source
var SetFileMasks = [8]Bitboard{}
View Source
var SetRankMasks = [8]Bitboard{}
View Source
var StandardPieceValuesScaled [7]int16 = [7]int16{
	100,
	300,
	300,
	500,
	900,
	CheckmateScore,
	0,
}
View Source
var ZobristSingleton zobrist

Functions

func ComputePieceMoveTables

func ComputePieceMoveTables()

func DividePerft

func DividePerft(currentPosition *Position, depth uint8, divisionPoint uint8, evaluator Evaluator) uint64

func File

func File(square uint8) uint8

func InitEvaluationRelatedMasks

func InitEvaluationRelatedMasks()

func InitializeLateMoveReductions

func InitializeLateMoveReductions()

func InitializeZobristHashing

func InitializeZobristHashing()

func OccupyBishopMagicNumbers

func OccupyBishopMagicNumbers()

func OccupyRookMagicNumbers

func OccupyRookMagicNumbers()

func OrderHighestScoredMove

func OrderHighestScoredMove(destinationIndex uint8, moves *MoveList)

func Perft

func Perft(currentPosition *Position, depth uint8, evaluator Evaluator) uint64

func Rank

func Rank(square uint8) uint8

Types

type Bitboard

type Bitboard uint64
const (
	// use ^EmptyBoard instead of FullBB
	EmptyBitBoard Bitboard = 0x0
	FullBitBoard  Bitboard = 0xffffffffffffffff
	FileHBitBoard Bitboard = 0x8080808080808080
	FileABitBoard Bitboard = 0x0101010101010101
)

func GetBishopPseudoLegalMoves

func GetBishopPseudoLegalMoves(square uint8, boardBlockersBitboard Bitboard) Bitboard

func GetRookBlockerMask

func GetRookBlockerMask(square uint8) Bitboard

func GetRookPseudoLegalMoves

func GetRookPseudoLegalMoves(square uint8, boardBlockersBitboard Bitboard) Bitboard

func (*Bitboard) ClearBit

func (bitboard *Bitboard) ClearBit(square uint8)

func (Bitboard) CountSetBits

func (bitboard Bitboard) CountSetBits() int

func (Bitboard) GetShiftedBitBoard

func (bitboard Bitboard) GetShiftedBitBoard(b uint64, direction Direction) Bitboard

func (Bitboard) MostSignificantBit

func (bitboard Bitboard) MostSignificantBit() uint8

func (*Bitboard) PopMostSignificantBit

func (bitboard *Bitboard) PopMostSignificantBit() uint8

func (*Bitboard) SetBit

func (bitboard *Bitboard) SetBit(square uint8)

func (Bitboard) String

func (bitboard Bitboard) String() (formattedBitBoard string)

type DefaultEvaluator

type DefaultEvaluator struct {
	// contains filtered or unexported fields
}

func (*DefaultEvaluator) EvaluatePosition

func (defaultClassicEvaluator *DefaultEvaluator) EvaluatePosition(position *Position) int16

func (*DefaultEvaluator) GetEndGamePieceSquareTable

func (evaluator *DefaultEvaluator) GetEndGamePieceSquareTable() *[6][64]int16

func (*DefaultEvaluator) GetEndGamePieceValues

func (evaluator *DefaultEvaluator) GetEndGamePieceValues() *[6]int16

func (*DefaultEvaluator) GetMiddleGamePieceSquareTable

func (evaluator *DefaultEvaluator) GetMiddleGamePieceSquareTable() *[6][64]int16

func (*DefaultEvaluator) GetMiddleGamePieceValues

func (evaluator *DefaultEvaluator) GetMiddleGamePieceValues() *[6]int16

func (*DefaultEvaluator) GetPhaseValues

func (evaluator *DefaultEvaluator) GetPhaseValues() *[6]int16

func (*DefaultEvaluator) GetTotalPhaseWeight

func (evaluator *DefaultEvaluator) GetTotalPhaseWeight() int16

type DefaultSearcher

type DefaultSearcher struct {
	// contains filtered or unexported fields
}

func (*DefaultSearcher) AssignScoresToMoves

func (searcher *DefaultSearcher) AssignScoresToMoves(moves *MoveList, pvFirstMove Move, depth uint8, previousMove Move)

func (*DefaultSearcher) ChangeCounterMoveSlot

func (searcher *DefaultSearcher) ChangeCounterMoveSlot(previousMove Move, counterMove Move)

func (*DefaultSearcher) ChangeKillerMoveSlot

func (searcher *DefaultSearcher) ChangeKillerMoveSlot(ply uint8, killerMove Move)

func (*DefaultSearcher) CleanUp

func (searcher *DefaultSearcher) CleanUp()

func (*DefaultSearcher) ClearCounterMoves

func (searcher *DefaultSearcher) ClearCounterMoves()

func (*DefaultSearcher) ClearHistoryHeuristicStats

func (searcher *DefaultSearcher) ClearHistoryHeuristicStats()

func (*DefaultSearcher) ClearKillerMoves

func (searcher *DefaultSearcher) ClearKillerMoves()

func (*DefaultSearcher) DecreaseMoveHistoryStrength

func (searcher *DefaultSearcher) DecreaseMoveHistoryStrength(move Move)

func (*DefaultSearcher) EraseLatestPositionHash

func (searcher *DefaultSearcher) EraseLatestPositionHash()

func (*DefaultSearcher) GetOptions

func (searcher *DefaultSearcher) GetOptions() map[string]EngineOption

func (*DefaultSearcher) IncreaseMoveHistoryStrength

func (searcher *DefaultSearcher) IncreaseMoveHistoryStrength(move Move, depth int8)

func (*DefaultSearcher) InitializeSearchInfo

func (searcher *DefaultSearcher) InitializeSearchInfo(fenString string, evaluator Evaluator)

func (*DefaultSearcher) InitializeTimeManager

func (searcher *DefaultSearcher) InitializeTimeManager(remainingTime int64, increment int64, moveTime int64, movesToGo int16, depth uint8, nodeCount uint64)

func (*DefaultSearcher) Negamax

func (searcher *DefaultSearcher) Negamax(evaluator Evaluator, depth int8, ply uint8, alpha int16, beta int16, pv *PV, nullMovePruningRequired bool, previousMove Move, singularMoveExtensionMove Move, singularMoveExtendedSearch bool) int16

func (*DefaultSearcher) Position

func (searcher *DefaultSearcher) Position() *Position

func (*DefaultSearcher) QuiescenceSearch

func (searcher *DefaultSearcher) QuiescenceSearch(evaluator Evaluator, alpha int16, beta int16, maximumAllowablePly uint8, pv *PV, ply uint8) int16

func (*DefaultSearcher) RecordPositionHash

func (searcher *DefaultSearcher) RecordPositionHash(positionHash uint64)

func (*DefaultSearcher) ReduceHistoryHeuristicScores

func (searcher *DefaultSearcher) ReduceHistoryHeuristicScores()

func (*DefaultSearcher) Reset

func (searcher *DefaultSearcher) Reset(evaluator Evaluator)

func (*DefaultSearcher) ResetToNewGame

func (searcher *DefaultSearcher) ResetToNewGame()

func (*DefaultSearcher) StartSearch

func (searcher *DefaultSearcher) StartSearch(evaluator Evaluator) Move

func (*DefaultSearcher) StopSearch

func (searcher *DefaultSearcher) StopSearch()

type DefaultTimeManager

type DefaultTimeManager struct {
	// contains filtered or unexported fields
}

func (*DefaultTimeManager) ChangeMoveAllocatedTime

func (timeManager *DefaultTimeManager) ChangeMoveAllocatedTime(newMoveAllocatedTime int64)

func (*DefaultTimeManager) Initialize

func (timeManager *DefaultTimeManager) Initialize(remainingTime int64, increment int64, moveTime int64, movesToGo int16, depth uint8, nodeCount uint64)

func (*DefaultTimeManager) SetMoveTimeIsUp

func (timeManager *DefaultTimeManager) SetMoveTimeIsUp()

func (*DefaultTimeManager) StartMoveTimeAllocation

func (timeManager *DefaultTimeManager) StartMoveTimeAllocation(plyNumber uint16)

type DefaultTranspositionTable

type DefaultTranspositionTable struct {
	// contains filtered or unexported fields
}

func (*DefaultTranspositionTable) ClearEntries

func (table *DefaultTranspositionTable) ClearEntries()

func (*DefaultTranspositionTable) DeleteEntries

func (table *DefaultTranspositionTable) DeleteEntries()

func (*DefaultTranspositionTable) GetEntryToRead

func (table *DefaultTranspositionTable) GetEntryToRead(hash uint64) *TableEntry

func (*DefaultTranspositionTable) GetEntryToReplace

func (table *DefaultTranspositionTable) GetEntryToReplace(hash uint64, requiredDepth uint8, ageState uint8) *TableEntry

func (*DefaultTranspositionTable) ResizeTable

func (table *DefaultTranspositionTable) ResizeTable(tableSize uint64, entrySize uint64)

type Direction

type Direction uint8
const (
	NORTH Direction = iota
	SOUTH
	EAST
	WEST
	North_East
	North_West
	South_East
	South_West
)

type EngineInterface

type EngineInterface struct {
	GameSearcher GameSearcher
	Evaluator    Evaluator
}

func NewCustomEngineInterface

func NewCustomEngineInterface(GameSearcher GameSearcher, Evaluator Evaluator) EngineInterface

func NewDefaultEngineInterface

func NewDefaultEngineInterface() EngineInterface

func (*EngineInterface) StartEngine

func (engineInterface *EngineInterface) StartEngine()

type EngineOption

type EngineOption struct {
	// contains filtered or unexported fields
}

type EvaluationData

type EvaluationData struct {
	MidgameScores           [2]int16
	EndgameScores           [2]int16
	ThreatToEnemyKingPoints [2]uint16
	EnemyKingAttackerCount  [2]uint8
}

type Evaluator

type Evaluator interface {
	EvaluatePosition(position *Position) int16
	GetMiddleGamePieceSquareTable() *[6][64]int16
	GetEndGamePieceSquareTable() *[6][64]int16
	GetMiddleGamePieceValues() *[6]int16
	GetEndGamePieceValues() *[6]int16
	GetPhaseValues() *[6]int16
	GetTotalPhaseWeight() int16
}

type GameSearcher

type GameSearcher interface {
	Reset(evaluator Evaluator)
	ResetToNewGame()
	GetOptions() map[string]EngineOption
	Position() *Position
	RecordPositionHash(positionHash uint64)
	InitializeSearchInfo(fenString string, evaluator Evaluator)
	InitializeTimeManager(remainingTime int64, increment int64, moveTime int64, movesToGo int16, depth uint8, nodeCount uint64)
	StartSearch(evaluator Evaluator) Move
	StopSearch()
	CleanUp()
}

type KingSafetyZone

type KingSafetyZone struct {
	OuterDefenseRing Bitboard
	InnerDefenseRing Bitboard
}

type MagicPackage

type MagicPackage struct {
	MagicNumber        uint64
	Shift              uint8
	MaximalBlockerMask Bitboard
}

type Move

type Move uint32

func CreateMove

func CreateMove(fromSquare, toSquare, moveType, moveInfo uint8) Move

func (Move) GetFromSquare

func (move Move) GetFromSquare() uint8

func (Move) GetMoveInfo

func (move Move) GetMoveInfo() uint8

func (Move) GetMoveType

func (move Move) GetMoveType() uint8

func (Move) GetScore

func (move Move) GetScore() uint16

func (Move) GetToSquare

func (move Move) GetToSquare() uint8

func (Move) IsSameMove

func (move Move) IsSameMove(otherMove Move) bool

func (*Move) ModifyMoveScore

func (move *Move) ModifyMoveScore(newScore uint16)

func (Move) String

func (move Move) String() string

type MoveList

type MoveList struct {
	Moves [MovesCapacity]Move
	Size  uint8
}

func GeneratePseudoLegalMoves

func GeneratePseudoLegalMoves(currentPosition *Position) (moveList MoveList)

func (*MoveList) AddMove

func (moveList *MoveList) AddMove(move Move)

type PV

type PV struct {
	// contains filtered or unexported fields
}

func (*PV) DeleteVariation

func (pv *PV) DeleteVariation()

func (*PV) GetVariationFirstMove

func (pv *PV) GetVariationFirstMove() Move

func (*PV) SetNewVariation

func (pv *PV) SetNewVariation(firstMove Move, continuation PV)

func (PV) String

func (pv PV) String() string

type Piece

type Piece struct {
	PieceType uint8
	Color     uint8
}

type Position

type Position struct {
	// Board representations
	SquareContent  [64]Piece
	PiecesBitBoard [2][6]Bitboard
	ColorsBitBoard [2]Bitboard

	// Game state information
	SideToMove      uint8
	PositionHash    uint64
	CastlingRights  uint8
	Rule50          uint8
	EnPassantSquare uint8
	PreviousStates  [100]StateInfo
	CurrentPly      uint16
	MidGameScores   [2]int16
	EndGameScores   [2]int16

	Phase int16
	// contains filtered or unexported fields
}

func (*Position) DoMove

func (position *Position) DoMove(move Move, evaluator Evaluator) (isValid bool)

func (*Position) DoNullMove

func (position *Position) DoNullMove()

func (Position) GenFEN

func (pos Position) GenFEN() string

func (*Position) HasNoMajorOrMinorPieces

func (position *Position) HasNoMajorOrMinorPieces() bool

func (*Position) IsCurrentSideInCheck

func (position *Position) IsCurrentSideInCheck() bool

func (*Position) LoadFEN

func (position *Position) LoadFEN(FEN string, evaluator Evaluator)

func (*Position) MoveIsPseduoLegal

func (pos *Position) MoveIsPseduoLegal(move Move) bool

func (*Position) See

func (position *Position) See(move Move) int16

func (Position) String

func (position Position) String() (boardStr string)

func (*Position) UnDoPreviousMove

func (position *Position) UnDoPreviousMove(previousMove Move, evaluator Evaluator)

type RandomNumberGenerator

type RandomNumberGenerator struct {
	// contains filtered or unexported fields
}

func (*RandomNumberGenerator) Random64

func (prng *RandomNumberGenerator) Random64() uint64

func (*RandomNumberGenerator) Seed

func (prng *RandomNumberGenerator) Seed(seed uint64)

func (*RandomNumberGenerator) SparseRandom64

func (prng *RandomNumberGenerator) SparseRandom64() uint64

type RookCastleMove

type RookCastleMove struct {
	// contains filtered or unexported fields
}

type StateInfo

type StateInfo struct {
	PositionHash    uint64
	CastlingRights  uint8
	Rule50          uint8
	EnPassantSquare uint8
	CapturedPiece   Piece
	MovedPiece      Piece
}

type TableEntry

type TableEntry struct {
	HashValue     uint64
	BestMove      Move
	DepthOfSearch uint8
	Score         int16
	EntryInfo     uint8
}

func (TableEntry) GetEntryAge

func (entry TableEntry) GetEntryAge() uint8

func (TableEntry) GetEntryType

func (entry TableEntry) GetEntryType() uint8

func (*TableEntry) ModifyTableEntry

func (entry *TableEntry) ModifyTableEntry(move Move, searchScore int16, hash uint64, pliesFromRoot uint8, requiredDepth uint8, entryType uint8, entryAge uint8)

func (*TableEntry) ReadEntryInfo

func (entry *TableEntry) ReadEntryInfo(ttMove *Move, hash uint64, pliesFromRoot uint8, requiredDepth uint8, alpha int16, beta int16) (int16, bool)

func (*TableEntry) SetEntryAge

func (entry *TableEntry) SetEntryAge(entryAge uint8)

func (*TableEntry) SetEntryType

func (entry *TableEntry) SetEntryType(entryType uint8)

type UciInterface

type UciInterface struct {
	// contains filtered or unexported fields
}

func (*UciInterface) ReInitialize

func (uciInterface *UciInterface) ReInitialize()

func (*UciInterface) Run

func (uciInterface *UciInterface) Run()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL