From 16e453ddc9d10b978ce2857c41131b8cac12adee Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 20 Feb 2025 11:22:06 -0500 Subject: [PATCH] thing --- src/bitboard.rs | 9 +++++++++ src/future_moves.rs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/bitboard.rs b/src/bitboard.rs index cf34966..98a3509 100644 --- a/src/bitboard.rs +++ b/src/bitboard.rs @@ -84,6 +84,15 @@ mod test { #[test] fn set_and_get() { let mut b = BitBoard::new(); + for i in 0..BOARD_SIZE { + for j in 0..BOARD_SIZE { + assert_eq!( + b.get(i, j), + false, + "A just-initalized BitBoard should be completely empty" + ) + } + } assert!(!b.get(2, 4)); b.set(2, 4, true); assert!(b.get(2, 4)); diff --git a/src/future_moves.rs b/src/future_moves.rs index 4e90c92..d478919 100644 --- a/src/future_moves.rs +++ b/src/future_moves.rs @@ -250,6 +250,14 @@ impl FutureMoves { for (depth, nodes) in by_depth.into_iter().enumerate().rev() { for idx in nodes { + // TODO! impl dynamic sorting based on children's states, maybe it propegates + // upwards using the `parent` field + // SAFETY! the sort_by_key function should not modify anything + unsafe { &mut *(self as *mut Self) }.arena[idx] + .children + // negative because we want the largest value in the first index + .sort_by_key(|&x| -self.arena[x].value); + let node = &self.arena[idx]; let self_value = node.compute_self_value(self.agent_color) / (depth + 1) as i64;