1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007-2009 Joshua Simmons <mud at majidejima dot com>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 /* A generic stack sp is the stack pointer (0 for an empty stack) */
35 /* All of the types of SGF properties that we understand. Not all of these
36 are handled, even if we understand them, unhandled properties are
37 handled differently (basically they are copied to a secondary location
38 and copied back if we output the tree) The ones at the end aren't real
39 SGF properties, they are only to help us in parsing/outputting/keeping
40 track of variations/etc. IMPORTANT: if you edit this, you must be
41 careful to keep it in line with prop_names, PROP_NAMES_SIZE, and
42 PROP_NAME_LEN otherwise really bad things will happen. There is too much
43 information on each of these to list here, please see
44 http://www.red-bean.com/sgf/ */
57 /* information about the position reached by the current node */
65 /* information about the current move */
71 /* marks on the board */
79 /* labels go on points, names name the node */
118 /* these are all the <whatever> left /after/ the current move */
119 PROP_BLACK_TIME_LEFT
,
120 PROP_WHITE_TIME_LEFT
,
121 PROP_BLACK_STONES_LEFT
, /* the number of stones left in a canadian
122 style overtime period */
123 PROP_WHITE_STONES_LEFT
, /* same for white */
126 /* these are mostly used for printing, we don't handle these */
128 PROP_PRINT_MOVE_MODE
,
130 /* view only part of the board. probably don't handle this */
135 /* psuedo PROP types, used for variations and parsing and such */
137 PROP_VARIATION
, /* used for branches */
139 PROP_GENERIC_UNHANDLED
, /* used to mark the place where an
140 unhandled property was copied to
141 secondary storage (so we can output it
142 again when we output the game tree) */
143 PROP_ANY
, /* Used as a parameter when any property
144 type is supposed to match */
145 PROP_VARIATION_TO_PROCESS
, /* Used in parsing/outputting */
146 PROP_VARIATION_CHOICE
, /* Used to store which variation we should
147 follow when we get to a branch */
148 PROP_ROOT_PROPS
/* Marks the place where we should output
149 the information from struct header_t
153 extern char *prop_names
[];
154 /* IMPORTANT: keep this array full of all properties that we want to be
155 able to parse out of an SGF file. This next part assumes that they go
156 before unparseable (psuedo) props in the above enum, or else we need to
157 insert placeholders in the array for unparseables */
159 #define PROP_NAMES_SIZE (63)
161 /* The only one character property names are the moves, everything else is
163 #define PROP_NAME_LEN(type) ((type == PROP_BLACK_MOVE || \
164 type == PROP_WHITE_MOVE) ? 1 : 2)
166 /* Data for a property. Can be a number, a node handle (for variations),
167 or a position and either a short or a character (the extras are for
168 label characters, and stone undo data (moves and added/removed)) */
175 unsigned short position
;
178 unsigned short stone_extra
;
179 unsigned char label_extra
;
184 /* What should happen when the user "plays" a move */
199 /* Different types of board marks */
210 /* An SGF property next is the handle to the next property in the node, or
211 less than zero if there isn't another */
214 union prop_data_t data
;
215 enum prop_type_t type
;
220 /* The names of the rulesets, ex. "AGA", "Japanese", etc. */
221 extern const char *ruleset_names
[];
223 /* IMPORTANT! keep in sync with ruleset_names!!! */
231 __RULESETS_SIZE
/* make sure i am last! */
234 #define NUM_RULESETS ((int) __RULESETS_SIZE)
237 /* One SGF node which can contain an indefinite number of SGF properties
238 Less than zero for any of these means that there is nothing in that
248 /* convenience union for keeping a mixed array of props and nodes */
256 /* The game metadata which can be stored in the SGF file */
259 #define MAX_EVENT 100
260 #define MAX_RESULT 16
265 #define MAX_PLACE 100
266 #define MAX_OVERTIME 32
267 #define MAX_RULESET 32
271 char white
[MAX_NAME
];
272 char black
[MAX_NAME
];
273 char white_rank
[MAX_RANK
];
274 char black_rank
[MAX_RANK
];
275 char white_team
[MAX_TEAM
];
276 char black_team
[MAX_TEAM
];
278 char round
[MAX_ROUND
];
279 char event
[MAX_EVENT
];
280 char place
[MAX_PLACE
];
281 char result
[MAX_RESULT
];
282 char overtime
[MAX_OVERTIME
];
283 char ruleset
[MAX_RULESET
];