Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- maximumDefended :: NPieces
- measurePieceSquareValue :: Num pieceSquareValue => PieceSquareByCoordinatesByRank pieceSquareValue -> Game -> pieceSquareValue
- measurePieceSquareValueIncrementally :: Num pieceSquareValue => pieceSquareValue -> PieceSquareByCoordinatesByRank pieceSquareValue -> Game -> pieceSquareValue
- measureValueOfMaterial :: RankValues -> RankValue -> Game -> CriterionValue
- measureValueOfCastlingPotential :: Game -> CriterionValue
- measureValueOfDefence :: Game -> CriterionValue
- measureValueOfDoubledPawns :: Game -> CriterionValue
- measureValueOfIsolatedPawns :: Game -> CriterionValue
- measureValueOfPassedPawns :: Game -> CriterionValue
- evaluateFitness :: (Fractional pieceSquareValue, Real pieceSquareValue) => Maybe pieceSquareValue -> Game -> Reader pieceSquareValue WeightedMeanAndCriterionValues
Types
Constants
maximumDefended :: NPieces Source #
- The constant maximum total number of times the pieces of either side, can be defended.
- Assumes all Pawns have been Queened.
- CAVEAT: assuming the optimal arrangement of pieces:
RQQB = 3 + 7 + 3 + 2 = 15 QQQN = 4 + 6 + 8 + 4 = 22 NQQK = 4 + 8 + 6 + 0 = 18 BQQR = 2 + 3 + 7 + 3 = 15 = 70
Functions
measurePieceSquareValue :: Num pieceSquareValue => PieceSquareByCoordinatesByRank pieceSquareValue -> Game -> pieceSquareValue Source #
Measures the piece-square value from the perspective of the last player to move.
measurePieceSquareValueIncrementally Source #
:: Num pieceSquareValue | |
=> pieceSquareValue | The value before the last move was applied, & therefore also from the perspective of the previous player. |
-> PieceSquareByCoordinatesByRank pieceSquareValue | |
-> Game | |
-> 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 Source #
:: RankValues | |
-> RankValue | Maximum total rank-value. |
-> Game | |
-> CriterionValue |
Measure the arithmetic difference between the total rank-value of the pieces currently held by either side; https://www.chessprogramming.org/Material.
measureValueOfCastlingPotential :: Game -> CriterionValue Source #
Measure the arithmetic difference between the potential to Castle, on either side.
measureValueOfDefence :: Game -> 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. CAVEAT: the validity of this depends on the duration of the battle.
- 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 not 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 :: Game -> CriterionValue Source #
- Measure the arithmetic difference between the number of doubled
Pawn
s on either side; https://www.chessprogramming.org/Doubled_Pawn. - N.B.: measures tripled
Pawn
s as equivalent to two doubledPawn
s. - CAVEAT: this is a negative attribute, so the weighted normalised value shouldn't exceed the reduction due to
measureValueOfMaterial
resulting from aPawn
-sacrifice.
measureValueOfIsolatedPawns :: Game -> CriterionValue Source #
- Measure the arithmetic difference between the number of isolated
Pawn
s on either side; https://www.chessprogramming.org/Isolated_Pawn. - CAVEAT: this is a negative attribute, so the weighted normalised value shouldn't exceed the reduction due to
measureValueOfMaterial
resulting from aPawn
-sacrifice.
measureValueOfPassedPawns :: Game -> CriterionValue Source #
Measure the arithmetic difference between the number of passed Pawn
s on either side; https://www.chessprogramming.org/Passed_Pawn.
:: (Fractional pieceSquareValue, Real pieceSquareValue) | |
=> Maybe pieceSquareValue | An optional value for the specified game. |
-> Game | |
-> Reader pieceSquareValue WeightedMeanAndCriterionValues |
- 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://www.chessprogramming.org/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.
- Many possible criteria aren't measured because they're, either currently or imminently, represented by those that are, typically by
measureValueOfMaterial
.