Beginning of implementation of a ctypes-based interface to libboard, which is a much cleaner set of Go routines than I hacked together originally. Including a copy of gnugo 3.8 so we can build a dynamic version of libboard.
This commit is contained in:
22
gnugo/sgf/CMakeLists.txt
Normal file
22
gnugo/sgf/CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
INCLUDE_DIRECTORIES(${GNUGo_SOURCE_DIR}/utils)
|
||||
|
||||
########### sgfgen program ###############
|
||||
|
||||
SET(sgfgen_SRCS
|
||||
sgfgen.c
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(sgfgen ${sgfgen_SRCS})
|
||||
|
||||
TARGET_LINK_LIBRARIES(sgfgen)
|
||||
|
||||
|
||||
########### sgf library ###############
|
||||
|
||||
SET(sgf_STAT_SRCS
|
||||
sgf_utils.c
|
||||
sgfnode.c
|
||||
sgftree.c
|
||||
)
|
||||
|
||||
ADD_LIBRARY(sgf STATIC ${sgf_STAT_SRCS})
|
27
gnugo/sgf/Makefile.am
Normal file
27
gnugo/sgf/Makefile.am
Normal file
@ -0,0 +1,27 @@
|
||||
noinst_PROGRAMS = sgfgen
|
||||
|
||||
sgfgen_SOURCES = sgfgen.c
|
||||
|
||||
EXTRA_DIST = sgf_extras.def sgf_properties.def sgfgen.dsp sgf.dsp CMakeLists.txt
|
||||
|
||||
noinst_HEADERS = \
|
||||
sgftree.h\
|
||||
sgf_properties.h
|
||||
|
||||
# Remove these files here... they are created locally
|
||||
DISTCLEANFILES = *~
|
||||
|
||||
AM_CPPFLAGS = $(GNU_GO_WARNINGS) -I$(top_srcdir)/utils
|
||||
|
||||
noinst_LIBRARIES = libsgf.a
|
||||
|
||||
libsgf_a_SOURCES = \
|
||||
sgf_utils.c \
|
||||
sgfnode.c \
|
||||
sgftree.c
|
||||
|
||||
# To rebuild sgf_properties.h in case sgf_properties.def or sgf_extras.def
|
||||
# is changed, 'make sgf_properties'. Normally this is not needed.
|
||||
sgf_properties:
|
||||
cat $(srcdir)/sgf_properties.def $(srcdir)/sgf_extras.def |\
|
||||
./sgfgen > sgf_properties.h
|
427
gnugo/sgf/Makefile.in
Normal file
427
gnugo/sgf/Makefile.in
Normal file
@ -0,0 +1,427 @@
|
||||
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
top_builddir = ..
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
INSTALL = @INSTALL@
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
noinst_PROGRAMS = sgfgen$(EXEEXT)
|
||||
subdir = sgf
|
||||
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.in
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LIBRARIES = $(noinst_LIBRARIES)
|
||||
AR = ar
|
||||
ARFLAGS = cru
|
||||
libsgf_a_AR = $(AR) $(ARFLAGS)
|
||||
libsgf_a_LIBADD =
|
||||
am_libsgf_a_OBJECTS = sgf_utils.$(OBJEXT) sgfnode.$(OBJEXT) \
|
||||
sgftree.$(OBJEXT)
|
||||
libsgf_a_OBJECTS = $(am_libsgf_a_OBJECTS)
|
||||
PROGRAMS = $(noinst_PROGRAMS)
|
||||
am_sgfgen_OBJECTS = sgfgen.$(OBJEXT)
|
||||
sgfgen_OBJECTS = $(am_sgfgen_OBJECTS)
|
||||
sgfgen_LDADD = $(LDADD)
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(libsgf_a_SOURCES) $(sgfgen_SOURCES)
|
||||
DIST_SOURCES = $(libsgf_a_SOURCES) $(sgfgen_SOURCES)
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMDEP_FALSE = @AMDEP_FALSE@
|
||||
AMDEP_TRUE = @AMDEP_TRUE@
|
||||
AMTAR = @AMTAR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DFA_ENABLED_FALSE = @DFA_ENABLED_FALSE@
|
||||
DFA_ENABLED_TRUE = @DFA_ENABLED_TRUE@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
GCC_MAJOR_VERSION = @GCC_MAJOR_VERSION@
|
||||
GCC_MINOR_VERSION = @GCC_MINOR_VERSION@
|
||||
GCC_ONLY_FALSE = @GCC_ONLY_FALSE@
|
||||
GCC_ONLY_TRUE = @GCC_ONLY_TRUE@
|
||||
GNU_GO_WARNINGS = @GNU_GO_WARNINGS@
|
||||
GREP = @GREP@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
|
||||
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
|
||||
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build_alias = @build_alias@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
glibconfig = @glibconfig@
|
||||
host_alias = @host_alias@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
sgfgen_SOURCES = sgfgen.c
|
||||
EXTRA_DIST = sgf_extras.def sgf_properties.def sgfgen.dsp sgf.dsp CMakeLists.txt
|
||||
noinst_HEADERS = \
|
||||
sgftree.h\
|
||||
sgf_properties.h
|
||||
|
||||
|
||||
# Remove these files here... they are created locally
|
||||
DISTCLEANFILES = *~
|
||||
AM_CPPFLAGS = $(GNU_GO_WARNINGS) -I$(top_srcdir)/utils
|
||||
noinst_LIBRARIES = libsgf.a
|
||||
libsgf_a_SOURCES = \
|
||||
sgf_utils.c \
|
||||
sgfnode.c \
|
||||
sgftree.c
|
||||
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu sgf/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu sgf/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
clean-noinstLIBRARIES:
|
||||
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
|
||||
libsgf.a: $(libsgf_a_OBJECTS) $(libsgf_a_DEPENDENCIES)
|
||||
-rm -f libsgf.a
|
||||
$(libsgf_a_AR) libsgf.a $(libsgf_a_OBJECTS) $(libsgf_a_LIBADD)
|
||||
$(RANLIB) libsgf.a
|
||||
|
||||
clean-noinstPROGRAMS:
|
||||
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
|
||||
sgfgen$(EXEEXT): $(sgfgen_OBJECTS) $(sgfgen_DEPENDENCIES)
|
||||
@rm -f sgfgen$(EXEEXT)
|
||||
$(LINK) $(sgfgen_LDFLAGS) $(sgfgen_OBJECTS) $(sgfgen_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgf_utils.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgfgen.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgfnode.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sgftree.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
uninstall-info-am:
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
|
||||
list='$(DISTFILES)'; for file in $$list; do \
|
||||
case $$file in \
|
||||
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
|
||||
esac; \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
|
||||
dir="/$$dir"; \
|
||||
$(mkdir_p) "$(distdir)$$dir"; \
|
||||
else \
|
||||
dir=''; \
|
||||
fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS)
|
||||
installdirs:
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-info-am
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-noinstLIBRARIES clean-noinstPROGRAMS ctags distclean \
|
||||
distclean-compile distclean-generic distclean-tags distdir dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-exec install-exec-am \
|
||||
install-info install-info-am install-man install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am uninstall-info-am
|
||||
|
||||
|
||||
# To rebuild sgf_properties.h in case sgf_properties.def or sgf_extras.def
|
||||
# is changed, 'make sgf_properties'. Normally this is not needed.
|
||||
sgf_properties:
|
||||
cat $(srcdir)/sgf_properties.def $(srcdir)/sgf_extras.def |\
|
||||
./sgfgen > sgf_properties.h
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
112
gnugo/sgf/sgf.dsp
Normal file
112
gnugo/sgf/sgf.dsp
Normal file
@ -0,0 +1,112 @@
|
||||
# Microsoft Developer Studio Project File - Name="sgf" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=sgf - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sgf.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sgf.mak" CFG="sgf - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "sgf - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "sgf - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "sgf - Win32 Release"
|
||||
|
||||
# PROP Use_MFC 0
|
||||
# ADD CPP /GX /Zi /I ".." /I "..\interface" /I "..\engine" /I "..\utils" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "_CONSOLE" /D "HAVE_CONFIG_H" /Fo"Release/" /Fd"Release/sgf" /FD /c
|
||||
# ADD BASE RSC /l 0x809
|
||||
# ADD RSC /l 0x809
|
||||
BSC32=bscmake.exe
|
||||
LIB32=link.exe -lib
|
||||
# ADD LIB32 /nologo /out:"Release\sgf.lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "sgf - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "_DEBUG" /YX /FD /GZ /c
|
||||
# ADD CPP /W2 /Gm /GX /ZI /Od /I ".." /I "..\engine" /I "..\interface" /I "../utils" /D "WIN32" /D "_MBCS" /D "_LIB" /D "_DEBUG" /D "_CONSOLE" /D "HAVE_CONFIG_H" /FR /Fd"Debug/sgf" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG" /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "sgf - Win32 Release"
|
||||
# Name "sgf - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sgf\sgf_utils.c
|
||||
|
||||
!IF "$(CFG)" == "sgf - Win32 Release"
|
||||
|
||||
# ADD CPP /W3
|
||||
|
||||
!ELSEIF "$(CFG)" == "sgf - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sgfnode.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sgftree.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sgf_properties.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sgf_utils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sgftree.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
22
gnugo/sgf/sgf_extras.def
Normal file
22
gnugo/sgf/sgf_extras.def
Normal file
@ -0,0 +1,22 @@
|
||||
#
|
||||
# These are additions to the SGF spec- old commands and some others
|
||||
#
|
||||
|
||||
#
|
||||
# outdated FF3 properties
|
||||
#
|
||||
BS
|
||||
WS
|
||||
ID
|
||||
RG
|
||||
SC
|
||||
|
||||
#
|
||||
# some random ones used by CGoban
|
||||
#
|
||||
SY
|
||||
|
||||
#
|
||||
# nonstandard SGF property used by GNU Go to mark illegal moves
|
||||
#
|
||||
IL
|
85
gnugo/sgf/sgf_properties.def
Normal file
85
gnugo/sgf/sgf_properties.def
Normal file
@ -0,0 +1,85 @@
|
||||
#
|
||||
# This document was taken from the SGF Specfication. See:
|
||||
# http://www.red-bean.com/sgf/
|
||||
#
|
||||
# [SGF FF[4] - Smart Game Format]
|
||||
#
|
||||
# FF[4] property index
|
||||
#
|
||||
# This is an alphabetical index to all properties defined in FF[4].
|
||||
# New properties are marked with '*', changed properties are marked with '!'.
|
||||
#
|
||||
#ID Description property type property value
|
||||
#---- --------------- --------------- --------------------------------------
|
||||
AB Add Black setup list of stone
|
||||
AE Add Empty setup list of point
|
||||
AN Annotation game-info simpletext
|
||||
*AP Application root composed simpletext ':' simpletext
|
||||
*AR Arrow - list of composed point ':' point
|
||||
*AS Who adds stones - (LOA) simpletext
|
||||
AW Add White setup list of stone
|
||||
B Black move move
|
||||
BL Black time left move real
|
||||
BM Bad move move double
|
||||
BR Black rank game-info simpletext
|
||||
BT Black team game-info simpletext
|
||||
C Comment - text
|
||||
*CA Charset root simpletext
|
||||
CP Copyright game-info simpletext
|
||||
CR Circle - list of point
|
||||
*DD Dim points - (inherit) elist of point
|
||||
DM Even position - double
|
||||
DO Doubtful move none
|
||||
!DT Date game-info simpletext
|
||||
EV Event game-info simpletext
|
||||
FF Fileformat root number (range: 1-4)
|
||||
!FG Figure - none | composed number ":" simpletext
|
||||
GB Good for Black - double
|
||||
GC Game comment game-info text
|
||||
GM Game root number (range: 1-5,7-16)
|
||||
GN Game name game-info simpletext
|
||||
GW Good for White - double
|
||||
HA Handicap game-info (Go) number
|
||||
HO Hotspot - double
|
||||
*IP Initial pos. game-info (LOA) simpletext
|
||||
IT Interesting move none
|
||||
*IY Invert Y-axis game-info (LOA) simpletext
|
||||
KM Komi game-info (Go) real
|
||||
KO Ko move none
|
||||
!LB Label - list of composed point ':' simpletext
|
||||
*LN Line - list of composed point ':' point
|
||||
MA Mark - list of point
|
||||
MN set move number move number
|
||||
N Nodename - simpletext
|
||||
OB OtStones Black move number
|
||||
ON Opening game-info text
|
||||
*OT Overtime game-info simpletext
|
||||
OW OtStones White move number
|
||||
PB Player Black game-info simpletext
|
||||
PC Place game-info simpletext
|
||||
PL Player to play setup color
|
||||
*PM Print move mode - (inherit) number
|
||||
PW Player White game-info simpletext
|
||||
!RE Result game-info simpletext
|
||||
RO Round game-info simpletext
|
||||
!RU Rules game-info simpletext
|
||||
*SE Markup - (LOA) point
|
||||
SL Selected - list of point
|
||||
SO Source game-info simpletext
|
||||
*SQ Square - list of point
|
||||
*ST Style root number (range: 0-3)
|
||||
*SU Setup type game-info (LOA) simpletext
|
||||
!SZ Size root (number | composed number ':' number)
|
||||
TB Territory Black - (Go) elist of point
|
||||
TE Tesuji move double
|
||||
TM Timelimit game-info real
|
||||
TR Triangle - list of point
|
||||
TW Territory White - (Go) elist of point
|
||||
UC Unclear pos - double
|
||||
US User game-info simpletext
|
||||
V Value - real
|
||||
*VW View - (inherit) elist of point
|
||||
W White move move
|
||||
WL White time left move real
|
||||
WR White rank game-info simpletext
|
||||
WT White team game-info simpletext
|
179
gnugo/sgf/sgf_properties.h
Normal file
179
gnugo/sgf/sgf_properties.h
Normal file
@ -0,0 +1,179 @@
|
||||
/* # */
|
||||
/* # This document was taken from the SGF Specfication. See: */
|
||||
/* # http://www.red-bean.com/sgf/ */
|
||||
/* # */
|
||||
/* # [SGF FF[4] - Smart Game Format] */
|
||||
/* # */
|
||||
/* # FF[4] property index */
|
||||
/* # */
|
||||
/* # This is an alphabetical index to all properties defined in FF[4]. */
|
||||
/* # New properties are marked with '*', changed properties are marked with '!'. */
|
||||
/* # */
|
||||
/* #ID Description property type property value */
|
||||
/* #---- --------------- --------------- -------------------------------------- */
|
||||
/* Add Black setup list of stone */
|
||||
#define SGFAB 16961
|
||||
/* Add Empty setup list of point */
|
||||
#define SGFAE 17729
|
||||
/* Annotation game-info simpletext */
|
||||
#define SGFAN 20033
|
||||
/* Application root composed simpletext ':' simpletext */
|
||||
#define SGFAP 20545
|
||||
/* Arrow - list of composed point ':' point */
|
||||
#define SGFAR 21057
|
||||
/* Who adds stones - (LOA) simpletext */
|
||||
#define SGFAS 21313
|
||||
/* Add White setup list of stone */
|
||||
#define SGFAW 22337
|
||||
/* Black move move */
|
||||
#define SGFB 8258
|
||||
/* Black time left move real */
|
||||
#define SGFBL 19522
|
||||
/* Bad move move double */
|
||||
#define SGFBM 19778
|
||||
/* Black rank game-info simpletext */
|
||||
#define SGFBR 21058
|
||||
/* Black team game-info simpletext */
|
||||
#define SGFBT 21570
|
||||
/* Comment - text */
|
||||
#define SGFC 8259
|
||||
/* Charset root simpletext */
|
||||
#define SGFCA 16707
|
||||
/* Copyright game-info simpletext */
|
||||
#define SGFCP 20547
|
||||
/* Circle - list of point */
|
||||
#define SGFCR 21059
|
||||
/* Dim points - (inherit) elist of point */
|
||||
#define SGFDD 17476
|
||||
/* Even position - double */
|
||||
#define SGFDM 19780
|
||||
/* Doubtful move none */
|
||||
#define SGFDO 20292
|
||||
/* Date game-info simpletext */
|
||||
#define SGFDT 21572
|
||||
/* Event game-info simpletext */
|
||||
#define SGFEV 22085
|
||||
/* Fileformat root number (range: 1-4) */
|
||||
#define SGFFF 17990
|
||||
/* Figure - none | composed number ":" simpletext */
|
||||
#define SGFFG 18246
|
||||
/* Good for Black - double */
|
||||
#define SGFGB 16967
|
||||
/* Game comment game-info text */
|
||||
#define SGFGC 17223
|
||||
/* Game root number (range: 1-5,7-16) */
|
||||
#define SGFGM 19783
|
||||
/* Game name game-info simpletext */
|
||||
#define SGFGN 20039
|
||||
/* Good for White - double */
|
||||
#define SGFGW 22343
|
||||
/* Handicap game-info (Go) number */
|
||||
#define SGFHA 16712
|
||||
/* Hotspot - double */
|
||||
#define SGFHO 20296
|
||||
/* Initial pos. game-info (LOA) simpletext */
|
||||
#define SGFIP 20553
|
||||
/* Interesting move none */
|
||||
#define SGFIT 21577
|
||||
/* Invert Y-axis game-info (LOA) simpletext */
|
||||
#define SGFIY 22857
|
||||
/* Komi game-info (Go) real */
|
||||
#define SGFKM 19787
|
||||
/* Ko move none */
|
||||
#define SGFKO 20299
|
||||
/* Label - list of composed point ':' simpletext */
|
||||
#define SGFLB 16972
|
||||
/* Line - list of composed point ':' point */
|
||||
#define SGFLN 20044
|
||||
/* Mark - list of point */
|
||||
#define SGFMA 16717
|
||||
/* set move number move number */
|
||||
#define SGFMN 20045
|
||||
/* Nodename - simpletext */
|
||||
#define SGFN 8270
|
||||
/* OtStones Black move number */
|
||||
#define SGFOB 16975
|
||||
/* Opening game-info text */
|
||||
#define SGFON 20047
|
||||
/* Overtime game-info simpletext */
|
||||
#define SGFOT 21583
|
||||
/* OtStones White move number */
|
||||
#define SGFOW 22351
|
||||
/* Player Black game-info simpletext */
|
||||
#define SGFPB 16976
|
||||
/* Place game-info simpletext */
|
||||
#define SGFPC 17232
|
||||
/* Player to play setup color */
|
||||
#define SGFPL 19536
|
||||
/* Print move mode - (inherit) number */
|
||||
#define SGFPM 19792
|
||||
/* Player White game-info simpletext */
|
||||
#define SGFPW 22352
|
||||
/* Result game-info simpletext */
|
||||
#define SGFRE 17746
|
||||
/* Round game-info simpletext */
|
||||
#define SGFRO 20306
|
||||
/* Rules game-info simpletext */
|
||||
#define SGFRU 21842
|
||||
/* Markup - (LOA) point */
|
||||
#define SGFSE 17747
|
||||
/* Selected - list of point */
|
||||
#define SGFSL 19539
|
||||
/* Source game-info simpletext */
|
||||
#define SGFSO 20307
|
||||
/* Square - list of point */
|
||||
#define SGFSQ 20819
|
||||
/* Style root number (range: 0-3) */
|
||||
#define SGFST 21587
|
||||
/* Setup type game-info (LOA) simpletext */
|
||||
#define SGFSU 21843
|
||||
/* Size root (number | composed number ':' number) */
|
||||
#define SGFSZ 23123
|
||||
/* Territory Black - (Go) elist of point */
|
||||
#define SGFTB 16980
|
||||
/* Tesuji move double */
|
||||
#define SGFTE 17748
|
||||
/* Timelimit game-info real */
|
||||
#define SGFTM 19796
|
||||
/* Triangle - list of point */
|
||||
#define SGFTR 21076
|
||||
/* Territory White - (Go) elist of point */
|
||||
#define SGFTW 22356
|
||||
/* Unclear pos - double */
|
||||
#define SGFUC 17237
|
||||
/* User game-info simpletext */
|
||||
#define SGFUS 21333
|
||||
/* Value - real */
|
||||
#define SGFV 8278
|
||||
/* View - (inherit) elist of point */
|
||||
#define SGFVW 22358
|
||||
/* White move move */
|
||||
#define SGFW 8279
|
||||
/* White time left move real */
|
||||
#define SGFWL 19543
|
||||
/* White rank game-info simpletext */
|
||||
#define SGFWR 21079
|
||||
/* White team game-info simpletext */
|
||||
#define SGFWT 21591
|
||||
/* # */
|
||||
/* # These are additions to the SGF spec- old commands and some others */
|
||||
/* # */
|
||||
|
||||
/* # */
|
||||
/* # outdated FF3 properties */
|
||||
/* # */
|
||||
#define SGFBS 21314
|
||||
#define SGFWS 21335
|
||||
#define SGFID 17481
|
||||
#define SGFRG 18258
|
||||
#define SGFSC 17235
|
||||
|
||||
/* # */
|
||||
/* # some random ones used by CGoban */
|
||||
/* # */
|
||||
#define SGFSY 22867
|
||||
|
||||
/* # */
|
||||
/* # nonstandard SGF property used by GNU Go to mark illegal moves */
|
||||
/* # */
|
||||
#define SGFIL 19529
|
288
gnugo/sgf/sgf_utils.c
Normal file
288
gnugo/sgf/sgf_utils.c
Normal file
@ -0,0 +1,288 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||
* 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. *
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "sgftree.h"
|
||||
|
||||
/*
|
||||
* Return the integer X move.
|
||||
*/
|
||||
|
||||
int
|
||||
get_moveX(SGFProperty *property, int boardsize)
|
||||
{
|
||||
int i;
|
||||
if (strlen(property->value) < 2)
|
||||
return -1;
|
||||
|
||||
i = toupper((int) property->value[1]) - 'A';
|
||||
if (i >= boardsize)
|
||||
return -1;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the integer Y move.
|
||||
*/
|
||||
|
||||
int
|
||||
get_moveY(SGFProperty *property, int boardsize)
|
||||
{
|
||||
int j;
|
||||
if (strlen(property->value) < 2)
|
||||
return -1;
|
||||
|
||||
j = toupper((int) property->value[0]) - 'A';
|
||||
if (j >= boardsize)
|
||||
return -1;
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
int
|
||||
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)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Debugging function to print properties as they are traversed.
|
||||
*/
|
||||
|
||||
int
|
||||
show_sgf_properties(SGFNode *node)
|
||||
{
|
||||
SGFProperty *sgf_prop;
|
||||
int propcount;
|
||||
|
||||
propcount = 0;
|
||||
|
||||
printf("P: ");
|
||||
if (!node->props) {
|
||||
printf("None\n");
|
||||
return propcount;
|
||||
}
|
||||
else {
|
||||
sgf_prop = node->props;
|
||||
while (sgf_prop) {
|
||||
printf("%c%c ", sgf_prop->name & 0x00FF, (sgf_prop->name & 0xFF00)>>8);
|
||||
sgf_prop = sgf_prop->next;
|
||||
propcount++;
|
||||
}
|
||||
|
||||
printf("(%d) ", propcount);
|
||||
if (node->next)
|
||||
printf("n");
|
||||
if (node->child)
|
||||
printf("c");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return propcount;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Recursively traverse each node showing all properties.
|
||||
*/
|
||||
|
||||
int
|
||||
show_sgf_tree(SGFNode *node)
|
||||
{
|
||||
int n = 0; /* number of nodes */
|
||||
|
||||
n++;
|
||||
show_sgf_properties(node);
|
||||
|
||||
/* must search depth first- siblings are equal! */
|
||||
if (node->child)
|
||||
n += show_sgf_tree(node->child);
|
||||
|
||||
if (node->next)
|
||||
n += show_sgf_tree(node->next);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Determine if a node has a mark property in it.
|
||||
*/
|
||||
|
||||
int
|
||||
is_markup_node(SGFNode *node)
|
||||
{
|
||||
SGFProperty *sgf_prop;
|
||||
|
||||
/* If the node has no properties, there's nothing to do.
|
||||
This should have been checked by the caller, but it can't hurt. */
|
||||
if (!node->props)
|
||||
return 0;
|
||||
|
||||
sgf_prop = node->props;
|
||||
while (sgf_prop) {
|
||||
switch (sgf_prop->name) {
|
||||
case SGFCR:
|
||||
case SGFSQ: /* Square */
|
||||
case SGFTR: /* Triangle */
|
||||
case SGFMA: /* Mark */
|
||||
case SGFBM: /* bad move */
|
||||
case SGFDO: /* doubtful move */
|
||||
case SGFIT: /* interesting move */
|
||||
case SGFTE: /* good move */
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sgf_prop = sgf_prop->next;
|
||||
}
|
||||
|
||||
/* No markup property found. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Determine if the node has a move in it.
|
||||
*/
|
||||
|
||||
int
|
||||
is_move_node(SGFNode *node)
|
||||
{
|
||||
SGFProperty *sgf_prop;
|
||||
|
||||
/* If the node has no properties, there's nothing to do.
|
||||
This should have been checked by the caller, but it can't hurt. */
|
||||
if (!node->props)
|
||||
return 0;
|
||||
|
||||
sgf_prop = node->props;
|
||||
while (sgf_prop) {
|
||||
switch (sgf_prop->name) {
|
||||
case SGFB:
|
||||
case SGFW:
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sgf_prop = sgf_prop->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Determine if the node has a pass move in it.
|
||||
*/
|
||||
|
||||
int
|
||||
is_pass_node(SGFNode *node, int boardsize)
|
||||
{
|
||||
SGFProperty *sgf_prop;
|
||||
int i, j;
|
||||
|
||||
/* If the node has no properties, there's nothing to do.
|
||||
This should have been checked by the caller, but it can't hurt. */
|
||||
if (!node->props)
|
||||
return 0;
|
||||
|
||||
sgf_prop = node->props;
|
||||
while (sgf_prop) {
|
||||
switch (sgf_prop->name) {
|
||||
case SGFB:
|
||||
case SGFW:
|
||||
return !get_moveXY(sgf_prop, &i, &j, boardsize);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sgf_prop = sgf_prop->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Determine whose move is in the node.
|
||||
*/
|
||||
|
||||
int
|
||||
find_move(SGFNode *node)
|
||||
{
|
||||
SGFProperty *sgf_prop;
|
||||
|
||||
/* If the node has no properties, there's nothing to do.
|
||||
This should have been checked by the caller, but it can't hurt. */
|
||||
if (!node->props)
|
||||
return 0;
|
||||
|
||||
sgf_prop = node->props;
|
||||
while (sgf_prop) {
|
||||
switch (sgf_prop->name) {
|
||||
case SGFB:
|
||||
return BLACK;
|
||||
break;
|
||||
case SGFW:
|
||||
return WHITE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sgf_prop = sgf_prop->next;
|
||||
}
|
||||
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* tab-width: 8
|
||||
* c-basic-offset: 2
|
||||
* End:
|
||||
*/
|
99
gnugo/sgf/sgfgen.c
Normal file
99
gnugo/sgf/sgfgen.c
Normal file
@ -0,0 +1,99 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||
* 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. *
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* A little program to convert the SGF Spec into something usable in a
|
||||
* parser- basically, the two letters moved into a 'short'
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_LINE 128
|
||||
|
||||
static short str2short(char *str);
|
||||
|
||||
/*
|
||||
* combine two characters into a short.
|
||||
*/
|
||||
|
||||
static short
|
||||
str2short(char *str)
|
||||
{
|
||||
return (str[0] | str[1] << 8);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
char instring[MAX_LINE];
|
||||
char sgf_tag[MAX_LINE];
|
||||
char comment[MAX_LINE];
|
||||
int i;
|
||||
|
||||
while (fgets(instring, MAX_LINE, stdin)) {
|
||||
i = strlen(instring) - 1;
|
||||
|
||||
/* Remove trailing newline and spaces */
|
||||
while (i >= 0
|
||||
&& (instring[i] == ' ' || instring[i] == 10))
|
||||
instring[i--] = 0;
|
||||
|
||||
/* Blank lines stay blank lines */
|
||||
if (strcmp(instring, "") == 0) {
|
||||
fprintf(stdout, "\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
sscanf(instring, "%4s %75s", sgf_tag, comment);
|
||||
strncpy(sgf_tag, instring, 4);
|
||||
if (strlen(instring) > 4)
|
||||
strncpy(comment, instring+4, MAX_LINE-4);
|
||||
else
|
||||
strcpy(comment, "");
|
||||
|
||||
/* outdated and modified notations. */
|
||||
/* just shift everything over */
|
||||
if (sgf_tag[0] == '*' || sgf_tag[0] == '!') {
|
||||
sgf_tag[0] = sgf_tag[1];
|
||||
sgf_tag[1] = sgf_tag[2];
|
||||
sgf_tag[2] = sgf_tag[3];
|
||||
}
|
||||
|
||||
/* If its not a real tag, just take it as a comment. */
|
||||
if (sgf_tag[0] < 'A' || sgf_tag[0] > 'Z') {
|
||||
fprintf(stdout, "/* %s */\n", instring);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* otherwise, write the tag and value to the file */
|
||||
if (strlen(comment))
|
||||
fprintf(stdout, " /* %s */\n", comment);
|
||||
fprintf(stdout, "#define SGF%s %5d\n", sgf_tag, str2short(sgf_tag));
|
||||
}
|
||||
}
|
||||
|
||||
/* Needs 0 exit status or else make fails. */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
98
gnugo/sgf/sgfgen.dsp
Normal file
98
gnugo/sgf/sgfgen.dsp
Normal file
@ -0,0 +1,98 @@
|
||||
# Microsoft Developer Studio Project File - Name="sgfgen" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=sgfgen - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sgfgen.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "sgfgen.mak" CFG="sgfgen - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "sgfgen - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "sgfgen - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "sgfgen - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /GX /Zi /O2 /I ".." /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "HAVE_CONFIG_H" /Fd"Release/sgfgen" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "sgfgen - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /W2 /Gm /GX /ZI /Od /I ".." /D "_DEBUG" /D "HAVE_CONFIG_H" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /FR /Fd"Debug/sgfgen" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "sgfgen - Win32 Release"
|
||||
# Name "sgfgen - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\sgfgen.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
1562
gnugo/sgf/sgfnode.c
Normal file
1562
gnugo/sgf/sgfnode.c
Normal file
File diff suppressed because it is too large
Load Diff
327
gnugo/sgf/sgftree.c
Normal file
327
gnugo/sgf/sgftree.c
Normal file
@ -0,0 +1,327 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||
* 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. *
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "gg_utils.h"
|
||||
#include "sgftree.h"
|
||||
|
||||
void
|
||||
sgftree_clear(SGFTree *tree)
|
||||
{
|
||||
tree->root = NULL;
|
||||
tree->lastnode = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
sgftree_readfile(SGFTree *tree, const char *infilename)
|
||||
{
|
||||
SGFNode *savetree = tree->root;
|
||||
|
||||
tree->root = readsgffile(infilename);
|
||||
if (tree->root == NULL) {
|
||||
tree->root = savetree;
|
||||
return 0;
|
||||
}
|
||||
|
||||
sgfFreeNode(savetree);
|
||||
tree->lastnode = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Go back one node in the tree. If lastnode is NULL, go to the last
|
||||
* node (the one in main variant which has no children).
|
||||
*/
|
||||
|
||||
int
|
||||
sgftreeBack(SGFTree *tree)
|
||||
{
|
||||
if (tree->lastnode) {
|
||||
if (tree->lastnode->parent)
|
||||
tree->lastnode = tree->lastnode->parent;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
while (sgftreeForward(tree))
|
||||
;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Go forward one node in the tree. If lastnode is NULL, go to the
|
||||
* tree root.
|
||||
*/
|
||||
|
||||
int
|
||||
sgftreeForward(SGFTree *tree)
|
||||
{
|
||||
if (tree->lastnode) {
|
||||
if (tree->lastnode->child)
|
||||
tree->lastnode = tree->lastnode->child;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
tree->lastnode = tree->root;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================ */
|
||||
/* High level functions */
|
||||
/* ================================================================ */
|
||||
|
||||
/*
|
||||
* Returns the node to modify. Use lastnode if available, otherwise
|
||||
* follow the main variation to the current end of the game.
|
||||
*/
|
||||
|
||||
SGFNode *
|
||||
sgftreeNodeCheck(SGFTree *tree)
|
||||
{
|
||||
SGFNode *node = NULL;
|
||||
assert(tree->root);
|
||||
|
||||
if (tree->lastnode)
|
||||
node = tree->lastnode;
|
||||
else {
|
||||
node = tree->root;
|
||||
while (node->child)
|
||||
node = node->child;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add a stone to the current or the given node.
|
||||
* Return the node where the stone was added.
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeAddStone(SGFTree *tree, int color, int movex, int movey)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
sgfAddStone(node, color, movex, movey);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add a move to the gametree.
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeAddPlay(SGFTree *tree, int color, int movex, int movey)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
tree->lastnode = sgfAddPlay(node, color, movex, movey);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add a move to the gametree. New variations are added after the old
|
||||
* ones rather than before.
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeAddPlayLast(SGFTree *tree, int color, int movex, int movey)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
tree->lastnode = sgfAddPlayLast(node, color, movex, movey);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sgftreeCreateHeaderNode(SGFTree *tree, int boardsize, float komi, int handicap)
|
||||
{
|
||||
SGFNode *root = sgfNewNode();
|
||||
|
||||
sgfAddPropertyInt(root, "SZ", boardsize);
|
||||
sgfAddPropertyFloat(root, "KM", komi);
|
||||
sgfAddPropertyInt(root, "HA", handicap);
|
||||
tree->root = root;
|
||||
tree->lastnode = root;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add a comment to a gametree.
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeAddComment(SGFTree *tree, const char *comment)
|
||||
{
|
||||
SGFNode *node;
|
||||
assert(tree && tree->root);
|
||||
|
||||
node = sgftreeNodeCheck(tree);
|
||||
sgfAddComment(node, comment);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Place text on the board at position (i, j).
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeBoardText(SGFTree *tree, int i, int j, const char *text)
|
||||
{
|
||||
SGFNode *node;
|
||||
assert(tree->root);
|
||||
|
||||
node = sgftreeNodeCheck(tree);
|
||||
sgfBoardText(node, i, j, text);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Place a character on the board at position (i, j).
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeBoardChar(SGFTree *tree, int i, int j, char c)
|
||||
{
|
||||
SGFNode *node;
|
||||
assert(tree->root);
|
||||
|
||||
node = sgftreeNodeCheck(tree);
|
||||
sgfBoardChar(node, i, j, c);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Place a number on the board at position (i, j).
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeBoardNumber(SGFTree *tree, int i, int j, int number)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
sgfBoardNumber(node, i, j, number);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Place a circle mark on the board at position (i, j).
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeTriangle(SGFTree *tree, int i, int j)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
sgfTriangle(node, i, j);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Place a circle mark on the board at position (i, j).
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeCircle(SGFTree *tree, int i, int j)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
sgfCircle(node, i, j);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Place a square mark on the board at position (i, j).
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeSquare(SGFTree *tree, int i, int j)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
sgfSquare(node, i, j);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Place a (square) mark on the board at position (i, j).
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeMark(SGFTree *tree, int i, int j)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
sgfMark(node, i, j);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Start a new variant.
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeStartVariant(SGFTree *tree)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
tree->lastnode = sgfStartVariant(node);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Start a new variant as first child.
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeStartVariantFirst(SGFTree *tree)
|
||||
{
|
||||
SGFNode *node = sgftreeNodeCheck(tree);
|
||||
tree->lastnode = sgfStartVariantFirst(node);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Write result of the game to the game tree.
|
||||
*/
|
||||
|
||||
void
|
||||
sgftreeWriteResult(SGFTree *tree, float score, int overwrite)
|
||||
{
|
||||
assert(tree->root);
|
||||
|
||||
sgfWriteResult(tree->root, score, overwrite);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sgftreeSetLastNode(SGFTree *tree, SGFNode *last_node)
|
||||
{
|
||||
tree->lastnode = last_node;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* tab-width: 8
|
||||
* c-basic-offset: 2
|
||||
* End:
|
||||
*/
|
||||
|
179
gnugo/sgf/sgftree.h
Normal file
179
gnugo/sgf/sgftree.h
Normal file
@ -0,0 +1,179 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||
* 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. *
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef _SGFTREE_H_
|
||||
#define _SGFTREE_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sgf_properties.h"
|
||||
|
||||
|
||||
#ifndef _BOARD_H_
|
||||
/*
|
||||
* NOTE: These MUST coincide with the definitions for the engine that we
|
||||
* are using. In this case they are defined in engine/gnugo.h.
|
||||
*
|
||||
* The reason that we put them here within the #ifndef clause is because
|
||||
* we want to decouple the GNU Go engine from SGF library, but we don't
|
||||
* want to redefine these symbols if we include this file into board.h.
|
||||
*/
|
||||
|
||||
#define EMPTY 0
|
||||
#define WHITE 1
|
||||
#define BLACK 2
|
||||
#endif
|
||||
|
||||
|
||||
void *xalloc(unsigned int);
|
||||
|
||||
/*
|
||||
* A property of an SGF node. An SGF node is described by a linked
|
||||
* list of these.
|
||||
*/
|
||||
|
||||
typedef struct SGFProperty_t {
|
||||
struct SGFProperty_t *next;
|
||||
short name;
|
||||
char *value;
|
||||
} SGFProperty;
|
||||
|
||||
|
||||
typedef struct SGFNode_t {
|
||||
SGFProperty *props;
|
||||
struct SGFNode_t *parent;
|
||||
struct SGFNode_t *child;
|
||||
struct SGFNode_t *next;
|
||||
} SGFNode;
|
||||
|
||||
|
||||
/* low level functions */
|
||||
SGFNode *sgfPrev(SGFNode *node);
|
||||
SGFNode *sgfRoot(SGFNode *node);
|
||||
SGFNode *sgfNewNode(void);
|
||||
void sgfFreeNode(SGFNode *node);
|
||||
|
||||
int sgfGetIntProperty(SGFNode *node, const char *name, int *value);
|
||||
int sgfGetFloatProperty(SGFNode *node, const char *name, float *value);
|
||||
int sgfGetCharProperty(SGFNode *node, const char *name, char **value);
|
||||
void sgfAddProperty(SGFNode *node, const char *name, const char *value);
|
||||
void sgfAddPropertyInt(SGFNode *node, const char *name, long val);
|
||||
void sgfAddPropertyFloat(SGFNode *node, const char *name, float val);
|
||||
void sgfOverwriteProperty(SGFNode *node, const char *name, const char *text);
|
||||
void sgfOverwritePropertyFloat(SGFNode *node, const char *name, float val);
|
||||
void sgfOverwritePropertyInt(SGFNode *node, const char *name, int val);
|
||||
void *xrealloc(void *pt, unsigned int size);
|
||||
SGFProperty *sgfMkProperty(const char *name, const char *value,
|
||||
SGFNode *node, SGFProperty *last);
|
||||
void sgfFreeProperty(SGFProperty *prop);
|
||||
|
||||
SGFNode *sgfAddStone(SGFNode *node, int color, int movex, int movey);
|
||||
SGFNode *sgfAddPlay(SGFNode *node, int who, int movex, int movey);
|
||||
SGFNode *sgfAddPlayLast(SGFNode *node, int who, int movex, int movey);
|
||||
|
||||
void sgfWriteResult(SGFNode *node, float score, int overwrite);
|
||||
void sgf_write_header(SGFNode *root, int overwrite, int seed, float komi,
|
||||
int handicap, int level, int rules);
|
||||
|
||||
SGFNode *sgfLabel(SGFNode *node, const char *label, int i, int j);
|
||||
SGFNode *sgfLabelInt(SGFNode *node, int num, int i, int j);
|
||||
SGFNode *sgfCircle(SGFNode *node, int i, int j);
|
||||
SGFNode *sgfSquare(SGFNode *node, int i, int j);
|
||||
SGFNode *sgfTriangle(SGFNode *node, int i, int j);
|
||||
SGFNode *sgfMark(SGFNode *node, int i, int j);
|
||||
SGFNode *sgfAddComment(SGFNode *node, const char *comment);
|
||||
SGFNode *sgfBoardText(SGFNode *node, int i, int j, const char *text);
|
||||
SGFNode *sgfBoardChar(SGFNode *node, int i, int j, char c);
|
||||
SGFNode *sgfBoardNumber(SGFNode *node, int i, int j, int number);
|
||||
SGFNode *sgfStartVariant(SGFNode *node);
|
||||
SGFNode *sgfStartVariantFirst(SGFNode *node);
|
||||
SGFNode *sgfAddChild(SGFNode *node);
|
||||
|
||||
SGFNode *sgfCreateHeaderNode(int boardsize, float komi, int handicap);
|
||||
|
||||
/* Read SGF tree from file. */
|
||||
SGFNode *readsgffile(const char *filename);
|
||||
/* Specific solution for fuseki */
|
||||
SGFNode *readsgffilefuseki(const char *filename, int moves_per_game);
|
||||
|
||||
/* Write SGF tree to a file. */
|
||||
int writesgf(SGFNode *root, const char *filename);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* --- SGFTree --- */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
|
||||
typedef struct SGFTree_t {
|
||||
SGFNode *root;
|
||||
SGFNode *lastnode;
|
||||
} SGFTree;
|
||||
|
||||
|
||||
void sgftree_clear(SGFTree *tree);
|
||||
int sgftree_readfile(SGFTree *tree, const char *infilename);
|
||||
|
||||
int sgftreeBack(SGFTree *tree);
|
||||
int sgftreeForward(SGFTree *tree);
|
||||
|
||||
void sgftreeAddPlay(SGFTree *tree, int color, int movex, int movey);
|
||||
void sgftreeAddPlayLast(SGFTree *tree, int color, int movex, int movey);
|
||||
void sgftreeAddStone(SGFTree *tree, int color, int movex, int movey);
|
||||
void sgftreeWriteResult(SGFTree *tree, float score, int overwrite);
|
||||
SGFNode *sgftreeNodeCheck(SGFTree *tree);
|
||||
|
||||
void sgftreeCircle(SGFTree *tree, int i, int j);
|
||||
void sgftreeSquare(SGFTree *tree, int i, int j);
|
||||
void sgftreeTriangle(SGFTree *tree, int i, int j);
|
||||
void sgftreeMark(SGFTree *tree, int i, int j);
|
||||
void sgftreeAddComment(SGFTree *tree, const char *comment);
|
||||
void sgftreeBoardText(SGFTree *tree, int i, int j, const char *text);
|
||||
void sgftreeBoardChar(SGFTree *tree, int i, int j, char c);
|
||||
void sgftreeBoardNumber(SGFTree *tree, int i, int j, int number);
|
||||
void sgftreeStartVariant(SGFTree *tree);
|
||||
void sgftreeStartVariantFirst(SGFTree *tree);
|
||||
void sgftreeCreateHeaderNode(SGFTree *tree, int boardsize, float komi,
|
||||
int handicap);
|
||||
void sgftreeSetLastNode(SGFTree *tree, SGFNode *lastnode);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* --- Utilities --- */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
|
||||
int get_moveX(SGFProperty *property, int boardsize);
|
||||
int get_moveY(SGFProperty *property, int boardsize);
|
||||
int get_moveXY(SGFProperty *property, int *i, int *j, int boardsize);
|
||||
|
||||
int show_sgf_properties(SGFNode *node);
|
||||
int show_sgf_tree(SGFNode *node);
|
||||
int is_markup_node(SGFNode *node);
|
||||
int is_move_node(SGFNode *node);
|
||||
int is_pass_node(SGFNode *node, int boardsize);
|
||||
int find_move(SGFNode *node);
|
||||
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user