1
1
{-# LANGUAGE NamedFieldPuns #-}
2
+ {-# LANGUAGE RecordWildCards #-}
2
3
{-# LANGUAGE OverloadedStrings #-}
3
4
module Core.Evaluator where
4
5
@@ -17,13 +18,19 @@ loose = -maxBound
17
18
18
19
data SimpleEvaluator = SimpleEvaluator {
19
20
seRules :: SomeRules ,
21
+ seNumericWeight :: Score ,
20
22
sePositionWeight :: Score ,
21
- seKingCoef :: Score
23
+ seCenterWeight :: Score ,
24
+ seOppositeSideWeight :: Score ,
25
+ seBackedWeight :: Score ,
26
+ seAsymetryWeight :: Score ,
27
+ seKingCoef :: Score ,
28
+ seHelpedKingCoef :: Score
22
29
}
23
30
deriving (Show )
24
31
25
32
defaultEvaluator :: GameRules rules => rules -> SimpleEvaluator
26
- defaultEvaluator rules = SimpleEvaluator (SomeRules rules) 1 3
33
+ defaultEvaluator rules = SimpleEvaluator (SomeRules rules) 12 1 2 1 3 1 3 5
27
34
28
35
instance Evaluator SimpleEvaluator where
29
36
evaluatorName _ = " simple"
@@ -35,13 +42,13 @@ instance Evaluator SimpleEvaluator where
35
42
Just (Just True ) -> e {sePositionWeight = 1 }
36
43
Just (Just False ) -> e {sePositionWeight = 0 }
37
44
38
- evalBoard (SimpleEvaluator {seKingCoef = k, sePositionWeight, seRules= SomeRules rules}) whoAsks whoMovesNext board =
45
+ evalBoard (SimpleEvaluator {seRules= SomeRules rules, .. }) whoAsks whoMovesNext board =
39
46
let kingCoef side =
40
47
-- King is much more useful when there are enough men to help it
41
48
let (men, _) = myCounts side board
42
49
in if men > 3
43
- then k + 2
44
- else k
50
+ then seHelpedKingCoef
51
+ else seKingCoef
45
52
46
53
numericScore side =
47
54
let (myMen, myKings) = myCounts side board
@@ -90,13 +97,13 @@ instance Evaluator SimpleEvaluator where
90
97
91
98
positionalScore side =
92
99
let (men, kings) = myLabelsCount side board isCenter
93
- in 2 * (kingCoef side * fromIntegral kings + fromIntegral men) +
94
- fromIntegral (opponentSideCount side) +
95
- fromIntegral ( 3 * backedScore side) -
96
- fromIntegral (asymetry side)
100
+ in seCenterWeight * (kingCoef side * fromIntegral kings + fromIntegral men) +
101
+ seOppositeSideWeight * fromIntegral (opponentSideCount side) +
102
+ seBackedWeight * fromIntegral ( backedScore side) -
103
+ seAsymetryWeight * fromIntegral (asymetry side)
97
104
98
- myScore = myNumeric * 12 + (positionalScore whoAsks) * sePositionWeight
99
- opponentScore = opponentNumeric * 12 + positionalScore (opposite whoAsks) * sePositionWeight
105
+ myScore = myNumeric * seNumericWeight + (positionalScore whoAsks) * sePositionWeight
106
+ opponentScore = opponentNumeric * seNumericWeight + positionalScore (opposite whoAsks) * sePositionWeight
100
107
101
108
in if myNumeric == 0
102
109
then loose
0 commit comments