FutureMoves: add (failing) test for situation encountered during testing
This commit is contained in:
parent
4ec9f3cf21
commit
e468464956
@ -637,4 +637,49 @@ mod tests {
|
||||
vec![(0, vec![0, 2]), (1, vec![1]), (2, vec![3])]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn best_move_failure() {
|
||||
let mut futm = FutureMoves::new(Piece::Black, FUTURE_MOVES_CONFIG);
|
||||
let mut board = Board::new().starting_pos();
|
||||
|
||||
// replay of a test I did
|
||||
// TODO! make this as small of a test as possible
|
||||
let moves = vec![
|
||||
(Some((5, 4)), Piece::Black),
|
||||
(Some((5, 5)), Piece::White),
|
||||
(Some((5, 6)), Piece::Black),
|
||||
(Some((6, 4)), Piece::White),
|
||||
(Some((7, 3)), Piece::Black),
|
||||
(Some((7, 4)), Piece::White),
|
||||
(Some((7, 5)), Piece::Black),
|
||||
(Some((2, 4)), Piece::White),
|
||||
(Some((1, 4)), Piece::Black),
|
||||
(Some((1, 5)), Piece::White),
|
||||
(Some((1, 6)), Piece::Black),
|
||||
(Some((0, 6)), Piece::White),
|
||||
(Some((3, 2)), Piece::Black),
|
||||
(Some((1, 7)), Piece::White),
|
||||
(None, Piece::Black), // black skips a move
|
||||
(Some((0, 4)), Piece::White),
|
||||
(None, Piece::Black), // black skips a move
|
||||
(Some((4, 2)), Piece::White),
|
||||
];
|
||||
|
||||
for (coords, color) in moves {
|
||||
if color == futm.agent_color {
|
||||
// my turn
|
||||
futm.update_from_board(&board);
|
||||
let best_move = futm.best_move();
|
||||
if coords.is_none() {
|
||||
assert_eq!(best_move, None);
|
||||
} else {
|
||||
assert_ne!(best_move, None);
|
||||
}
|
||||
}
|
||||
if let Some((i, j)) = coords {
|
||||
board.place(i, j, color).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user