home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / go / prog / sgf2mi13.taz / sgf2mi13 / gogame.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-27  |  4.8 KB  |  187 lines

  1. /* #[info:            */
  2. /************************************************************************
  3.  *                                    *
  4.  *         ####   ####   ####     #    #    # #####        *
  5.  *        #      #    # #        # #   ##  ## #            *
  6.  *        #      #    # #       #   #  # ## # #            *
  7.  *        #  ##  #    # #  ##  ####### #    # ###            *
  8.  *        #    # #    # #    # #     # #    # #            *
  9.  *        #    # #    # #    # #     # #    # #            *
  10.  *         ####   ####   ####  #     # #    # #####        *
  11.  *                                    *
  12.  *                Jan van der Steen                *
  13.  *                                    *
  14.  *          Centre for Mathematics and Computer Science        *
  15.  *              Amsterdam, the Netherlands            *
  16.  *                                    *
  17.  *----------------------------------------------------------------------*
  18.  * File      : gogame.h                         *
  19.  * Purpose : Implement functions to maintain a Go Game Data structure    *
  20.  * Version : 1.5                         *
  21.  * Modified: 2/6/93 19:44:48                        *
  22.  * Author  : Jan van der Steen (jansteen@cwi.nl)             *
  23.  ************************************************************************/
  24. /* #]info:            */ 
  25.  
  26. #ifndef __GOGAMEH
  27. #define __GOGAMEH
  28.  
  29. /* #[include:        */
  30.  
  31.  
  32. /* #]include:        */ 
  33. /* #[define:        */
  34.  
  35. #ifdef    FREE
  36. #undef    FREE
  37. #endif
  38. #ifdef    BLACK
  39. #undef    BLACK
  40. #endif
  41. #ifdef    WHITE
  42. #undef    WHITE
  43. #endif
  44.  
  45. #define    FREE        0
  46. #define BLACK        1
  47. #define WHITE        2
  48.  
  49. /*
  50.  * Defines for gn_print field in GONODE
  51.  */
  52. #define PRINT_NOTHING     0
  53. #define PRINT_BLACK    -1
  54. #define PRINT_WHITE    -2
  55.  
  56. #define    MAXSIZE        19
  57.  
  58. #define NODE(g,p)    (((g)->gm_goban)->gb_node + (p))
  59. #define SIDE(g,p)    (NODE(g,p)->gn_stone->mv_side)
  60. #define NODE2I(g,n)    ((int)((n) - NODE(g,0)) % (g)->gm_size)
  61. #define NODE2J(g,n)    ((int)((n) - NODE(g,0)) / (g)->gm_size)
  62.  
  63. /* #]define:        */ 
  64. /* #[typedef:        */
  65.  
  66. #ifdef __STDC__
  67. #    define    PROTO(s) s
  68. #else
  69. #    define    PROTO(s) ()
  70. #endif
  71.  
  72. /*    #[text  info:        */
  73.  
  74. typedef struct text_info {
  75.     char         *    cc_name;    /* Name of kibitzer    */
  76.     char         *    cc_rank;    /* Rank of kibitzer    */
  77.     char         *    cc_text;    /* Text of kibitzer    */
  78.     struct text_info *    cc_next;    /* Next     kibitz    */
  79.     struct text_info *    cc_prev;    /* Previous kibitz    */
  80. } TEXT;
  81.  
  82. /*    #]text  info:        */ 
  83. /*    #[goban info:        */
  84.  
  85. typedef struct gn_info {
  86.     struct gn_info *    gn_n;        /* Northern neighour    */
  87.     struct gn_info *    gn_e;        /* Eastern  neighour    */
  88.     struct gn_info *    gn_s;        /* Southern neighour    */
  89.     struct gn_info *    gn_w;        /* Western  neighour    */
  90.     struct mv_info *    gn_stone;    /* Actually (GOMOVE *)    */
  91.     int            gn_print;    /* Used while printing    */
  92.     int            gn_cache;    /* Used while printing    */
  93.     int            gn_loop;    /* No endless recursion    */
  94. } GONODE;
  95.  
  96. typedef struct gb_info {
  97.     GONODE *        gb_node;    /* All grid points    */
  98.     int            gb_loop;    /* No endless recursion    */
  99. } GOBAN;
  100.  
  101. /*    #]goban info:        */ 
  102. /*    #[chain info:        */
  103.  
  104. typedef struct chain_info {
  105.     struct mv_info    *    ch_stone;    /* Actually (GOMOVE *)    */
  106.     struct chain_info *    ch_next;    /* Next  stone in chain    */
  107. } CHAIN;
  108.  
  109. /*    #]chain info:        */ 
  110. /*    #[move  info:        */
  111.  
  112. /*
  113.  * Place on the Goban
  114.  */
  115. typedef int    PLACE;
  116.  
  117. /*
  118.  * Mark on the Goban or on a stone
  119.  */
  120. typedef int    MARK;
  121.  
  122. typedef struct mv_info {
  123.     GONODE       *    mv_place;    /* Place on the Goban    */
  124.     short        mv_side;    /* Color (B/W)        */
  125.     short        mv_nr;        /* When it was played    */
  126.     CHAIN       *    mv_captured;    /* Captured stones    */
  127.     TEXT       *    mv_text;    /* Kibitz list on move    */
  128.     TEXT       *    mv_textlast;    /* Last kibitz on move    */
  129.     struct mv_info *    mv_prev;    /* Previous move    */
  130.     struct mv_info *    mv_next;    /* Next     move    */
  131. } GOMOVE;
  132.  
  133. /*    #]move  info:        */ 
  134. /*    #[game  info:        */
  135.  
  136. typedef struct game_info {
  137.     GOMOVE *        gm_move;    /* All the moves    */
  138.     GOMOVE *        gm_movelast;    /* Current move        */
  139.     GOBAN  *        gm_goban;    /* The Go board        */
  140.     int            gm_movenr;    /* Current move number    */
  141.     int            gm_size;    /* Board size        */
  142.     char   *        gm_event;    /* Event specification    */
  143.     char   *        gm_user;    /* Message for user    */
  144.     char   *        gm_view;    /* ???            */
  145.     char   *        gm_game;    /* Game number        */
  146.     char   *        gm_name;    /* Game name        */
  147.     char   *        gm_black;    /* Black player        */
  148.     char   *        gm_brank;    /* Black rank        */
  149.     char   *        gm_btime;    /* Black alloted time    */
  150.     char   *        gm_bleft;    /* Black time left    */
  151.     char   *        gm_white;    /* White player        */
  152.     char   *        gm_wrank;    /* White rank        */
  153.     char   *        gm_wtime;    /* White alloted time    */
  154.     char   *        gm_wleft;    /* White time left    */
  155.     char   *        gm_komi;    /* Komi            */
  156.     char   *        gm_date;    /* Date            */
  157.     char   *        gm_place;    /* Place        */
  158.     char   *        gm_result;    /* Result        */
  159. } GOGAME;
  160.  
  161. /*    #]game  info:        */ 
  162.  
  163. /* #]typedef:        */ 
  164. /* #[prototype:        */
  165.  
  166. #ifdef __STDC__
  167. #    define    PROTO(s) s
  168. #else
  169. #    define    PROTO(s) ()
  170. #endif
  171.  
  172. /*
  173.  * Memory managers
  174.  */
  175. GOGAME *    game_alloc    PROTO((void));
  176. void        game_free    PROTO((GOGAME *g));
  177. void        text_store    PROTO((GOGAME *g, char *text));
  178. void        move_store    PROTO((GOGAME *g, int side, PLACE place));
  179. void        capture_store    PROTO((GOGAME *gogame, GONODE *gonode));
  180. GOBAN *        goban_new    PROTO((GOGAME *g, int size));
  181.  
  182. #undef PROTO
  183.  
  184. /* #]prototype:        */ 
  185.  
  186. #endif
  187.