Commit | Line | Data |
---|---|---|
7eeb782e AT |
1 | /* |
2 | * src/gmp.h | |
3 | * Copyright (C) 1995-1996 William Shubert. | |
4 | * | |
5 | * Parts of this file are taken from "protocol.c", which is covered under | |
6 | * the copyright notice below. | |
7 | * Any code that is not present in the original "proocol.c" is covered under | |
8 | * the copyright notice above. | |
9 | */ | |
10 | /******************************************************* | |
11 | protocol.c 1.00 | |
12 | JCGA Go Communication Protocol | |
13 | copyright(c) Shuji Sunaga 95.7.9 | |
14 | original Standard Go Modem Protocol 1.0 | |
15 | by David Fotland | |
16 | * Permission granted to use this code for any | |
17 | * commercial or noncommercial purposes as long as this | |
18 | * copyright notice is not removed. | |
19 | * This code was written for Borland C++ 4.0J | |
20 | *******************************************************/ | |
21 | /* | |
22 | * You may use this code in any way you wish as long as you retain the | |
23 | * above copyright notices. | |
24 | */ | |
25 | ||
26 | /* Modified by Paul Pogonyshev on 10.07.2003. | |
27 | * Added support for Simplified GTP. | |
28 | */ | |
29 | ||
30 | #ifndef _GMP_H_ | |
31 | #define _GMP_H_ 1 | |
32 | ||
33 | ||
34 | /********************************************************************** | |
35 | * Data types | |
36 | **********************************************************************/ | |
37 | typedef enum { | |
38 | gmp_nothing, gmp_move, gmp_pass, gmp_reset, gmp_newGame, gmp_undo, gmp_err | |
39 | } GmpResult; | |
40 | ||
41 | ||
42 | #ifndef _GMP_C_ | |
43 | typedef struct Gmp_struct Gmp; | |
44 | #endif /* _GMP_C_ */ | |
45 | ||
46 | ||
47 | /********************************************************************** | |
48 | * Fuctions | |
49 | **********************************************************************/ | |
50 | extern Gmp *gmp_create(int inFile, int outFile); | |
51 | ||
52 | extern void gmp_destroy(Gmp *ge); | |
53 | ||
54 | /* | |
55 | * This starts a game up. | |
56 | * If you want, you can pass in -1 for size, handicap, and chineseRules, | |
57 | * and it will query. You can also pass in -1 for iAmWhite, but if you do | |
58 | * this then it will send a RESET command. If the other machine is black | |
59 | * and doesn't support arbitration, then this could screw things up. | |
60 | * Komi must be specified since GMP doesn't let you exchange komi information. | |
61 | * After calling this function, you should call gmp_check until you get a | |
62 | * "gmp_newGame" returned. Then you know that the size, etc. have all been | |
63 | * verified, you can call "gmp_size()" or whatever to find out values you | |
64 | * set to -1, and you can start the game. | |
65 | */ | |
66 | extern void gmp_startGame(Gmp *ge, int boardsize, int handicap, | |
67 | float komi, int chineseRules, int iAmWhite, | |
68 | int simplified); | |
69 | ||
70 | /* | |
71 | * Pretty self-explanatory set of routines. For sendMove, (0,0) is the | |
72 | * corner. | |
73 | */ | |
74 | extern void gmp_sendMove(Gmp *ge, int x, int y); | |
75 | extern void gmp_sendPass(Gmp *ge); | |
76 | extern void gmp_sendUndo(Gmp *ge, int numUndos); | |
77 | ||
78 | /* | |
79 | * gmp_check() process all data queued up until the next command that needs | |
80 | * to be returned to the application. If sleep is nonzero, then it will | |
81 | * stay here until a command arrives. If sleep is zero, then it will | |
82 | * return immediately if no command is ready. | |
83 | * It should be called about once per second to prevent the connection | |
84 | * between the programs from timing out. | |
85 | * If you get a move, "out1" will be the X and "out2" will be the y. | |
86 | */ | |
87 | extern GmpResult gmp_check(Gmp *ge, int sleepy, | |
88 | int *out1, int *out2, const char **error); | |
89 | ||
90 | ||
91 | /* | |
92 | * These routines return the configuration of the game that you are playing | |
93 | * in. They should all be set up by the time you get a gmpResult_newGame | |
94 | * from gmp_read(). | |
95 | * If you get a -1 back from these, it means that you didn't set the value | |
96 | * when you called gmp_startGame() and your opponent wouldn't say what | |
97 | * they had the parameter set to. | |
98 | */ | |
99 | extern int gmp_size(Gmp *ge); | |
100 | extern int gmp_handicap(Gmp *ge); | |
101 | extern float gmp_komi(Gmp *ge); | |
102 | extern int gmp_chineseRules(Gmp *ge); | |
103 | extern int gmp_iAmWhite(Gmp *ge); | |
104 | ||
105 | /* | |
106 | * This is handy if you want to print out, as an ascii string, the result | |
107 | * that you got bock from gmp_read(). | |
108 | */ | |
109 | extern const char *gmp_resultString(GmpResult result); | |
110 | ||
111 | #endif /* _GMP_H_ */ |