-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay.cpp
44 lines (30 loc) · 863 Bytes
/
play.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
#include "player.hpp"
#include <iostream>
#include <fstream>
#include <string>
#include <thread>
using std::cout;
using std::cin;
using std::endl;
using std::ifstream;
using std::string;
int main(int argc, char **argv){
int player_nr = atoi(argv[1]);
Player p(player_nr);
cout << "Playing as player " << player_nr << endl;
int round = player_nr; // 1 or 2
while(true){
string board_name = "board_" + std::to_string(round) + ".txt";
ifstream infile(board_name);
if(infile.good()){
cout << "Reading board " << board_name << endl;
infile.close();
std::this_thread::sleep_for (std::chrono::milliseconds(100));
p.load_board(board_name);
p.move();
board_name = "board_" + std::to_string(++round) + ".txt";
p.store_board(board_name);
round++;
}
}
}