Previous: , Up: Machine learning with tarot   [Contents][Index]


5.5 Playing a game against the AI

libtarot has an API endpoint to run a game against the AI.

struct: TarotSolo

A game, where all players but the specific dealt player play using the AI.

Function: TarotSolo * tarot_solo_alloc (void)
Function: TarotSolo * tarot_solo_alloc_fuzzy (double fuzziness, size_t seed_size, const void *seed, const TarotAi *ai)
Function: void tarot_solo_free (TarotSolo *solo)

Allocate and free a new game against the AI. The fuzzy variant uses an AI that will incorporate a random evaluation in all moves. If fuzziness is set to 0, then no random evaluation will be considered. If fuzziness is set to 1, then all moves will be chosen at random. If ai is ‘NULL’, then a default AI will be used.

This is an easy way to change the difficulty of the game.

Function: void tarot_solo_copy (TarotSolo *dest, const TarotSolo *source)
Function: void tarot_solo_copy_as (TarotSolo *dest, const TarotSolo *source, TarotPlayer who)

Copy source to dest (optionally changing the human player to who).

Function: TarotSolo * tarot_solo_dup (const TarotSolo *source)

Allocate and return a copy of source.

Function: void tarot_solo_get (const TarotSolo *solo, TarotGame *game)
Function: TarotGame * tarot_solo_get_alloc (const TarotSolo *solo)

Get the game as known by the human player in solo. The second function allocates the results.

Function: TarotGameError tarot_solo_setup (TarotSolo *solo, size_t nplayers, int withcall, TarotPlayer player, size_t nowners, const TarotPlayer *owners, TarotPlayer taker, TarotCard call)
Function: TarotGameError tarot_solo_setup_random (TarotSolo *solo, size_t nplayers, int withcall, size_t seedsize, const char *seed)

Set up the solo game for nplayers players (and withcall if there is a call). The random-suffixed function will select an interesting game at random. Otherwise, you can specify which player to play, the individual owners for each card (an array of size nowners, which should be 78), the expected taker and call if relevant.

This function returns an error code. The only error that could happen is a petit sec. There cannot be any duplicaté-related ticking bomb as seen in the duplicaté section, so nothing bad to fear here.

Function: TarotGameError tarot_solo_add (TarotSolo *game, const TarotGameEvent *event)

Try and add event to game. This function may only fail if event is not correct for the human player.


Previous: , Up: Machine learning with tarot   [Contents][Index]