This commit is contained in:
Mylloon 2023-03-29 14:24:11 +02:00
parent 54b40d7918
commit 67b02e2f9d
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 8 additions and 1 deletions

View file

@ -79,6 +79,7 @@ struct bt_t {
bool black_can_move_forward(int _line, int _col); bool black_can_move_forward(int _line, int _col);
bool black_can_move_left(int _line, int _col); bool black_can_move_left(int _line, int _col);
bt_move_t get_mcts_move();
bt_move_t get_rand_move(); bt_move_t get_rand_move();
bool can_play(bt_move_t _m); bool can_play(bt_move_t _m);
void play(bt_move_t _m); void play(bt_move_t _m);

View file

@ -58,7 +58,7 @@ void genmove() {
printf("= \n\n"); printf("= \n\n");
return; return;
} }
bt_move_t m = B.get_rand_move(); bt_move_t m = B.get_mcts_move();
B.play(m); B.play(m);
if (verbose) { if (verbose) {
m.print(stderr, white_turn, B.nbl); m.print(stderr, white_turn, B.nbl);

View file

@ -192,6 +192,12 @@ bt_move_t bt_t::get_rand_move() {
return moves[r]; return moves[r];
} }
bt_move_t bt_t::get_mcts_move() {
update_moves();
int r = (static_cast<int>(rand())) % nb_moves;
return moves[r];
}
bool bt_t::can_play(bt_move_t _m) { bool bt_t::can_play(bt_move_t _m) {
int dx = abs(_m.col_f - _m.col_i); int dx = abs(_m.col_f - _m.col_i);
if (dx > 1) { if (dx > 1) {