From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- .../context-sgf/doc/context/third/sgf/README | 7 + .../doc/context/third/sgf/deadstone-lua.pdf | Bin 0 -> 19927 bytes .../doc/context/third/sgf/deadstone-mkii.pdf | Bin 0 -> 81860 bytes .../doc/context/third/sgf/deadstone-mkiv.pdf | Bin 0 -> 69473 bytes .../doc/context/third/sgf/t-deadstone.pdf | Bin 0 -> 73226 bytes .../context-sgf/doc/context/third/sgf/t-sgf.pdf | Bin 0 -> 109898 bytes .../tex/context/third/sgf/deadstone.lua | 224 ++++++++++ .../tex/context/third/sgf/deadstone.mkii | 343 +++++++++++++++ .../tex/context/third/sgf/deadstone.mkiv | 63 +++ .../tex/context/third/sgf/go-view-test-1.tex | 27 ++ .../tex/context/third/sgf/go-view-test-2.tex | 27 ++ .../tex/context/third/sgf/go-view-test-3.tex | 21 + .../tex/context/third/sgf/go-view-test-4.tex | 34 ++ .../tex/context/third/sgf/go-view-test-5.tex | 21 + .../tex/context/third/sgf/t-deadstone.tex | 90 ++++ .../context-sgf/tex/context/third/sgf/t-go.tex | 16 + .../tex/context/third/sgf/t-sgf-generic.tex | 108 +++++ .../tex/context/third/sgf/t-sgf-library.tex | 163 ++++++++ .../context-sgf/tex/context/third/sgf/t-sgf.tex | 458 +++++++++++++++++++++ .../context-sgf/tex/context/third/sgf/t-weiqi.tex | 16 + 20 files changed, 1618 insertions(+) create mode 100644 obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/README create mode 100644 obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-lua.pdf create mode 100644 obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-mkii.pdf create mode 100644 obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-mkiv.pdf create mode 100644 obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/t-deadstone.pdf create mode 100644 obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/t-sgf.pdf create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.lua create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkii create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkiv create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-1.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-2.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-3.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-4.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-5.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-deadstone.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-go.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-generic.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-library.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf.tex create mode 100644 obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-weiqi.tex (limited to 'obsolete/macros/context/contrib/context-sgf') diff --git a/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/README b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/README new file mode 100644 index 0000000000..331ec51a16 --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/README @@ -0,0 +1,7 @@ +Name of module: Go Module for ConTeXt +Author: Wolfgang Schuster and Zhichu Chen + +Description: You can set go boards in your document. + +The module documentation is available in doc/context/third/go/t-go.pdf + diff --git a/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-lua.pdf b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-lua.pdf new file mode 100644 index 0000000000..44f33fafbe Binary files /dev/null and b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-lua.pdf differ diff --git a/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-mkii.pdf b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-mkii.pdf new file mode 100644 index 0000000000..db5ac6475f Binary files /dev/null and b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-mkii.pdf differ diff --git a/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-mkiv.pdf b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-mkiv.pdf new file mode 100644 index 0000000000..2602eaadb7 Binary files /dev/null and b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/deadstone-mkiv.pdf differ diff --git a/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/t-deadstone.pdf b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/t-deadstone.pdf new file mode 100644 index 0000000000..aecb9b7753 Binary files /dev/null and b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/t-deadstone.pdf differ diff --git a/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/t-sgf.pdf b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/t-sgf.pdf new file mode 100644 index 0000000000..d526398f5c Binary files /dev/null and b/obsolete/macros/context/contrib/context-sgf/doc/context/third/sgf/t-sgf.pdf differ diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.lua b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.lua new file mode 100644 index 0000000000..656de4e17c --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.lua @@ -0,0 +1,224 @@ +if not modules then modules = { } end modules ['deadstone'] = { + version = 0.100, + comment = "Dead stone calculator for go", + author = "Wolfgang Schuster", + copyright = "Public Domain", +} + +--[[ldx-- +

This is the version of my deadstone calculator. +It is a nearly one to one copy of my original idea of my method, +I developed to find the dead stones on the goban.

+--ldx]]-- + +laststone = 1 + +--[[ldx-- +

The clearboard is called at the +begin of a new board to initialize all fields with the value 0 +and the margins with the value 3. I need this values for the later +calculations of the field states.

+--ldx]]-- + +function clearboard() + field = {} + for y=0,tex.count.boardsize+1 do + field[y] = {} + for x=0,tex.count.boardsize+1 do + if x==0 then + field[y][x] = { 3, 0 } + elseif x==tex.count.boardsize+1 then + field[y][x] = { 3, 0 } + elseif y==0 then + field[y][x] = { 3, 0 } + elseif y==tex.count.boardsize+1 then + field[y][x] = { 3, 0 } + else + field[y][x] = { 0, 0 } + end + end + end +end + +--[[ldx-- +

To decide wheter I handle in the calculation a white or a black +stone the state for stone and enemy depends of the current color.

+

The value for marked depends also on the current stone color to +reset already living stones in the last step back to the normal color. +This could have been done also by checking the current stone color +but two different values work without this test.

+

The values for wall, error (should never happen) and dead is the +same for both, black and white stones. There is no need to make a +difference between them.

+--ldx]]-- + +function blackstone() + stone=1 + enemy=2 + wall=3 + marked=4 + error=6 + dead=7 +end + +function whitestone() + stone=2 + enemy=1 + wall=3 + marked=5 + error=6 + dead=7 +end + +--[[ldx-- +

The doprocesstones is used to call all +subfunctions. It is called twice, once for the black stones and a second +time for the white stones.

+--ldx]]-- + +function doprocesstones() + markstones() + deadstones() + -- for n=1,tex.count.deadcount + -- checkstones() + -- end + checkstones() + checkstones() + revertstones() +end + +--[[ldx-- +

The order in which the last doporocesstones +ist called depends on the current placed stones.

+

This mean if the last stone was a black one, we look at the begin for +dead white stone and reverse if the last stone was a white one.

+

We could check the current stone color with the variable +laststone and test for the numeric value.

+--ldx]]-- + +function processtones() + -- we placed a black stone + if laststone==1 then + processwhitetones() + processblackstones() + -- we placed a white stone + elseif laststone==2 then + processblackstones() + processwhitetones() + end +end + +function processblackstones() + blackstone() + doprocesstones() +end + +function processwhitetones() + whitestone() + doprocesstones() +end + +--[[ldx-- +

The markstones mark the stones if they +have the right stones on their sides or let them keep untouched.

+--ldx]]-- + +function markstones() + for y=1,tex.count.boardsize do + for x=1,tex.count.boardsize do + if field[y][x][1]==stone then + if (field[y][x-1][1]==wall or field[y][x-1][1]==enemy or field[y][x-1][1]==marked) + and (field[y][x+1][1]==wall or field[y][x+1][1]==enemy or field[y][x+1][1]==stone) + and (field[y-1][x][1]==wall or field[y-1][x][1]==enemy or field[y-1][x][1]==marked) + and (field[y+1][x][1]==wall or field[y+1][x][1]==enemy or field[y+1][x][1]==stone) + then + field[y][x] = { marked, field[y][x][2] } + end + end + end + end +end + +--[[ldx-- +

The deadstones set stones with the value marked +to dead if the conditions in the function are true.

+--ldx]]-- + +function deadstones() + for y=tex.count.boardsize,1,-1 do + for x=tex.count.boardsize,1,-1 do + if field[y][x][1]==marked then + if (field[y][x-1][1]==wall or field[y][x-1][1]==enemy or field[y][x-1][1]==marked) + and (field[y][x+1][1]==enemy or field[y][x+1][1]==wall or field[y][x+1][1]==dead) + and (field[y+1][x][1]==enemy or field[y+1][x][1]==wall or field[y+1][x][1]==dead) + then + field[y][x] = { dead, field[y][x][2] } + end + end + end + end +end + +--[[ldx-- +

Because the deadstones can sometimes set +already living stones to dead. To prevent this in the final result this +function looks through all stones with a loop in reverse direction and +reset the values to their original value if the stone is not dead and +should remain on the board. The function is currently called twice within +processtones but this can be changed with the counter deadcount.

+--ldx]]-- + +function checkstones() + for y=1,tex.count.boardsize do + for x=1,tex.count.boardsize do + if field[y][x][1]==marked then + field[y][x] = { stone, field[y][x][2] } + elseif field[y][x][1]==dead then + if (field[y][x-1][1]==dead or field[y][x-1][1]==enemy or field[y][x-1][1]==wall) + and (field[y][x+1][1]==dead or field[y][x+1][1]==enemy or field[y][x+1][1]==wall) + and (field[y-1][x][1]==dead or field[y-1][x][1]==enemy or field[y-1][x][1]==wall) + and (field[y+1][x][1]==dead or field[y+1][x][1]==enemy or field[y+1][x][1]==wall) + then + field[y][x] = { dead, field[y][x][2] } + else + field[y][x] = { stone, field[y][x][2] } + end + end + end + end +end + +--[[ldx-- +

The last thing to do after all dead stones are found on the board +is to remove them and to reset all other stones which are still in a +marked state or we will get wrong input for the next move.

+--ldx]]-- + +function revertstones() + for y=1,tex.count.boardsize do + for x=1,tex.count.boardsize do + if field[y][x][1]==marked then + field[y][x] = { stone, field[y][x][2] } + elseif field[y][x][1]==dead then + appendtodeadstonelist(y,x,stone,field[y][x][2]) -- append to deadstonelist + field[y][x] = { 0, 0 } -- before reseting the field + end + end + end +end + +--[[ldx-- +

To use the dead stones we found in this run on the board for later +use they are saved in two commalist, one for white stones and another +one for the black ones. They can be used by other macros, the only thing +here is done is to append the removed stones in the current run to the +already romved stones in one of the former calculations.

+--ldx]]-- + +function appendtodeadstonelist(row,column,color,count) + if color==1 then + tex.print("\\expanded{\\appendtocommalist{{" .. row .. ":" .. column .. ":1:" .. count .. "}}}\\deadblackstones") + elseif color==2 then + tex.print("\\expanded{\\appendtocommalist{{" .. row .. ":" .. column .. ":2:" .. count .. "}}}\\deadwhitestones") + end +end diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkii b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkii new file mode 100644 index 0000000000..7698017a0b --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/deadstone.mkii @@ -0,0 +1,343 @@ +%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] + +\writestatus{loading}{Context User Module / Dead stone calculator for go} + +\unprotect + +%D This is the \TEX\ version of the dead stone calculator for the +%D go module. They are a copy of the original idea of the algorithm +%D to find dead stones with a few modifications the author needed +%D to make them work. + +%D \macros{clearboard} +%D +%D The \tex{clearboard} set all fields with a intial value of~0 for +%D the empty fields and a value of~3 for the margins. The command +%D can also be used to clear a board and remove all set values. + +\def\clearboard + {\dorecurse{\numexpr\boardsize+\plustwo\relax} + {\edef\boardrow{\the\numexpr\recurselevel-\plusone\relax}% + \dorecurse{\numexpr\boardsize+\plustwo\relax} + {\edef\boardcolumn{\the\numexpr\recurselevel-\plusone\relax}% + \presetcurrentstone + {\ifnum\boardrow=\zerocount + \plusthree + \else\ifnum\boardrow=\numexpr\boardsize+\plusone\relax + \plusthree + \else\ifnum\boardcolumn=\zerocount + \plusthree + \else\ifnum\boardcolumn=\numexpr\boardsize+\plusone\relax + \plusthree + \else + \zerocount + \fi\fi\fi\fi}}}} + +\let\laststone\plusone + +%D \macros{addstone} +%D +%D The \tex{addstone} is the used to place a stone on the board. +%D The three arguments keeps the current row, the column and the +%D stone color. The values for the row and the column have to be +%D a number, the stone color has do be given with the two values +%D \type{B} for black and \type{W} for white. + +\def\addstone(#1:#2:#3)% + {\global\advance\stonecount\plusone + \ifx#3B + \global\let\laststone\plusone + \else\ifx#3W + \global\let\laststone\plustwo + \fi\fi + \setevalue{field:\number#1:\number#2}% + {\ifx#3B + \plusone + \else\ifx#3W + \plustwo + \fi\fi:\number\stonecount}} + +\def\blackstone + {\let\stone \plusone + \let\enemy \plustwo + \let\wall \plusthree + \let\marked\plusfour + \let\dead \plusseven} + +\def\whitestone + {\let\stone \plustwo + \let\enemy \plusone + \let\wall \plusthree + \let\marked\plusfive + \let\dead \plusseven} + +\def\firstofcurrentstone #1:#2\relax{\number#1} +\def\secondofcurrentstone#1:#2\relax{\number#2} + +\def\currentstone + {\@EA\@EA\@EA\@EA\@EA\@EA\@EA\firstofcurrentstone\getvalue{field:\boardrow:\boardcolumn}\relax} + +\def\currentstonenumber + {\@EA\@EA\@EA\@EA\@EA\@EA\@EA\secondofcurrentstone\getvalue{field:\boardrow:\boardcolumn}\relax} + +\def\leftstone + {\@EA\@EA\@EA\@EA\@EA\@EA\@EA\firstofcurrentstone\getvalue{field:\boardrow:\the\numexpr\boardcolumn-\plusone\relax}\relax} + +\def\rightstone + {\@EA\@EA\@EA\@EA\@EA\@EA\@EA\firstofcurrentstone\getvalue{field:\boardrow:\the\numexpr\boardcolumn+\plusone\relax}\relax} + +\def\topstone + {\@EA\@EA\@EA\@EA\@EA\@EA\@EA\firstofcurrentstone\getvalue{field:\the\numexpr\boardrow-\plusone\relax:\boardcolumn}\relax} + +\def\bottomstone + {\@EA\@EA\@EA\@EA\@EA\@EA\@EA\firstofcurrentstone\getvalue{field:\the\numexpr\boardrow+\plusone\relax:\boardcolumn}\relax} + +\newif\iftracingstones + +\def\doprocessstones + {\markstones + \iftracingstones\placeterminalboard\fi + \deadstones + \dorecurse\deadcount\checkstones + \revertstones} + +\def\processtones + {\ifcase\laststone + \or\processwhitetones\processblackstones + \or\processblackstones\processwhitetones + \fi} + +\def\processblackstones + {\blackstone + \doprocessstones} + +\def\processwhitetones + {\whitestone + \doprocessstones} + +\def\setstonemark + {\setcurrentstone{\ifcase\stone\or\plusfour\or\plusfive\else\plussix\fi}} + +%D \macros{markstones} +%D +%D The first internal command is \tex{markstones}, it set the stone value +%D to marked if all consitions are true, otherwise the state will remain +%D with the old value and we check the next one. + +\def\markbottomstone + {\ifcase\bottomstone + \or\setstonemark + \or\setstonemark + \or\setstonemark + \fi} + +\def\markrightstone + {\ifcase\rightstone + \or\markbottomstone + \or\markbottomstone + \or\markbottomstone + \fi} + +\def\marktopstone + {\ifcase\topstone + \or\ifnum\stone=\plusone\else\markrightstone\fi + \or\ifnum\stone=\plustwo\else\markrightstone\fi + \or\markrightstone + \or\ifnum\stone=\plusone\relax\markrightstone\fi + \or\ifnum\stone=\plustwo\relax\markrightstone\fi + \fi} + +\def\markstones + {\dorecurse\boardsize + {\edef\boardrow{\recurselevel}% + \dorecurse\boardsize + {\edef\boardcolumn{\recurselevel}% + \ifnum\currentstone=\stone + \ifcase\leftstone + \or\ifnum\stone=\plusone\else\marktopstone\fi + \or\ifnum\stone=\plustwo\else\marktopstone\fi + \or\marktopstone + \or\ifnum\stone=\plusone\relax\marktopstone\fi + \or\ifnum\stone=\plustwo\relax\marktopstone\fi + \fi + \fi}}} + +%D \macros{deadstones} +%D +%D The \tex{deadstones} macro check the marked stones from the last +%D step for a dead state. We will now state from the right bottom and +%D go to the left top corner. + +\def\deadleftstone + {\ifcase\leftstone + \or\ifnum\stone=\plusone\else\setdeadstone\fi + \or\ifnum\stone=\plustwo\else\setdeadstone\fi + \or\setdeadstone + \or\setdeadstone + \or\setdeadstone + \fi} + +\def\deadbottomstone + {\ifcase\bottomstone + \or\ifnum\stone=\plusone\else\deadleftstone\fi + \or\ifnum\stone=\plustwo\else\deadleftstone\fi + \or\deadleftstone + \or\resetdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\deadleftstone + \fi} + +\def\deadstones + {\dostepwiserecurse\boardsize\plusone\minusone + {\edef\boardrow{\recurselevel}% + \dostepwiserecurse\boardsize\plusone\minusone + {\edef\boardcolumn{\recurselevel}% + \ifnum\currentstone=\marked + \ifcase\rightstone + \or\ifnum\stone=\plusone\else\deadbottomstone\fi + \or\ifnum\stone=\plustwo\else\deadbottomstone\fi + \or\deadbottomstone + \or + \or + \or + \or\deadbottomstone + \fi + \fi}}} + +%D \macros{revertstones} +%D +%D The \tex{revertstones} is called after all dead stones are and we will +%D make the board ready for the next move. There are still fields with the +%D value marked on the board and we have to make sure they get their normal +%D state with the values for stone and enemy. + +\def\revertstones + {\dorecurse\boardsize + {\edef\boardrow{\recurselevel}% + \dorecurse\boardsize + {\edef\boardcolumn{\recurselevel}% + \ifcase\currentstone + \or + \or + \or + \or\resetstone + \or\resetstone + \or + \or\removedeadstone + \fi}}} + +\def\presetcurrentstone#1% + {\setxvalue{field:\boardrow:\boardcolumn}{\number#1:0}} + +\def\setcurrentstone#1% + {\setxvalue{field:\boardrow:\boardcolumn}{\number#1:\number\currentstonenumber}} + +\def\setdeadstone + {\setcurrentstone{\plusseven}} + +\def\resetdeadstone + {\setcurrentstone{\ifcase\stone\or\plusone\or\plustwo\else\plussix\fi}} + +\let\resetstone\resetdeadstone + +\def\keepdeadstone + {\setcurrentstone{\ifcase\stone\or\plusseven\or\plusseven\else\plussix\fi}} + +\def\removedeadstone + {\appendtodeadstonelist + \setcurrentstone{\zerocount}} + +%D \macros{deadblackstones,deadwhitestones} +%D +%D The dead stones we found in one run are saved in two commalists, their names +%D are \tex{deadblacktones} and \tex{deadwhitestones}. They can be used by users +%D to their positions and numbers in their own macros. + +\def\appendtodeadstonelist + {\ifcase\stone + \or\expanded{\appendtocommalist{{\boardrow:\boardcolumn:\number\stone:\currentstonenumber}}}\deadblackstones + \or\expanded{\appendtocommalist{{\boardrow:\boardcolumn:\number\stone:\currentstonenumber}}}\deadwhitestones + \fi} + +\def\cleardeadstonelist + {\let\deadblackstones\empty + \let\deadwhitestones\empty} + +%D \macros{checkstones} +%D +%D As one of the first examples has shown sometimes still living stones +%D get the value dead in the last step and we have to check for such +%D a case. Tests has shown this need to be done at least two times and +%D make sure this can be increased without problems users can change this +%D with the counter \tex{deadcount} but you should also know increasing +%D this counter will result in longer processing time. + +\def\checkdeadstones + {\ifcase\leftstone + \or\ifnum\stone=\plusone\relax\resetdeadstone\else\checktopdeadstone\fi + \or\ifnum\stone=\plustwo\relax\resetdeadstone\else\checktopdeadstone\fi + \or\checktopdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\checktopdeadstone + \fi} + +\def\checktopdeadstone + {\ifcase\topstone + \or\ifnum\stone=\plusone\relax\resetdeadstone\else\checkrightdeadstone\fi + \or\ifnum\stone=\plustwo\relax\resetdeadstone\else\checkrightdeadstone\fi + \or\checkrightdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\checkrightdeadstone + \fi} + +\def\checkrightdeadstone + {\ifcase\rightstone + \or\ifnum\stone=\plusone\relax\resetdeadstone\else\checkbottomdeadstone\fi + \or\ifnum\stone=\plustwo\relax\resetdeadstone\else\checkbottomdeadstone\fi + \or\checkbottomdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\checkbottomdeadstone + \fi} + +\def\checkbottomdeadstone + {\ifcase\bottomstone + \or\ifnum\stone=\plusone\relax\resetdeadstone\else\keepdeadstone\fi + \or\ifnum\stone=\plustwo\relax\resetdeadstone\else\keepdeadstone\fi + \or\keepdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\resetdeadstone + \or\keepdeadstone + \fi} + +\def\checkstones + {\dorecurse\boardsize + {\edef\boardrow{\recurselevel}% + \dorecurse\boardsize + {\edef\boardcolumn{\recurselevel}% + \ifcase\currentstone + \or + \or + \or + \or\ifnum\stone=\plusone\relax\resetdeadstone\fi + \or\ifnum\stone=\plustwo\relax\resetdeadstone\fi + \or + \or\checkdeadstones + \fi}}} + +\protect \endinput 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 diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-1.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-1.tex new file mode 100644 index 0000000000..cbecb8ea35 --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-1.tex @@ -0,0 +1,27 @@ +\usemodule[go] + +\starttext + +\setupboard + [calculate=yes, + alternative=a] + +\startSGF +;B[jj];W[ji];B[jh];W[ij];B[ii];W[jk];B[ki];W[kj];B[lj];W[ji];B[kk];W[lk] +\stopSGF + +\setupboard + [alternative=b] + +\startSGF +;B[jj];W[ji];B[jh];W[ij];B[ii];W[jk];B[ki];W[kj];B[lj];W[ji];B[kk];W[lk] +\stopSGF + +\setupboard + [alternative=c] + +\startSGF +;B[jj];W[ji];B[jh];W[ij];B[ii];W[jk];B[ki];W[kj];B[lj];W[ji];B[kk];W[lk] +\stopSGF + +\stoptext diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-2.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-2.tex new file mode 100644 index 0000000000..e01d7b3c2a --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-2.tex @@ -0,0 +1,27 @@ +\usemodule[go] + +\starttext + +\setupboard + [calculate=yes] + +\startSGF +;B[qd];W[cp];B[pp];W[dc];B[ep];W[od];B[cq];W[de];B[oc];W[nc] +;B[pc];W[nd];B[qf];W[bq];B[dq];W[bo];B[iq];W[jd];B[dm];W[cn] +;B[dn];W[nq];B[np];W[op];B[oo];W[oq];B[pq];W[po];B[qo];W[pn] +;B[mp];W[qn];B[mq];W[ro];B[rq];W[qh];B[nn];W[nl];B[lb];W[mb] +;B[lc];W[ic];B[le];W[pe];B[qe];W[og];B[kf];W[if];B[kh];W[lg] +;B[jf];W[ig];B[jh];W[hi];B[mi];W[oi];B[mk];W[nj];B[mj];W[ch] +;B[ei];W[hk];B[eg];W[fh];B[eh];W[cf];B[ci];W[cj];B[bi];W[dj] +;B[ej];W[di];B[cg];W[bg];B[bh];W[dg];B[dh];W[cg];B[bk];W[bj] +;B[dk];W[ah];B[nk];W[ok];B[ol];W[pl];B[hm];W[il];B[im];W[kl] +;B[ml];W[fk];B[gj];W[fj];B[fi];W[gi];B[fl];W[jm];B[jk];W[jl] +;B[ek];W[gk];B[br];W[ar];B[bs];W[do];B[bm];W[eo];B[bn];W[fo] +;B[gp];W[hp];B[gq];W[go];B[fm];W[io];B[jn];W[hq];B[gr];W[hr] +;B[jq];W[kq];B[kr];W[kp];B[jr];W[lr];B[lq];W[mr];B[kn];W[jp] +;B[ls];W[nr];B[ns];W[os];B[ks];W[fp];B[fq];W[er];B[eq];W[dr] +;B[cr];W[ds];B[fs];W[hs];B[gs];W[ho];B[es];W[in];B[ck];W[lm] +;B[ln];W[mm];B[nm];W[mn];B[lo] +\stopSGF + +\stoptext diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-3.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-3.tex new file mode 100644 index 0000000000..9b53493f20 --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-3.tex @@ -0,0 +1,21 @@ +\usemodule[go] + +\starttext + +\setupboard + [calculate=yes, + alternative=b] + +\startSGF +;B[jj];W[ji];B[jh];W[ij];B[ii];W[jk];B[ki];W[kj];B[lj];W[ji];B[kk];W[lk];B[jj] +\stopSGF + +\setupboard + [conversion=stone 1, + size=small] + +\startSGF +;B[de];B[ed];W[ee];B[ef];B[fe] +\stopSGF + +\stoptext diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-4.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-4.tex new file mode 100644 index 0000000000..644e7acac1 --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-4.tex @@ -0,0 +1,34 @@ +\usemodule[go] + +\starttext + +\setupboard + [calculate=yes] + +\startSGF +;B[ji];W[jl];B[ij];W[ik];B[kj];W[kk];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +\stopSGF + +\setupboard + [alternative=b] + +\startSGF +;B[ji];W[jl];B[ij];W[ik];B[kj];W[kk];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +;B[jk];W[jj];B[jk];W[jj];B[jk];W[jj];B[jk];W[jj] +\stopSGF + +\stoptext diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-5.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-5.tex new file mode 100644 index 0000000000..b7c55fd1de --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/go-view-test-5.tex @@ -0,0 +1,21 @@ +\usemodule[go] + +\starttext + +\startSGF[printable=yes] +;B[jj];W[ji];B[jh];W[ij];B[ii];W[jk];B[ki];W[kj];B[lj];W[ji];B[kk];W[lk];B[jj] +\stopSGF + +\startSGF[printable=no] +;B[jj];W[ji];B[jh];W[ij];B[ii];W[jk];B[ki];W[kj];B[lj];W[ji];B[kk];W[lk];B[jj] +\stopSGF + +\startSGF[printable=no,calculate=yes] +;B[jj];W[ji];B[jh];W[ij];B[ii];W[jk];B[ki];W[kj];B[lj];W[ji];B[kk];W[lk];B[jj] +\stopSGF + +\startSGF +;B[jj];W[ji];B[jh];W[ij];B[ii];W[jk];B[ki];W[kj];B[lj];W[ji];B[kk];W[lk];B[jj] +\stopSGF + +\stoptext diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-deadstone.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-deadstone.tex new file mode 100644 index 0000000000..dab8ad9f3d --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-deadstone.tex @@ -0,0 +1,90 @@ +%D \module +%D [ file=t-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] + + +\writestatus{loading}{Context User Module / Dead stone calculator for go} + +\unprotect + +\newcount\boardsize +\newcount\deadcount +\newcount\stonecount + +\chardef\plussix =6 +\chardef\plusseven=7 + +\boardsize=19 +\deadcount=2 + +%D \macros{placeboard,placeterminalboard} +%D +%D The following two commands can be used to draw a simple board with +%D the current state, \tex{placeboard} is only used for testing the module +%D and let me see the current values of every node. +%D +%D The second board is intended for tracing the output and calculations +%D of my macros on the terminal and will also appear in the log file +%D if the user has it enabled. It use a symbols instead of numeric values +%D for the output. +%D +%D Only meant for my test files and not for real output. I need another +%D name to prevent a clash with another modules. + +\def\intersctionfield{.} % was previously 0 +\def\blackfield {X} % was previously 1 +\def\whitefield {O} % was previously 2 +\def\fieldstyle {\tt} + +\def\placeboard + {\dorecurse{\the\boardsize} + {\edef\boardrow{\recurselevel}% + \hbox{\dorecurse{\the\boardsize} + {\edef\boardcolumn{\recurselevel}% + \hbox\!!to1em + {\hss\fieldstyle % switched from roman to mono + \ifcase\currentstone\relax + \intersctionfield\or + \blackfield \or + \whitefield \or + 3\ignorespaces \or + 4\ignorespaces \or + 5\ignorespaces \or + 6\ignorespaces \or + 7\ignorespaces \fi\hss}}}}} + +%D Todo: +%D +%D \startitemize[intro] +%D \item header above every board +%D \item empty line before and after every board +%D \item frame for the baord on all four sides +%D \stopitemize + +\def\placeterminalboard + {\newlinechar=`\^^J + \message{^^J}% start a new line before we place the board + \dorecurse{\the\boardsize} + {\edef\boardrow{\recurselevel}% + \edef\zahl{ }% put a space to the left of the line + \dorecurse{\the\boardsize} + {\edef\boardcolumn{\recurselevel}% + \edef\zahl + {\zahl + \ifcase\currentstone + \intersctionfield\space\or + \blackfield \space\or + \whitefield \space\fi}} + \message{\zahl^^J}}} % place the current line and move to the next + +%D Loading of the mkii and mkiv files. + +\loadmarkfile{deadstone} + +\protect \endinput diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-go.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-go.tex new file mode 100644 index 0000000000..f527aacfd5 --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-go.tex @@ -0,0 +1,16 @@ +%D \module +%D [ file=t-go, +%D version=2007.09.09, +%D title=\CONTEXT\ User Module, +%D subtitle=Go Module, +%D author={Zhichu Chen \& Wolfgang Schuster}, +%D date=\currentdate, +%D copyright=Public Domain] + +\writestatus{loading}{Context User Module / Go Module} + +\unprotect + +\usemodule[sgf] + +\protect \endinput diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-generic.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-generic.tex new file mode 100644 index 0000000000..c703e99061 --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-generic.tex @@ -0,0 +1,108 @@ +%D \module +%D [ file=t-go-generic, +%D version=2007.08.15, +%D title=\CONTEXT\ User Module, +%D subtitle=Go extensions, +%D author={Zhichu Chen \& Wolfgang Schuster}, +%D date=\currentdate, +%D copyright=Public Domain] + +\writestatus{loading}{Context User Module / Go extensions} + +\unprotect + +\startvariables all + game: game + stone: stone + black: black + white: white +\stopvariables + +\startconstants all + printable: printable +\stopconstants + +\def\????bd{@@@@bd} % BoarD + +\newif\ifhighlightlabel \highlightlabeltrue + +\def\dosetupboardsize[#1]% + {\assigndimension{#1}\boardsize{9}{13}{19}} + +\def\setupboardsize + {\dosingleargument\dosetupboardsize} + +\def\dosetupboard[#1][#2]% + {\ifsecondargument + \getparameters[\????bd#1][#2]% + \else + \getparameters[\????bd][#1]% + \setupboardsize[\@@@@bdsize]% + \fi} + +\def\setupboard + {\dodoubleempty\dosetupboard} + +\def\charactertonumber#1% + {\ifx#1a1\else + \ifx#1b2\else + \ifx#1c3\else + \ifx#1d4\else + \ifx#1e5\else + \ifx#1f6\else + \ifx#1g7\else + \ifx#1h8\else + \ifx#1i9\else + \ifx#1j10\else + \ifx#1k11\else + \ifx#1l12\else + \ifx#1m13\else + \ifx#1n14\else + \ifx#1o15\else + \ifx#1p16\else + \ifx#1q17\else + \ifx#1r18\else + \ifx#1s19\else + \ifx#1t20\else + \ifx#1u21\else + \ifx#1v22\else + \ifx#1w23\else + \ifx#1x24\else + \ifx#1y25\else + \ifx#1z26\fi\fi + \fi\fi\fi\fi\fi + \fi\fi\fi\fi\fi + \fi\fi\fi\fi\fi + \fi\fi\fi\fi\fi + \fi\fi\fi\fi} + +\def\sgfcharacter#1% + {\ifcase#1\unknowncharacter + \or A\or B\or C\or D\or E\or F\or G\or H\or J\or K\or L\or M\or N% + \or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\or + \else + \unknowncharacter + \fi} + +\setupboard + [\c!alternative=\v!a, + \c!calculate=\v!no, + \c!color=\v!black, + \c!conversion=stone 2, + \c!distance=\boardunit, + \c!n=3, + \c!printable=\v!no, + \c!size=\v!big, + \c!style=\v!sans] + +\setupboard + [\v!black] + [\c!style=\@@@@bdstyle, + \c!color=\v!white] + +\setupboard + [\v!white] + [\c!style=\@@@@bdstyle, + \c!color=\v!black] + +\protect \endinput diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-library.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-library.tex new file mode 100644 index 0000000000..972f24e718 --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf-library.tex @@ -0,0 +1,163 @@ +%D \module +%D [ file=t-go-library, +%D version=2007.08.15, +%D title=\CONTEXT\ User Module, +%D subtitle=Go extensions, +%D author={Zhichu Chen \& Wolfgang Schuster}, +%D date=\currentdate, +%D copyright=Public Domain] + +\writestatus{loading}{Context User Module / Go extensions} + +\unprotect + +\startMPinitializations + StoneUnit=\the\stoneunit ; + BoardSize=\the\boardsize ; + BoardUnit=\the\boardunit ; + BoardColumns=\@@@@bdn ; + + GridWidth=.7pt ; + + defaultfont := "cmss10" ; + defaultscale := .05*BoardUnit ; + + vardef Alph (expr n) = + if (n = 1) : "A" + elseif (n = 2) : "B" + elseif (n = 3) : "C" + elseif (n = 4) : "D" + elseif (n = 5) : "E" + elseif (n = 6) : "F" + elseif (n = 7) : "G" + elseif (n = 8) : "H" + elseif (n = 9) : "J" + elseif (n = 10) : "K" + elseif (n = 11) : "L" + elseif (n = 12) : "M" + elseif (n = 13) : "N" + elseif (n = 14) : "O" + elseif (n = 15) : "P" + elseif (n = 16) : "Q" + elseif (n = 17) : "R" + elseif (n = 18) : "S" + elseif (n = 19) : "T" + fi + enddef ; +\stopMPinitializations + +%D Stone set 1, simple black and white stones: + +\startreusableMPgraphic{blackstone pure} +drawfill fullcircle scaled StoneUnit withcolor black ; +\stopreusableMPgraphic + +\startreusableMPgraphic{whitestone pure} +fill fullcircle scaled StoneUnit withcolor white ; +draw fullcircle scaled StoneUnit withcolor black ; +\stopreusableMPgraphic + +%D Stone set 2, shaded black and white stones: + +\startreusableMPgraphic{blackstone shade} +circular_shade ( fullcircle scaled StoneUnit , 4 , \MPcolor{gray} , black ) ; +\stopreusableMPgraphic + +\startreusableMPgraphic{whitestone shade} +circular_shade ( fullcircle scaled StoneUnit , 2 , .8white , white ) ; +\stopreusableMPgraphic + +%D The board, one for all stone sets. + +\startuseMPgraphic{board} +numeric u , v ; +if "\@@@@bdalternative"="a" : + u = OverlayWidth/(BoardSize+2) ; + v = (OverlayHeight-BoardColumns*2*BoardUnit)/(BoardSize+2) ; +elseif "\@@@@bdalternative"="b": + u = (OverlayWidth-BoardColumns*4*BoardUnit)/(BoardSize+2) ; + v = OverlayHeight/(BoardSize+2) ; +elseif "\@@@@bdalternative"="c": + u = OverlayWidth/(BoardSize+2) ; + v = OverlayHeight/(BoardSize+2) ; +fi + +for i=3 upto BoardSize : + draw ((2u,-i*v)--((BoardSize+1)*u,-i*v)) + if "\@@@@bdalternative"="a" : + shifted (-.5u,.5v) + elseif "\@@@@bdalternative"="b" : + shifted (BoardColumns*2*BoardUnit-.5u,.5v) + elseif "\@@@@bdalternative"="c" : + shifted (-.5u,.5v) + fi withpen pencircle scaled GridWidth ; + draw ((i*u,-2v)--(i*u,(BoardSize+1)*-v)) + if "\@@@@bdalternative"="a" : + shifted (-.5u,.5v) + elseif "\@@@@bdalternative"="b" : + shifted (BoardColumns*2*BoardUnit-.5u,.5v) + elseif "\@@@@bdalternative"="c" : + shifted (-.5u,.5v) + fi withpen pencircle scaled GridWidth ; +endfor + +draw if "\@@@@bdalternative"="b" : ( fi + (1.5u,-1.5v)--(1.5u,(-.5-BoardSize)*v)-- + ((BoardSize+.5)*u,(-.5-BoardSize)*v)-- + ((BoardSize+.5)*u,-1.5v)--cycle + if "\@@@@bdalternative"="b" : ) shifted (BoardColumns*2*BoardUnit,0) fi + withpen pencircle scaled (2*GridWidth) ; + +if BoardSize=19 : + for i=4,10,16 : + for j=4,10,16 : + drawdot ((i+.5)*u , -(j+.5)*v) + if "\@@@@bdalternative"="b" : shifted (BoardColumns*2*BoardUnit,0) fi + withpen pencircle scaled (6*GridWidth) ; + endfor + endfor +elseif BoardSize=13 : + for i=4,7,10 : + for j=4,7,10 : + drawdot ((i+.5)*u , -(j+.5)*v) + if "\@@@@bdalternative"="b" : shifted (BoardColumns*2*BoardUnit,0) fi + withpen pencircle scaled (6*GridWidth) ; + endfor + endfor +elseif BoardSize=9 : + for i=3,7 : + for j=3,7 : + drawdot ((i+.5)*u , -(j+.5)*v) + if "\@@@@bdalternative"="b" : shifted (BoardColumns*2*BoardUnit,0) fi + withpen pencircle scaled (6*GridWidth) ; + endfor + endfor + drawdot ((5.5)*u , -(5.5)*v) + if "\@@@@bdalternative"="b" : shifted (BoardColumns*2*BoardUnit,0) fi + withpen pencircle scaled (6*GridWidth) ; +fi + +%D Draw labels on the edge of the board +for i=1 upto BoardSize : + label ( Alph(i) , ( if "\@@@@bdalternative"="b" : (i+2.5)*u else : (i+.5)*u fi , -.5*v ) ) + if "\@@@@bdalternative"="b" : shifted ((BoardColumns-1)*2*BoardUnit,0) fi ; + label ( decimal i, ( if "\@@@@bdalternative"="b" : 2.5*u else : .5*u fi , ( BoardSize - i + 1.5 ) * (-v) ) ) + if "\@@@@bdalternative"="b" : shifted ((BoardColumns-1)*2*BoardUnit,0) fi ; +endfor + +setbounds currentpicture to (0,0)--(OverlayWidth,0)--(OverlayWidth,-OverlayHeight)--(0,-OverlayHeight)--cycle; +\stopuseMPgraphic + +%D Here we define a conversion set for our two stone sets. + +\defineconversion + [stone 1] + [\reuseMPgraphic{blackstone pure}, + \reuseMPgraphic{whitestone pure}] + +\defineconversion + [stone 2] + [\reuseMPgraphic{blackstone shade}, + \reuseMPgraphic{whitestone shade}] + +\protect \endinput diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf.tex new file mode 100644 index 0000000000..4909848d91 --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-sgf.tex @@ -0,0 +1,458 @@ +%D \module +%D [ file=t-sgf, +%D version=2007.09.09, +%D title=\CONTEXT\ User Module, +%D subtitle=Go Module, +%D author={Zhichu Chen \& Wolfgang Schuster}, +%D date=\currentdate, +%D copyright=Public Domain] + +\writestatus{loading}{Context User Module / Go Module} + +\unprotect + +%D The dead stone calculator, the board background and the +%D stones are saved in two extra modules. The third module +%D contains two extra conversion commands and the default setup. + +\usemodule[deadstone] +\usemodule[sgf-generic] +\usemodule[sgf-library] + +\useJSscripts[fld][FieldStack] + +\setuppagenumbering[\c!location=,\c!state=\v!stop] + +\setupcolors[\c!state=\v!start] +\definecolor[boardbackground][r=1,g=.625,b=.0625] +\definecolor[deadstonebackground][r=1,g=1,b=1] + +\setupinteraction + [\c!state=\v!start, + \c!focus=\v!height, + \c!page=\v!yes, + \c!openaction=\v!firstpage, + \c!click=\v!off] + +\newcounter\thegame +\newcounter\thestep + +\definesymbol[\v!empty][]% + +\newdimen\stoneunit \stoneunit=.5632cm +\newdimen\boardunit \boardunit=.6cm +\newdimen\capturedunit \capturedunit=.4cm + +\defineoverlay[board][{\useMPgraphic{board}}] + +\setupinterlinespace + [\c!height=0, + \c!depth=1, + \c!top=0, + \c!bottom=0, + \c!line=\boardunit] + +%D \macros{drawboard} +%D +%D The main loop to draw the board with all stones and the +%D stone numbers. The number color depends on the current +%D stone color and on the currently placed stone. + +\def\drawboard + {\vbox{\dorecurse\boardsize + {\edef\boardrow{\recurselevel}% + \hbox{\dorecurse\boardsize + {\edef\boardcolumn{\recurselevel}% + \hbox\!!to\boardunit + {\hss\vbox\!!to\boardunit + {\vss + \ifcase\currentstone + \or\convertnumber\@@@@bdconversion\currentstone + \or\convertnumber\@@@@bdconversion\currentstone + \fi + \vss}\hss}% + \hskip-\boardunit + \hbox\!!to\boardunit + {\vbox\!!to\boardunit + {\hsize\boardunit + \vss + \ifhighlightlabel + \ifnum\currentstonenumber=\stonecount + \def\@@@@bdblackcolor{red}% I overload the preset values + \def\@@@@bdwhitecolor{red}% from the setupbaord settings! + \fi + \fi + \ifcase\currentstone + \or\hbox\!!to\hsize{\hss\doattributes{\????bd\v!black}\c!style\c!color\currentstonenumber\hss} + \or\hbox\!!to\hsize{\hss\doattributes{\????bd\v!white}\c!style\c!color\currentstonenumber\hss} + \fi + \vss}}}}}}} + +%D \macros{drawboarda,drawboardb,drawboardc} +%D +%D The next three macros take care of the three board alternatives +%D and put the area for the removed stones on the left and right +%D side or at the bottom. + +\def\drawboarda + {\increment\thestep + \definesymbol + [stone:\thegame:\thestep] + [{\vbox + {\offinterlineskip + \framed + [\c!offset=\boardunit,\c!frameoffset=\!!zeropoint,\c!strut=\v!no, + \c!top=\!!zeropoint,\c!bottom=\!!zeropoint,\c!depth=\!!zeropoint, + \c!frame=\v!off] + {\offinterlineskip + \drawboard} + \framed + [\c!frame=\v!off, + \c!width=\dimexpr\boardsize\boardunit+\plustwo\boardunit\relax, + \c!height=\numexpr\@@@@bdn*\plustwo\relax\boardunit, + \c!background=color, + \c!backgroundcolor=deadstonebackground] + {\vbox\!!to\vsize + {\vbox\!!to.5\vsize{\processdeadstones[\deadblackstones]\vfill} + \vbox\!!to.5\vsize{\processdeadstones[\deadwhitestones]\vfill}}}}}]} + +\def\drawboardb + {\increment\thestep + \definesymbol + [stone:\thegame:\thestep] + [{\hbox + {\framed + [\c!frame=\v!off, + \c!width=\numexpr\@@@@bdn*\plustwo\relax\boardunit, + \c!height=\dimexpr\boardsize\boardunit+\plustwo\boardunit\relax, + \c!background=color, + \c!backgroundcolor=deadstonebackground]% + {\vbox\!!to\vsize{\processdeadstones[\deadblackstones]\vfill}}% + \framed + [\c!offset=\boardunit,\c!frameoffset=\!!zeropoint,\c!strut=\v!no, + \c!top=\!!zeropoint,\c!bottom=\!!zeropoint,\c!depth=\!!zeropoint, + \c!frame=\v!off]% + {\offinterlineskip + \drawboard}% + \framed + [\c!frame=\v!off, + \c!width=\numexpr\@@@@bdn*\plustwo\relax\boardunit, + \c!height=\dimexpr\boardsize\boardunit+\plustwo\boardunit\relax, + \c!background=color, + \c!backgroundcolor=deadstonebackground]% + {\vbox\!!to\vsize + {\processdeadstones[\deadwhitestones]\vfill}}}}]} + +\def\drawboardc + {\increment\thestep + \definesymbol + [stone:\thegame:\thestep] + [{\framed + [\c!offset=\boardunit,\c!frameoffset=\!!zeropoint,\c!strut=\v!no, + \c!top=\!!zeropoint,\c!bottom=\!!zeropoint,\c!depth=\!!zeropoint, + \c!frame=\v!off]% + {\offinterlineskip + \drawboard}}]} + +%D \macros{processdeadstones} +%D +%D The removed stones in the interactive version are placed with +%D the \tex{processdeadstones} command. It is called twice, once +%D for the black stones and a second time for the white stones. + +\def\processdeadstones[#1]% + {\def\dodoprocessdeadstones##1:##2:##3:##4\relax + {\hbox\!!to\boardunit + {\hss\vbox\!!to\boardunit{\convertnumber\@@@@bdconversion{##3}}\hss}% + \hskip-\boardunit + \hbox\!!to\boardunit + {\vbox\!!to\boardunit + {\hsize\boardunit + \vss + \ifcase##3 + \or\hbox\!!to\hsize{\hss\doattributes{\????bd\v!black}\c!style\c!color{##4}\hss} + \or\hbox\!!to\hsize{\hss\doattributes{\????bd\v!white}\c!style\c!color{##4}\hss} + \fi + \vss}}% + \hbox\!!to\boardunit + {\vbox\!!to\boardunit + {\vfill + \smallbodyfont % problems in mkiv + \hbox\!!to\hsize{\doattributes\????bd\c!style\c!color + {\sgfcharacter{##2}\Numbers{\numexpr\boardsize-##1+\plusone\relax}}\hss} + \vfill\vfill}}}% + \def\doprocessdeadstones##1% + {\ifdim\wd\scratchbox>\hsize + \hbox\!!to\hsize{\box\scratchbox\hss}% + \setbox\scratchbox\hbox + {\box\scratchbox\hbox\!!to\plustwo\boardunit{\@EA\dodoprocessdeadstones##1\relax}}% + \else + \setbox\scratchbox\hbox + {\box\scratchbox\hbox\!!to\plustwo\boardunit{\@EA\dodoprocessdeadstones##1\relax}}% + \fi}% + \processcommacommand[#1]\doprocessdeadstones + \hbox\!!to\hsize{\box\scratchbox\hss}} + +%D \macros{flushboard} +%D +%D After \tex{drawboard} with its three alternatives had drawn a board +%D and saved it in a field we flush it with the \tex{flushboard} command. + +\def\flushboard + {\ifnum\thestep=\@@fdstart\relax + \definefield + [\v!game:\thegame:\thestep][\s!check][\v!game:\thegame] + [\v!stone:\thegame:\thestep,\v!empty] + [\v!stone:\thegame:\thestep]% + \else + \definefield + [\v!game:\thegame:\thestep][\s!check][\v!game:\thegame] + [\v!stone:\thegame:\thestep,\v!empty][\v!empty]% + \fi + \removeunwantedspaces + \vbox\!!to\!!zeropoint + {\vskip-\plusone\points\hbox\!!to\!!zeropoint{\fitfield[\v!game:\thegame:\thestep]\hss}\vss}% + \vskip-\baselineskip} + +\def\clearoverlapstatus + {\dorecurse\boardsize + {\edef\boardrow{\recurselevel}% + \dorecurse\boardsize + {\edef\boardcolumn{\recurselevel}% + \presetcurrentstatus{\zerocount}}}% + \global\let\overlaplist\empty} + +\def\presetcurrentstatus#1% + {\setxvalue{status:\boardrow:\boardcolumn}{#1}% + \resetvalue{overlap:\boardrow:\boardcolumn}} + +\def\makeoverlaplist#1% + {\appendtocommalist{#1}\overlaplist} + +\def\stonecolor#1% + {\@EA\@EA\@EA\@EA\@EA\@EA\@EA\firstofcurrentstone\getvalue{field:#1}\relax} + +\def\stonestep#1% + {\@EA\@EA\@EA\@EA\@EA\@EA\@EA\secondofcurrentstone\getvalue{field:#1}\relax} + +\def\currentstatus + {\getvalue{status:\boardrow:\boardcolumn}} + +\def\setstatus#1#2% + {\setevalue{status:\number#1:\number#2}} + +\def\setcurrentstatus + {\setstatus\boardrow\boardcolumn} + +\def\currentoverlap + {\getvalue{overlap:\boardrow:\boardcolumn}} + +\def\setoverlap#1#2% + {\setevalue{overlap:\number#1:\number#2}} + +\def\setcurrentoverlap + {\setoverlap\boardrow\boardcolumn} + +\def\dummystonebox + {\hbox\!!to\boardunit + {\hss\vbox\!!to\boardunit + {\vss + \ifcase\currentstone + \or\convertnumber\@@@@bdconversion\currentstone + \or\convertnumber\@@@@bdconversion\currentstone + \fi + \vss}% + \hss}% + \hskip-\boardunit + \hbox\!!to\boardunit + {\vbox\!!to\boardunit + {\hsize\boardunit + \vss + \ifcase\currentstone + \or\hbox\!!to\hsize{\hss\doattributes{\????bd\v!black}{\c!style}{\c!color}{\currentstonenumber}\hss} + \or\hbox\!!to\hsize{\hss\doattributes{\????bd\v!white}{\c!style}{\c!color}{\currentstonenumber}\hss} + \fi + \vss}}} + +%D \macros{adddummystone} +%D +%D This is a alternative for the \tex{addstone} command in the +%D dead stone calculator. It saves only the position and states +%D of every field in a macro and make a listentry if there is +%D already a stone on the position and we replace it. + +\def\adddummystone(#1:#2:#3)% + {\global\advance\stonecount\plusone + \edef\boardrow{\number#1}% + \edef\boardcolumn{\number#2}% + \ifcase\currentstatus + \setcurrentstatus{\plusone}% + \or + \setcurrentstatus{\plustwo}% + \makeoverlaplist\currentstonenumber + \setvalue{overlaplist:\currentstonenumber}{\csname overlap:#1:#2\endcsname}% + \setcurrentoverlap{\dummystonebox}% + \else + \setcurrentstatus{\plusthree}% + \fi + \setevalue{field:\number#1:\number#2}% + {\ifx#3B + \plusone + \else\ifx#3W + \plustwo + \fi\fi:\number\stonecount}% + \ifcase\currentstatus\or\else + \setcurrentoverlap + {\hbox + {\currentoverlap + \vbox\!!to\boardunit{\vss\hbox\!!to\boardunit{\hss$\mathstrut{}={}$\hss}\vss}% + \dummystonebox}}% + \fi} + +%D \macros{processoverlappedstones} +%D +%D This is the alternative to \tex{processdeadstones} for the printable +%D version. The stones are sorted from the lowest number to the highest. + +\def\processoverlappedstones + {\scratchdimen\hsize + \def\doprocessoverlappedstones##1% + {\setbox\globalscratchbox\hbox{\getvalue{overlaplist:##1}}% + \ifdim\wd\globalscratchbox>\scratchdimen + \scratchdimen\dimexpr\hsize-\wd\globalscratchbox\relax + \hbox\!!to\hsize{\box\scratchbox\hfill}% + \box\scratchbox\box\globalscratchbox + \else + \scratchdimen\dimexpr\scratchdimen-\wd\globalscratchbox-\@@@@bddistance\relax + \setbox\scratchbox\hbox{\box\scratchbox\box\globalscratchbox\hskip\@@@@bddistance}% + \fi}% + \sortcommacommand[\overlaplist]\donumericcompare + \processcommacommand[\sortedcommalist]\doprocessoverlappedstones + \hbox\!!to\hsize{\box\scratchbox\hss}} + +\bgroup +\catcode`\;=13 +\gdef\dostartSGFbox + {\setupboard[\c!alternative=\v!c]% + \switchtobodyfont[\the\dimexpr.45\boardunit\relax]% + \doglobal\increment\thegame + \clearboard\clearoverlapstatus + \doglobal\let\thestep\zerocountervalue + \global\stonecount\!!zerocount + \def;##1[##2##3]% + {\adddummystone(\charactertonumber##2:\charactertonumber##3:##1)}% + \catcode`\^^M=\@@ignore} +\egroup + +\def\stopSGFbox + {\framed + [\c!offset=\v!overlay,\c!strut=\v!no, + \c!top=\!!zeropoint,\c!bottom=\!!zeropoint,\c!depth=\!!zeropoint, + \c!frame=\v!on] + {\vbox + {\offinterlineskip + \framed + [\c!offset=\boardunit,\c!frameoffset=\!!zeropoint,\c!strut=\v!no, + \c!top=\!!zeropoint,\c!bottom=\!!zeropoint,\c!depth=\!!zeropoint, + \c!width=\dimexpr\boardsize\boardunit+2\boardunit\relax, + \c!frame=\v!on,\c!background={color,board}, + \c!backgroundcolor=boardbackground]% + {\dontcomplain + \offinterlineskip + \highlightlabelfalse + \drawboard} + \framed + [\c!frame=\v!on, + \c!width=\dimexpr\boardsize\boardunit+\plustwo\boardunit\relax, + \c!height=\numexpr\@@@@bdn*\plustwo\relax\boardunit, + \c!offset=.2\boardunit]% + {\vbox\!!to\vsize{\processoverlappedstones}}}}} + +\bgroup +\catcode`\;=13 +\gdef\dostartSGFpage + {\startTEXpage + [\c!width=\dimexpr\boardsize\boardunit + \if\@@@@bdalternative\v!a + +\plustwo\boardunit + \else\if\@@@@bdalternative\v!b + +\numexpr\@@@@bdn*\plusfour+\plustwo\relax\boardunit + \else + +\plustwo\boardunit + \fi\fi\relax, + \c!height=\dimexpr\boardsize\boardunit + \if\@@@@bdalternative\v!a + +\numexpr\@@@@bdn*\plustwo+\plustwo\relax\boardunit + \else\if\@@@@bdalternative\v!b + +\plustwo\boardunit + \else + +\plustwo\boardunit + \fi\fi\relax, + \c!background={color,board}, + \c!backgroundcolor=boardbackground]% + \switchtobodyfont[\the\dimexpr.45\boardunit\relax]% + \doglobal\increment\thegame + \clearboard + \getparameters[\??fd][\c!start=1,\c!width=\v!fit,\c!height=\c!fit,\c!offset=\v!overlay,\c!frame=\v!off]% + \doglobal\let\thestep\zerocountervalue + \global\stonecount\!!zerocount + \setupfield + [\v!game:\thegame] + [\v!reset]% + \setupfield + [\v!game:\thegame] + [\c!option=\v!readonly, + \c!frameoffset=\!!zeropoint, + \c!strut=\v!no, + \c!top=\!!zeropoint, + \c!bottom=\!!zeropoint, + \c!depth=\!!zeropoint, + \c!width=\v!fit, + \c!height=\v!fit, + \c!offset=\v!overlay, + \c!frame=\v!off]% + \definefield + [\v!game:\thegame:\thestep][\s!check][\v!game:\thegame] + [\v!empty,\v!empty][\v!empty]% + \cleardeadstonelist + \executeifdefined{drawboard\@@@@bdalternative}\drawboarda + \flushboard + \def;##1[##2##3]% + {\addstone(\charactertonumber##2:\charactertonumber##3:##1)% + \doif\@@@@bdcalculate\v!yes\processtones + \executeifdefined{drawboard\@@@@bdalternative}\drawboarda + \flushboard}% + \catcode`\^^M=\@@ignore} +\egroup + +%D \macros{starSGF,stopSGF} +%D +%D The two macros \tex{startSGF} and \tex{stopSGF} begin and end +%D the parser for the go stones saved with the \type{sgf} syntax. + +\def\stopSGFpage + {\startoverlay{\overlaybutton{JS(Walk_Field{\v!game:\thegame})}}\stopoverlay + \stopTEXpage} + +\def\startSGF + {\bgroup + \catcode`\;=13 + \dosingleempty\dostartSGF} + +\def\dostartSGF[#1]% + {\iffirstargument + \setupboard[#1]% + \fi + \doif\@@@@bdcalculate\v!no + {\setupboard[\c!alternative=\v!c]}% + \doifelse\@@@@bdprintable\v!no + \dostartSGFpage + \dostartSGFbox} + +\def\stopSGF + {\doifelse\@@@@bdprintable\v!no + \stopSGFpage + \stopSGFbox + \egroup} + +\protect \endinput diff --git a/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-weiqi.tex b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-weiqi.tex new file mode 100644 index 0000000000..5c9ac0d79b --- /dev/null +++ b/obsolete/macros/context/contrib/context-sgf/tex/context/third/sgf/t-weiqi.tex @@ -0,0 +1,16 @@ +%D \module +%D [ file=t-weiqi, +%D version=2007.09.09, +%D title=\CONTEXT\ User Module, +%D subtitle=Go Module, +%D author={Zhichu Chen \& Wolfgang Schuster}, +%D date=\currentdate, +%D copyright=Public Domain] + +\writestatus{loading}{Context User Module / Go Module} + +\unprotect + +\usemodule[sgf] + +\protect \endinput -- cgit v1.2.3