Commit fbf391cd by Vivien Kraus

### The imputation procedure does not respect the cuts

```If a player cannot follow but she had received a card of the trumped
suit in the dog, we need to assume that she has discarded this card.```
parent 360234b3
 ... ... @@ -295,28 +295,30 @@ counter_may_own (const TarotCounter * counter, size_t n, size_t i = 0; for (i = 0; i < n; i++) { int is_excuse = tarot_decompose (c, &number, &suit); unsigned int s_n = (unsigned int) suit; int in_range = 1; if (who[i] >= counter->n_players) { /* Should we make this an assert? Basically, the client * asks: "Are any of the following players able to have C: * ", with a list of players including the dog. There is * already a function for the dog. */ return 0; } if (owner == who[i]) if (!is_excuse) { in_range = (number <= counter->by_player[who[i]].max_of[s_n]); } if (in_range && owner == who[i]) { return 1; } else if (owner == TAROT_COUNTER_CARD_OWNER_UNKNOWN) else if (in_range && owner == TAROT_COUNTER_CARD_OWNER_UNKNOWN) { int is_excuse = tarot_decompose (c, &number, &suit); unsigned int s_n = (unsigned int) suit; if (is_excuse) { return 1; } else { return counter->by_player[who[i]].max_of[s_n] >= number; } return 1; } else else if (in_range) { return 0; } ... ... @@ -653,6 +655,7 @@ counter_and_game_impute (TarotCounter * counter, } if (energy < 0.5) { size_t n_owners; TarotPlayer owners[78]; for (i = 0; i < 78; i++) { ... ... @@ -665,38 +668,24 @@ counter_and_game_impute (TarotCounter * counter, assert (owners[c] == (TarotPlayer) (-1)); owners[c] = p; } for (i = TAROT_PETIT + 1; i <= TAROT_TWENTYONE && owners[i] != owners[TAROT_PETIT]; i++) ; if (i > TAROT_TWENTYONE) { return TAROT_IMPUTATION_FAILED; } for (i = 0; i < current_solution.n_remaining; i++) { c = current_solution.cards[i].card; p = current_solution.cards[i].assigned; if (game_assign_missing_card (game, c, p) != 0 || counter_assign_missing_card (counter, c, p) != 0) { assert (0); } } /* Also add the cards that we know have only one owner. */ for (c = 0; c < 78; c++) { p = counter->current_owner_of[c]; if (p < n_players && !(counter->may_be_discarded[c])) { if (game_assign_missing_card (game, c, p) != 0 || counter_assign_missing_card (counter, c, p) != 0) { return TAROT_IMPUTATION_FAILED; } owners[c] = p; } else if (p == TAROT_COUNTER_CARD_OWNER_DISCARDED) { p = n_players; owners[c] = n_players; } } for (c = 0; c < 78; c++) { p = owners[c]; if (p != (TarotPlayer) (-1)) { if (game_assign_missing_card (game, c, p) != 0 || counter_assign_missing_card (counter, c, p) != 0) { ... ... @@ -704,8 +693,21 @@ counter_and_game_impute (TarotCounter * counter, } } } assert (game_is_imputed (game)); (void) &game_is_imputed; if (game_get_deal_all (game, &n_owners, 0, 78, owners) != TAROT_GAME_OK) { assert (0); } for (i = TAROT_PETIT + 1; i <= TAROT_TWENTYONE && owners[i] != owners[TAROT_PETIT]; i++) ; if (i > TAROT_TWENTYONE) { return TAROT_IMPUTATION_FAILED; } if (!game_is_imputed (game)) { assert (0); } } if (energy >= 0.5) { ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!