3ba29ca3747f057eac4a8609a33aee7c2eeb60a1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* This is GNU Go, a Go program. Contact gnugo@gnu.org, or see *
* http://www.gnu.org/software/gnugo/ for more information. *
* Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008 and 2009 by the Free Software Foundation. *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation - either version 3 *
* or (at your option) any later version. *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License in file COPYING for more details. *
* You should have received a copy of the GNU General Public *
* License along with this program; if not, write to the Free *
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02111, USA. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
* Return the integer X move.
get_moveX(SGFProperty
*property
, int boardsize
)
if (strlen(property
->value
) < 2)
i
= toupper((int) property
->value
[1]) - 'A';
* Return the integer Y move.
get_moveY(SGFProperty
*property
, int boardsize
)
if (strlen(property
->value
) < 2)
j
= toupper((int) property
->value
[0]) - 'A';
/* Fills (*i, *j) from the property value, in GNU Go co-ords.
* Note that GNU Go uses different conventions from sgf for
* co-ordinates been called.
* Returns 1 for a move, 0 for a pass.
get_moveXY(SGFProperty
*property
, int *i
, int *j
, int boardsize
)
*i
= get_moveX(property
, boardsize
);
*j
= get_moveY(property
, boardsize
);
if (*i
== -1 && *j
== -1)
* Debugging function to print properties as they are traversed.
show_sgf_properties(SGFNode
*node
)
printf("%c%c ", sgf_prop
->name
& 0x00FF, (sgf_prop
->name
& 0xFF00)>>8);
sgf_prop
= sgf_prop
->next
;
printf("(%d) ", propcount
);
* Recursively traverse each node showing all properties.
show_sgf_tree(SGFNode
*node
)
int n
= 0; /* number of nodes */
show_sgf_properties(node
);
/* must search depth first- siblings are equal! */
n
+= show_sgf_tree(node
->child
);
n
+= show_sgf_tree(node
->next
);
* Determine if a node has a mark property in it.
is_markup_node(SGFNode
*node
)
/* If the node has no properties, there's nothing to do.
This should have been checked by the caller, but it can't hurt. */
switch (sgf_prop
->name
) {
case SGFTR
: /* Triangle */
case SGFBM
: /* bad move */
case SGFDO
: /* doubtful move */
case SGFIT
: /* interesting move */
case SGFTE
: /* good move */
sgf_prop
= sgf_prop
->next
;
/* No markup property found. */
* Determine if the node has a move in it.
is_move_node(SGFNode
*node
)
/* If the node has no properties, there's nothing to do.
This should have been checked by the caller, but it can't hurt. */
switch (sgf_prop
->name
) {
sgf_prop
= sgf_prop
->next
;
* Determine if the node has a pass move in it.
is_pass_node(SGFNode
*node
, int boardsize
)
/* If the node has no properties, there's nothing to do.
This should have been checked by the caller, but it can't hurt. */
switch (sgf_prop
->name
) {
return !get_moveXY(sgf_prop
, &i
, &j
, boardsize
);
sgf_prop
= sgf_prop
->next
;
* Determine whose move is in the node.
/* If the node has no properties, there's nothing to do.
This should have been checked by the caller, but it can't hurt. */
switch (sgf_prop
->name
) {
sgf_prop
= sgf_prop
->next
;