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

Use the perceptron as the default AI

parent 78ceee64
......@@ -28,6 +28,9 @@
#include <nettle/yarrow.h>
#include <float.h>
#define TAROT_SOLO_USE_PREDICTOR 0
#define TAROT_SOLO_USE_PERCEPTRON 1
static inline void solo_advance (TarotSolo * dest);
static inline size_t
......@@ -231,23 +234,38 @@ solo_advance (TarotSolo * solo)
}
else if (has_next)
{
TarotPredictor predictor;
size_t unused;
size_t sz =
predictor_construct (sizeof (predictor), (char *) &predictor,
&unused);
const TarotGameEvent *chosen;
TarotGameEvent *chosen;
double predicted_score;
(void) unused;
(void) sz;
assert (sz == sizeof (predictor));
predictor_set_game (&predictor, &(solo->game));
chosen = predictor_best (&predictor, &predicted_score);
(void) predicted_score;
if (TAROT_SOLO_USE_PREDICTOR)
{
TarotPredictor predictor;
size_t unused;
size_t sz =
predictor_construct (sizeof (predictor), (char *) &predictor,
&unused);
(void) unused;
(void) sz;
assert (sz == sizeof (predictor));
predictor_set_game (&predictor, &(solo->game));
chosen =
tarot_game_event_dup (predictor_best
(&predictor, &predicted_score));
}
else if (TAROT_SOLO_USE_PERCEPTRON)
{
TarotPerceptron *perceptron = tarot_perceptron_static_default ();
chosen =
tarot_game_event_dup (tarot_perceptron_best
(perceptron, &(solo->game),
&predicted_score));
tarot_perceptron_free (perceptron);
}
if (game_add_event (&(solo->game), chosen) != TAROT_GAME_OK)
{
assert (0);
}
(void) predicted_score;
tarot_game_event_free (chosen);
solo_advance (solo);
}
else if (game_can_autoreveal (&(solo->game), &n_dog, 0, 6, dog))
......
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