thing
This commit is contained in:
parent
20c43f3717
commit
16e453ddc9
@ -84,6 +84,15 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn set_and_get() {
|
fn set_and_get() {
|
||||||
let mut b = BitBoard::new();
|
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));
|
assert!(!b.get(2, 4));
|
||||||
b.set(2, 4, true);
|
b.set(2, 4, true);
|
||||||
assert!(b.get(2, 4));
|
assert!(b.get(2, 4));
|
||||||
|
|||||||
@ -250,6 +250,14 @@ impl FutureMoves {
|
|||||||
|
|
||||||
for (depth, nodes) in by_depth.into_iter().enumerate().rev() {
|
for (depth, nodes) in by_depth.into_iter().enumerate().rev() {
|
||||||
for idx in nodes {
|
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 node = &self.arena[idx];
|
||||||
let self_value = node.compute_self_value(self.agent_color) / (depth + 1) as i64;
|
let self_value = node.compute_self_value(self.agent_color) / (depth + 1) as i64;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user