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

Revert "Also learn from the empty games"

This reverts commit d5318d1d.
parent fb81d2a7
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: tarot 0.4.2.83-ebdc-dirty\n"
"Report-Msgid-Bugs-To: vivien@planete-kraus.eu\n"
"POT-Creation-Date: 2019-11-28 22:16+0100\n"
"POT-Creation-Date: 2019-11-29 07:47+0100\n"
"PO-Revision-Date: 2019-11-28 22:17+0100\n"
"Last-Translator: Vivien Kraus <vivien@planete-kraus.eu>\n"
"Language-Team: French\n"
......
......@@ -305,6 +305,28 @@ random_move (const TarotGame * game)
return NULL;
}
static int
is_empty_game (const TarotGame * game)
{
size_t i_bid;
size_t n_bids;
TarotBid *bids;
if (tarot_game_get_bids_alloc (game, &n_bids, &bids) != TAROT_GAME_OK)
{
assert (0);
}
for (i_bid = 0; i_bid < n_bids; i_bid++)
{
if (bids[i_bid] != TAROT_PASS)
{
free (bids);
return 0;
}
}
free (bids);
return 1;
}
static void
self_learn (TarotPerceptron * perceptron)
{
......@@ -316,10 +338,7 @@ self_learn (TarotPerceptron * perceptron)
uint8_t sub_seed[256];
size_t n_scores;
double metric;
double update;
static int until_print_game = 100;
double *data = NULL, max_weight = 0;
size_t n = 0, w;
double exploration_reduction_remaining = current_exploration - exploration;
exploration_reduction_remaining *= 0.99999;
current_exploration = exploration + exploration_reduction_remaining;
......@@ -406,31 +425,36 @@ self_learn (TarotPerceptron * perceptron)
}
}
metric = tarot_perceptron_validate (perceptron, game);
update = tarot_perceptron_learn_game (perceptron, game);
tarot_perceptron_save_alloc (perceptron, &n, &data);
for (w = 0; w < n; w++)
if (!is_empty_game (game))
{
if (w != 0)
double *data = NULL, max_weight = 0;
size_t n = 0, w;
double update = tarot_perceptron_learn_game (perceptron, game);
tarot_perceptron_save_alloc (perceptron, &n, &data);
for (w = 0; w < n; w++)
{
printf ("\t");
}
printf ("%f", data[w]);
if (data[w] > max_weight || -data[w] > max_weight)
{
if (data[w] > max_weight)
if (w != 0)
{
max_weight = data[w];
printf ("\t");
}
else
printf ("%f", data[w]);
if (data[w] > max_weight || -data[w] > max_weight)
{
max_weight = -data[w];
if (data[w] > max_weight)
{
max_weight = data[w];
}
else
{
max_weight = -data[w];
}
}
}
printf ("\n");
fprintf (stderr, "%g\t%g\t%g\t%g\n", current_exploration, update,
metric, max_weight);
free (data);
}
printf ("\n");
fprintf (stderr, "%g\t%g\t%g\t%g\n", current_exploration, update, metric,
max_weight);
free (data);
if (--until_print_game == 0)
{
char *data = tarot_game_save_to_xml_alloc (game);
......
Supports Markdown
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