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.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 pieceSquareValue = (Input.PieceSquareTable.PieceSquareTable pieceSquareValue, Input.PieceSquareTable.PieceSquareTable pieceSquareValue)
data EvaluationOptions pieceSquareValue = MkEvaluationOptions {
EvaluationOptions pieceSquareValue -> RankValues
getRankValues :: Input.RankValues.RankValues,
EvaluationOptions pieceSquareValue -> RankValue
getMaximumTotalRankValue :: Type.Mass.RankValue,
EvaluationOptions pieceSquareValue -> CriteriaWeights
getCriteriaWeights :: Input.CriteriaWeights.CriteriaWeights,
EvaluationOptions pieceSquareValue -> IncrementalEvaluation
getIncrementalEvaluation :: IncrementalEvaluation,
EvaluationOptions pieceSquareValue
-> Maybe (PieceSquareTablePair pieceSquareValue)
getMaybePieceSquareTablePair :: Maybe (PieceSquareTablePair pieceSquareValue),
EvaluationOptions pieceSquareValue
-> Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
getMaybePieceSquareByCoordinatesByRank :: Maybe (
Component.PieceSquareByCoordinatesByRank.PieceSquareByCoordinatesByRank pieceSquareValue
)
} deriving (EvaluationOptions pieceSquareValue
-> EvaluationOptions pieceSquareValue -> IncrementalEvaluation
(EvaluationOptions pieceSquareValue
-> EvaluationOptions pieceSquareValue -> IncrementalEvaluation)
-> (EvaluationOptions pieceSquareValue
-> EvaluationOptions pieceSquareValue -> IncrementalEvaluation)
-> Eq (EvaluationOptions pieceSquareValue)
forall pieceSquareValue.
Eq pieceSquareValue =>
EvaluationOptions pieceSquareValue
-> EvaluationOptions pieceSquareValue -> IncrementalEvaluation
forall a.
(a -> a -> IncrementalEvaluation)
-> (a -> a -> IncrementalEvaluation) -> Eq a
/= :: EvaluationOptions pieceSquareValue
-> EvaluationOptions pieceSquareValue -> IncrementalEvaluation
$c/= :: forall pieceSquareValue.
Eq pieceSquareValue =>
EvaluationOptions pieceSquareValue
-> EvaluationOptions pieceSquareValue -> IncrementalEvaluation
== :: EvaluationOptions pieceSquareValue
-> EvaluationOptions pieceSquareValue -> IncrementalEvaluation
$c== :: forall pieceSquareValue.
Eq pieceSquareValue =>
EvaluationOptions pieceSquareValue
-> EvaluationOptions pieceSquareValue -> IncrementalEvaluation
Eq, Int -> EvaluationOptions pieceSquareValue -> ShowS
[EvaluationOptions pieceSquareValue] -> ShowS
EvaluationOptions pieceSquareValue -> String
(Int -> EvaluationOptions pieceSquareValue -> ShowS)
-> (EvaluationOptions pieceSquareValue -> String)
-> ([EvaluationOptions pieceSquareValue] -> ShowS)
-> Show (EvaluationOptions pieceSquareValue)
forall pieceSquareValue.
Show pieceSquareValue =>
Int -> EvaluationOptions pieceSquareValue -> ShowS
forall pieceSquareValue.
Show pieceSquareValue =>
[EvaluationOptions pieceSquareValue] -> ShowS
forall pieceSquareValue.
Show pieceSquareValue =>
EvaluationOptions pieceSquareValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvaluationOptions pieceSquareValue] -> ShowS
$cshowList :: forall pieceSquareValue.
Show pieceSquareValue =>
[EvaluationOptions pieceSquareValue] -> ShowS
show :: EvaluationOptions pieceSquareValue -> String
$cshow :: forall pieceSquareValue.
Show pieceSquareValue =>
EvaluationOptions pieceSquareValue -> String
showsPrec :: Int -> EvaluationOptions pieceSquareValue -> ShowS
$cshowsPrec :: forall pieceSquareValue.
Show pieceSquareValue =>
Int -> EvaluationOptions pieceSquareValue -> ShowS
Show)
instance Control.DeepSeq.NFData pieceSquareValue => Control.DeepSeq.NFData (EvaluationOptions pieceSquareValue) where
rnf :: EvaluationOptions pieceSquareValue -> ()
rnf MkEvaluationOptions {
getMaximumTotalRankValue :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> RankValue
getMaximumTotalRankValue = RankValue
maximumTotalValue,
getCriteriaWeights :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> CriteriaWeights
getCriteriaWeights = CriteriaWeights
criteriaWeights,
getIncrementalEvaluation :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
incrementalEvaluation,
getMaybePieceSquareByCoordinatesByRank :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue
-> Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
getMaybePieceSquareByCoordinatesByRank = Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
maybePieceSquareByCoordinatesByRank
} = (RankValue, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareByCoordinatesByRank pieceSquareValue))
-> ()
forall a. NFData a => a -> ()
Control.DeepSeq.rnf (RankValue
maximumTotalValue, CriteriaWeights
criteriaWeights, IncrementalEvaluation
incrementalEvaluation, Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
maybePieceSquareByCoordinatesByRank)
instance (Real pieceSquareValue, Show pieceSquareValue) => Property.ShowFloat.ShowFloat (EvaluationOptions pieceSquareValue) where
showsFloat :: (RankValue -> ShowS) -> EvaluationOptions pieceSquareValue -> ShowS
showsFloat RankValue -> ShowS
fromDouble MkEvaluationOptions {
getRankValues :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> RankValues
getRankValues = RankValues
rankValues,
getCriteriaWeights :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> CriteriaWeights
getCriteriaWeights = CriteriaWeights
criteriaWeights,
getIncrementalEvaluation :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
incrementalEvaluation,
getMaybePieceSquareTablePair :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue
-> Maybe (PieceSquareTablePair pieceSquareValue)
getMaybePieceSquareTablePair = Maybe (PieceSquareTablePair pieceSquareValue)
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 pieceSquareValue -> [(String, ShowS)])
-> Maybe (PieceSquareTablePair pieceSquareValue)
-> [(String, ShowS)]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [] (
\(PieceSquareTable pieceSquareValue
t, PieceSquareTable pieceSquareValue
t') -> [
(
String
Input.PieceSquareTable.tag,
(RankValue -> ShowS) -> PieceSquareTable pieceSquareValue -> ShowS
forall a. ShowFloat a => (RankValue -> ShowS) -> a -> ShowS
Property.ShowFloat.showsFloat RankValue -> ShowS
fromDouble PieceSquareTable pieceSquareValue
t
), (
String
pieceSquareTableEndGameTag,
(RankValue -> ShowS) -> PieceSquareTable pieceSquareValue -> ShowS
forall a. ShowFloat a => (RankValue -> ShowS) -> a -> ShowS
Property.ShowFloat.showsFloat RankValue -> ShowS
fromDouble PieceSquareTable pieceSquareValue
t'
)
]
) Maybe (PieceSquareTablePair pieceSquareValue)
maybePieceSquareTablePair
instance Data.Default.Default (EvaluationOptions pieceSquareValue) where
def :: EvaluationOptions pieceSquareValue
def = MkEvaluationOptions :: forall pieceSquareValue.
RankValues
-> RankValue
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe (PieceSquareTablePair pieceSquareValue)
-> Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
-> EvaluationOptions pieceSquareValue
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 pieceSquareValue)
getMaybePieceSquareTablePair = Maybe (PieceSquareTablePair pieceSquareValue)
forall a. Maybe a
Nothing,
getMaybePieceSquareByCoordinatesByRank :: Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
getMaybePieceSquareByCoordinatesByRank = Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
forall a. Maybe a
Nothing
} where
rankValues :: RankValues
rankValues = RankValues
forall a. Default a => a
Data.Default.def
instance (
Fractional pieceSquareValue,
Ord pieceSquareValue,
Real pieceSquareValue,
Show pieceSquareValue
) => HXT.XmlPickler (EvaluationOptions pieceSquareValue) where
xpickle :: PU (EvaluationOptions pieceSquareValue)
xpickle = EvaluationOptions pieceSquareValue
-> PU (EvaluationOptions pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue)
forall a. Eq a => a -> PU a -> PU a
HXT.xpDefault EvaluationOptions pieceSquareValue
def (PU (EvaluationOptions pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue))
-> (PU (PieceSquareTablePair pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue))
-> PU (PieceSquareTablePair pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String
-> PU (EvaluationOptions pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue)
forall a. String -> PU a -> PU a
HXT.xpElem String
tag (PU (EvaluationOptions pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue))
-> (PU (PieceSquareTablePair pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue))
-> PU (PieceSquareTablePair pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue))
-> EvaluationOptions pieceSquareValue,
EvaluationOptions pieceSquareValue
-> (RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue)))
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue))
-> PU (EvaluationOptions pieceSquareValue)
forall a b. (a -> b, b -> a) -> PU a -> PU b
HXT.xpWrap (
\(RankValues
a, CriteriaWeights
b, IncrementalEvaluation
c, Maybe (PieceSquareTablePair pieceSquareValue)
d) -> RankValues
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe (PieceSquareTablePair pieceSquareValue)
-> EvaluationOptions pieceSquareValue
forall pieceSquareValue.
Fractional pieceSquareValue =>
RankValues
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe (PieceSquareTablePair pieceSquareValue)
-> EvaluationOptions pieceSquareValue
mkEvaluationOptions RankValues
a CriteriaWeights
b IncrementalEvaluation
c Maybe (PieceSquareTablePair pieceSquareValue)
d,
\MkEvaluationOptions {
getRankValues :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> RankValues
getRankValues = RankValues
rankValues,
getCriteriaWeights :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> CriteriaWeights
getCriteriaWeights = CriteriaWeights
criteriaWeights,
getIncrementalEvaluation :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
incrementalEvaluation,
getMaybePieceSquareTablePair :: forall pieceSquareValue.
EvaluationOptions pieceSquareValue
-> Maybe (PieceSquareTablePair pieceSquareValue)
getMaybePieceSquareTablePair = Maybe (PieceSquareTablePair pieceSquareValue)
maybePieceSquareTablePair
} -> (
RankValues
rankValues,
CriteriaWeights
criteriaWeights,
IncrementalEvaluation
incrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue)
maybePieceSquareTablePair
)
) (PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue))
-> PU (EvaluationOptions pieceSquareValue))
-> (PU (PieceSquareTablePair pieceSquareValue)
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue)))
-> PU (PieceSquareTablePair pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PU RankValues
-> PU CriteriaWeights
-> PU IncrementalEvaluation
-> PU (Maybe (PieceSquareTablePair pieceSquareValue))
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue))
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 pieceSquareValue -> IncrementalEvaluation
forall pieceSquareValue.
EvaluationOptions pieceSquareValue -> IncrementalEvaluation
getIncrementalEvaluation EvaluationOptions pieceSquareValue
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 pieceSquareValue))
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue)))
-> (PU (PieceSquareTablePair pieceSquareValue)
-> PU (Maybe (PieceSquareTablePair pieceSquareValue)))
-> PU (PieceSquareTablePair pieceSquareValue)
-> PU
(RankValues, CriteriaWeights, IncrementalEvaluation,
Maybe (PieceSquareTablePair pieceSquareValue))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PU (PieceSquareTablePair pieceSquareValue)
-> PU (Maybe (PieceSquareTablePair pieceSquareValue))
forall a. PU a -> PU (Maybe a)
HXT.xpOption (PU (PieceSquareTablePair pieceSquareValue)
-> PU (Maybe (PieceSquareTablePair pieceSquareValue)))
-> (PU (PieceSquareTablePair pieceSquareValue)
-> PU (PieceSquareTablePair pieceSquareValue))
-> PU (PieceSquareTablePair pieceSquareValue)
-> PU (Maybe (PieceSquareTablePair pieceSquareValue))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String
-> PU (PieceSquareTablePair pieceSquareValue)
-> PU (PieceSquareTablePair pieceSquareValue)
forall a. String -> PU a -> PU a
HXT.xpElem String
pieceSquareTablesTag (PU (PieceSquareTablePair pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue))
-> PU (PieceSquareTablePair pieceSquareValue)
-> PU (EvaluationOptions pieceSquareValue)
forall a b. (a -> b) -> a -> b
$ String
-> PU (PieceSquareTable pieceSquareValue)
-> PU (PieceSquareTable pieceSquareValue)
forall a. String -> PU a -> PU a
HXT.xpElem String
Input.PieceSquareTable.tag PU (PieceSquareTable pieceSquareValue)
forall a. XmlPickler a => PU a
HXT.xpickle PU (PieceSquareTable pieceSquareValue)
-> PU (PieceSquareTable pieceSquareValue)
-> PU (PieceSquareTablePair pieceSquareValue)
forall a b. PU a -> PU b -> PU (a, b)
`HXT.xpPair` String
-> PU (PieceSquareTable pieceSquareValue)
-> PU (PieceSquareTable pieceSquareValue)
forall a. String -> PU a -> PU a
HXT.xpElem String
pieceSquareTableEndGameTag PU (PieceSquareTable pieceSquareValue)
forall a. XmlPickler a => PU a
HXT.xpickle where
def :: EvaluationOptions pieceSquareValue
def = EvaluationOptions pieceSquareValue
forall a. Default a => a
Data.Default.def
fromPieceSquareTablePair :: Fractional pieceSquareValue => PieceSquareTablePair pieceSquareValue -> Component.PieceSquareByCoordinatesByRank.PieceSquareByCoordinatesByRank pieceSquareValue
fromPieceSquareTablePair :: PieceSquareTablePair pieceSquareValue
-> PieceSquareByCoordinatesByRank pieceSquareValue
fromPieceSquareTablePair PieceSquareTablePair pieceSquareValue
pieceSquareTablePair = (Rank
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue)
-> PieceSquareByCoordinatesByRank pieceSquareValue
forall pieceSquareValue.
(Rank
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue)
-> PieceSquareByCoordinatesByRank pieceSquareValue
Component.PieceSquareByCoordinatesByRank.mkPieceSquareByCoordinatesByRank ((Rank
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue)
-> PieceSquareByCoordinatesByRank pieceSquareValue)
-> (Rank
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue)
-> PieceSquareByCoordinatesByRank pieceSquareValue
forall a b. (a -> b) -> a -> b
$ \Rank
rank -> (
\(Array Coordinates pieceSquareValue
openingGamePieceSquareValuesByCoordinates, Maybe (Array Coordinates pieceSquareValue)
maybeEndGamePieceSquareValuesByCoordinates) -> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue
-> (Array Coordinates pieceSquareValue
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue)
-> Maybe (Array Coordinates pieceSquareValue)
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe (
Array Coordinates pieceSquareValue
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue
forall a b. a -> Either a b
Left Array Coordinates pieceSquareValue
openingGamePieceSquareValuesByCoordinates
) (
Array Coordinates (PieceSquareValueByNPieces pieceSquareValue)
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue
forall a b. b -> Either a b
Right (Array Coordinates (PieceSquareValueByNPieces pieceSquareValue)
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue)
-> (Array Coordinates pieceSquareValue
-> Array Coordinates (PieceSquareValueByNPieces pieceSquareValue))
-> Array Coordinates pieceSquareValue
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PieceSquareValueByNPieces pieceSquareValue]
-> Array Coordinates (PieceSquareValueByNPieces pieceSquareValue)
forall (a :: * -> * -> *) e. IArray a e => [e] -> a Coordinates e
Cartesian.Coordinates.listArrayByCoordinates ([PieceSquareValueByNPieces pieceSquareValue]
-> Array Coordinates (PieceSquareValueByNPieces pieceSquareValue))
-> (Array Coordinates pieceSquareValue
-> [PieceSquareValueByNPieces pieceSquareValue])
-> Array Coordinates pieceSquareValue
-> Array Coordinates (PieceSquareValueByNPieces pieceSquareValue)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (pieceSquareValue
-> pieceSquareValue -> PieceSquareValueByNPieces pieceSquareValue)
-> [pieceSquareValue]
-> [pieceSquareValue]
-> [PieceSquareValueByNPieces pieceSquareValue]
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith pieceSquareValue
-> pieceSquareValue -> PieceSquareValueByNPieces pieceSquareValue
forall pieceSquareValue.
Fractional pieceSquareValue =>
pieceSquareValue
-> pieceSquareValue -> PieceSquareValueByNPieces pieceSquareValue
Component.PieceSquareByCoordinatesByRank.interpolatePieceSquareValues (
Array Coordinates pieceSquareValue -> [pieceSquareValue]
forall (t :: * -> *) a. Foldable t => t a -> [a]
Data.Foldable.toList Array Coordinates pieceSquareValue
openingGamePieceSquareValuesByCoordinates
) ([pieceSquareValue]
-> [PieceSquareValueByNPieces pieceSquareValue])
-> (Array Coordinates pieceSquareValue -> [pieceSquareValue])
-> Array Coordinates pieceSquareValue
-> [PieceSquareValueByNPieces pieceSquareValue]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array Coordinates pieceSquareValue -> [pieceSquareValue]
forall (t :: * -> *) a. Foldable t => t a -> [a]
Data.Foldable.toList
) Maybe (Array Coordinates pieceSquareValue)
maybeEndGamePieceSquareValuesByCoordinates
) ((Array Coordinates pieceSquareValue,
Maybe (Array Coordinates pieceSquareValue))
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue)
-> (Array Coordinates pieceSquareValue,
Maybe (Array Coordinates pieceSquareValue))
-> EitherPieceSquareValueByNPiecesByCoordinates pieceSquareValue
forall a b. (a -> b) -> a -> b
$ (
Maybe (Array Coordinates pieceSquareValue)
-> Array Coordinates pieceSquareValue
forall a. HasCallStack => Maybe a -> a
Data.Maybe.fromJust (Maybe (Array Coordinates pieceSquareValue)
-> Array Coordinates pieceSquareValue)
-> (PieceSquareTable pieceSquareValue
-> Maybe (Array Coordinates pieceSquareValue))
-> PieceSquareTable pieceSquareValue
-> Array Coordinates pieceSquareValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rank
-> PieceSquareTable pieceSquareValue
-> Maybe (Array Coordinates pieceSquareValue)
forall pieceSquareValue.
Rank
-> PieceSquareTable pieceSquareValue
-> Maybe (ArrayByCoordinates pieceSquareValue)
Input.PieceSquareTable.dereference Rank
rank (PieceSquareTable pieceSquareValue
-> Array Coordinates pieceSquareValue)
-> (PieceSquareTable pieceSquareValue
-> Maybe (Array Coordinates pieceSquareValue))
-> PieceSquareTablePair pieceSquareValue
-> (Array Coordinates pieceSquareValue,
Maybe (Array Coordinates pieceSquareValue))
forall (a :: * -> * -> *) b c b' c'.
Arrow a =>
a b c -> a b' c' -> a (b, b') (c, c')
*** Rank
-> PieceSquareTable pieceSquareValue
-> Maybe (Array Coordinates pieceSquareValue)
forall pieceSquareValue.
Rank
-> PieceSquareTable pieceSquareValue
-> Maybe (ArrayByCoordinates pieceSquareValue)
Input.PieceSquareTable.dereference Rank
rank
) PieceSquareTablePair pieceSquareValue
pieceSquareTablePair
mkEvaluationOptions
:: Fractional pieceSquareValue
=> Input.RankValues.RankValues
-> Input.CriteriaWeights.CriteriaWeights
-> IncrementalEvaluation
-> Maybe (PieceSquareTablePair pieceSquareValue)
-> EvaluationOptions pieceSquareValue
mkEvaluationOptions :: RankValues
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe (PieceSquareTablePair pieceSquareValue)
-> EvaluationOptions pieceSquareValue
mkEvaluationOptions RankValues
rankValues CriteriaWeights
criteriaWeights IncrementalEvaluation
incrementalEvaluation Maybe (PieceSquareTablePair pieceSquareValue)
maybePieceSquareTablePair
| Just (PieceSquareTable pieceSquareValue
pieceSquareTable, PieceSquareTable pieceSquareValue
_) <- Maybe (PieceSquareTablePair pieceSquareValue)
maybePieceSquareTablePair
, let undefinedRanks :: Set Rank
undefinedRanks = PieceSquareTable pieceSquareValue -> Set Rank
forall pieceSquareValue.
PieceSquareTable pieceSquareValue -> Set Rank
Input.PieceSquareTable.findUndefinedRanks PieceSquareTable pieceSquareValue
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 pieceSquareValue
forall a e. Exception e => e -> a
Control.Exception.throw (Exception -> EvaluationOptions pieceSquareValue)
-> (String -> Exception)
-> String
-> EvaluationOptions pieceSquareValue
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 pieceSquareValue)
-> String -> EvaluationOptions pieceSquareValue
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 pieceSquareValue)
-> IncrementalEvaluation
forall a. Maybe a -> IncrementalEvaluation
Data.Maybe.isNothing Maybe (PieceSquareTablePair pieceSquareValue)
maybePieceSquareTablePair
= Exception -> EvaluationOptions pieceSquareValue
forall a e. Exception e => e -> a
Control.Exception.throw (Exception -> EvaluationOptions pieceSquareValue)
-> (String -> Exception)
-> String
-> EvaluationOptions pieceSquareValue
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 pieceSquareValue)
-> String -> EvaluationOptions pieceSquareValue
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 pieceSquareValue
forall a e. Exception e => e -> a
Control.Exception.throw (Exception -> EvaluationOptions pieceSquareValue)
-> (String -> Exception)
-> String
-> EvaluationOptions pieceSquareValue
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 pieceSquareValue)
-> String -> EvaluationOptions pieceSquareValue
forall a b. (a -> b) -> a -> b
$ RankValues -> ShowS
forall a. Show a => a -> ShowS
shows RankValues
rankValues String
"."
| IncrementalEvaluation
otherwise = MkEvaluationOptions :: forall pieceSquareValue.
RankValues
-> RankValue
-> CriteriaWeights
-> IncrementalEvaluation
-> Maybe (PieceSquareTablePair pieceSquareValue)
-> Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
-> EvaluationOptions pieceSquareValue
MkEvaluationOptions {
getRankValues :: RankValues
getRankValues = RankValues
rankValues,
getMaximumTotalRankValue :: RankValue
getMaximumTotalRankValue = RankValue
maximumTotalRankValue,
getCriteriaWeights :: CriteriaWeights
getCriteriaWeights = CriteriaWeights
criteriaWeights,
getIncrementalEvaluation :: IncrementalEvaluation
getIncrementalEvaluation = IncrementalEvaluation
incrementalEvaluation,
getMaybePieceSquareTablePair :: Maybe (PieceSquareTablePair pieceSquareValue)
getMaybePieceSquareTablePair = Maybe (PieceSquareTablePair pieceSquareValue)
maybePieceSquareTablePair,
getMaybePieceSquareByCoordinatesByRank :: Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
getMaybePieceSquareByCoordinatesByRank = PieceSquareTablePair pieceSquareValue
-> PieceSquareByCoordinatesByRank pieceSquareValue
forall pieceSquareValue.
Fractional pieceSquareValue =>
PieceSquareTablePair pieceSquareValue
-> PieceSquareByCoordinatesByRank pieceSquareValue
fromPieceSquareTablePair (PieceSquareTablePair pieceSquareValue
-> PieceSquareByCoordinatesByRank pieceSquareValue)
-> Maybe (PieceSquareTablePair pieceSquareValue)
-> Maybe (PieceSquareByCoordinatesByRank pieceSquareValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` Maybe (PieceSquareTablePair pieceSquareValue)
maybePieceSquareTablePair
} where
maximumTotalRankValue :: RankValue
maximumTotalRankValue = RankValues -> RankValue
Input.RankValues.calculateMaximumTotalValue RankValues
rankValues
type Reader pieceSquareValue = Control.Monad.Reader.Reader (EvaluationOptions pieceSquareValue)