-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (71 loc) · 2.05 KB
/
Copy pathmain.cpp
File metadata and controls
74 lines (71 loc) · 2.05 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "gipfengine.h"
using namespace std;
int main(int argc, char *argv[])
{
string input;
GipfEngine gipf(2, 4, 15, 15);
while (getline(cin, input))
{
if (input == "LOAD_GAME_BOARD")
{
gipf.scanBoard();
}
else if (input.find("DO_MOVE") != string::npos)
{
int from_x, from_y, to_x, to_y;
bool success;
from_x = input[8] - 97;
from_y = input[9] - 49;
to_x = input[11] - 97;
to_y = input[12] - 49;
Move move(from_x, from_y, to_x, to_y);
success = gipf.doMove(move);
if (input.find(':') != string::npos)
{
char color = input[14] - 32;
from_x = input[17] - 97;
from_y = input[18] - 49;
to_x = input[20] - 97;
to_y = input[21] - 49;
success = gipf.priority_erase(from_x, from_y, to_x, to_y, color);
}
if (success)
{
cout << "MOVE_COMMITTED" << endl;
}
gipf.count_sequence(true);
}
else if (input == "PRINT_GAME_BOARD")
{
gipf.printBoard();
}
else if (input == "GEN_ALL_POS_MOV_NUM")
{
cout << gipf.count_posible_moves() << "_UNIQUE_MOVES" << endl;
}
else if (input == "GEN_ALL_POS_MOV")
{
gipf.count_posible_moves(false, true);
}
else if (input == "GEN_ALL_POS_MOV_EXT_NUM")
{
cout << gipf.count_posible_moves(true) << "_UNIQUE_MOVES" << endl;
}
else if (input == "GEN_ALL_POS_MOV_EXT")
{
gipf.count_posible_moves(true, true);
}
else if (input == "IS_GAME_OVER")
{
if (gipf.is_game_over())
{
cout << "THE_WINNER_IS_" << gipf.get_winner() << endl;
}
else
{
cout << "GAME_IN_PROGRESS" << endl;
}
}
cout << endl;
}
}