diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index f3ee325..aaf6f3f 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -293,6 +293,33 @@ impl FutureMoves { } } + fn get_board_from_idx(&self, idx: usize) -> Option { + if let Some(root) = self.current_root { + let mut hist = Vec::new(); + + let mut current = Some(idx); + while let Some(parent_idx) = current { + if parent_idx == root { + break; + } + + let n = &self.arena[parent_idx]; + hist.push((n.coord, n.color)); + current = n.parent; + } + + let mut board = self.arena[root].board.clone(); + for (m, c) in hist.into_iter().rev() { + if let Some(m) = m { + let _ = board.place(m, c); + } + } + Some(board) + } else { + None + } + } + /// Return the best move which is a child of `self.current_root` pub fn best_move(&self) -> Option> { self.current_root