Commit abf726bc authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Do not select the double keep that many times

If someone bids a straight keep, there is a 1/2 chance that the next
player would bid a double keep.  This is not acceptable.  This patch
reverts this.
parent acb741e8
...@@ -204,19 +204,23 @@ random_move (const TarotGame * game) ...@@ -204,19 +204,23 @@ random_move (const TarotGame * game)
TarotCard *additional; TarotCard *additional;
if (tarot_game_get_hint_bid (game, &next, &mini_bid) == TAROT_GAME_OK) if (tarot_game_get_hint_bid (game, &next, &mini_bid) == TAROT_GAME_OK)
{ {
TarotBid acceptable[5] = { TAROT_PASS }; TarotBid bids[] = {
size_t n_acceptable = 1; TAROT_PASS, TAROT_TAKE, TAROT_PUSH, TAROT_STRAIGHT_KEEP,
TarotBid consider; TAROT_DOUBLE_KEEP
};
size_t position; size_t position;
uint8_t position_data[sizeof (position)]; uint8_t position_data[sizeof (position)];
for (consider = mini_bid; consider <= TAROT_DOUBLE_KEEP; consider++)
{
acceptable[n_acceptable++] = consider;
}
yarrow256_random (&generator, sizeof (position_data), position_data); yarrow256_random (&generator, sizeof (position_data), position_data);
memcpy (&position, position_data, sizeof (position)); memcpy (&position, position_data, sizeof (position));
position %= n_acceptable; position %= (sizeof (bids) / sizeof (bids[0]));
return tarot_game_event_alloc_bid (acceptable[position]); if (bids[position] >= mini_bid)
{
return tarot_game_event_alloc_bid (bids[position]);
}
else
{
return tarot_game_event_alloc_bid (TAROT_PASS);
}
} }
else if (tarot_game_get_hint_decl (game, &next, &decl_allowed) == else if (tarot_game_get_hint_decl (game, &next, &decl_allowed) ==
TAROT_GAME_OK) TAROT_GAME_OK)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment