logic fixes and nits
This commit is contained in:
@@ -142,11 +142,8 @@ impl FutureMoves {
|
||||
|
||||
fn compute_values(&mut self) {
|
||||
for depth in (0..=self.current_depth).rev() {
|
||||
let nodes_at_depth: Vec<usize> = self
|
||||
.arena
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(idx, node)| (self.depth_of(node.parent) == depth).then_some(idx))
|
||||
let nodes_at_depth: Vec<usize> = (0..self.arena.len())
|
||||
.filter(|&idx| self.depth_of(idx) == depth)
|
||||
.collect();
|
||||
|
||||
for idx in nodes_at_depth {
|
||||
@@ -166,9 +163,10 @@ impl FutureMoves {
|
||||
}
|
||||
}
|
||||
|
||||
fn depth_of(&self, node_parent: Option<usize>) -> usize {
|
||||
/// Given an index from `self.arena`, what depth is it at? 0-indexed
|
||||
fn depth_of(&self, node_parent: usize) -> usize {
|
||||
let mut depth = 0;
|
||||
let mut current = node_parent;
|
||||
let mut current = Some(node_parent);
|
||||
while let Some(parent_idx) = current {
|
||||
depth += 1;
|
||||
current = self.arena[parent_idx].parent;
|
||||
@@ -203,7 +201,7 @@ impl FutureMoves {
|
||||
})
|
||||
.inspect(|&root| {
|
||||
self.current_root = Some(root);
|
||||
self.current_depth = self.max_depth - self.depth_of(Some(root));
|
||||
self.current_depth = self.max_depth - self.depth_of(root);
|
||||
self.prune_unrelated();
|
||||
})
|
||||
.is_some()
|
||||
@@ -254,8 +252,8 @@ pub struct ComplexAgent {
|
||||
}
|
||||
|
||||
impl ComplexAgent {
|
||||
pub fn new(color: Piece) -> Self {
|
||||
const MAX_DEPTH: usize = 6;
|
||||
pub const fn new(color: Piece) -> Self {
|
||||
const MAX_DEPTH: usize = 8;
|
||||
Self {
|
||||
color,
|
||||
future_moves: FutureMoves::new(color, MAX_DEPTH),
|
||||
|
||||
Reference in New Issue
Block a user