Documentation ¶
Overview ¶
Package eval contains position evaluation logic and utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FindCapture ¶ added in v0.90.1
FindCapture returns the pieces of the given color that directly target the square.
Types ¶
type Evaluator ¶
type Evaluator interface { // Evaluate returns the position score in Pawns. Evaluate(ctx context.Context, b *board.Board) Pawns }
Evaluator is a static position evaluator.
type Material ¶
type Material struct{}
Material returns the nominal material advantage balance for the side to move.
type Pawns ¶
type Pawns float32
Pawns presents a fractional number of pawns.
func NominalValue ¶
NominalValue the absolute nominal value in pawns of a piece. The King has an arbitrary value of 100 pawns.
func NominalValueGain ¶
NominalValueGain is the nominal material gain for a move.
type Pin ¶
Pin represents a pinned piece. A pinned piece cannot attack anything but the attacker itself, if the relative value of attacker/target is high enough.
type Random ¶ added in v0.89.2
type Random struct {
// contains filtered or unexported fields
}
Random is a randomized noise generator. It is used to a small amount of randomness to evaluations. The limit specifies how many millipawns to add/remove in the range [-limit/2; limit/2]. The default value always returns zero.
type Score ¶
type Score struct { Type ScoreType Mate int8 // Non-zero ply to forced mate. Negative if being mated. Pawns Pawns }
Score is signed position score in "pawns", unless decided or mate-in-X. Positive favors the side to move. If all pawns become queens and the opponent has only the king left, the standard material advantage score is: 9*8 (p) + 9 (q) + 2*5 (r) + 2*3 (k) + 2*3 (b) = 103. The score can be arbitrary, but is reported as centi-pawns to humans. 64bits.
func HeuristicScore ¶
HeuristicScore returns a Heuristic score with the given evaluation.
func IncrementMateDistance ¶
IncrementMateDistance adds 1 ply to a MateInX or Inf/NegInf. Heuristic scores are unchanged.
func MateInXScore ¶
MateInXScore returns a MateInX score with the given evaluation.
func (Score) IsHeuristic ¶
func (Score) Less ¶
Less implements < Score ordering. The group ordering is: -inf < negative mate < heuristic < positive mate < inf. Mates are ordered by closeness to checkmate within each mate group, e.g., M2 < M1 and M-1 < M-2.
func (Score) MateDistance ¶
MateDistance returns the ply distance to CheckMate, if known. If a forced mate is possible, there is generally no reason to search deeper.