Commit 1e994adf authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Document the scheme bindings.

parent 0e11af20
Pipeline #48325 passed with stage
in 2 minutes and 45 seconds
# Err.. Should I put a license on this file?
Vivien Kraus
Table of Contents
_________________
Vivien Kraus <vivien@planete-kraus.eu>
Vivien Kraus <vivien@planete-kraus.eu>
# Err.. Should I put a license on this file?
Vivien Kraus <vivien@planete-kraus.eu>
......@@ -29,16 +29,20 @@ pkgconfigdir = $(datadir)/pkgconfig
pkgconfig_DATA =
INDENTED =
SUFFIXES =
dist_noinst_SCRIPTS = \
autogen.sh \
.git/hooks/pre-commit \
hooks/pre-commit.sh
ACLOCAL_AMFLAGS = -I m4 -I custom-m4
EXTRA_DIST = \
.gitignore \
.git/hooks/pre-commit \
hooks/ChangeLog \
hooks/pre-commit.sh \
deploy.sh \
README.org \
README.md \
AUTHORS.org \
AUTHORS.md \
.dir-locals.el.in \
m4/gnulib-cache.m4 \
.gitlab-ci.yml \
......@@ -84,6 +88,13 @@ README: %reldir%/README.org
--eval "(require 'ox-ascii)" \
-f org-ascii-export-to-ascii \
&& mv "$(srcdir)/README.txt" "$(srcdir)/README")
AUTHORS: %reldir%/AUTHORS.org
$(org_verbose) (echo "$(srcdir)/AUTHORS.txt" \
| ./missing emacs "$(srcdir)/AUTHORS.org" \
--batch \
--eval "(require 'ox-ascii)" \
-f org-ascii-export-to-ascii \
&& mv "$(srcdir)/AUTHORS.txt" "$(srcdir)/AUTHORS")
githook_setup_verbose = $(githook_setup_verbose_@AM_V@)
githook_setup_verbose_ = $(githook_setup_verbose_@AM_DEFAULT_V@)
githook_setup_verbose_0 = @echo "ORG-EXPORT $@";
......
#!/bin/sh
# autogen.sh
#
# Copyright (C) 2018 Vivien Kraus <vivien@planete-kraus.eu>
#
# 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/>.
gnulib-tool --import --libtool malloc-gnu gettext-h snprintf || exit 1
autoreconf -vif || exit 1
#!/bin/sh
gnulib-tool --import --libtool malloc-gnu gettext-h snprintf || exit 1
autoreconf -vif || exit 1
cp /usr/share/gettext/gettext.h src/ || exit 1
./autogen.sh
# First, install on the system
./configure CFLAGS="-Wall -Wextra -g -O0" \
......
......@@ -25,6 +25,9 @@ TAROT_PETIT: the code for the petit;
TAROT_TWENTYONE: the code for the 21;
@item
TAROT_EXCUSE: the code for the excuse.
@defun excuse
Return the code for the excuse in the scheme world.
@end defun
@end itemize
It is perfectly safe to compare any card to @code{TAROT_EXCUSE} to
......@@ -145,16 +148,23 @@ To switch from the card index to the pair (@emph{number},
@emph{suit}), you can use the following functions:
@deftypefun {TarotError} tarot_of (TarotNumber @var{n}, TarotSuit @var{s}, TarotCard *@var{c})
Build in @var{c} the @var{n} of @var{s}.
@deftypefunx {SCM} of @var{n} @var{s}
Build in @var{c} (return it in the scheme function) the @var{n} of
@var{s}. In scheme, @var{s} is a symbol (@code{hearts}, @code{clubs},
@code{diamonds}, @code{spades}, @code{trumps}), and @var{n} is either
a number or a face as a symbol.
@end deftypefun
@deftypefun {TarotError} tarot_decompose (TarotCard @var{c}, TarotNumber *@var{n}, TarotSuit *@var{s})
Decompose @var{c} as the @var{n} of @var{s}.
@deftypefunx {SCM} decompose @var{c}
Decompose @var{c} as the @var{n} of @var{s}. The scheme function
returns a length-two list (@var{n}, @var{s}).
@end deftypefun
@xref{Error handling} for the use of the return value.
@deftypefun {TarotCard} tarot_str_to_card (const char *@var{str}, char **@var{end}, int @var{atend})
@deftypefunx {SCM} string->card @var{str}
Read a card from @var{str}, and set @code{*@var{end}} to the
address of the first char that is not part of the card.
Return the card.
......@@ -181,9 +191,13 @@ completed with the new. However, if no more data may ever be read
(for instance, the connection is closed), then @var{atend} should be
set to 1 in order to signal an error (i.e., set @code{*@var{end}} to
@var{str}).
The scheme function only return the parsed card, or @code{#f} if the
parsing failed.
@end deftypefun
@deftypefun {size_t} tarot_card_to_str (char *@var{dest}, size_t @var{max_dst}, TarotCard @var{c})
@deftypefunx {SCM} card->string @var{c}
Write @var{c} and a NUL character to @var{dest}, using at most
@var{max_dst} bytes, and return the total number of characters that
are needed to represent @var{c}. If @var{max_dst} is insufficient to
......@@ -191,6 +205,8 @@ hold both @var{c} AND the NUL character, then @var{dest} is truncated
in order to guarantee that after this function call, either
@var{max_dst} is 0, or @var{dest} is NUL terminated. Just like
@code{snprintf}.
The scheme function returns a string.
@end deftypefun
@cindex straight cut
......
......@@ -22,6 +22,7 @@ index is written as @code{P1}, @code{P2}, ..., i.e. the capital letter
P and a number starting at 1.
@deftypefun {TarotPlayer} tarot_str_to_player (const char *@var{str}, char **@var{end}, int @var{atend})
@deftypefunx {SCM} string->player @var{str}
Read a player index from @var{str}, and set @code{*@var{end}} to the
address of the first char that is not part of the player index.
Return the player ID. For instance, ``P14 is still a valid player
......@@ -43,9 +44,13 @@ completed with the new. However, if no more data may ever be read
(for instance, the connection is closed), then @var{atend} should be
set to 1 in order to signal an error (i.e., set @code{*@var{end}} to
@var{str}).
The scheme function only returns the parsed player, or @code{#f} if it
failed.
@end deftypefun
@deftypefun {size_t} tarot_player_to_str (char *@var{dest}, size_t @var{max_dst}, TarotPlayer @var{p})
@deftypefunx {SCM} player->string @var{p}
Write @var{p} and a NUL character to @var{dest}, using at most
@var{max_dst} bytes, and return the total number of characters that
are needed to represent @var{p}. If @var{max_dst} is insufficient to
......@@ -53,4 +58,6 @@ hold both @var{p} AND the NUL character, then @var{dest} is truncated
in order to guarantee that after this function call, either
@var{max_dst} is 0, or @var{dest} is NUL terminated. Just like
@code{snprintf}.
The scheme function returns a string.
@end deftypefun
......@@ -94,9 +94,19 @@ Enumerated values for the team.
@end deftp
@deftypefun {const TarotBid *} tarot_game_bids (const TarotGame *@var{game}, unsigned int *@var{n}, TarotPlayer *@var{taker})
@deftypefunx {SCM} game-bids @var{game}
Return all @var{n} bids made in @var{game}, and set @var{taker} to the
player that has the strongest bid, or the next player to bid otherwise
if everyone passed.
The scheme function returns a two-item list, with:
@itemize
@item
the list of bids, as symbols (@code{pass}, @code{take}, @code{push},
@code{straight-keep}, @code{double-keep});
@item
the taker.
@end itemize
@end deftypefun
To perform a bid, you will want to proceed in three steps:
......@@ -110,18 +120,27 @@ if it is valid, perform the bid.
@end enumerate
@deftypefun {int} tarot_game_hint_bid (const TarotGame *@var{game}, TarotPlayer *@var{next}, TarotBid *@var{minimum})
@deftypefunx {SCM} hint-bid @var{game}
Set @var{next} to the next player to bid and @var{minimum} to the
minimum bid in order to outbid, only if there is another bid to do.
Return whether there is another bid to do.
The scheme function returns a list of two items: the @var{next} player
to bid, and the @var{minimum} bid to make. Or, if there is no bid to
be done, return @code{#f}.
@end deftypefun
@deftypefun {int} tarot_game_check_bid (const TarotGame *@var{game}, TarotPlayer @var{player}, TarotBid @var{bid})
@deftypefunx {SCM} check-bid @var{game} @var{player} @var{bid}
Check that @var{player} can bid @var{bid} in @var{game}. Return
whether this is accepted. To know who should bid and what, you can
call @code{tarot_game_hint_bid}.
@end deftypefun
@deftypefun {void} tarot_game_do_bid (TarotGame *@var{game}, TarotBid @var{bid})
@deftypefunx {SCM} do-bid @var{game} @var{bid}
Perform the bid @var{bid} in @var{game}. You should always check that
it is possible with @code{tarot_game_check_bid}.
The scheme function returns whether the action was accepted.
@end deftypefun
......@@ -59,22 +59,33 @@ known.
@end deftp
@deftypefun {TarotCall} tarot_game_call (const TarotGame *@var{game}, TarotCard *@var{call}, TarotPlayer *@var{partner})
@deftypefunx {SCM} call @var{game}
Return the call state, and if available set @var{call} and/or
@var{partner} to the respective called card and/or partner.
The scheme function returns a list of 3 elements: the call state, the
@var{call}ed card, and the @var{partner}.
@end deftypefun
@deftypefun {int} tarot_game_hint_call (const TarotGame *@var{game}, TarotPlayer *@var{p}, TarotNumber *@var{minimum})
@deftypefunx {SCM} hint-call @var{game}
If a call is waiting in @var{game}, set @var{p} to the taker and
@var{minimum} to the minimum face that can be called. Return whether
a call is waiting.
The scheme function returns either @code{#f}, or a list with the
@var{p}layer and the @var{minimum} number.
@end deftypefun
@deftypefun {int} tarot_game_check_call (const TarotGame *@var{game}, TarotPlayer @var{p}, TarotCard @var{call})
@deftypefunx {SCM} check-call @var{game} @var{player} @var{call}
Check that @var{p} can call @var{call} in @var{game}.
@end deftypefun
@deftypefun {void} tarot_game_do_call (TarotGame *@var{game}, TarotCard @var{call})
@deftypefunx {SCM} do-call @var{game} @var{call}
Call @var{call} in @var{game}. You should always check that this
operation is valid with @code{tarot_game_check_call}.
operation is valid with @code{tarot_game_check_call}. The scheme
function returns whether the call was accepted.
@end deftypefun
......@@ -53,26 +53,35 @@ cards. In a @emph{server} game, all cards are dealt at once.
The following functions check that the deal is possible.
@deftypefun {int} tarot_game_check_deal_one (const TarotGame *@var{game}, const TarotCardSet *@var{cards})
@deftypefunx {SCM} check-deal-one @var{game} @var{cards}
Check that a regular player can be given @var{cards}. The computation
is faster if @var{cards} are sorted.
is faster if @var{cards} are sorted. In the scheme world, @var{cards}
is a list of numbers as the result of card construction
(@code{excuse}, or @code{of}).
@end deftypefun
@deftypefun {int} tarot_game_check_deal_multi (const TarotGame *@var{game}, const TarotPlayer *owner)
@var{owner} is a 78-player array, whose @var{i} element is the owner
of the cards @var{i}. Check that this deal is valid for all players.
@deftypefunx {SCM} check-deal-multi @var{game} @var{owner_of}
@var{owner} is a 78-player array (or a list in the scheme world),
whose @var{i} element is the owner of the cards @var{i}. Check that
this deal is valid for all players.
@end deftypefun
And now the corresponding functions to perform the deal.
@deftypefun {void} tarot_game_do_deal_one (TarotGame *@var{game}, TarotPlayer @var{recipient}, const TarotCardSet *@var{cards})
@deftypefunx {SCM} do-deal-one @var{game} @var{recipient} @var{cards}
Do deal the @var{cards} to @var{recipient}. You should always
validate the input by calling @code{tarot_game_check_deal_one}, even
if you receive the cards from a server.
if you receive the cards from a server. However the scheme function
returns whether the action succeeded.
@end deftypefun
@deftypefun {void} tarot_game_do_deal_multi (TarotGame *@var{game}, const TarotPlayer *@var{owner_of})
@deftypefunx {SCM} do-deal-multi @var{game} @var{owner_of}
For each @var{i}, deal card @var{i} to @code{@var{owner_of[@var{i}]}}.
You should always validate the input by calling
@code{tarot_game_check_deal_multi}, even if you set up a
@emph{duplicat@'e} game and get the deal from the referee.
@emph{duplicat@'e} game and get the deal from the referee. The scheme
function returns whether the deal succeeded.
@end deftypefun
......@@ -51,19 +51,24 @@ Describe the state of the dog in a @emph{game}. It can be:
@end deftp
@deftypefun {TarotDog} tarot_game_dog (const TarotGame *@var{game}, TarotCardSet **@var{dog}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} dog @var{game}
Set @var{dog} to the dog in @var{game}, and return the state of the
dog. If @var{allocator} is @code{NULL}, then *@var{dog} has to be
released to avoid memory leaks.
released to avoid memory leaks. The scheme function returns a list of
two items: the dog state, as a symbol, and the list of cards.
@end deftypefun
@deftypefun {int} tarot_game_check_dog (const TarotGame *@var{game}, const TarotCardSet *@var{cards})
Check that the dog in @var{game} can be @var{cards}. Return 1 if it
is valid, 0 otherwise.
@deftypefunx {SCM} check-dog @var{game}, @var{cards}
Check that the dog in @var{game} can be @var{cards}. Return whether
it is valid.
@end deftypefun
@deftypefun {void} tarot_game_do_dog (TarotGame *@var{game}, const TarotCardSet *@var{cards})
@deftypefunx {SCM} do-dog @var{game} @var{cards}
Reveal the dog in @var{game}, which are @var{cards}. You should check
that this is possible with @code{tarot_game_check_dog}.
that this is possible with @code{tarot_game_check_dog}. The scheme
function returns whether this is valid.
@end deftypefun
@deftp {enum} TarotDiscard @{ @code{TAROT_DISCARD_WAITING}, @code{TAROT_DISCARD_SKIPPED}, @code{TAROT_DISCARD_DONE}, @code{TAROT_DISCARD_KNOWN} @}
......@@ -83,12 +88,16 @@ Describe the state of the discard in a @emph{game}. It can be:
@end deftp
@deftypefun {TarotDiscard} tarot_game_discard (const TarotGame *@var{game}, TarotCardSet **@var{discard}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} discard @var{game}
Set @var{discard} to the discard, and return the discard state. If
@var{allocator} is @code{NULL}, then @var{discard} should be destroyed in
order to avoid memory leaks.
@var{allocator} is @code{NULL}, then @var{discard} should be destroyed
in order to avoid memory leaks. The scheme function returns a list
with 2 items: the state of the discard, and the list of the known
cards.
@end deftypefun
@deftypefun {int} tarot_game_hint_discard (const TarotGame *@var{game}, TarotPlayer *@var{p}, unsigned int *@var{n}, TarotCardSet **@var{prio}, TarotCardSet **@var{additional}, TarotAllocator *@var{allocator}
@deftypefunx {SCM} hint-discard @var{game}
Query the cards that can be discarded in @var{game}. Set @var{p} to
the taker, @var{n} to the total number of cards to discard, from the
@var{prio} cards and - only if @var{n} is strictly less than
......@@ -105,9 +114,23 @@ Return whether there is a discard to do.
If we do not know @var{p}'s cards, then all possible cards are added
to the additional set. So, there may be other cards than trumps in
@var{additional}.
The scheme function returns either @code{#f}, if no discard is to be
done, or a list of four items:
@itemize
@item
the taker;
@item
the number of cards to discard, @var{n};
@item
the @var{prio} list of cards;
@item
the @var{additional} list of cards.
@end itemize
@end deftypefun
@deftypefun {int} tarot_game_check_discard (const TarotGame *@var{game}, TarotPlayer @var{p}, const TarotCardSet *@var{cards}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} check-discard @var{game} @var{player} @var{cards}
Check and return whether @var{p} can discard @var{cards} in
@var{game}. If we do not know @var{p}'s cards, then the discard is
acceptable only if it has 0 cards or only non-oudler trumps that we do
......@@ -117,6 +140,8 @@ not own.
@end deftypefun
@deftypefun {void} tarot_game_do_discard (TarotGame *@var{game}, const TarotCardSet *@var{cards})
@deftypefunx {SCM} do-discard @var{game} @var{cards}
Discard @var{cards}. It is your responsibility to check that it is
possible with @code{tarot_game_check_discard}.
possible with @code{tarot_game_check_discard}. The scheme function
returns whether the action was valid.
@end deftypefun
......@@ -43,9 +43,17 @@ when the player may show a handful,
@end deftp
@deftypefun {TarotHandful} tarot_game_handful (const TarotGame *@var{game}, TarotPlayer @var{p}, TarotCardSet **@var{handful}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} handful @var{game} @var{player}
Set @var{handful} to the cards shown by @var{p} in @var{game}, and
return the handful size of @var{p}. If @var{allocator} is @code{NULL},
then @code{*@var{handful}} should be destroyed.
return the handful size of @var{p}. If @var{allocator} is
@code{NULL}, then @code{*@var{handful}} should be destroyed. The
scheme function returns a list with 2 items:
@itemize
@item
the state of the handful;
@item
the @var{handful} as a list of cards.
@end itemize
@end deftypefun
@deftp {struct} TarotHandfulSizeHint @{unsigned int @var{n_simple}; unsigned int @var{n_double}; unsigned int @var{n_triple};@}
......@@ -53,6 +61,7 @@ Hold the three handful sizes.
@end deftp
@deftypefun {int} tarot_game_hint_handful (const TarotGame *@var{game}, TarotPlayer *@var{p}, TarotHandfulSizeHint *@var{size}, TarotCardSet **@var{prio}, TarotCardSet **@var{additional}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} hint-handful @var{game}
Query the @dfn{priority} and @dfn{additional} set of cards that can be
shown in @var{game}. You should then show all priority cards, and add
cards from the additional set to complete it. Set @var{p} to the next
......@@ -68,15 +77,31 @@ de-allocation should be @var{additional} and the @var{prio}.
Return whether a handful can be shown or @var{p} does not have enough
trumps to show a handful.
The scheme function returns either @code{#f} in case no handful is to
be shown, or a list with:
@itemize
@item
the next @var{p}layer to show a handful;
@item
the list of handful @var{size}s as a three-int list;
@item
the @var{prio} card list;
@item
the @var{additional} card list.
@end itemize
@end deftypefun
@deftypefun {int} tarot_game_check_handful (const TarotGame *@var{game}, TarotPlayer @var{p}, const TarotCardSet *@var{cards}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} check-handful @var{game} @var{p} @var{cards}
Return whether @var{p} can show @var{cards} in @var{game}.
@var{allocator} may be @code{NULL} to use the heap.
@end deftypefun
@deftypefun {void} tarot_game_do_handful (TarotGame *@var{game}, const TarotCardSet *@var{cards})
@deftypefunx {SCM} do-handful @var{game} @var{cards}
Show @var{cards} in @var{game}. The behaviour is undefined if the
rules are not respected (i.e. @code{tarot_game_check_handful} returned
0).
0) in the C world, but in the scheme world the action is not performed
and the function returns @code{#f}.
@end deftypefun
......@@ -11,6 +11,7 @@ Not reentrant.
@deftypefun {const char *} tarot_libtarot_version ()
@deftypefunx {SCM} libtarot-version
Return the linked libtarot version.
@end deftypefun
......
......@@ -21,3 +21,5 @@ calls to @var{alloc}. However, if the allocated data is the return
value of a libtarot function, the caller may de-allocate it when it
wishes.
@end deftp
In the scheme world, all the allocations use the garbage collector.
......@@ -24,5 +24,6 @@ the number of errors, which is never used as an error code.
@end deftp
@deftypefun {const char *} tarot_strerror (TarotError @var{err})
@deftypefunx {SCM} error->string @var{err}
Return a string representation of @var{err}.
@end deftypefun
......@@ -16,10 +16,13 @@ The options that define a game: @var{n_players} may be 3, 4 or 5, and
@end deftp
@deftypefun {TarotGame *} tarot_game_alloc (const TarotGameOptions *@var{options}, TarotAllocator *@var{allocator})
Construct a game with @var{options}, using @var{allocator} if not
@code{NULL}, or the libc heap allocator. Return the built game. You
must call @code{free} on the return value in order to avoid memory
leaks only if @var{allocator} is @code{NULL}.
@deftypefunx {SCM} alloc @var{n-players} @var{with-call}
Construct a game with @var{options} (or the number of players,
@var{n-players}, and whether there is a call, @var{with-call}, in the
scheme world), using @var{allocator} if not @code{NULL}, or the libc
heap allocator. Return the built game. You must call @code{free} on
the return value in the C world in order to avoid memory leaks only if
@var{allocator} is @code{NULL}.
@end deftypefun
@deftypefun {TarotGame *} tarot_game_free (TarotGame *@var{game}, TarotAllocator *@var{allocator})
......@@ -28,8 +31,16 @@ Free @var{game} using the same @var{allocator} as passed to
@end deftypefun
@deftypefun {void} tarot_game_options (const TarotGame *@var{game}, TarotGameOptions *@var{options})
@deftypefunx {SCM} options @var{game}
Get in @var{options}the options that have been passed during the call
to @code{tarot_game_init}.
to @code{tarot_game_init}. The scheme function returns a list with
two entries:
@itemize
@item
the number of players;
@item
whether a call is allowed.
@end itemize
@end deftypefun
@deftp {struct} TarotGameState @{TarotStep @var{step}; unsigned int @var{i_trick}; TarotPlayer @var{next};@}
......@@ -40,10 +51,21 @@ play if @var{step} is neither @code{TAROT_DEAL}, @code{TAROT_DOG} nor
@end deftp
@deftypefun {void} tarot_game_state (const TarotGame *@var{game}, TarotGameState *@var{state})
Get the current state of @var{game} in @var{state}.
@deftypefunx {SCM} state @var{game}
Get the current state of @var{game} in @var{state}. The scheme
function returns a list with 3 items:
@itemize
@item
the step;
@item
the index of the trick;
@item
the next player to play.
@end itemize
@end deftypefun
@deftypefun {TarotCardSet *} tarot_game_cards (const TarotGame *@var{game}, TarotPlayer @var{p}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} cards @var{game} @var{p}
Get the cards of @var{p} in @var{game}, using the allocator in
@var{allocator} if not @code{NULL}, or the heap.
@end deftypefun
......@@ -144,6 +144,8 @@ A new game can then begin, with the new first player being the
previous second.
@deftypefun {void} tarot_game_score (const TarotGame *@var{game}, int *@var{score})
@deftypefunx {SCM} score @var{game}
For each player @var{p}, set @code{@var{score}[@var{p}]} to the score
of @var{p} in @var{game}.
of @var{p} in @var{game}. The scheme function returns the list of
scores.
@end deftypefun
......@@ -29,13 +29,21 @@ slam declaration.
@end itemize
@end deftp
@deftypefun {int} tarot_game_decl (const TarotGame *@var{game}, unsigneed int *@var{n}, TarotPlayer *@var{declarant})
@deftypefun {int} tarot_game_decl (const TarotGame *@var{game}, unsigned int *@var{n}, TarotPlayer *@var{declarant})
@deftypefunx {SCM} decl @var{game}
Return whether there is a slam declaration, and if so set
@var{declarant} to the declarant. Set @var{n} to the number of
declarations so far.
declarations so far. The scheme function returns a list with 2 entries:
@itemize
@item
the number of declarations, @var{n};
@item
the @var{declarant}, or undefined.
@end itemize
@end deftypefun
@deftypefun {int} tarot_game_check_decl (const TarotGame *@var{game}, TarotPlayer @var{player}, int @var{declare})
@deftypefunx {SCM} check-decl @var{game} @var{player} @var{declare}
Check and return whether @var{player} can declare or not declare a
slam in @var{game}. If @var{declare} is not null, then check whether
@var{player} can declare a slam. Otherwise, check whether
......@@ -43,8 +51,10 @@ slam in @var{game}. If @var{declare} is not null, then check whether
@end deftypefun
@deftypefun {void} tarot_game_do_decl (TarotGame *@var{game}, int @var{decl})
@deftypefunx {SCM} do-decl @var{game} @var{decl}
Perform the slam declaration @var{decl} in @var{game}. You should
check with @code{tarot_game_check_decl} that this operation is valid
before actually performing it.
before actually performing it. In the scheme world, the function
returns whether the operation was valid.
@end deftypefun
......@@ -64,16 +64,40 @@ the number of cards played @var{n_cards}.
@end deftp
@deftypefun {void} tarot_game_trick (const TarotGame *@var{game}, unsigned int @var{i}, TarotTrickInfo *@var{dest})
@deftypefunx {SCM} trick @var{game} @var{i}
Analyse trick number @var{i} in @var{game} and get the results in
@var{dest}.
@var{dest}. In the scheme world, the trick info is a list:
@itemize
@item
the trick leader;
@item
the lead suit;
@item
the number of cards;
@item
the trick taker.
@end itemize
@end deftypefun
@deftypefun {TarotCard} tarot_game_trick_card (const TarotGame *@var{game}, unsigned int @var{i_trick}, TarotPlayer @var{p}, TarotHint *@var{hint})
@deftypefunx {SCM} trick-card @var{game} @var{i_trick} @var{p}
Return the card played by @var{p} in the @var{i_trick}-th trick in
@var{game}, and analyze this move if @var{hint} is not @code{NULL}.
In the scheme world, the trick card info is a list:
@itemize
@item
the card;
@item
whether the player could not follow;
@item
whether the player could not overtrump;
@item
whether the player could not undertrump.
@end itemize
@end deftypefun
@deftypefun {int} tarot_game_hint_card (const TarotGame *@var{game}, TarotPlayer *@var{p}, TarotCardSet **@var{dest}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} hint-card @var{game}
Fill @var{dest} with the cards that can be played in @var{game}, and
@var{p} to the next player to play. Return whether there is a card to
play in @var{game}. If @var{allocator} is @code{NULL}, then
......@@ -82,9 +106,19 @@ value is 0, then @code{@var{*dest}} is set to @code{NULL}.
If we do not know @var{p}'s cards, then we hint to 0 cards.
Otherwise, the AI would be very slow.
The scheme function returns either @code{#f} if there is no card to be
played, or a list with two items:
@itemize
@item
the next @var{p}layer to play;
@item
the possible cards.
@end itemize
@end deftypefun
@deftypefun {int} tarot_game_check_card (const TarotGame *@var{game}, TarotPlayer @var{p}, TarotCard @var{c}, TarotAllocator *@var{allocator})
@deftypefunx {SCM} check-card @var{game} @var{p} @var{c}
Check and return whether @var{p} can play @var{c} in @var{game}.
This function needs additional memory, you have to pass it through
......@@ -92,6 +126,8 @@ This function needs additional memory, you have to pass it through
@end deftypefun
@deftypefun {void} tarot_game_do_card (TarotGame *@var{game}, TarotCard @var{c})
Play @var{c} in @var{game}.
@deftypefunx {SCM} do-card @var{game} @var{c}
Play @var{c} in @var{game}. The scheme function returns whether the
action was accepted.
@end deftypefun
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