summaryrefslogtreecommitdiff
path: root/ai_rand.cpp
blob: 7479d01673db68d40d2478645ae4d8143ca634c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <cassert>
#include <climits>
#include "ai_rand.h"
#include "util.h"

using namespace std;


int RAND::calcMove(Board &bd, uint8_t myclr) {
	(void)myclr;
	assert(bd.bag.totalLeft() > 0);

	int moves[BSZ * BSZ], nmoves = 0;
	bd.forEachMove([&moves, &nmoves](int idx) { moves[nmoves++] = idx; });

	assert(nmoves > 0);
	return moves[random() % nmoves];
}