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