summaryrefslogtreecommitdiff
path: root/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkiv')
-rw-r--r--obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkiv63
1 files changed, 63 insertions, 0 deletions
diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkiv b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkiv
new file mode 100644
index 0000000000..6b0513fb38
--- /dev/null
+++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkiv
@@ -0,0 +1,63 @@
+%D \module
+%D [ file=deadstone,
+%D version=2007.07.31,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Dead stone calculator for go,
+%D author=Wolfgang Schuster,
+%D email=schuster.wolfgang@googlemail.com,
+%D date=\currentdate,
+%D copyright=Public Domain]
+
+\unprotect
+
+%D This is the \MKIV\ part of the dead stone calculator, it was
+%D written to get rid of tex \TEX\ workarounds used in the \MKII\
+%D version. If you want to understand how the algoritm works you
+%D should use the \LUA\ implementation.
+%D
+%D The functions to calculate the current state of the stones are
+%D saved in a seperate \LUA\ file, loading this file is the first
+%D thing we do here.
+
+\ctxloadluafile{deadstone}{}
+
+%D The \tex{clearboard} command is only a call to the \LUA\
+%D implementation and no longer a \TEX\ loop as in the first version.
+
+\def\clearboard{\ctxlua{clearboard()}}
+
+\def\processtones{\ctxlua{processtones()}}
+
+%D \macros{addstone}
+%D
+%D The \tex{addstone} macro is shorter as in the \MKII\ version because
+%D I can now use \tex{doifelse} and can avoid the low level \tex{ifx}
+%D test as needed before. I can now also pass laststone as argument for
+%D \tex{ctxlua} and prevent a extra \tex{ifx} as before.
+
+\def\addstone(#1:#2:#3)%
+ {\global\advance\stonecount\plusone
+ \doifelse{#3}{B}
+ {\ctxlua{field[#1][#2] = { 1, tex.count.stonecount }; laststone = 1}}
+ {\doif{#3}{W}
+ {\ctxlua{field[#1][#2] = { 2, tex.count.stonecount }; laststone = 2}}}}
+
+\def\currentstone
+ {\ctxlua{tex.print(field[\boardrow][\boardcolumn][1])}}
+
+\def\currentstonenumber
+ {\ctxlua{tex.print(field[\boardrow][\boardcolumn][2])}}
+
+%D \macros{cleardeadstonelist}
+%D
+%D This is the only pure \TEX\ command I use in this module, all other
+%D commands are only wrappers for the \LUA\ part but I need this because
+%D the two commands \tex{deadblackstones} and \tex{deadwhitestones} can
+%D be used by other macros and this seems to be the best solution I found
+%D for the moment.
+
+\def\cleardeadstonelist
+ {\let\deadblackstones\empty
+ \let\deadwhitestones\empty}
+
+\protect