summaryrefslogtreecommitdiff
path: root/ai_mc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ai_mc.cpp')
-rw-r--r--ai_mc.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/ai_mc.cpp b/ai_mc.cpp
index 6175d96..2c95222 100644
--- a/ai_mc.cpp
+++ b/ai_mc.cpp
@@ -22,11 +22,10 @@ static int playout(Board bd, uint8_t myclr) {
while (bd.bag.totalLeft() > 0) {
uint8_t clr = bd.bag.drawRandom();
- int moves[BSZ * BSZ], nmoves = 0;
- bd.forEachMove([&moves, &nmoves](int idx) { moves[nmoves++] = idx; });
+ const vector<int> &moves = bd.getEdgeCells();
- assert(nmoves > 0);
- int idx = moves[random() % nmoves];
+ assert(moves.size() > 0);
+ int idx = moves[random() % moves.size()];
// cerr << " idx = " << Idx(idx) << " clr=" << (unsigned)clr << endl;
@@ -46,7 +45,8 @@ int MC::calcMove(Board &bd, uint8_t myclr) {
float maxscore = INT_MIN;
int maxat = -1;
- bd.forEachMove([&bd, myclr, &maxscore, &maxat](int idx) {
+ vector<int> edgeCells = bd.getEdgeCells();
+ for (int idx : edgeCells) {
// cerr << "MC::calcMove: trying idx=" << Idx(idx) << endl;
float score = 0;
@@ -73,7 +73,7 @@ int MC::calcMove(Board &bd, uint8_t myclr) {
maxscore = score;
maxat = idx;
}
- });
+ }
return maxat;
}