impl prune_bad_children
This commit is contained in:
parent
563726ffd5
commit
dd236118fe
@ -305,11 +305,32 @@ impl FutureMoves {
|
|||||||
fn set_root_idx_raw(&mut self, idx: usize) {
|
fn set_root_idx_raw(&mut self, idx: usize) {
|
||||||
self.update_root_idx_raw(idx);
|
self.update_root_idx_raw(idx);
|
||||||
|
|
||||||
|
self.prune_bad_children();
|
||||||
self.refocus_tree();
|
self.refocus_tree();
|
||||||
self.extend_layers();
|
self.extend_layers();
|
||||||
self.compute_values(0..self.arena.len());
|
self.compute_values(0..self.arena.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn prune_bad_children(&mut self) {
|
||||||
|
const BOTTOM_PERC: f32 = 20.0;
|
||||||
|
let Some(root) = self.current_root else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut children = self.arena[root].children.clone();
|
||||||
|
|
||||||
|
children.sort_by_key(|&i| -self.arena[i].value);
|
||||||
|
let start_len = ((children.len()) as f32 * (1.0 - BOTTOM_PERC)) as usize;
|
||||||
|
let drained = children.drain(start_len..);
|
||||||
|
println!("{}", drained.len());
|
||||||
|
|
||||||
|
for i in drained {
|
||||||
|
self.arena[i].parent = None;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.arena[root].children = children;
|
||||||
|
}
|
||||||
|
|
||||||
/// Rebuilds the Arena based on `self.current_root`, prunes unrelated nodes
|
/// Rebuilds the Arena based on `self.current_root`, prunes unrelated nodes
|
||||||
fn refocus_tree(&mut self) {
|
fn refocus_tree(&mut self) {
|
||||||
let Some(root) = self.current_root else {
|
let Some(root) = self.current_root else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user