diff options
Diffstat (limited to 'ai_rand.cpp')
-rw-r--r-- | ai_rand.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ai_rand.cpp b/ai_rand.cpp new file mode 100644 index 0000000..7479d01 --- /dev/null +++ b/ai_rand.cpp @@ -0,0 +1,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]; +} |