This commit is contained in:
Henri Bourcereau 2025-01-25 23:51:30 +01:00
parent e95b25a9bc
commit 38100a61b2
2 changed files with 44 additions and 2 deletions

View file

@ -23,4 +23,34 @@ lib
## Algorithme de détermination des coups ## Algorithme de détermination des coups
- get_possible_moves_sequences(with_excedents: bool) - strategy::choose_move
- GameRules.get_possible_moves_sequences(with_excedents: bool)
- get_possible_moves_sequences_by_dices(dice_max, dice_min, with_excedents, false);
- get_possible_moves_sequences_by_dices(dice_min, dice_max, with_excedents, true);
- has_checkers_outside_last_quarter() ok
- board.get_possible_moves ok
- check_corner_rules(&(first_move, second_move)) ok
- handle_event
- state.validate (ok)
- rules.moves_follow_rules (ok)
- moves_possible ok
- moves_follows_dices ok
- moves_allowed (ok)
- check_corner_rules ok
- can_take_corner_by_effect ok
- get_possible_moves_sequences -> cf. l.15
- check_exit_rules
- get_possible_moves_sequences -> cf l.15
- get_quarter_filling_moves_sequences
- get_possible_moves_sequences -> cf l.15
- state.consume (RollResult) (ok)
- get_rollresult_jans -> points_rules.get_result_jans (ok)
- get_jans (ok)
- get_jans_by_ordered_dice (ok)
- get_jans_by_ordered_dice ( dices.poped )
- move_rules.get_scoring_quarter_filling_moves_sequences (ok)
- get_quarter_filling_moves_sequences cf l.8 (ok)
- board.get_quarter_filling_candidate -> is_quarter_fillable ok
- move_rules.get_possible_moves_sequence -> cf l.15
- get_jans_points -> jan.get_points ok

View file

@ -432,19 +432,31 @@ impl MoveRules {
continue; continue;
} }
// XXX : the goal here is to replicate moves_allowed() checks without using get_possible_moves_sequences to
// avoid an infinite loop...
let mut has_second_dice_move = false; let mut has_second_dice_move = false;
for second_move in for second_move in
board2.get_possible_moves(*color, dice2, with_excedents, true, forbid_exits) board2.get_possible_moves(*color, dice2, with_excedents, true, forbid_exits)
{ {
if self.check_corner_rules(&(first_move, second_move)).is_ok() { if self.check_corner_rules(&(first_move, second_move)).is_ok()
&& !(self.is_move_by_puissance(&(first_move, second_move))
&& self.can_take_corner_by_effect())
{
moves_seqs.push((first_move, second_move)); moves_seqs.push((first_move, second_move));
has_second_dice_move = true; has_second_dice_move = true;
} }
// TODO : autres règles à vérifier (cf. moves_allowed)
// - check_exit_rules -> utilise get_possible_moves_sequences !
// - get_quarter_filling_moves_sequences -> utilise get_possible_moves_sequences !
} }
if !has_second_dice_move if !has_second_dice_move
&& with_excedents && with_excedents
&& !ignore_empty && !ignore_empty
&& self.check_corner_rules(&(first_move, EMPTY_MOVE)).is_ok() && self.check_corner_rules(&(first_move, EMPTY_MOVE)).is_ok()
// TODO : autres règles à vérifier (cf. moves_allowed)
// - can_take_corner_by_effect
// - check_exit_rules
// - get_quarter_filling_moves_sequences
{ {
// empty move // empty move
moves_seqs.push((first_move, EMPTY_MOVE)); moves_seqs.push((first_move, EMPTY_MOVE));