-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeight.h
86 lines (72 loc) · 2.23 KB
/
Weight.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#include "GameState.h"
#include <algorithm>
class Weight {
public:
GameState * parentGameState;
double multiplier;
Weight (){}
Weight (double multiplier): multiplier(multiplier){};
//initialize to a parent node
virtual void initialize(GameState * g){
parentGameState = g;
};
//after intializing to a parent node,
//see what things to tweak in order to update heuristics
virtual double evaluate(MoveInfo){return 0;};
virtual void correct(double amount){
multiplier += amount;
};
};
class RandomWeight: public Weight {
public:
RandomWeight():Weight{0}{};
double calculate(MoveInfo) {return 0;};
};
class KillShotCountWeight: public Weight {
//places in the hive that would trigger a recount
Bitboard watchPoints;
Bitboard pinnedWatchPoints;
Bitboard unpinnedWatchPoints;
double scores[2];
int queenCount;
public:
KillShotCountWeight(double multiplier) :Weight(multiplier){};
void initialize(GameState * g) override;
double evaluate(MoveInfo) override;
vector<int> recalculate();
};
class PinnedWeight : public Weight {
public:
PinnedWeight(double multiplier) : Weight(multiplier) {};
double evaluate(MoveInfo) override;
};
class PieceCountWeight : public Weight{
int pieceCounts[2];
public:
PieceCountWeight(double multiplier) :Weight(multiplier) {};
void initialize(GameState*) override;
double evaluate(MoveInfo) override;
};
class PinningPowerWeight : public Weight {
unordered_map <PieceName , double> piecePowers {
{GRASSHOPPER, 1.5}, //worth a bit more than spiders
{QUEEN, 4.5}, //best thing to pin
{LADYBUG, 2}, //more flexible than grasshoppers
{PILLBUG, .75}, //even if pinned, can still use power
{MOSQUITO, 3}, //worth a little more than ants
{BEETLE, 3.5}, //almost as good as having queen pinned
{ANT, 2.5},
{SPIDER, 1}, //not very useful to pin
};
//an inline pin requires twice as many pieces to unpin as
//does an elbow Pin
double inlinePinWeight = 1;
double elbowPinWeight = .5;
public:
PinningPowerWeight(unordered_map<PieceName, double> initialMap){
for (auto iter: initialMap)
piecePowers[iter.first] = iter.second;
}
double evaluate(MoveInfo) override;
};