This commit is contained in:
Simon Gardling 2025-02-20 11:22:06 -05:00
parent 20c43f3717
commit 16e453ddc9
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 17 additions and 0 deletions

View File

@ -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));

View File

@ -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;