-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
72 lines (52 loc) · 1.49 KB
/
main.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
#include <iostream>
#include <chrono>
#include "utils/entities.h"
#include "utils/board.h"
#include "utils/ai.h"
#include "utils/color.h"
using namespace std;
using namespace chrono;
void stringifyBoard(Board board)
{
cout << string(64, '-') << endl;
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
color("yellow", to_string(board.board[i][j]), false);
cout << "\t";
}
cout << "\n";
}
cout << string(64, '-') << endl;
}
int main()
{
srand(time(NULL)); // initialize the random seed
Board board;
Ai ai;
color("blue", "game: 2048", true);
color("blue", "board: 4 x 4", true);
color("blue", "==============", true);
board.opponentAction();
board.opponentAction();
// board.setTile(1, 1, 4);
// board.setTile(1, 2, 4);
// stringifyBoard(board);
// board.agentAction(LEFT);
stringifyBoard(board);
while (!ai.losed)
{
auto t1 = high_resolution_clock::now();
Direction direction = ai.suggest(board);
auto t2 = high_resolution_clock::now();
duration<double> time_span = duration_cast<duration<double>>(t2 - t1);
std::cout << "AI suggests: " << time_span.count() << " seconds." << endl;
board.agentAction(direction);
board.opponentAction();
stringifyBoard(board);
}
color("red", "game ended", true);
cout << "exiting! Go fuck yourself nor giving me stupid tasks!" << endl;
return 0;
}