-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameStateBuilderVistor.cpp
More file actions
56 lines (41 loc) · 1.21 KB
/
Copy pathGameStateBuilderVistor.cpp
File metadata and controls
56 lines (41 loc) · 1.21 KB
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
#include "ScoreVisitor.h"
#include "TreeBuilder.h"
//constructor is sent the maxLevel and the first boardposition
// it creates the gameStates
mMaxLevel
GameState* mpGameStateRoot;
Board& arBoard
GameStateBuilderVistor::GameStateBuilderVistor(int aMaxLevel, Board& arBoard)
{
mpGameStateRoot = new GameState();
}
GameStateBuilderVistor::build()
{
visit(*mpGameStateRoot);
}
void GameStateBuilderVistor::visit(Board& arBoard)
{
mpCurrent = new GameState();
if (mpGameStateRoot == null) {
mpGameStateRoot = mpCurrent;
mpGameStateRoot->setLevel(0);
}
std::vector<Board> nextBoards = arBoard.generateNextTurns();
if (
}
void GameStateBuilderVistor::visit(GameState& arGameState)
{
setScoreOnGameState(arGameState);
NextStates* pNextStates = arGameState.getNextStates();
for (int idx = 0; pNextStates != 0 && idx < 7; ++idx) {
GameState* pGameState = pNextStates->getGameState(idx);
if (pGameState != 0)
visit(*pGameState);
}
}
void GameStateBuilderVistor::setScoreOnGameState(GameState& arGameState)
{
mStrength.setTree(arGameState);
int score = mStrength.getBoardStrength();
arGameState.setScore(score);
}