Compare commits
12 commits
150efe302f
...
3c0316e1b7
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c0316e1b7 | |||
| 8146733157 | |||
| 41b3fc5dad | |||
| 7d37eebe52 | |||
| 2329b76f7e | |||
| 27e0536978 | |||
| 0235fd46c2 | |||
| 0619cf6001 | |||
| 9606e175b8 | |||
| c0d844fdf6 | |||
| 0a4f139e1d | |||
| bc94d1fb3d |
1 changed files with 3 additions and 52 deletions
|
|
@ -224,10 +224,7 @@ pub fn get_valid_actions(game_state: &GameState) -> anyhow::Result<Vec<TrictracA
|
||||||
let cum = rules.board.white_checker_cumulative();
|
let cum = rules.board.white_checker_cumulative();
|
||||||
for (move1, move2) in possible_moves {
|
for (move1, move2) in possible_moves {
|
||||||
valid_actions.push(white_checker_moves_to_trictrac_action(
|
valid_actions.push(white_checker_moves_to_trictrac_action(
|
||||||
&move1,
|
&move1, &move2, &game_state.dice, &cum,
|
||||||
&move2,
|
|
||||||
&game_state.dice,
|
|
||||||
&cum,
|
|
||||||
)?);
|
)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -242,10 +239,7 @@ pub fn get_valid_actions(game_state: &GameState) -> anyhow::Result<Vec<TrictracA
|
||||||
let cum = rules.board.white_checker_cumulative();
|
let cum = rules.board.white_checker_cumulative();
|
||||||
for (move1, move2) in possible_moves {
|
for (move1, move2) in possible_moves {
|
||||||
valid_actions.push(white_checker_moves_to_trictrac_action(
|
valid_actions.push(white_checker_moves_to_trictrac_action(
|
||||||
&move1,
|
&move1, &move2, &game_state.dice, &cum,
|
||||||
&move2,
|
|
||||||
&game_state.dice,
|
|
||||||
&cum,
|
|
||||||
)?);
|
)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -300,7 +294,7 @@ fn white_checker_moves_to_trictrac_action(
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// double sortie
|
// double sortie
|
||||||
if from1 < from2 || from2 == 0 {
|
if from1 < from2 {
|
||||||
max(dice.values.0, dice.values.1) as usize
|
max(dice.values.0, dice.values.1) as usize
|
||||||
} else {
|
} else {
|
||||||
min(dice.values.0, dice.values.1) as usize
|
min(dice.values.0, dice.values.1) as usize
|
||||||
|
|
@ -464,48 +458,5 @@ mod tests {
|
||||||
}),
|
}),
|
||||||
ttaction.ok()
|
ttaction.ok()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Black player
|
|
||||||
state.active_player_id = 2;
|
|
||||||
state.dice = Dice { values: (6, 3) };
|
|
||||||
state.board.set_positions(
|
|
||||||
&crate::Color::White,
|
|
||||||
[
|
|
||||||
2, -11, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 6, 4,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
let ttaction = super::checker_moves_to_trictrac_action(
|
|
||||||
&CheckerMove::new(21, 0).unwrap(),
|
|
||||||
&CheckerMove::new(0, 0).unwrap(),
|
|
||||||
&crate::Color::Black,
|
|
||||||
&state,
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
Some(TrictracAction::Move {
|
|
||||||
dice_order: true,
|
|
||||||
checker1: 2,
|
|
||||||
checker2: 0, // blocked by white on last field
|
|
||||||
}),
|
|
||||||
ttaction.ok()
|
|
||||||
);
|
|
||||||
|
|
||||||
// same with dice order reversed
|
|
||||||
state.dice = Dice { values: (3, 6) };
|
|
||||||
let ttaction = super::checker_moves_to_trictrac_action(
|
|
||||||
&CheckerMove::new(21, 0).unwrap(),
|
|
||||||
&CheckerMove::new(0, 0).unwrap(),
|
|
||||||
&crate::Color::Black,
|
|
||||||
&state,
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
Some(TrictracAction::Move {
|
|
||||||
dice_order: false,
|
|
||||||
checker1: 2,
|
|
||||||
checker2: 0, // blocked by white on last field
|
|
||||||
}),
|
|
||||||
ttaction.ok()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue