LIBGAME(3) Portland State U. CS 441/541 LIBGAME(3) NNAAMMEE 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 inter- face to LOA game daemon SSYYNNOOPPSSIISS ##iinncclluuddee ""lliibbggaammee..hh"" iinntt ggdd__ssttaarrtt__ggaammee((eennuumm ggdd__wwhhoo _s_i_d_e,, cchhaarr **_h_o_s_t,, iinntt _s_e_r_v_e_r)) eennuumm ggdd__ssttaattee ggdd__mmaakkee__mmoovvee((cchhaarr **_f_r_o_m,, cchhaarr **_t_o)) eennuumm ggdd__ssttaattee ggdd__ggeett__mmoovvee((cchhaarr **_f_r_o_m,, cchhaarr **_t_o)) eennuumm ggdd__wwhhoo ggdd__wwiinnnneerr iinntt ggdd__ttiimmee__ccoonnttrroollss iinntt ggdd__wwhhiittee__ttiimmee__ccoonnttrrooll iinntt ggdd__bbllaacckk__ttiimmee__ccoonnttrrooll iinntt ggdd__mmyy__ttiimmee iinntt ggdd__oopppp__ttiimmee DDEESSCCRRIIPPTTIIOONN The ggdd__ssttaarrtt__ggaammee(()) function attempts to connect to the LOA server with the given _s_e_r_v_e_r number on the given _h_o_s_t, and start a game as side _s_i_d_e as described by the enumera- tion eennuumm ggdd__wwhhoo. ggdd__ssttaarrtt__ggaammee(()) will not return until the client side's first opportunity to move in the set-up game. The ggdd__mmaakkee__mmoovvee(()) function attempts to make the given move on the LOA server, where _f_r_o_m and _t_o are two-charac- ter lowercase algebraic coordinate strings on the LOA board (in the range aa11...hh88). It returns an eennuumm ggdd__ssttaattee indicating whether the game is over, and if so, which side has won. The ggdd__ggeett__mmoovvee(()) function attempts to retrieve an oppo- nent move from the LOA server, where _f_r_o_m and _t_o are the algebraic coordinates of the resulting move. The _f_r_o_m and _t_o arguments must be pointers to two-character strings (i.e. 3 character area), whose contents will be filled in by the call. ggdd__ggeett__mmoovvee(()) returns an eennuumm ggdd__ssttaattee indi- cating whether the game is over, and if so, which side has won. A number of globally accessible variables are side- GAMED November 25, 2000 1 LIBGAME(3) Portland State U. CS 441/541 LIBGAME(3) effected by the functions, and contain useful state infor- mation about the game in progress. enum gd_who gd_winner; /* winning side at game end */ int gd_time_controls; /* 1 if game is time-controlled */ int gd_white_time_control; /* total time in secs */ int gd_black_time_control; int gd_my_time; /* secs remaining */ int gd_opp_time; The ggdd__wwhhoo enum is defined in ""lliibbggaammee..hh"" as follows: GD_WHO_NONE=0, /* nobody */ GD_WHO_WHITE=1, /* white player */ GD_WHO_BLACK=2, /* black player */ GD_WHO_OTHER=3, /* some other player */ The ggdd__ssttaattee enum is defined in ""lliibbggaammee..hh"" as follows: GD_STATE_ERROR=-1, /* something is wrong */ GD_STATE_CONTINUE=0, /* game continues */ GD_STATE_DONE=1, /* game over */ EERRRROORRSS The ggdd__ssttaarrtt__ggaammee(()) function returns 0 on success, and -1 on error. The ggdd__mmaakkee__mmoovvee(()) and ggdd__ggeett__mmoovvee(()) functions return GGDD__SSTTAATTEE__EERRRROORR if an error is discovered in the arguments or the interaction with the server is unsuccess- ful. GAMED November 25, 2000 2