blob: c53f5ae78b0ec470a4c1144d6e96264ec46b22f2 (
plain)
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
|
#include <iostream>
#include <cstdlib>
#include <sys/time.h>
#include "board.h"
#include "mc.h"
#include "ui.h"
#include "util.h"
using namespace std;
int main() {
struct timeval tv;
gettimeofday(&tv, nullptr);
srandom(tv.tv_sec * 1000000U + tv.tv_usec);
Board bd = Board::makeEmpty();
cerr << "Initial stone at " << Idx(BSZ * BMID + BMID) << endl;
bd.put(BSZ * BMID + BMID, bd.bag.drawRandom());
cout << bd << endl;
uint8_t onturn = 1;
while (bd.bag.totalLeft() > 0) {
cout << "--- NEXT TURN: " << Stone(onturn) << " ---" << endl;
int idx;
if (onturn == 1) {
cout << "YOUR TURN." << endl;
idx = UI::getMove(bd);
} else {
idx = MC::calcMove(bd, onturn);
}
uint8_t clr = bd.bag.drawRandom();
uint8_t win = bd.putCW(idx, clr);
cout << bd << endl;
if (win != 0) {
cout << "Winner: " << Stone(clr) << endl;
break;
}
onturn = NEXTTURN(onturn);
}
}
|