init mcts
This commit is contained in:
parent
4c53f3669a
commit
f2b585958a
2 changed files with 31 additions and 2 deletions
|
@ -108,4 +108,13 @@ struct bt_t {
|
|||
}
|
||||
};
|
||||
|
||||
// Node MCTS
|
||||
struct bt_node_t {
|
||||
bt_node_t *parent;
|
||||
std::vector<bt_node_t *> children;
|
||||
bt_move_t move;
|
||||
int wins;
|
||||
int nb_simulation;
|
||||
};
|
||||
|
||||
#endif /* MYBT_H */
|
||||
|
|
|
@ -194,8 +194,28 @@ bt_move_t bt_t::get_rand_move() {
|
|||
|
||||
bt_move_t bt_t::get_mcts_move() {
|
||||
update_moves();
|
||||
int r = (static_cast<int>(rand())) % nb_moves;
|
||||
return moves[r];
|
||||
|
||||
// Init tree
|
||||
bt_node_t *tree = new bt_node_t;
|
||||
tree->children = {};
|
||||
tree->parent = NULL;
|
||||
tree->nb_simulation = 0;
|
||||
tree->wins = 0;
|
||||
|
||||
// MCTS
|
||||
while (true) {
|
||||
//
|
||||
}
|
||||
|
||||
// Select best move
|
||||
bt_node_t *best_node;
|
||||
int best_score = -1;
|
||||
for (auto i : tree->children) {
|
||||
if (i->nb_simulation > best_score) {
|
||||
best_node = i;
|
||||
}
|
||||
}
|
||||
return best_node->move;
|
||||
}
|
||||
|
||||
bool bt_t::can_play(bt_move_t _m) {
|
||||
|
|
Reference in a new issue