-
Notifications
You must be signed in to change notification settings - Fork 10
/
PartialPlayer_Defense_Solver.cpp
37 lines (28 loc) · 1.15 KB
/
PartialPlayer_Defense_Solver.cpp
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
#include "PartialPlayer_Defense_Solver.h"
using namespace Prismata;
PartialPlayer_Defense_Solver::PartialPlayer_Defense_Solver(const PlayerID playerID, EvaluationType (*heuristic)(const Card &, const GameState & state, const HealthType))
: _heuristic(heuristic)
{
_playerID = playerID;
_phaseID = PPPhases::DEFENSE;
}
void PartialPlayer_Defense_Solver::getMove(GameState & state, Move & move)
{
PRISMATA_ASSERT(state.getActivePlayer() == _playerID, "GameState player does not match PartialPlayer player: %d != %d", (int)state.getActivePlayer(), (int)_playerID);
if (state.getActivePhase() != Phases::Defense)
{
return;
}
BlockIterator blockIterator(state, _heuristic);
blockIterator.solve();
blockIterator.getBestMove(move);
for (size_t a(0); a<move.size(); ++a)
{
PRISMATA_ASSERT(state.isLegal(move.getAction(a)), "This move should have been legal!");
state.doAction(move.getAction(a));
}
Action end(state.getActivePlayer(), ActionTypes::END_PHASE, 0);
PRISMATA_ASSERT(state.isLegal(end), "Should be able to end defense phase");
state.doAction(end);
move.addAction(end);
}