/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 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 - 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. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Usage : uncompress_fuseki boardsize filename\n\
/* Write a board point in sgf format. Also do a sanity check. */
write_stone(int i
, int j
)
assert(i
> 0 && i
<= MAX_BOARDSIZE
);
assert(j
> 0 && j
<= MAX_BOARDSIZE
);
printf("%c%c", j
+ 'a' - 1, i
+ 'a' - 1);
main(int argc
, char *argv
[])
/* Check number of arguments. */
input_FILE
= fopen(filename
, "r");
fprintf(stderr
, "compress_fuseki: Cannot open file %s\n", filename
);
while (fgets(line
, BUFSIZE
, input_FILE
)) {
if (sscanf(line
, "Pattern %s", name
) == 1) {
/* A new name has been picked up.
* Reset the row counter and the lists of stones.
else if (line
[0] == ':') {
/* The colon line ends the pattern. First get the move value. */
if (sscanf(line
, ":8,-,value(%d)", &value
) != 1) {
fprintf(stderr
, "compress_fuseki: Misformed colon line \"%s\"\n",
/* Write the compressed description of this pattern.
* Pad the stone list with passes (tt) if unbalanced colors.
printf("%s %d ", name
, value
);
write_stone(movei
, movej
);
while (num_x
> 0 || num_o
> 0) {
write_stone(xi
[num_x
], xj
[num_x
]);
write_stone(oi
[num_o
], oj
[num_o
]);
else if (line
[0] == '|') {
/* Found a diagram line. */
for (k
= 1; line
[k
] && line
[k
] != '|'; k
++) {
else if (line
[k
] == 'X') {
assert(num_x
< MAX_STONES
);
else if (line
[k
] == 'O') {
assert(num_o
< MAX_STONES
);