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
*move*s & select the fittest.

- maximumDefended :: NPieces
- measurePieceSquareValue :: (Enum x, Enum y, Num pieceSquareValue, Ord x, Ord y) => PieceSquareArray x y pieceSquareValue -> Game x y -> pieceSquareValue
- measurePieceSquareValueIncrementally :: (Enum x, Enum y, Num pieceSquareValue, Ord x, Ord y) => pieceSquareValue -> PieceSquareArray x y pieceSquareValue -> Game x y -> pieceSquareValue
- measureValueOfMaterial :: (Fractional criterionValue, Fractional rankValue, Ord criterionValue, Real rankValue) => RankValues rankValue -> Game x y -> CriterionValue criterionValue
- measureValueOfCastlingPotential :: (Fractional criterionValue, Ord criterionValue) => Game x y -> CriterionValue criterionValue
- measureValueOfDefence :: (Fractional criterionValue, Ord criterionValue) => Game x y -> CriterionValue criterionValue
- measureValueOfDoubledPawns :: (Fractional criterionValue, Ord criterionValue) => Game x y -> CriterionValue criterionValue
- measureValueOfIsolatedPawns :: (Enum x, Fractional criterionValue, Ord criterionValue, Ord x) => Game x y -> CriterionValue criterionValue
- measureValueOfPassedPawns :: forall x y criterionValue. (Enum y, Fractional criterionValue, Ord criterionValue) => Game x y -> CriterionValue criterionValue
- evaluateFitness :: (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 -> Game x y -> Reader criterionWeight pieceSquareValue rankValue x y (WeightedMeanAndCriterionValues weightedMean criterionValue)

# Constants

maximumDefended :: NPieces Source #

- The constant maximum total number of times the
*piece*s 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*piece*s, beyond which there're zero*pieces*to defend, so the outer*piece*s can never be fully utilised; all`Pawn`

s 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 #

:: (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 *piece*s 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
*piece*s 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 #

- Measure the arithmetic difference between the number of
*doubled*`Pawn`

s on either side; https://chessprogramming.wikispaces.com/Doubled+Pawn. - N.B.: measures tripled
`Pawn`

s as equivalent to two doubled`Pawn`

s. - CAVEAT: this is a negative attribute, so the weighted normalised value shouldn't exceed the reduction due to
`measureValueOfMaterial`

resulting from a`Pawn`

-sacrifice.

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

- Measure the arithmetic difference between the number of
*isolated*`Pawn`

s on either side; https://chessprogramming.wikispaces.com/Isolated+Pawn. - CAVEAT: this is a negative attribute, so the weighted normalised value shouldn't exceed the reduction due to
`measureValueOfMaterial`

resulting from a`Pawn`

-sacrifice.

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* `Pawn`

s on either side; https://chessprogramming.wikispaces.com/Passed+Pawn.

:: (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-value*s 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`

.