-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboardstate.cpp
64 lines (58 loc) · 1.45 KB
/
boardstate.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
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
#include "boardstate.h"
#include <QDebug>
#include <iostream>
using namespace std;
BoardState::BoardState()
{
for(int i = 0; i < 6; i++)
{
for(int j = 0; j < 6; j++)
{
this->currentOccupancy[i][j] = 0;
this->nextState[i][j] = 0;
}
}
}
BoardState::BoardState(int currentoccupancy[6][6])
{
for(int i = 0; i < 6; i++)
{
for(int j = 0; j < 6; j++)
{
this->currentOccupancy[i][j] = currentoccupancy[i][j];
}
}
}
int BoardState::getUtility(int board[6][6], int currentoccpancy[6][6],int player)
{
/*cout << "BOARD" << endl;
for(int i = 0; i < 6; i++)
{
for(int j = 0; j < 6; j++)
{
cout << board[i][j] << " ";
}
cout << endl;
}*/
int utility = 0;
for(int i = 0; i < 6; i++)
{
for(int j = 0; j < 6; j++)
{
if(currentoccpancy[i][j] == 1) // AGENT as 1, human as 2, no occupation as 0
{
this->sumOfGreenPlayer += board[i][j];
} else if(currentoccpancy[i][j] == 2) {
this->sumOfBluePlayer += board[i][j];
}
}
}
//qDebug() << "Blue " << this->sumOfBluePlayer << " green " << this->sumOfGreenPlayer;
if(player == 2)
{
utility = this->sumOfBluePlayer - this->sumOfGreenPlayer;
}else{
utility = this->sumOfGreenPlayer - this->sumOfBluePlayer;
}
return utility;
}