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
97b7f8f0
Commit
97b7f8f0
authored
Oct 13, 2019
by
Vivien Kraus
Browse files
Use only the bids likelihood for the biased imputation
parent
16821358
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/libtarot/counter/tarot/counter_private_impl.h
View file @
97b7f8f0
...
...
@@ -870,7 +870,8 @@ counter_and_game_impute_likely (TarotCounter * counter,
sizeof
(
current_seed
),
current_seed
);
if
(
candidate_err
==
TAROT_IMPUTATION_OK
)
{
double
candidate_errors
=
features_errors
(
&
candidate_game
);
double
candidate_errors
=
features_errors_just_bids
(
&
candidate_game
);
if
(
ret
!=
TAROT_IMPUTATION_OK
||
best_errors
>
candidate_errors
)
{
ret
=
candidate_err
;
...
...
src/libtarot/features/tarot/features_private.h
View file @
97b7f8f0
...
...
@@ -135,6 +135,7 @@ extern "C"
double
*
confidence
,
TarotCard
*
call
);
static
double
features_errors
(
const
TarotGame
*
game
);
static
double
features_errors_just_bids
(
const
TarotGame
*
game
);
static
size_t
predictor_construct
(
size_t
max_mem
,
char
*
mem
,
size_t
*
alignment
);
...
...
src/libtarot/features/tarot/features_private_impl.h
View file @
97b7f8f0
...
...
@@ -2187,7 +2187,7 @@ features_strongest_player (size_t n_players,
}
static
inline
double
features_errors_client
(
const
TarotGame
*
game
)
features_errors_client
(
const
TarotGame
*
game
,
int
just_bids
)
{
double
ret
=
0
;
TarotGameIterator
it
;
...
...
@@ -2196,8 +2196,10 @@ features_errors_client (const TarotGame * game)
size_t
alignment
;
TarotGame
rebuilt
;
TarotPlayer
main_player
;
size_t
n_bids_seen
=
0
;
size_t
n_players
=
game_n_players
(
game
);
game_iterator_setup
(
&
it
,
game
);
game_initialize
(
&
rebuilt
,
game_
n_players
(
game
)
,
game_with_call
(
game
));
game_initialize
(
&
rebuilt
,
n_players
,
game_with_call
(
game
));
if
(
game_get_main_player
(
game
,
&
main_player
)
!=
TAROT_GAME_OK
)
{
assert
(
0
);
...
...
@@ -2211,55 +2213,70 @@ features_errors_client (const TarotGame * game)
while
((
event
=
game_iterator_next_value
(
&
it
))
!=
NULL
)
{
TarotPlayer
next
;
if
(
game_get_next
(
&
rebuilt
,
&
next
)
==
TAROT_GAME_OK
)
if
(
!
just_bids
||
n_bids_seen
<
n_players
)
{
if
(
next
==
main_player
)
if
(
game_get_next
(
&
rebuilt
,
&
next
)
==
TAROT_GAME_OK
)
{
double
best_score
,
score
;
predictor_set_game
(
&
predictor
,
&
rebuilt
);
predictor_best
(
&
predictor
,
&
best_score
);
if
(
predictor_eval
(
&
predictor
,
1
,
(
TarotGameEvent
**
)
(
&
event
),
0
,
1
,
&
score
)
!=
1
)
{
assert
(
0
);
}
if
(
score
<=
best_score
)
if
(
next
==
main_player
)
{
/* It is possible that the predictor missed this
* one. */
ret
+=
best_score
-
score
;
double
best_score
,
score
;
predictor_set_game
(
&
predictor
,
&
rebuilt
);
predictor_best
(
&
predictor
,
&
best_score
);
if
(
predictor_eval
(
&
predictor
,
1
,
(
TarotGameEvent
**
)
(
&
event
),
0
,
1
,
&
score
)
!=
1
)
{
assert
(
0
);
}
if
(
score
<=
best_score
)
{
/* It is possible that the predictor missed this
* one. */
ret
+=
best_score
-
score
;
}
}
}
}
if
(
game_add_event
(
&
rebuilt
,
event
)
!=
TAROT_GAME_OK
)
{
assert
(
0
);
if
(
game_add_event
(
&
rebuilt
,
event
)
!=
TAROT_GAME_OK
)
{
assert
(
0
);
}
}
}
return
ret
;
}
static
inline
double
features_errors
(
const
TarotGame
*
game
)
features_errors
_aux
(
const
TarotGame
*
game
,
int
just_bids
)
{
TarotPlayer
main
;
size_t
i
,
n
=
game_n_players
(
game
);
double
ret
=
0
;
if
(
game_get_main_player
(
game
,
&
main
)
==
TAROT_GAME_OK
)
{
return
features_errors_client
(
game
);
return
features_errors_client
(
game
,
just_bids
);
}
for
(
i
=
0
;
i
<
n
;
i
++
)
{
TarotGame
g
;
game_initialize
(
&
g
,
n
,
game_with_call
(
game
));
game_copy_as
(
&
g
,
game
,
i
);
ret
+=
features_errors_client
(
&
g
);
ret
+=
features_errors_client
(
&
g
,
just_bids
);
}
return
(
ret
/
n
);
}
static
inline
double
features_errors
(
const
TarotGame
*
game
)
{
return
features_errors_aux
(
game
,
0
);
}
static
inline
double
features_errors_just_bids
(
const
TarotGame
*
game
)
{
return
features_errors_aux
(
game
,
1
);
}
static
size_t
predictor_construct
(
size_t
max_mem
,
char
*
mem
,
size_t
*
alignment
)
{
...
...
src/libtarot/mcts/tarot/mcts_private_impl.h
View file @
97b7f8f0
...
...
@@ -510,7 +510,7 @@ mcts_impute (TarotGame * game, struct yarrow256_ctx *rng)
yarrow256_random
(
rng
,
sz
,
(
void
*
)
imputation_seed
);
counter_load_from_game
(
&
counter
,
game
);
ret
=
(
counter_and_game_impute
(
counter_and_game_impute
_likely
(
&
counter
,
game
,
sz
,
(
void
*
)
imputation_seed
)
!=
TAROT_IMPUTATION_OK
);
return
ret
;
}
...
...
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