fix: black mirror
This commit is contained in:
parent
817dbd77a7
commit
de414ebebb
2 changed files with 28 additions and 14 deletions
|
|
@ -349,7 +349,6 @@ impl MoveRules {
|
|||
let board_to_check = if moves.0.get_to() == moves.1.get_from() {
|
||||
// Chained move: apply first move to get the board state
|
||||
let mut board_copy = self.board.clone();
|
||||
println!("mv 352");
|
||||
let _ = board_copy.move_checker(&Color::White, moves.0);
|
||||
board_copy
|
||||
} else {
|
||||
|
|
@ -531,11 +530,8 @@ impl MoveRules {
|
|||
let ignored_rules = vec![TricTracRule::Exit, TricTracRule::MustFillQuarter];
|
||||
for moves in self.get_possible_moves_sequences(true, ignored_rules) {
|
||||
let mut board = self.board.clone();
|
||||
println!("mv 534");
|
||||
board.move_checker(color, moves.0).unwrap();
|
||||
println!("mv 536 {:?} {:?}", self.board, moves);
|
||||
board.move_checker(color, moves.1).unwrap();
|
||||
println!("done 536");
|
||||
// println!("get_quarter_filling_moves_sequences board : {:?}", board);
|
||||
if board.any_quarter_filled(*color) && !moves_seqs.contains(&moves) {
|
||||
moves_seqs.push(moves);
|
||||
|
|
@ -561,7 +557,6 @@ impl MoveRules {
|
|||
.get_possible_moves(*color, dice1, with_excedents, false, forbid_exits)
|
||||
{
|
||||
let mut board2 = self.board.clone();
|
||||
println!("mv 560");
|
||||
if board2.move_checker(color, first_move).is_err() {
|
||||
println!("err move");
|
||||
continue;
|
||||
|
|
@ -1413,6 +1408,25 @@ mod tests {
|
|||
vec![moves],
|
||||
state.get_possible_moves_sequences(true, vec![])
|
||||
);
|
||||
|
||||
let mut board = Board::new();
|
||||
board.set_positions(
|
||||
&crate::Color::White,
|
||||
[
|
||||
-3, -3, -2, -2, -2, -2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 3, 8,
|
||||
],
|
||||
);
|
||||
let state = MoveRules::new(&Color::Black, &board, Dice { values: (5, 3) });
|
||||
let moves = (
|
||||
// CheckerMove::new(2, 0).unwrap(),
|
||||
// CheckerMove::new(1, 0).unwrap(),
|
||||
CheckerMove::new(23, 0).unwrap(),
|
||||
CheckerMove::new(24, 0).unwrap(),
|
||||
);
|
||||
assert_eq!(
|
||||
vec![moves],
|
||||
state.get_possible_moves_sequences(true, vec![])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ impl TrictracAction {
|
|||
let checker_move1 = CheckerMove::new(from1, to1).unwrap_or_default();
|
||||
|
||||
let mut tmp_board = state.board.clone();
|
||||
println!("mv training_common 127");
|
||||
let move_result = tmp_board.move_checker(color, checker_move1);
|
||||
if move_result.is_err() {
|
||||
None
|
||||
|
|
@ -262,11 +261,12 @@ fn checker_moves_to_trictrac_action(
|
|||
let board = &state.board;
|
||||
|
||||
if color == &crate::Color::Black {
|
||||
// Moves are already 'white', so we don't mirror them
|
||||
white_checker_moves_to_trictrac_action(
|
||||
// move1,
|
||||
// move2,
|
||||
&move1.clone().mirror(),
|
||||
&move2.clone().mirror(),
|
||||
move1,
|
||||
move2,
|
||||
// &move1.clone().mirror(),
|
||||
// &move2.clone().mirror(),
|
||||
dice,
|
||||
&board.clone().mirror(),
|
||||
)
|
||||
|
|
@ -324,10 +324,8 @@ fn white_checker_moves_to_trictrac_action(
|
|||
let checker1 = board.get_field_checker(&crate::Color::White, from1) as usize;
|
||||
let mut tmp_board = board.clone();
|
||||
// should not raise an error for a valid action
|
||||
println!("mv training_common 327");
|
||||
tmp_board.move_checker(&crate::Color::White, *move1)?;
|
||||
let checker2 = tmp_board.get_field_checker(&crate::Color::White, from2) as usize;
|
||||
println!("white action {checker1} {checker2}");
|
||||
Ok(TrictracAction::Move {
|
||||
dice_order,
|
||||
checker1,
|
||||
|
|
@ -442,8 +440,10 @@ mod tests {
|
|||
],
|
||||
);
|
||||
let ttaction = super::checker_moves_to_trictrac_action(
|
||||
&CheckerMove::new(2, 0).unwrap(),
|
||||
&CheckerMove::new(1, 0).unwrap(),
|
||||
// &CheckerMove::new(2, 0).unwrap(),
|
||||
// &CheckerMove::new(1, 0).unwrap(),
|
||||
&CheckerMove::new(23, 0).unwrap(),
|
||||
&CheckerMove::new(24, 0).unwrap(),
|
||||
&crate::Color::Black,
|
||||
&state,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue