Skip to content
GitLab
Menu
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
864a3cdb
Commit
864a3cdb
authored
Nov 27, 2019
by
Vivien Kraus
Browse files
Use the perceptron to make the call
parent
bb6bcd7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libtarot/features/tarot/features_private_impl.h
View file @
864a3cdb
...
...
@@ -2107,8 +2107,8 @@ features_strongest_player_aux (size_t n_players,
return
features_strongest_player_try_bid
(
&
predictor
);
}
static
int
predictor_select_call
(
int
cnn
,
const
TarotGame
*
game
,
TarotCard
*
call
,
double
*
score
);
static
int
predictor_
perceptron_
select_call
(
const
TarotGame
*
game
,
TarotCard
*
call
,
double
*
score
);
static
inline
TarotCard
features_strongest_call
(
size_t
n_players
,
size_t
n_cards
,
...
...
@@ -2150,13 +2150,61 @@ features_strongest_call (size_t n_players, size_t n_cards,
assert
(
0
);
}
}
if
(
predictor_select_call
(
0
,
&
game
,
&
call
,
&
score
)
!=
0
)
if
(
predictor_
perceptron_
select_call
(
&
game
,
&
call
,
&
score
)
!=
0
)
{
assert
(
0
);
}
return
call
;
}
static
int
predictor_perceptron_select_call
(
const
TarotGame
*
game
,
TarotCard
*
call
,
double
*
best_score
)
{
static
const
TarotSuit
suits
[
4
]
=
{
TAROT_HEARTS
,
TAROT_CLUBS
,
TAROT_DIAMONDS
,
TAROT_SPADES
};
TarotNumber
minimum
,
candidate
;
TarotGameEvent
e
;
TarotPlayer
player
;
int
ret
=
1
;
int
isuit
;
TarotPerceptron
*
perceptron
;
e
.
n
=
0
;
*
best_score
=
-
DBL_MAX
;
if
(
game_get_hint_call
(
game
,
&
player
,
&
minimum
)
!=
TAROT_GAME_OK
)
{
return
1
;
}
perceptron
=
tarot_perceptron_static_default
();
for
(
isuit
=
0
;
isuit
<
4
;
isuit
++
)
{
TarotSuit
suit
=
suits
[
isuit
];
for
(
candidate
=
minimum
;
candidate
<=
TAROT_KING
;
candidate
++
)
{
TarotCard
c
;
double
candidate_score
;
if
(
tarot_of
(
candidate
,
suit
,
&
c
)
!=
0
)
{
assert
(
0
);
}
event_set_call
(
&
e
,
c
);
candidate_score
=
tarot_perceptron_predict
(
perceptron
,
game
,
&
e
);
if
(
candidate_score
>
*
best_score
)
{
*
call
=
c
;
*
best_score
=
candidate_score
;
ret
=
0
;
}
}
}
tarot_perceptron_free
(
perceptron
);
return
ret
;
}
static
inline
TarotPlayer
features_strongest_player
(
size_t
n_players
,
int
with_call
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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