Commit 048bed52 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Fix some annotations

When trying to get the guile bindings work, I noticed some API
endpoints were not understood correctly by the introspection scanner.
parent 7a7b16df
Pipeline #169019 passed with stages
in 33 minutes and 2 seconds
......@@ -120,7 +120,6 @@
/src/libtarot/test/no-slam
/src/libtarot/test/no-slam.c
/src/libtarot/xml/check_xml
/src/scheme/tarot/api.scm
/src/tarot-app/ai.c
/src/tarot-app/card_painter.c
/src/tarot-app/card_painter_default.c
......
......@@ -39,7 +39,6 @@ apt-get install -y \
gnulib \
gobject-introspection \
gperf \
guile-2.2 \
help2man \
imagemagick \
indent \
......
......@@ -2377,7 +2377,7 @@ play, then return the best event and set /score/ to the predicted
score. Otherwise, return =NULL=.
#+end_deftypefun
#+attr_texinfo: :options {size_t} tarot_predictor_eval (const TarotPredictor *@var{predictor}, size_t @var{ncandidates}, const TarotGameEvent **@var{candidates}, size_t @var{start}, size_t @var{max}, double *@var{score})
#+attr_texinfo: :options {size_t} tarot_predictor_eval (const TarotPredictor *@var{predictor}, size_t @var{ncandidates}, TarotGameEvent **@var{candidates}, size_t @var{start}, size_t @var{max}, double *@var{score})
#+begin_deftypefun
Predict the final score when playing each of the /candidate/ events.
Write the results to /score/, starting at /start/, up to /max/
......
......@@ -366,7 +366,7 @@ tarot_predictor_best (const TarotPredictor * predictor, double *score)
size_t
tarot_predictor_eval (const TarotPredictor * predictor, size_t n_candidates,
const TarotGameEvent ** candidates, size_t start,
TarotGameEvent ** candidates, size_t start,
size_t max, double *score)
{
return predictor_eval (predictor, n_candidates, candidates, start, max,
......
......@@ -42,6 +42,8 @@ extern "C"
/**
* tarot_features_arff_data:
* @base: (type TarotGame):
* @added: (type TarotGameEvent):
* @encoded: (type boolean):
* @dest_out: (array length=max):
*/
......@@ -49,6 +51,8 @@ extern "C"
/**
* tarot_features_arff_data_alloc:
* @base: (type TarotGame):
* @added: (type TarotGameEvent):
* @encoded: (type boolean):
* @returns: (transfer full):
*/
......@@ -58,6 +62,7 @@ extern "C"
/**
* tarot_features_variant:
* @game: (type TarotGame):
* @n_players: (out):
* @with_call: (type boolean) (out):
*/
......@@ -65,6 +70,7 @@ extern "C"
/**
* tarot_features_position:
* @game: (type TarotGame):
* @i_trick: (out): the number of tricks played so far
* @position: (out): the number of players that play before me (for
* bids, decls, or for the current trick)
......@@ -73,6 +79,7 @@ extern "C"
/**
* tarot_features_partner_known:
* @game: (type TarotGame):
* @known: (out) (type boolean):
*/
void tarot_features_partner_known (const struct TarotGame *game, int *known);
......@@ -81,12 +88,14 @@ extern "C"
/**
* tarot_features_bid_minimum:
* @game: (type TarotGame):
* @minimum: (out):
*/
void tarot_features_bid_minimum (const struct TarotGame *game, TarotBid *minimum);
/**
* tarot_features_count_faces:
* @game: (type TarotGame):
* @n_kings: (out):
* @n_marriages: (out):
* @n_extended_marriages: (out):
......@@ -102,6 +111,7 @@ extern "C"
/**
* tarot_features_count_minor:
* @game: (type TarotGame):
* @n_shortest: (out):
* @n_second_shortest: (out):
* @n_second_longest: (out):
......@@ -115,6 +125,7 @@ extern "C"
/**
* tarot_features_count_oudlers:
* @game: (type TarotGame):
* @has_petit: (out) (type boolean):
* @has_excuse: (out) (type boolean):
* @has_twentyone: (out) (type boolean):
......@@ -126,6 +137,7 @@ extern "C"
/**
* tarot_features_count_trumps:
* @game: (type TarotGame):
* @n_trumps: (out):
* @max_trump: (out):
* @min_trump: (out):
......@@ -143,6 +155,8 @@ extern "C"
/**
* tarot_strategy_bid:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @bid: (out):
*/
void tarot_strategy_bid (const struct TarotGame *game,
......@@ -151,6 +165,8 @@ extern "C"
/**
* tarot_strategy_outbid:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @outbid: (out):
*/
void tarot_strategy_outbid (const struct TarotGame *game,
......@@ -159,6 +175,8 @@ extern "C"
/**
* tarot_strategy_call_by_length:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @shortest: (out) (type boolean):
* @second_shortest: (out) (type boolean):
* @second_longest: (out) (type boolean):
......@@ -173,6 +191,8 @@ extern "C"
/**
* tarot_strategy_call_myself:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @myself: (out) (type boolean):
*/
void tarot_strategy_call_myself (const struct TarotGame *game,
......@@ -181,6 +201,8 @@ extern "C"
/**
* tarot_strategy_call_marriage:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @will_own_marriage: (out) (type boolean):
*/
void tarot_strategy_call_marriage (const struct TarotGame *game,
......@@ -189,6 +211,8 @@ extern "C"
/**
* tarot_strategy_discard_save:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @n_queens_saved: (out): number of queens for which we don't plan to own the king
* @n_knights_saved: (out):
* @n_jacks_saved: (out):
......@@ -201,6 +225,8 @@ extern "C"
/**
* tarot_strategy_discard_junk:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @n_lesser_cards_left_behind: (out):
*/
void tarot_strategy_discard_junk (const struct TarotGame *game,
......@@ -209,6 +235,8 @@ extern "C"
/**
* tarot_strategy_discard_by_length:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @from_shortest: (out): number of cards discarded from the shortest suit with the dog
* @from_second_shortest: (out):
* @from_second_longest: (out):
......@@ -223,6 +251,7 @@ extern "C"
/**
* tarot_features_team:
* @game: (type TarotGame):
* @attack: (out) (type boolean): whether we may be an attacker
* @defence: (out) (type boolean): whether we may be a defendent
*/
......@@ -232,6 +261,7 @@ extern "C"
/**
* tarot_features_trick_players:
* @game: (type TarotGame):
* @n_already_played: (out):
* @n_allies_after_last_opponent: (out):
*/
......@@ -241,6 +271,7 @@ extern "C"
/**
* tarot_features_minor_suit:
* @game: (type TarotGame):
* @ally_may_be_master: (out) (type boolean): whether noone can play
* a stronger card of the minor suit than the current taker and the
* current taker is an ally, or whether an ally who has still not
......@@ -264,6 +295,7 @@ extern "C"
/**
* tarot_features_trump:
* @game: (type TarotGame):
* @n_remaining: (out):
* @ally_may_be_master: (out) (type boolean):
* @ennemy_may_be_master: (out) (type boolean):
......@@ -275,6 +307,7 @@ extern "C"
/**
* tarot_features_points:
* @game: (type TarotGame):
* @n_halfpoints: (out):
* @n_oudlers: (out):
*/
......@@ -284,6 +317,8 @@ extern "C"
/**
* tarot_strategy_lead:
* @game: (type TarotGame):
* @card: (type TarotGameEvent):
* @called_suit: (out) (type boolean):
* @suit_length: (out):
* @n_times_lead: (out):
......@@ -298,6 +333,8 @@ extern "C"
/**
* tarot_strategy_purity:
* @game: (type TarotGame):
* @event: (type TarotGameEvent):
* @n_smaller_kept: (out):
* @n_greater_nonface_kept: (out):
* @n_points_kept: (out):
......@@ -312,6 +349,8 @@ extern "C"
/**
* tarot_strategy_excuse:
* @game: (type TarotGame):
* @card: (type TarotGameEvent):
* @excuse: (out) (type boolean):
*/
void tarot_strategy_excuse (const struct TarotGame *game,
......@@ -320,6 +359,8 @@ extern "C"
/**
* tarot_strategy_trump_master:
* @game: (type TarotGame):
* @card: (type TarotGameEvent):
* @actually_master: (out) (type boolean):
* @obvious_master: (out) (type boolean):
*/
......@@ -330,6 +371,8 @@ extern "C"
/**
* tarot_strategy_play_points:
* @game: (type TarotGame):
* @card: (type TarotGameEvent):
* @n_halfpoints: (out):
* @oudler: (out) (type bool):
*/
......@@ -363,6 +406,10 @@ extern "C"
void tarot_predictor_free (TarotPredictor *predictor);
/**
* tarot_predictor_set_game:
* @game: (type TarotGame):
*/
void tarot_predictor_set_game (TarotPredictor *predictor, const struct TarotGame *game);
......@@ -376,13 +423,14 @@ extern "C"
/**
* tarot_predictor_eval:
* @score_out: (array length=max):
* @candidates: (array length=n_candidates) (type TarotGameEvent*) (transfer none):
*/
size_t tarot_predictor_eval (const TarotPredictor *predictor, size_t n_candidates, const struct TarotGameEvent **candidates,
size_t tarot_predictor_eval (const TarotPredictor *predictor, size_t n_candidates, struct TarotGameEvent **candidates,
size_t start, size_t max, double *score_out);
/**
* tarot_features_cnn_add:
* @data_out (array length=max):
* @data_out: (array length=max):
*/
size_t tarot_features_cnn_add (const TarotGame *game, size_t max, double *data_out);
......
......@@ -139,7 +139,7 @@ extern "C"
predictor, double *score);
static size_t predictor_eval (const TarotPredictor * predictor,
size_t n_candidates,
const TarotGameEvent ** candidates,
TarotGameEvent ** candidates,
size_t start, size_t max, double *score);
static void features_cnn_add_event (const TarotGame * base,
......
......@@ -2730,7 +2730,7 @@ predictor_best (const TarotPredictor * predictor, double *score)
static inline size_t
predictor_eval (const TarotPredictor * predictor, size_t n_candidates,
const TarotGameEvent ** candidates, size_t start, size_t max,
TarotGameEvent ** candidates, size_t start, size_t max,
double *score)
{
size_t i = 0;
......
......@@ -176,6 +176,7 @@ extern "C"
/**
* tarot_game_get_bids:
* @n: (out):
* @bids_out: (array length=max):
*/
TarotGameError tarot_game_get_bids (const TarotGame * game, size_t *n,
......@@ -198,6 +199,7 @@ extern "C"
/**
* tarot_game_get_declarations:
* @n: (out):
* @decls_out: (array length=max) (type boolean):
*/
TarotGameError tarot_game_get_declarations (const TarotGame * game,
......@@ -287,7 +289,9 @@ extern "C"
/**
* tarot_game_get_handful:
* @n_cards: (out):
* @size: (out):
* @cards: (array length=max):
*/
TarotGameError tarot_game_get_handful (const TarotGame * game,
TarotPlayer p, int *size,
......@@ -388,6 +392,7 @@ extern "C"
/**
* tarot_game_get_scores:
* @n: (out):
* @scores_out: (array length=max):
*/
TarotGameError tarot_game_get_scores (const TarotGame * game, size_t *n,
......
......@@ -59,6 +59,10 @@ extern "C"
TAROT_MCTS_NOMEM
} TarotMctsError;
/**
* tarot_mcts_set_base:
* @base: (type TarotGame):
*/
TarotMctsError tarot_mcts_set_base (TarotMcts * mcts,
const struct TarotGame * base);
......@@ -118,6 +122,12 @@ extern "C"
#define TAROT_MCTS_NULL NULL
const struct TarotMctsNode *tarot_mcts_root (const TarotMcts * mcts);
/**
* tarot_mcts_get:
* @n_simulations: (out):
* @sum_scores: (out):
*/
const struct TarotGameEvent *tarot_mcts_get (const struct TarotMctsNode * node,
size_t *n_simulations,
int *sum_scores);
......
......@@ -49,13 +49,13 @@ extern "C"
/**
* tarot_player_parse:
* end: (transfer none):
* @end: (out) (transfer none):
*/
TarotPlayer tarot_player_parse (const char *text, char **end);
/**
* tarot_player_parse_c:
* end: (transfer none):
* @end: (out) (transfer none):
*/
TarotPlayer tarot_player_parse_c (const char *text, char **end);
......
......@@ -15,21 +15,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST += \
%reldir%/semantic-api.xsl \
%reldir%/convert-to-scm
%reldir%/semantic-api.xsl
dist_pkgdata_DATA += %reldir%/api.xml src/scheme/tarot/api.scm
dist_pkgdata_DATA += %reldir%/api.xml
MAINTAINERCLEANFILES += \
$(srcdir)/%reldir%/api.xml \
$(srcdir)/src/scheme/tarot/api.scm
$(srcdir)/%reldir%/api.xml
$(srcdir)/%reldir%/api.xml: %reldir%/semantic-api.xsl src/libtarot/gobject/Tarot.gir
$(AM_V_GEN) $(XSLTPROC) $(srcdir)/%reldir%/semantic-api.xsl $(srcdir)/src/libtarot/gobject/Tarot.gir \
| $(XMLLINT) --format - > $(srcdir)/%reldir%/api.xml-t
@mv $(srcdir)/%reldir%/api.xml-t $(srcdir)/%reldir%/api.xml
$(srcdir)/src/scheme/tarot/api.scm: %reldir%/api.xml %reldir%/convert-to-scm
$(MKDIR_P) $(srcdir)/src/scheme/tarot
$(AM_V_GEN) $(srcdir)/%reldir%/convert-to-scm < $(srcdir)/%reldir%/api.xml > $(srcdir)/src/scheme/tarot/api.scm-t
@mv $(srcdir)/src/scheme/tarot/api.scm-t $(srcdir)/src/scheme/tarot/api.scm
#!/usr/bin/env sh
# tarot implements the rules of the tarot game
# Copyright (C) 2019 Vivien Kraus
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
exec guile --no-auto-compile -s "$0" "$@"
!#
(use-modules (sxml simple))
(define data (xml->sxml #:trim-whitespace? #t))
(use-modules (ice-9 pretty-print))
(pretty-print `(library (tarot api) (export api) (import (rnrs)) (define api (quote ,data))))
(display ";; Local variables:\n")
(display ";; mode: scheme\n")
(display ";; End:\n")
......@@ -35,18 +35,21 @@ extern "C"
/**
* tarot_simulate:
* @game: (type TarotGame):
*/
TarotSimulationError tarot_simulate (struct yarrow256_ctx *prng,
struct TarotGame *game);
/**
* tarot_simulate_random:
* @game: (type TarotGame):
*/
TarotSimulationError tarot_simulate_random (struct yarrow256_ctx *prng,
struct TarotGame *game);
/**
* tarot_simulate_agreed:
* @game: (type TarotGame):
*/
TarotSimulationError tarot_simulate_agreed (struct yarrow256_ctx *prng,
struct TarotGame *game);
......
......@@ -66,6 +66,11 @@ extern "C"
const struct TarotGameEvent *tarot_xml_parser_iterator_next_value
(TarotXmlParserIterator * iterator);
/**
* tarot_xml_save:
* @game: (type TarotGame):
*/
size_t tarot_xml_save (const struct TarotGame * game, size_t start, size_t max,
char *dest);
......@@ -77,6 +82,7 @@ extern "C"
/**
* tarot_xml_save_mcts_tree:
* @mcts: (type TarotMcts):
* @dest_out: (array length=max):
*/
size_t tarot_xml_save_mcts_tree (const struct TarotMcts * mcts, size_t start,
......
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