module BishBosh.Input.EvaluationOptions(
IncrementalEvaluation,
Reader,
EvaluationOptions(
getRankValues,
getMaximumTotalRankValue,
getCriteriaWeights,
getIncrementalEvaluation,
getMaybePieceSquareByCoordinatesByRank
),
tag,
mkEvaluationOptions
) where
import BishBosh.Data.Bool()
import Control.Arrow((***))
import qualified BishBosh.Cartesian.Coordinates as Cartesian.Coordinates
import qualified BishBosh.Component.PieceSquareByCoordinatesByRank as Component.PieceSquareByCoordinatesByRank
import qualified BishBosh.Data.Exception as Data.Exception
import qualified BishBosh.Input.CriteriaWeights as Input.CriteriaWeights
import qualified BishBosh.Input.PieceSquareTable as Input.PieceSquareTable
import qualified BishBosh.Input.RankValues as Input.RankValues
import qualified BishBosh.Property.ShowFloat as Property.ShowFloat
import qualified BishBosh.Text.ShowList as Text.ShowList
import qualified BishBosh.Type.Mass as Type.Mass
import qualified Control.DeepSeq
import qualified Control.Exception
import qualified Control.Monad.Reader
import qualified Data.Array.IArray
import qualified Data.Default
import qualified Data.Foldable
import qualified Data.Maybe
import qualified Text.XML.HXT.Arrow.Pickle as HXT
tag :: String
tag :: String
tag = String
"evaluationOptions"
incrementalEvaluationTag :: String
incrementalEvaluationTag :: String
incrementalEvaluationTag = String
"incrementalEvaluation"
pieceSquareTablesTag :: String
pieceSquareTablesTag :: String
pieceSquareTablesTag = String -> ShowS
showString String
Input.PieceSquareTable.tag String
"s"
pieceSquareTableEndGameTag :: String
pieceSquareTableEndGameTag :: String
pieceSquareTableEndGameTag = String -> ShowS
showString String
Input.PieceSquareTable.tag String
"EndGame"
type IncrementalEvaluation = Bool
type PieceSquareTablePair = (Input.PieceSquareTable.PieceSquareTable, Input.PieceSquareTable.PieceSquareTable)
data EvaluationOptions = MkEvaluationOptions {
EvaluationOptions -> RankValues
getRankValues :: Input.RankValues.RankValues,
EvaluationOptions -> RankValue
getMaximumTotalRankValue :: Type.Mass.RankValue,
EvaluationOptions -> CriteriaWeights
getCriteriaWeights :: Input.CriteriaWeights.CriteriaWeights,
EvaluationOptions -> IncrementalEvaluation
getIncrementalEvaluation :: IncrementalEvaluation,
EvaluationOptions -> Maybe PieceSquareTablePair
getMaybePieceSquareTablePair :: Maybe PieceSquareTablePair,
EvaluationOptions -> Maybe PieceSquareByCoordinatesByRank
getMaybePieceSquareByCoordinatesByRank :: Maybe Component.PieceSquareByCoordinatesByRank.PieceSquareByCoordinatesByRank
} deriving (EvaluationOptions -> EvaluationOptions -> IncrementalEvaluation
(EvaluationOptions -> EvaluationOptions -> IncrementalEvaluation)
-> (EvaluationOptions
-> EvaluationOptions -> IncrementalEvaluation)
-> Eq EvaluationOptions
forall a.
(a -> a -> IncrementalEvaluation)
-> (a -> a -> IncrementalEvaluation) -> Eq a
/= :: EvaluationOptions -> EvaluationOptions -> IncrementalEvaluation
$c/= :: EvaluationOptions -> EvaluationOptions -> IncrementalEvaluation
== :: EvaluationOptions -> EvaluationOptions -> IncrementalEvaluation
$c== :: EvaluationOptions -> EvaluationOptions -> IncrementalEvaluation
Eq, Int -> EvaluationOptions -> ShowS
[EvaluationOptions] -> ShowS
EvaluationOptions -> String
(Int -> EvaluationOptions -> ShowS)
-> (EvaluationOptions -> String)
-> ([EvaluationOptions] -> ShowS)
-> Show EvaluationOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluationOptions] -> ShowS
$cshowList :: [EvaluationOptions] -> ShowS
show :: EvaluationOptions -> String
$cshow :: EvaluationOptions -> String
showsPrec :: Int -> EvaluationOptions -> ShowS
$cshowsPrec :: Int -> EvaluationOptions -> ShowS
Show)
instance Control.DeepSeq.NFData EvaluationOptions where
rnf :: EvaluationOptions -> ()
rnf MkEvaluationOptions {
getMaximumTotalRankValue :: EvaluationOptions -> RankValue
getMaximumTotalRankValue = RankValue
maximumTotalValue,
getCriteriaWeights :: EvaluationOptions -> CriteriaWeights
getCriteriaWeights = CriteriaWeights
criteriaWeights,
getIncrementalEvaluation :: EvaluationOptions -> IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
incrementalEvaluation,
getMaybePieceSquareByCoordinatesByRank :: EvaluationOptions -> Maybe PieceSquareByCoordinatesByRank
getMaybePieceSquareByCoordinatesByRank = Maybe PieceSquareByCoordinatesByRank
maybePieceSquareByCoordinatesByRank
} = (RankValue, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareByCoordinatesByRank)
-> ()
forall a. NFData a => a -> ()
Control.DeepSeq.rnf (RankValue
maximumTotalValue, CriteriaWeights
criteriaWeights, IncrementalEvaluation
incrementalEvaluation, Maybe PieceSquareByCoordinatesByRank
maybePieceSquareByCoordinatesByRank)
instance Property.ShowFloat.ShowFloat EvaluationOptions where
showsFloat :: (RankValue -> ShowS) -> EvaluationOptions -> ShowS
showsFloat RankValue -> ShowS
fromDouble MkEvaluationOptions {
getRankValues :: EvaluationOptions -> RankValues
getRankValues = RankValues
rankValues,
getCriteriaWeights :: EvaluationOptions -> CriteriaWeights
getCriteriaWeights = CriteriaWeights
criteriaWeights,
getIncrementalEvaluation :: EvaluationOptions -> IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
incrementalEvaluation,
getMaybePieceSquareTablePair :: EvaluationOptions -> Maybe PieceSquareTablePair
getMaybePieceSquareTablePair = Maybe PieceSquareTablePair
maybePieceSquareTablePair
} = [(String, ShowS)] -> ShowS
Text.ShowList.showsAssociationList' ([(String, ShowS)] -> ShowS) -> [(String, ShowS)] -> ShowS
forall a b. (a -> b) -> a -> b
$ [
(
String
Input.RankValues.tag, (RankValue -> ShowS) -> RankValues -> ShowS
forall a. ShowFloat a => (RankValue -> ShowS) -> a -> ShowS
Property.ShowFloat.showsFloat RankValue -> ShowS
fromDouble RankValues
rankValues
), (
String
incrementalEvaluationTag, IncrementalEvaluation -> ShowS
forall a. Show a => a -> ShowS
shows IncrementalEvaluation
incrementalEvaluation
), (
String
Input.CriteriaWeights.tag, (RankValue -> ShowS) -> CriteriaWeights -> ShowS
forall a. ShowFloat a => (RankValue -> ShowS) -> a -> ShowS
Property.ShowFloat.showsFloat RankValue -> ShowS
fromDouble CriteriaWeights
criteriaWeights
)
] [(String, ShowS)] -> [(String, ShowS)] -> [(String, ShowS)]
forall a. [a] -> [a] -> [a]
++ [(String, ShowS)]
-> (PieceSquareTablePair -> [(String, ShowS)])
-> Maybe PieceSquareTablePair
-> [(String, ShowS)]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [] (
\(PieceSquareTable
t, PieceSquareTable
t') -> [
(
String
Input.PieceSquareTable.tag,
(RankValue -> ShowS) -> PieceSquareTable -> ShowS
forall a. ShowFloat a => (RankValue -> ShowS) -> a -> ShowS
Property.ShowFloat.showsFloat RankValue -> ShowS
fromDouble PieceSquareTable
t
), (
String
pieceSquareTableEndGameTag,
(RankValue -> ShowS) -> PieceSquareTable -> ShowS
forall a. ShowFloat a => (RankValue -> ShowS) -> a -> ShowS
Property.ShowFloat.showsFloat RankValue -> ShowS
fromDouble PieceSquareTable
t'
)
]
) Maybe PieceSquareTablePair
maybePieceSquareTablePair
instance Data.Default.Default EvaluationOptions where
def :: EvaluationOptions
def = MkEvaluationOptions :: RankValues
-> RankValue
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe PieceSquareTablePair
-> Maybe PieceSquareByCoordinatesByRank
-> EvaluationOptions
MkEvaluationOptions {
getRankValues :: RankValues
getRankValues = RankValues
rankValues,
getMaximumTotalRankValue :: RankValue
getMaximumTotalRankValue = RankValues -> RankValue
Input.RankValues.calculateMaximumTotalValue RankValues
rankValues,
getCriteriaWeights :: CriteriaWeights
getCriteriaWeights = CriteriaWeights
forall a. Default a => a
Data.Default.def,
getIncrementalEvaluation :: IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
True,
getMaybePieceSquareTablePair :: Maybe PieceSquareTablePair
getMaybePieceSquareTablePair = Maybe PieceSquareTablePair
forall a. Maybe a
Nothing,
getMaybePieceSquareByCoordinatesByRank :: Maybe PieceSquareByCoordinatesByRank
getMaybePieceSquareByCoordinatesByRank = Maybe PieceSquareByCoordinatesByRank
forall a. Maybe a
Nothing
} where
rankValues :: RankValues
rankValues = RankValues
forall a. Default a => a
Data.Default.def
instance HXT.XmlPickler EvaluationOptions where
xpickle :: PU EvaluationOptions
xpickle = EvaluationOptions -> PU EvaluationOptions -> PU EvaluationOptions
forall a. Eq a => a -> PU a -> PU a
HXT.xpDefault EvaluationOptions
def (PU EvaluationOptions -> PU EvaluationOptions)
-> (PU PieceSquareTablePair -> PU EvaluationOptions)
-> PU PieceSquareTablePair
-> PU EvaluationOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> PU EvaluationOptions -> PU EvaluationOptions
forall a. String -> PU a -> PU a
HXT.xpElem String
tag (PU EvaluationOptions -> PU EvaluationOptions)
-> (PU PieceSquareTablePair -> PU EvaluationOptions)
-> PU PieceSquareTablePair
-> PU EvaluationOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareTablePair)
-> EvaluationOptions,
EvaluationOptions
-> (RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareTablePair))
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareTablePair)
-> PU EvaluationOptions
forall a b. (a -> b, b -> a) -> PU a -> PU b
HXT.xpWrap (
\(RankValues
a, CriteriaWeights
b, IncrementalEvaluation
c, Maybe PieceSquareTablePair
d) -> RankValues
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe PieceSquareTablePair
-> EvaluationOptions
mkEvaluationOptions RankValues
a CriteriaWeights
b IncrementalEvaluation
c Maybe PieceSquareTablePair
d,
\MkEvaluationOptions {
getRankValues :: EvaluationOptions -> RankValues
getRankValues = RankValues
rankValues,
getCriteriaWeights :: EvaluationOptions -> CriteriaWeights
getCriteriaWeights = CriteriaWeights
criteriaWeights,
getIncrementalEvaluation :: EvaluationOptions -> IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
incrementalEvaluation,
getMaybePieceSquareTablePair :: EvaluationOptions -> Maybe PieceSquareTablePair
getMaybePieceSquareTablePair = Maybe PieceSquareTablePair
maybePieceSquareTablePair
} -> (
RankValues
rankValues,
CriteriaWeights
criteriaWeights,
IncrementalEvaluation
incrementalEvaluation,
Maybe PieceSquareTablePair
maybePieceSquareTablePair
)
) (PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareTablePair)
-> PU EvaluationOptions)
-> (PU PieceSquareTablePair
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareTablePair))
-> PU PieceSquareTablePair
-> PU EvaluationOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PU RankValues
-> PU CriteriaWeights
-> PU IncrementalEvaluation
-> PU (Maybe PieceSquareTablePair)
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareTablePair)
forall a b c d. PU a -> PU b -> PU c -> PU d -> PU (a, b, c, d)
HXT.xp4Tuple PU RankValues
forall a. XmlPickler a => PU a
HXT.xpickle PU CriteriaWeights
forall a. XmlPickler a => PU a
HXT.xpickle (
EvaluationOptions -> IncrementalEvaluation
getIncrementalEvaluation EvaluationOptions
def IncrementalEvaluation
-> PU IncrementalEvaluation -> PU IncrementalEvaluation
forall a. Eq a => a -> PU a -> PU a
`HXT.xpDefault` String -> PU IncrementalEvaluation -> PU IncrementalEvaluation
forall a. String -> PU a -> PU a
HXT.xpAttr String
incrementalEvaluationTag PU IncrementalEvaluation
forall a. XmlPickler a => PU a
HXT.xpickle
) (PU (Maybe PieceSquareTablePair)
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareTablePair))
-> (PU PieceSquareTablePair -> PU (Maybe PieceSquareTablePair))
-> PU PieceSquareTablePair
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe PieceSquareTablePair)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PU PieceSquareTablePair -> PU (Maybe PieceSquareTablePair)
forall a. PU a -> PU (Maybe a)
HXT.xpOption (PU PieceSquareTablePair -> PU (Maybe PieceSquareTablePair))
-> (PU PieceSquareTablePair -> PU PieceSquareTablePair)
-> PU PieceSquareTablePair
-> PU (Maybe PieceSquareTablePair)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> PU PieceSquareTablePair -> PU PieceSquareTablePair
forall a. String -> PU a -> PU a
HXT.xpElem String
pieceSquareTablesTag (PU PieceSquareTablePair -> PU EvaluationOptions)
-> PU PieceSquareTablePair -> PU EvaluationOptions
forall a b. (a -> b) -> a -> b
$ String -> PU PieceSquareTable -> PU PieceSquareTable
forall a. String -> PU a -> PU a
HXT.xpElem String
Input.PieceSquareTable.tag PU PieceSquareTable
forall a. XmlPickler a => PU a
HXT.xpickle PU PieceSquareTable
-> PU PieceSquareTable -> PU PieceSquareTablePair
forall a b. PU a -> PU b -> PU (a, b)
`HXT.xpPair` String -> PU PieceSquareTable -> PU PieceSquareTable
forall a. String -> PU a -> PU a
HXT.xpElem String
pieceSquareTableEndGameTag PU PieceSquareTable
forall a. XmlPickler a => PU a
HXT.xpickle where
def :: EvaluationOptions
def = EvaluationOptions
forall a. Default a => a
Data.Default.def
fromPieceSquareTablePair :: PieceSquareTablePair -> Component.PieceSquareByCoordinatesByRank.PieceSquareByCoordinatesByRank
fromPieceSquareTablePair :: PieceSquareTablePair -> PieceSquareByCoordinatesByRank
fromPieceSquareTablePair PieceSquareTablePair
pieceSquareTablePair = (Rank -> EitherPieceSquareValueByNPiecesByCoordinates)
-> PieceSquareByCoordinatesByRank
Component.PieceSquareByCoordinatesByRank.mkPieceSquareByCoordinatesByRank ((Rank -> EitherPieceSquareValueByNPiecesByCoordinates)
-> PieceSquareByCoordinatesByRank)
-> (Rank -> EitherPieceSquareValueByNPiecesByCoordinates)
-> PieceSquareByCoordinatesByRank
forall a b. (a -> b) -> a -> b
$ \Rank
rank -> (
\(Array Coordinates RankValue
openingGamePieceSquareValueByCoordinates, Maybe (Array Coordinates RankValue)
maybeEndGamePieceSquareValueByCoordinates) -> EitherPieceSquareValueByNPiecesByCoordinates
-> (Array Coordinates RankValue
-> EitherPieceSquareValueByNPiecesByCoordinates)
-> Maybe (Array Coordinates RankValue)
-> EitherPieceSquareValueByNPiecesByCoordinates
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe (
Array Coordinates RankValue
-> EitherPieceSquareValueByNPiecesByCoordinates
forall a b. a -> Either a b
Left Array Coordinates RankValue
openingGamePieceSquareValueByCoordinates
) (
Array Coordinates PieceSquareValueByNPieces
-> EitherPieceSquareValueByNPiecesByCoordinates
forall a b. b -> Either a b
Right (Array Coordinates PieceSquareValueByNPieces
-> EitherPieceSquareValueByNPiecesByCoordinates)
-> (Array Coordinates RankValue
-> Array Coordinates PieceSquareValueByNPieces)
-> Array Coordinates RankValue
-> EitherPieceSquareValueByNPiecesByCoordinates
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PieceSquareValueByNPieces]
-> Array Coordinates PieceSquareValueByNPieces
forall (a :: * -> * -> *) e. IArray a e => [e] -> a Coordinates e
Cartesian.Coordinates.listArrayByCoordinates ([PieceSquareValueByNPieces]
-> Array Coordinates PieceSquareValueByNPieces)
-> (Array Coordinates RankValue -> [PieceSquareValueByNPieces])
-> Array Coordinates RankValue
-> Array Coordinates PieceSquareValueByNPieces
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RankValue -> RankValue -> PieceSquareValueByNPieces)
-> [RankValue] -> [RankValue] -> [PieceSquareValueByNPieces]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith RankValue -> RankValue -> PieceSquareValueByNPieces
Component.PieceSquareByCoordinatesByRank.interpolatePieceSquareValues (
Array Coordinates RankValue -> [RankValue]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
Data.Array.IArray.elems Array Coordinates RankValue
openingGamePieceSquareValueByCoordinates
) ([RankValue] -> [PieceSquareValueByNPieces])
-> (Array Coordinates RankValue -> [RankValue])
-> Array Coordinates RankValue
-> [PieceSquareValueByNPieces]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array Coordinates RankValue -> [RankValue]
forall (a :: * -> * -> *) e i. (IArray a e, Ix i) => a i e -> [e]
Data.Array.IArray.elems
) Maybe (Array Coordinates RankValue)
maybeEndGamePieceSquareValueByCoordinates
) ((Array Coordinates RankValue, Maybe (Array Coordinates RankValue))
-> EitherPieceSquareValueByNPiecesByCoordinates)
-> (Array Coordinates RankValue,
Maybe (Array Coordinates RankValue))
-> EitherPieceSquareValueByNPiecesByCoordinates
forall a b. (a -> b) -> a -> b
$ (
Maybe (Array Coordinates RankValue) -> Array Coordinates RankValue
forall a. HasCallStack => Maybe a -> a
Data.Maybe.fromJust (Maybe (Array Coordinates RankValue)
-> Array Coordinates RankValue)
-> (PieceSquareTable -> Maybe (Array Coordinates RankValue))
-> PieceSquareTable
-> Array Coordinates RankValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rank -> PieceSquareTable -> Maybe (Array Coordinates RankValue)
Input.PieceSquareTable.dereference Rank
rank (PieceSquareTable -> Array Coordinates RankValue)
-> (PieceSquareTable -> Maybe (Array Coordinates RankValue))
-> PieceSquareTablePair
-> (Array Coordinates RankValue,
Maybe (Array Coordinates RankValue))
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** Rank -> PieceSquareTable -> Maybe (Array Coordinates RankValue)
Input.PieceSquareTable.dereference Rank
rank
) PieceSquareTablePair
pieceSquareTablePair
mkEvaluationOptions
:: Input.RankValues.RankValues
-> Input.CriteriaWeights.CriteriaWeights
-> IncrementalEvaluation
-> Maybe PieceSquareTablePair
-> EvaluationOptions
mkEvaluationOptions :: RankValues
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe PieceSquareTablePair
-> EvaluationOptions
mkEvaluationOptions RankValues
rankValues CriteriaWeights
criteriaWeights IncrementalEvaluation
incrementalEvaluation Maybe PieceSquareTablePair
maybePieceSquareTablePair
| Just (PieceSquareTable
pieceSquareTable, PieceSquareTable
_) <- Maybe PieceSquareTablePair
maybePieceSquareTablePair
, let undefinedRanks :: Set Rank
undefinedRanks = PieceSquareTable -> Set Rank
Input.PieceSquareTable.findUndefinedRanks PieceSquareTable
pieceSquareTable
, IncrementalEvaluation -> IncrementalEvaluation
not (IncrementalEvaluation -> IncrementalEvaluation)
-> IncrementalEvaluation -> IncrementalEvaluation
forall a b. (a -> b) -> a -> b
$ Set Rank -> IncrementalEvaluation
forall (t :: * -> *) a. Foldable t => t a -> IncrementalEvaluation
Data.Foldable.null Set Rank
undefinedRanks
= Exception -> EvaluationOptions
forall a e. Exception e => e -> a
Control.Exception.throw (Exception -> EvaluationOptions)
-> (String -> Exception) -> String -> EvaluationOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Exception
Data.Exception.mkInsufficientData (String -> Exception) -> ShowS -> String -> Exception
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
"BishBosh.Input.EvaluationOptions.mkEvaluationOptions:\tranks" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
Text.ShowList.showsAssociation (String -> EvaluationOptions) -> String -> EvaluationOptions
forall a b. (a -> b) -> a -> b
$ [Rank] -> ShowS
forall a. Show a => a -> ShowS
shows (Set Rank -> [Rank]
forall (t :: * -> *) a. Foldable t => t a -> [a]
Data.Foldable.toList Set Rank
undefinedRanks) String
" are undefined."
| CriteriaWeights -> CriterionWeight
Input.CriteriaWeights.getWeightOfPieceSquareValue CriteriaWeights
criteriaWeights CriterionWeight -> CriterionWeight -> IncrementalEvaluation
forall a. Eq a => a -> a -> IncrementalEvaluation
/= CriterionWeight
forall a. Bounded a => a
minBound
, Maybe PieceSquareTablePair -> IncrementalEvaluation
forall a. Maybe a -> IncrementalEvaluation
Data.Maybe.isNothing Maybe PieceSquareTablePair
maybePieceSquareTablePair
= Exception -> EvaluationOptions
forall a e. Exception e => e -> a
Control.Exception.throw (Exception -> EvaluationOptions)
-> (String -> Exception) -> String -> EvaluationOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Exception
Data.Exception.mkIncompatibleData (String -> Exception) -> ShowS -> String -> Exception
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
"BishBosh.Input.EvaluationOptions.mkEvaluationOptions:\tweight of " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
forall a. Show a => a -> ShowS
shows String
Input.CriteriaWeights.weightOfPieceSquareValueTag ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" is defined but " (String -> EvaluationOptions) -> String -> EvaluationOptions
forall a b. (a -> b) -> a -> b
$ String -> ShowS
forall a. Show a => a -> ShowS
shows String
Input.PieceSquareTable.tag String
" isn't."
| RankValue
maximumTotalRankValue RankValue -> RankValue -> IncrementalEvaluation
forall a. Eq a => a -> a -> IncrementalEvaluation
== RankValue
0 IncrementalEvaluation
-> IncrementalEvaluation -> IncrementalEvaluation
&& CriteriaWeights -> CriterionWeight
Input.CriteriaWeights.getWeightOfMaterial CriteriaWeights
criteriaWeights CriterionWeight -> CriterionWeight -> IncrementalEvaluation
forall a. Eq a => a -> a -> IncrementalEvaluation
/= CriterionWeight
0 = Exception -> EvaluationOptions
forall a e. Exception e => e -> a
Control.Exception.throw (Exception -> EvaluationOptions)
-> (String -> Exception) -> String -> EvaluationOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Exception
Data.Exception.mkIncompatibleData (String -> Exception) -> ShowS -> String -> Exception
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
"BishBosh.Input.EvaluationOptions.mkEvaluationOptions:\tweight of " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
forall a. Show a => a -> ShowS
shows String
Input.CriteriaWeights.weightOfMaterialTag ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" is non-zero, but the maximum total rank-value is " (String -> EvaluationOptions) -> String -> EvaluationOptions
forall a b. (a -> b) -> a -> b
$ RankValues -> ShowS
forall a. Show a => a -> ShowS
shows RankValues
rankValues String
"."
| IncrementalEvaluation
otherwise = MkEvaluationOptions :: RankValues
-> RankValue
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe PieceSquareTablePair
-> Maybe PieceSquareByCoordinatesByRank
-> EvaluationOptions
MkEvaluationOptions {
getRankValues :: RankValues
getRankValues = RankValues
rankValues,
getMaximumTotalRankValue :: RankValue
getMaximumTotalRankValue = RankValue
maximumTotalRankValue,
getCriteriaWeights :: CriteriaWeights
getCriteriaWeights = CriteriaWeights
criteriaWeights,
getIncrementalEvaluation :: IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
incrementalEvaluation,
getMaybePieceSquareTablePair :: Maybe PieceSquareTablePair
getMaybePieceSquareTablePair = Maybe PieceSquareTablePair
maybePieceSquareTablePair,
getMaybePieceSquareByCoordinatesByRank :: Maybe PieceSquareByCoordinatesByRank
getMaybePieceSquareByCoordinatesByRank = PieceSquareTablePair -> PieceSquareByCoordinatesByRank
fromPieceSquareTablePair (PieceSquareTablePair -> PieceSquareByCoordinatesByRank)
-> Maybe PieceSquareTablePair
-> Maybe PieceSquareByCoordinatesByRank
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe PieceSquareTablePair
maybePieceSquareTablePair
} where
maximumTotalRankValue :: RankValue
maximumTotalRankValue = RankValues -> RankValue
Input.RankValues.calculateMaximumTotalValue RankValues
rankValues
type Reader = Control.Monad.Reader.Reader EvaluationOptions