fix test
This commit is contained in:
parent
2c31589e51
commit
fae4aaab6f
@ -237,17 +237,13 @@ impl FutureMoves {
|
|||||||
/// The board is supposed to be after the opposing move
|
/// The board is supposed to be after the opposing move
|
||||||
/// Returns whether or not the arena was regenerated (bool)
|
/// Returns whether or not the arena was regenerated (bool)
|
||||||
pub fn update_from_board(&mut self, board: &Board) -> bool {
|
pub fn update_from_board(&mut self, board: &Board) -> bool {
|
||||||
let curr_board = self
|
let curr_board = (0..self.arena.len())
|
||||||
.arena
|
// needs to be every other generation in order to
|
||||||
.iter()
|
// match the agent_color usually root or great-grand child
|
||||||
.enumerate()
|
.filter(|&idx| self.depth_of(idx) % 2 == 0)
|
||||||
.filter(|(idx, _)| {
|
.find(|&idx| {
|
||||||
self.current_root
|
&self.arena[idx].board == board && self.arena[idx].color == !self.agent_color
|
||||||
.map(|x| self.arena[x].children.contains(idx))
|
});
|
||||||
.unwrap_or(false)
|
|
||||||
})
|
|
||||||
.find(|(_, m)| &m.board == board)
|
|
||||||
.map(|(idx, _)| idx);
|
|
||||||
|
|
||||||
if let Some(curr_board_idx) = curr_board {
|
if let Some(curr_board_idx) = curr_board {
|
||||||
self.set_root_idx_raw(curr_board_idx);
|
self.set_root_idx_raw(curr_board_idx);
|
||||||
@ -447,7 +443,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const FUTURE_MOVES_CONFIG: FutureMoveConfig = FutureMoveConfig {
|
const FUTURE_MOVES_CONFIG: FutureMoveConfig = FutureMoveConfig {
|
||||||
max_depth: 1,
|
max_depth: 3, // we want great-grand children for traversing moves
|
||||||
min_arena_depth_sub: 0,
|
min_arena_depth_sub: 0,
|
||||||
top_k_children: 1,
|
top_k_children: 1,
|
||||||
up_to_minus: 0,
|
up_to_minus: 0,
|
||||||
@ -658,7 +654,9 @@ mod tests {
|
|||||||
|
|
||||||
// make sure that the arena should only be
|
// make sure that the arena should only be
|
||||||
// regenerated on the first move
|
// regenerated on the first move
|
||||||
assert!(i <= 0 || update_result, "board regenerated on move #{}", i);
|
if i > 0 && update_result {
|
||||||
|
panic!("board regenerated on move #{}", i);
|
||||||
|
}
|
||||||
|
|
||||||
let best_move = futm.best_move();
|
let best_move = futm.best_move();
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user