summaryrefslogtreecommitdiff
path: root/ai_rand.cpp
blob: 9bd3eed8e1ff9d637c36371046610d8c1c4230b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "ai_rand.h"


Move AI::Rand::findMove(const Board &bd, int player) {
	Move poss[N * N * N];
	int nposs = 0;

	bd.forEachMove(player, [&bd, &poss, &nposs](Move mv) {
		poss[nposs++] = mv;
	});

	if (nposs == 0) return Move(-1, -1);
	return poss[rand() % nposs];
}