Commit 595aafe6 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Do not let each player have a chance to ruin the taker

The fuzziness of the AI is expressed as summed up for all players,
because each random bid or slam declaration results in an unbalanced
game which is uninteresting.
parent 9cef8a0d
Pipeline #202007 passed with stages
in 39 minutes and 17 seconds
/* tarot implements the rules of the tarot game
* Copyright (C) 2019 Vivien Kraus
* Copyright (C) 2019, 2020 Vivien Kraus
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -171,12 +171,20 @@ ai_fuzzy_eval (void *state, const TarotGame * base,
double flt_random;
size_t random_value;
uint8_t random_buffer[sizeof (random_value)];
double fuzziness = ai->fuzziness;
ai_eval (&(ai->base), base, n_candidates, candidates, start, max, scores);
yarrow256_random (&(ai->prng), sizeof (random_buffer), random_buffer);
memcpy (&random_value, random_buffer, sizeof (random_value));
flt_random = random_value / max_random;
/* If we are evaluating bids, then the fuzziness should be reduced
* because each player having a chance of bidding at random is
* another chance of the taker being not correct. */
if (game_step (base) == TAROT_BIDS || game_step (base) == TAROT_DECLS)
{
fuzziness /= game_n_players (base);
}
/* If the behavior is to play randomly, shuffle the scores. */
if (flt_random < ai->fuzziness)
if (flt_random < fuzziness)
{
size_t size_shuffled = 1;
size_t position = 0;
......
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