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


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

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

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