Fixed missing non terminal error
This commit is contained in:
parent
a2711f341f
commit
a7102a0e44
@ -16,7 +16,7 @@ rand = "~0.9"
|
||||
thiserror = "~2.0"
|
||||
|
||||
[dev-dependencies]
|
||||
divan = "0.1.21"
|
||||
divan = "~0.1"
|
||||
|
||||
[[bench]]
|
||||
name = "e2e"
|
||||
|
@ -75,9 +75,16 @@ impl<'conf, S: GameState + std::fmt::Debug> MCTS<'conf, S> {
|
||||
if !selected_node.state.is_terminal() {
|
||||
self.expand(selected_id);
|
||||
let children: &Vec<usize> = &self.arena.get_node(selected_id).children;
|
||||
let random_child: usize = *children.choose(&mut rand::rng()).unwrap();
|
||||
match children.choose(&mut rand::rng()) {
|
||||
Some(&random_child) => {
|
||||
selected_id = random_child;
|
||||
}
|
||||
None => {
|
||||
// We ran out of nodes
|
||||
return Err(MCTSError::NonTerminalGame);
|
||||
}
|
||||
}
|
||||
}
|
||||
let rewards = self.simulate(selected_id);
|
||||
self.backprop(selected_id, &rewards);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user