simplify FutureMoves::get_board_from_idx

This commit is contained in:
Simon Gardling 2025-04-22 15:51:10 -04:00
parent cf21f981e5
commit 9fff000746
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -357,17 +357,15 @@ impl FutureMoves {
} }
fn get_board_from_idx(&self, idx: usize) -> Option<Board> { fn get_board_from_idx(&self, idx: usize) -> Option<Board> {
if let Some(hist) = self.move_history(idx) { self.move_history(idx).map(|hist| {
let mut board = self.board; let mut board = self.board;
for (m, c) in hist { for (m, c) in hist {
if let Some(m) = m { if let Some(m) = m {
board.place(m, c).expect("move would not propegate"); board.place(m, c).expect("move would not propegate");
} }
} }
Some(board) board
} else { })
None
}
} }
/// Return the best move which is a child of `self.current_root` /// Return the best move which is a child of `self.current_root`