future_move: add comments to pruning logic
This commit is contained in:
parent
e1207153ab
commit
9757264854
@ -468,9 +468,7 @@ impl FutureMoves {
|
|||||||
// values are needed in order to prune and see what's best
|
// values are needed in order to prune and see what's best
|
||||||
self.compute_values(0..self.arena_len());
|
self.compute_values(0..self.arena_len());
|
||||||
|
|
||||||
let by_depth = self.by_depth(0..self.arena.len());
|
for (depth, indexes) in self.by_depth(0..self.arena.len()) {
|
||||||
|
|
||||||
for (depth, indexes) in by_depth {
|
|
||||||
// TODO! maybe update by_depth every iteration or something?
|
// TODO! maybe update by_depth every iteration or something?
|
||||||
if depth > self.current_depth.saturating_sub(self.config.up_to_minus) {
|
if depth > self.current_depth.saturating_sub(self.config.up_to_minus) {
|
||||||
return;
|
return;
|
||||||
@ -482,15 +480,25 @@ impl FutureMoves {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for idx in indexes {
|
for idx in indexes {
|
||||||
|
// TODO! add check here to make sure that this index is
|
||||||
|
// still connected to the root from the previous trimming
|
||||||
|
// steps
|
||||||
|
|
||||||
let mut m = self.arena[idx].clone();
|
let mut m = self.arena[idx].clone();
|
||||||
|
// don't attempt and trim moves that have already been trimmed
|
||||||
if m.is_trimmed {
|
if m.is_trimmed {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m.is_trimmed = true;
|
m.is_trimmed = true;
|
||||||
m.sort_children(&self.arena);
|
m.sort_children(&self.arena);
|
||||||
|
// prune the selected non top_k children
|
||||||
if m.children.len() > self.config.top_k_children {
|
if m.children.len() > self.config.top_k_children {
|
||||||
|
// remove parent-child relation
|
||||||
let drained = m.children.drain(self.config.top_k_children..);
|
let drained = m.children.drain(self.config.top_k_children..);
|
||||||
|
|
||||||
for idx in drained {
|
for idx in drained {
|
||||||
|
// remove child-parent relation
|
||||||
self.arena[idx].parent = None;
|
self.arena[idx].parent = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user