summaryrefslogtreecommitdiff
path: root/ai_rand.cpp
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2019-02-15 11:32:44 +0100
committerTom Smeding <tom.smeding@gmail.com>2019-02-15 11:32:44 +0100
commit3711c92f43eedbd698a9c477e3248fb87892fbd9 (patch)
tree7132c9f0396304acfbab612469d6386a9a2ab2a2 /ai_rand.cpp
parent99f3ad9bc30815213af5c666150daa6080c509db (diff)
Multiple AI's (+RAND)
Diffstat (limited to 'ai_rand.cpp')
-rw-r--r--ai_rand.cpp19
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];
+}