bishbosh-0.0.0.2: Plays chess.

Safe HaskellNone
LanguageHaskell2010

BishBosh.Evaluation.Fitness

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
  • Quantifies the fitness of a game.
  • By measuring the fitness from the perspective of the player who just moved (rather than the next player to move), an automated player can test various moves & select the fittest.

Synopsis

Constants

maximumDefended :: NPieces Source #

  • The constant maximum total number of times the pieces of either side, can be defended.
  • This calculation assumes that: every piece can defend another in every direction it can attack, which is impossible, since in a 2-D board one can always draw a perimeter around the pieces, beyond which there're zero pieces to defend, so the outer pieces can never be fully utilised; all Pawns have been queened, which is unrealistic.

Functions

measurePieceSquareValue :: (Enum x, Enum y, Num pieceSquareValue, Ord x, Ord y) => PieceSquareArray x y pieceSquareValue -> Game x y -> pieceSquareValue Source #

Measures the piece-square value from the perspective of the last player to move.

measurePieceSquareValueIncrementally Source #

Arguments

:: (Enum x, Enum y, Num pieceSquareValue, Ord x, Ord y) 
=> pieceSquareValue

The value before the last move was applied, & therefore also from the perspective of the previous player.

-> PieceSquareArray x y pieceSquareValue 
-> Game x y 
-> pieceSquareValue 
  • Measures the piece-square value from the perspective of the last player to move.
  • The previous value is provided, to enable calculation by difference.
  • N.B.: because of diminishing returns, the piece-square value for everything but quiet moves is calculated from scratch.

measureValueOfMaterial :: (Fractional criterionValue, Fractional rankValue, Ord criterionValue, Real rankValue) => RankValues rankValue -> Game x y -> CriterionValue criterionValue Source #

Measure the arithmetic difference between the total rank-value of the pieces currently held by either side; https://chessprogramming.wikispaces.com/Material.

measureValueOfCastlingPotential :: (Fractional criterionValue, Ord criterionValue) => Game x y -> CriterionValue criterionValue Source #

Measure the arithmetic difference between the potential to Castle, on either side.

measureValueOfDefence :: (Fractional criterionValue, Ord criterionValue) => Game x y -> CriterionValue criterionValue Source #

  • Measure the normalised arithmetic difference between the number of pieces defending each of one's own, on either side.
  • N.B. the rank-value of the defended piece is irrelevant because; it's the unknown value of the attacker that counts, since that's what the defender has the opportunity to counter-strike.
  • N.B. defence of the King is irrelevent, because it can't be taken.
  • N.B. it's the total number of defenders which is relevant, rather than whether each piece has some protection, since it's the individual battles but the war which counts.
  • CAVEAT: this criterion competes with mobility, since each defended piece blocks the path of the defender.

measureValueOfDoubledPawns :: (Fractional criterionValue, Ord criterionValue) => Game x y -> CriterionValue criterionValue Source #

measureValueOfIsolatedPawns :: (Enum x, Fractional criterionValue, Ord criterionValue, Ord x) => Game x y -> CriterionValue criterionValue Source #

measureValueOfPassedPawns :: forall x y criterionValue. (Enum y, Fractional criterionValue, Ord criterionValue) => Game x y -> CriterionValue criterionValue Source #

Measure the arithmetic difference between the number of passed Pawns on either side; https://chessprogramming.wikispaces.com/Passed+Pawn.

evaluateFitness Source #

Arguments

:: (Enum x, Enum y, Fractional criterionValue, Fractional pieceSquareValue, Fractional rankValue, Fractional weightedMean, Ord x, Ord y, Real criterionValue, Real criterionWeight, Real pieceSquareValue, Real rankValue, Show x, Show y) 
=> Maybe pieceSquareValue

An optional value for the specified game.

-> Game x y 
-> Reader criterionWeight pieceSquareValue rankValue x y (WeightedMeanAndCriterionValues weightedMean criterionValue) 
  • Evaluates the fitness of the board from the perspective of the last player to move. If the game has ended, the fitness is maximum for checkmate or zero for a draw, but otherwise is the weighted mean of various criteria; https://chessprogramming.wikispaces.com/Evaluation.
  • Also returns the break-down of those criterion-values with a non-zero criterion-weight.
  • Besides measuring the difference between the total rank-value on either side, other criteria are selected to represent known attributes of a good position, but which won't be pay dividends any time soon, & therefore won't be represented by measureValueOfMaterial within the limited future predicted.
  • Many possible criteria aren't measured because they're, either currently or soon, represented by those that are, typically measureValueOfMaterial.