NAME
SYNOPSIS
#include "libgame.h"
enum gd_who gd_winner
int gd_time_controls
int gd_white_time_control
int gd_black_time_control
int gd_my_time
int gd_opp_time
DESCRIPTION
ERRORS

NAME

gd_start_game, gd_make_move, gd_get_move, gd_winner, gd_time_controls, gd_white_time_control, gd_black_time_control, gd_my_time, gd_opp_time - C interface to LOA game daemon

SYNOPSIS

#include "libgame.h"

int gd_start_game(enum gd_who side, char *host, int server)

enum gd_state gd_make_move(char *from, char *to)

enum gd_state gd_get_move(char *from, char *to)

enum gd_who gd_winner

int gd_time_controls

int gd_white_time_control

int gd_black_time_control

int gd_my_time

int gd_opp_time

DESCRIPTION

The gd_start_game() function attempts to connect to the LOA server with the given server number on the given host, and start a game as side side as described by the enumeration enum gd_who. gd_start_game() will not return until the client side's first opportunity to move in the set-up game.

The gd_make_move() function attempts to make the given move on the LOA server, where from and to are two- character lowercase algebraic coordinate strings on the LOA board (in the range a1...h8). It returns an enum gd_state indicating whether the game is over, and if so, which side has won.

The gd_get_move() function attempts to retrieve an opponent move from the LOA server, where from and to are the algebraic coordinates of the resulting move. The from and to arguments must be pointers to two-character strings (i.e. 3 character area), whose contents will be filled in by the call. gd_get_move() returns an enum gd_state indicating whether the game is over, and if so, which side has won.

A number of globally accessible variables are side-effected by the functions, and contain useful state information about the game in progress.

enum gd_who gd_winner;
int gd_time_controls;
int gd_white_time_control;
int gd_black_time_control;
int gd_my_time;

/* winning side at game end */
/* 1 if game is time-controlled */
/* total time in secs */

/* secs remaining */

int gd_opp_time;

The gd_who enum is defined in "libgame.h" as follows:

GD_WHO_NONE=0,
GD_WHO_WHITE=1,
GD_WHO_BLACK=2,
GD_WHO_OTHER=3,

/* nobody */
/* white player */
/* black player */
/* some other player */

The gd_state enum is defined in "libgame.h" as follows:

GD_STATE_ERROR=-1,
GD_STATE_CONTINUE=0,
GD_STATE_DONE=1,

/* something is wrong */
/* game continues */
/* game over */


ERRORS

The gd_start_game() function returns 0 on success, and -1 on error. The gd_make_move() and gd_get_move() functions return GD_STATE_ERROR if an error is discovered in the arguments or the interaction with the server is unsuccessful.