Next: , Previous: libliquidwar6, Up: C API


5.2 libbot

5.2.1 Overview

View lcov test coverage results on http://www.gnu.org/software/liquidwar6/coverage/src/lib/bot/index.html.

5.2.2 API

— Function: int lw6bot_init (lw6bot_backend_t * backend, lw6bot_seed_t * seed)

backend: backend to use

seed: parameters required to build bot (game state, among other things)

Initializes a bot object. Must be performed before any other call. The seed is absolutely required, for a bot really needs to know what map/context it's working on, including at creation time

Return value: 1 on success, 0 on failure.

— Function: void lw6bot_quit (lw6bot_backend_t * backend)

backend: unitialize a bot backend

Closes a bot, but does not free all ressources.

— Function: int lw6bot_next_move (lw6bot_backend_t * backend, int * x, int * y)

backend: bot to work on

x: next x position (out param)

y: next y position (out param)

Queries the bot for its next move, this is actually the one interesting function in the whole bot API.

Return value: 1 on success, 0 on failure.

— Function: char * lw6bot_repr (lw6bot_backend_t * backend)

backend: bot to represent

Gives a human readable representation of bot

Return value: dynamically allocated string.

— Function: lw6sys_assoc_t * lw6bot_get_backends (int argc, char * [] argv)

argc: argc, as passed to main

argv: argv, as passed to main

List available bot backends. The hash contains pairs with id and name for each backend. The id is the technical key you can use to load the backend, the name is something more readable you can display in an interface. The backend objects themselves are not instanciated by this (in fact, they are, but released on the fly) you need to load and initialize them afterwards.

Return value: hash containing id/name pairs.

— Function: lw6bot_backend_t * lw6bot_create_backend (int argc, char * [] argv, char * name)

argc: argc, as passed to main

argv: argv, as passed to main

name: string containing bot key, typically got from lw6bot_get_backends

Creates a bot backend, this is just about loading the dynamic library if needed, and/or check bot engine is available, and connect to it. It does not perform initialization.

Return value: bot backend.

— Function: void lw6bot_destroy_backend (lw6bot_backend_t * backend)

backend: bot backend to destroy

Frees the ressources associated to a bot, which must have been properly uninitialized before.

Return value: none.

— Function: int lw6bot_test (int mode)

mode: 0 for check only, 1 for full test

Runs the bot module test suite. Will try several engines and query basic moves.

Return value: 1 if test is successfull, 0 on error.