move comment regarding FutureMoves::by_depth

This commit is contained in:
Simon Gardling 2025-02-26 14:28:05 -05:00
parent 063ef47a27
commit 9fd3b45c0e
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -151,12 +151,16 @@ impl FutureMoves {
depth - 1
}
//// PERF! pre-organize all indexes based on what depth they're at
/// previously, I did a lookup map based on if a node was visited, still resulted in a full
/// O(n) iteration each depth
fn by_depth(&self, indexes: impl Iterator<Item = usize>) -> Vec<(usize, Vec<usize>)> {
let mut by_depth: HashMap<
usize,
Vec<usize>,
BuildHasherDefault<nohash_hasher::NoHashHasher<usize>>,
> = HashMap::with_hasher(BuildHasherDefault::default());
for idx in indexes {
let depth = self.depth_of(idx);
if let Some(got) = by_depth.get_mut(&depth) {
@ -173,9 +177,6 @@ impl FutureMoves {
/// Compute `Move.value`, propegating upwards from the furthest out Moves
/// in the Arena.
fn compute_values(&mut self, indexes: impl Iterator<Item = usize>) {
// PERF! pre-organize all indexes based on what depth they're at
// previously, I did a lookup map based on if a node was visited, still resulted in a full
// O(n) iteration each depth
let by_depth_vec = self.by_depth(indexes);
// reversed so we build up the value of the closest (in time) moves from the future