-
Notifications
You must be signed in to change notification settings - Fork 1
/
tester.cpp
109 lines (93 loc) · 2.78 KB
/
tester.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Tests for various functions in various files
#include <iostream>
#include <vector>
#include <assert.h>
#include "Game.h"
// #include "Player.h"
#include "Utility.h"
#include <cstdlib>
#include <unistd.h>
/**
* List of Functions tested
* 1. Utility::splitString
* 2. Utility::arrayToPolar -- Utility::polarToArray Invertibility
* 3.
*/
bool testerSplitString();
bool testerConversion();
void testerMoveIO();
void testMakeMove();
int main()
{
testerConversion();
testMakeMove();
}
bool testerSplitString()
{
Utility util = Utility();
vector<string> sp = util.splitString(" .. S 1 2 M 2 4 RS 1 2 RE 4 16 X 3 4");
for (auto it = sp.begin(); it != sp.end(); it++)
{
cout << *it << endl;
}
return true;
}
bool testerConversion()
{
Utility *tester = new Utility();
// Tests the conversion functions
int boardSize = 101;
for (int i = 0; i < boardSize; i++)
{
for (int j = 0; j < boardSize; j++)
{
pair<int, int> arrCoord = make_pair(i, j);
pair<int, int> polarCoord = tester->arrayToPolar(arrCoord, boardSize);
// cout << "P | " << polarCoord.first << " " << polarCoord.second << endl;
arrCoord = tester->polarToArray(polarCoord, boardSize);
// if (arrCoord.first != i || arrCoord.second != j) {
// cout << i << " " << j << " | " << polarCoord.first << " " << polarCoord.second << " | " << arrCoord.first << " " << arrCoord.second << endl;
// }
assert(arrCoord.first == i);
assert(arrCoord.second == j);
}
}
return true;
}
void testerMoveIO()
{
// Tests move input output
string line;
while (getline(cin, line))
{
// do something with the line
Move move(line, 11);
cout << move.cartesianToPolarString(11) << endl;
}
}
void testMakeMove()
{
Game game(5, 1);
// Tests move input output
string line;
// game.displayHexagonalBoard();
cout << "Player " << game.getPlayerToMove() << "'s turn: ";
while (getline(cin, line))
{
// do something with the line
// system("cls");
Move move(line, 11);
// cout << game.getRingsPositive();
game.makeMove(move);
// game.displayHexagonalBoard();
// cout << "Player " << (game.getPlayerToMove()*-1) << " played: " << move.cartesianToPolarString(game.getBoardSize()) << endl;
cout << "\t\t\t\t\t\t\t\t\t" << game.getUtility() << endl;
cout << "\t\t\t\t\t\t" << game.getRingUtility() << endl;
// game.getPlayerToMove() *= -1; // flip turn
// cout << "Player " << game.getPlayerToMove() << "'s turn: ";
// usleep(1500000);
}
// game.displayBoard();
game.displayHexagonalBoard();
cout << "Final Game State" << endl;
}