#include #include #include #include "board.h" #include "ai_mc.h" #include "ai_rand.h" #include "ui.h" #include "util.h" using namespace std; #define STR_(x) #x #define STR(x) STR_(x) #ifndef AI #define AI MC #endif int main() { struct timeval tv; gettimeofday(&tv, nullptr); srandom(tv.tv_sec * 1000000U + tv.tv_usec); cerr << "Using AI " << STR(AI) << endl; 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 = AI::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); } cout << "TIE" << endl; }