home *** CD-ROM | disk | FTP | other *** search
- /* #[info: */
- /************************************************************************
- * *
- * #### #### #### # # # ##### *
- * # # # # # # ## ## # *
- * # # # # # # # ## # # *
- * # ## # # # ## ####### # # ### *
- * # # # # # # # # # # # *
- * # # # # # # # # # # # *
- * #### #### #### # # # # ##### *
- * *
- * Jan van der Steen *
- * *
- * Centre for Mathematics and Computer Science *
- * Amsterdam, the Netherlands *
- * *
- *----------------------------------------------------------------------*
- * File : gogame.h *
- * Purpose : Implement functions to maintain a Go Game Data structure *
- * Version : 1.5 *
- * Modified: 2/6/93 19:44:48 *
- * Author : Jan van der Steen (jansteen@cwi.nl) *
- ************************************************************************/
- /* #]info: */
-
- #ifndef __GOGAMEH
- #define __GOGAMEH
-
- /* #[include: */
-
-
- /* #]include: */
- /* #[define: */
-
- #ifdef FREE
- #undef FREE
- #endif
- #ifdef BLACK
- #undef BLACK
- #endif
- #ifdef WHITE
- #undef WHITE
- #endif
-
- #define FREE 0
- #define BLACK 1
- #define WHITE 2
-
- /*
- * Defines for gn_print field in GONODE
- */
- #define PRINT_NOTHING 0
- #define PRINT_BLACK -1
- #define PRINT_WHITE -2
-
- #define MAXSIZE 19
-
- #define NODE(g,p) (((g)->gm_goban)->gb_node + (p))
- #define SIDE(g,p) (NODE(g,p)->gn_stone->mv_side)
- #define NODE2I(g,n) ((int)((n) - NODE(g,0)) % (g)->gm_size)
- #define NODE2J(g,n) ((int)((n) - NODE(g,0)) / (g)->gm_size)
-
- /* #]define: */
- /* #[typedef: */
-
- #ifdef __STDC__
- # define PROTO(s) s
- #else
- # define PROTO(s) ()
- #endif
-
- /* #[text info: */
-
- typedef struct text_info {
- char * cc_name; /* Name of kibitzer */
- char * cc_rank; /* Rank of kibitzer */
- char * cc_text; /* Text of kibitzer */
- struct text_info * cc_next; /* Next kibitz */
- struct text_info * cc_prev; /* Previous kibitz */
- } TEXT;
-
- /* #]text info: */
- /* #[goban info: */
-
- typedef struct gn_info {
- struct gn_info * gn_n; /* Northern neighour */
- struct gn_info * gn_e; /* Eastern neighour */
- struct gn_info * gn_s; /* Southern neighour */
- struct gn_info * gn_w; /* Western neighour */
- struct mv_info * gn_stone; /* Actually (GOMOVE *) */
- int gn_print; /* Used while printing */
- int gn_cache; /* Used while printing */
- int gn_loop; /* No endless recursion */
- } GONODE;
-
- typedef struct gb_info {
- GONODE * gb_node; /* All grid points */
- int gb_loop; /* No endless recursion */
- } GOBAN;
-
- /* #]goban info: */
- /* #[chain info: */
-
- typedef struct chain_info {
- struct mv_info * ch_stone; /* Actually (GOMOVE *) */
- struct chain_info * ch_next; /* Next stone in chain */
- } CHAIN;
-
- /* #]chain info: */
- /* #[move info: */
-
- /*
- * Place on the Goban
- */
- typedef int PLACE;
-
- /*
- * Mark on the Goban or on a stone
- */
- typedef int MARK;
-
- typedef struct mv_info {
- GONODE * mv_place; /* Place on the Goban */
- short mv_side; /* Color (B/W) */
- short mv_nr; /* When it was played */
- CHAIN * mv_captured; /* Captured stones */
- TEXT * mv_text; /* Kibitz list on move */
- TEXT * mv_textlast; /* Last kibitz on move */
- struct mv_info * mv_prev; /* Previous move */
- struct mv_info * mv_next; /* Next move */
- } GOMOVE;
-
- /* #]move info: */
- /* #[game info: */
-
- typedef struct game_info {
- GOMOVE * gm_move; /* All the moves */
- GOMOVE * gm_movelast; /* Current move */
- GOBAN * gm_goban; /* The Go board */
- int gm_movenr; /* Current move number */
- int gm_size; /* Board size */
- char * gm_event; /* Event specification */
- char * gm_user; /* Message for user */
- char * gm_view; /* ??? */
- char * gm_game; /* Game number */
- char * gm_name; /* Game name */
- char * gm_black; /* Black player */
- char * gm_brank; /* Black rank */
- char * gm_btime; /* Black alloted time */
- char * gm_bleft; /* Black time left */
- char * gm_white; /* White player */
- char * gm_wrank; /* White rank */
- char * gm_wtime; /* White alloted time */
- char * gm_wleft; /* White time left */
- char * gm_komi; /* Komi */
- char * gm_date; /* Date */
- char * gm_place; /* Place */
- char * gm_result; /* Result */
- } GOGAME;
-
- /* #]game info: */
-
- /* #]typedef: */
- /* #[prototype: */
-
- #ifdef __STDC__
- # define PROTO(s) s
- #else
- # define PROTO(s) ()
- #endif
-
- /*
- * Memory managers
- */
- GOGAME * game_alloc PROTO((void));
- void game_free PROTO((GOGAME *g));
- void text_store PROTO((GOGAME *g, char *text));
- void move_store PROTO((GOGAME *g, int side, PLACE place));
- void capture_store PROTO((GOGAME *gogame, GONODE *gonode));
- GOBAN * goban_new PROTO((GOGAME *g, int size));
-
- #undef PROTO
-
- /* #]prototype: */
-
- #endif
-