Commit 54d49710 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Also use the perceptron for the initial bid instead of the stacking predictor

parent 979d9a0a
......@@ -2034,14 +2034,14 @@ strategy_play_points (const TarotGame * game,
}
static double
features_strongest_player_try_bid (const TarotPredictor * predictor)
features_strongest_player_try_bid (const TarotGame * game)
{
double scores[4];
TarotGameEvent candidates[4];
TarotGameEvent *pointers[4];
size_t i;
size_t n;
double max = -DBL_MAX;
TarotPerceptron *perceptron = tarot_perceptron_static_default ();
for (i = 0; i < 4; i++)
{
candidates[i].t = TAROT_BID_EVENT;
......@@ -2051,8 +2051,10 @@ features_strongest_player_try_bid (const TarotPredictor * predictor)
candidates[1].u.bid = TAROT_PUSH;
candidates[2].u.bid = TAROT_STRAIGHT_KEEP;
candidates[3].u.bid = TAROT_DOUBLE_KEEP;
n = predictor_eval (predictor, 4, pointers, 0, 4, scores);
assert (n == 4);
for (i = 0; i < 4; i++)
{
scores[i] = tarot_perceptron_predict (perceptron, game, pointers[i]);
}
for (i = 0; i < 4; i++)
{
if (scores[i] > max)
......@@ -2060,6 +2062,7 @@ features_strongest_player_try_bid (const TarotPredictor * predictor)
max = scores[i];
}
}
tarot_perceptron_free (perceptron);
return max;
}
......@@ -2073,8 +2076,6 @@ features_strongest_player_aux (size_t n_players,
TarotGameEvent deal_all;
TarotPlayer my_owners[78];
size_t i;
TarotPredictor predictor;
size_t unused;
assert (n_cards == 78);
for (i = 0; i < 78; i++)
{
......@@ -2096,15 +2097,7 @@ features_strongest_player_aux (size_t n_players,
/* Petit sec */
return -DBL_MAX;
}
if (predictor_construct
(sizeof (TarotPredictor), (char *) &predictor,
&unused) != sizeof (TarotPredictor))
{
assert (0);
}
(void) unused;
predictor_set_game (&predictor, &game);
return features_strongest_player_try_bid (&predictor);
return features_strongest_player_try_bid (&game);
}
static int predictor_perceptron_select_call (const TarotGame * game,
......
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