Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tarot
tarot
Commits
bb6bcd7d
Commit
bb6bcd7d
authored
Nov 27, 2019
by
Vivien Kraus
Browse files
Use the perceptron as the default AI
parent
78ceee64
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libtarot/solo/tarot/solo_private_impl.h
View file @
bb6bcd7d
...
...
@@ -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
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment