bayes.pl: Calculate MSE on original style scores
[gostyle.git] / tex / psgo.sty
blob15bd25506ed948778bdd39b6ec0247543911c1e0
1 %% psgo.sty
2 %% Copyright 2004, 2003,2001 V. Bos
4 % This program may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.2
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.2 or later is part of all distributions of LaTeX
10 % version 1999/12/01 or later.
12 % This program consists of the files:
14 % psgo.sty
15 % psgomanual.tex
16 % psgomanual.ps
18 % RCS-ID: $Id: psgo.sty,v 1.7 2004/02/24 10:20:11 vbos Exp $
20 \NeedsTeXFormat{LaTeX2e}%
21 \ProvidesPackage{psgo}[2008/09/04, v0.17]
22 \message{`PSGO', <2008/09/04>, v0.17}
23 \RequirePackage{pstricks,pst-node,calc,ifthen}
25 \newcommand{\psgo}{\textsf{psgo}}
26 \newsavebox{\stmarkbox}
27 \newcounter{gomove}
28 \setcounter{gomove}{-1}
29 \newcounter{boardsize}
30 \newboolean{blackmove}
31 \setboolean{blackmove}{true}
32 \newcommand{\toggleblackmove}{%
33 \ifthenelse{\boolean{blackmove}}{\setboolean{blackmove}{false}}{\setboolean{blackmove}{true}}%
35 \newlength{\goxunit}
36 \newlength{\goyunit}
37 \newcommand{\setgounit}[1]{\setlength{\goxunit}{#1}\setlength{\goyunit}{1.115\goxunit}}
38 \setgounit{0.6cm}
39 \newcommand{\hatchangle}{-42.5}
40 \newlength{\tmplx}
41 \newlength{\tmply}
42 \newlength{\tmpxa}%
43 \newlength{\tmpxb}%
44 \newlength{\tmpya}%
45 \newlength{\tmpyb}%
46 \newcounter{gotmpc}
47 \newcommand{\pointbox}[1]{\raisebox{-0.5\height+0.5\depth}[0pt][0pt]{\makebox[0pt]{#1}}}
48 \newcommand{\golabelformat}[1]{{\sffamily #1}}
49 \newcommand{\goxposition}[1]{%
50 \ifx#1a 0\else%
51 \ifx#1b 1\else%
52 \ifx#1c 2\else%
53 \ifx#1d 3\else%
54 \ifx#1e 4\else%
55 \ifx#1f 5\else%
56 \ifx#1g 6\else%
57 \ifx#1h 7\else%
58 \ifx#1j 8\else%
59 \ifx#1k 9\else%
60 \ifx#1l 10\else%
61 \ifx#1m 11\else%
62 \ifx#1n 12\else%
63 \ifx#1o 13\else%
64 \ifx#1p 14\else%
65 \ifx#1q 15\else%
66 \ifx#1r 16\else%
67 \ifx#1s 17\else%
68 \ifx#1t 18\else%
69 \relax%
70 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
72 \newcommand{\goyposition}[1]{%
73 \ifnum#1=1 0\else%
74 \ifnum#1=2 1\else%
75 \ifnum#1=3 2\else%
76 \ifnum#1=4 3\else%
77 \ifnum#1=5 4\else%
78 \ifnum#1=6 5\else%
79 \ifnum#1=7 6\else%
80 \ifnum#1=8 7\else%
81 \ifnum#1=9 8\else%
82 \ifnum#1=10 9\else%
83 \ifnum#1=11 10\else%
84 \ifnum#1=12 11\else%
85 \ifnum#1=13 12\else%
86 \ifnum#1=14 13\else%
87 \ifnum#1=15 14\else%
88 \ifnum#1=16 15\else%
89 \ifnum#1=17 16\else%
90 \ifnum#1=18 17\else%
91 \ifnum#1=19 18\else%
92 \relax%
93 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
96 \newenvironment{gomoves}{%
97 \newcommand{\mdd}[4]{%
98 \setlength{\tmpxa}{\goxposition{##1}\goxunit}\addtolength{\tmpxa}{-0.5\goxunit}%
99 \setlength{\tmpxb}{\goxposition{##3}\goxunit}\addtolength{\tmpxb}{0.5\goxunit}%
100 \setlength{\tmpya}{\goyposition{##2}\goyunit}\addtolength{\tmpya}{-0.5\goyunit}%
101 \setlength{\tmpyb}{\goyposition{##4}\goyunit}\addtolength{\tmpyb}{0.5\goyunit}%
102 \psframe[dimen=middle,fillstyle=vlines,hatchsep=2pt,hatchwidth=0.2pt,hatchangle=\hatchangle,linestyle=none]%
103 (\tmpxa,\tmpya)(\tmpxb,\tmpyb)%
105 \newcommand{\placesymbol}[3]{%
106 \ifthenelse{\value{boardsize} > \goxposition{##2}%
107 \and \value{boardsize} > \goyposition{##3}}{%
108 \rput(\goxposition{##2},\goyposition{##3}){##1}%
109 }{}%
111 \newcommand{\markpos}[3]{\placesymbol{\psframebox[dimen=inner,fillcolor=white,fillstyle=solid,linestyle=none,boxsep=false,framesep=0.3\goxunit]{##1}}{##2}{##3}}%
112 \newcommand{\blackstone}[3][\relax]{%
113 \placesymbol{\pscircle[linewidth=0.4pt,fillstyle=solid,fillcolor=black](0,0){0.5\goxunit}%
114 {\psset{linecolor=white,fillcolor=white,hatchcolor=gray}\color{white}##1}}{##2}{##3}%
116 \newcommand{\whitestone}[3][\relax]{%
117 \placesymbol{\pscircle[linewidth=0.4pt,fillstyle=solid,fillcolor=white](0,0){0.5\goxunit}%
118 {\psset{linecolor=black,fillcolor=black,hatchcolor=gray}\color{black}##1}}{##2}{##3}%
120 \renewcommand{\stone}[4][\nomark{\relax}]{%
121 % \def\stmark{\raisebox{-0.5\height+0.5\depth}[0.5\totalheight][0.5\totalheight]{\makebox[0pt]{##1}}}%
122 \def\stmark{\pointbox{##1}}
123 \ifthenelse{\equal{##2}{black}}%
124 {\blackstone[\stmark]{##3}{##4}}%
125 {\whitestone[\stmark]{##3}{##4}}%
127 \newcommand{\move}{\@ifstar{\movestar}{\movenostar}}%
128 \newcommand{\movestar}[3][\nomark]{%
129 \ifthenelse{\boolean{blackmove}}%
130 {\stone[##1]{black}{##2}{##3}}%
131 {\stone[##1]{white}{##2}{##3}}%
132 \toggleblackmove%
134 \newcommand{\movenostar}[3][\nomark]{%
135 \refstepcounter{gomove}%
136 \ifthenelse{\boolean{blackmove}}%
137 {\stone[##1\rput(0,0){\golabelformat{\thegomove}}]{black}{##2}{##3}}%
138 {\stone[##1\rput(0,0){\golabelformat{\thegomove}}]{white}{##2}{##3}}%
139 \toggleblackmove%
141 \newcommand{\pass}{\@ifstar{\passstar}{\passnostar}}%
142 \newcommand{\passstar}{\toggleblackmove}%
143 \newcommand{\passnostar}{\refstepcounter{gomove}\toggleblackmove}%
144 \newcommand{\goline}[4]{\psline[linewidth=1.4pt,linecolor=black,linestyle=solid]%
145 (\goxposition{##1},\goyposition{##2})(\goxposition{##3},\goyposition{##4})%
147 \newcommand{\goarrow}[4]{\psline[linewidth=1.4pt,linecolor=black,linestyle=solid,arrowscale=1.5]%
148 {->}%
149 (\goxposition{##1},\goyposition{##2})(\goxposition{##3},\goyposition{##4})%
151 }{}%
152 \newcommand{\xpositionmarks}[2]{%
153 \whiledo{\value{#1} < #2}{%
154 \rput[t](\value{#1},-\goyunit){%
155 \addtocounter{#1}{1}%
156 \ifthenelse{\value{#1} > 8}%
157 {\addtocounter{#1}{1}\golabelformat{\Alph{#1}}\addtocounter{#1}{-1}}%
158 {\golabelformat{\Alph{#1}}}%
159 \addtocounter{#1}{-1}}%
160 \setlength{\tmply}{#2\goyunit}%
161 \rput[B](\value{#1},\tmply){%
162 \addtocounter{#1}{1}%
163 \ifthenelse{\value{#1} > 8}%
164 {\addtocounter{#1}{1}\golabelformat{\Alph{#1}}\addtocounter{#1}{-1}}%
165 {\golabelformat{\Alph{#1}}}%
166 \addtocounter{#1}{-1}}%
167 \stepcounter{#1}%
170 \newcommand{\ypositionmarks}[2]{%
171 \whiledo{\value{#1} < #2}{%
172 \addtocounter{#1}{1}%
173 \edef\ypos{\arabic{#1}}%
174 \addtocounter{#1}{-1}%
175 \rput[r](-\goxunit,\value{#1}){\golabelformat{\ypos}}%
176 \setlength{\tmplx}{#2\goxunit}%
177 \rput[l](\tmplx,\value{#1}){\golabelformat{\ypos}}%
178 \stepcounter{#1}%
182 \def\psgosetboardsizes(#1,#2)(#3,#4){%
183 \def\psgollx{#1}%
184 \def\psgolly{#2}%
185 \ifthenelse{#3 > \value{boardsize}}{\def\psgourx{\value{boardsize}}}{\def\psgourx{#3}}%
186 \ifthenelse{#4 > \value{boardsize}}{\def\psgoury{\value{boardsize}}}{\def\psgoury{#4}}%
188 \newboolean{withindices}%
189 \setboolean{withindices}{true}%
190 \newenvironment{psgopartialboard}[2][19]{%
191 \setcounter{boardsize}{#1}%
192 \psgosetboardsizes#2%
193 \psset{xunit=\goxunit,yunit=\goyunit}%
194 \ifthenelse{\boolean{withindices}}%
195 {\def\xoffset{2\goxunit}\def\yoffset{2\goyunit}}%
196 {\def\xoffset{.5\goxunit}\def\yoffset{.5\goyunit}}%
197 \ifthenelse{\psgollx = 1 \or \psgollx < 1}%
198 {\def\psgollxval{-\xoffset}}%
199 {\setlength{\tmplx}{\psgollx\goxunit - 1\goxunit}\edef\psgollxval{\the\tmplx}}%
200 \ifthenelse{\psgolly = 1 \or \psgolly < 1}%
201 {\def\psgollyval{-\yoffset}}%
202 {\setlength{\tmply}{\psgolly\goyunit - 1\goyunit}\edef\psgollyval{\the\tmply}}%
203 \ifthenelse{\psgourx = \value{boardsize} \or \psgourx > \value{boardsize}}%
204 {\setlength{\tmplx}{\value{boardsize}\goxunit - \goxunit + \xoffset}%
205 \edef\psgourxval{\the\tmplx}}%
206 {\def\psgourxval{\psgourx\goxunit}}%
207 \ifthenelse{\psgoury = \value{boardsize} \or \psgoury > \value{boardsize}}%
208 {\setlength{\tmply}{\value{boardsize}\goyunit - \goyunit + \yoffset}%
209 \edef\psgouryval{\the\tmply}}%
210 {\def\psgouryval{\psgoury\goyunit}}%
211 \begin{pspicture}(\psgollxval,\psgollyval)(\psgourxval,\psgouryval)%
212 \ifthenelse{\psgollx = 1 \or \psgollx < 1}%
213 {\def\psgollxval{-\xoffset}}%
214 {\setlength{\tmplx}{\psgollx\goxunit - 1.5\goxunit}\edef\psgollxval{\the\tmplx}}%
215 \ifthenelse{\psgolly = 1 \or \psgolly < 1}%
216 {\def\psgollyval{-\yoffset}}%
217 {\setlength{\tmply}{\psgolly\goyunit - 1.5\goyunit}\edef\psgollyval{\the\tmply}}%
218 \ifthenelse{\psgourx = \value{boardsize} \or \psgourx > \value{boardsize}}%
219 {\setlength{\tmplx}{\value{boardsize}\goxunit - \goxunit + \xoffset}%
220 \edef\psgourxval{\the\tmplx}}%
221 {\setlength{\tmplx}{\psgourx\goxunit - .5\goxunit}%
222 \edef\psgourxval{\the\tmplx}}%
223 \ifthenelse{\psgoury = \value{boardsize} \or \psgoury > \value{boardsize}}%
224 {\setlength{\tmply}{\value{boardsize}\goyunit - \goyunit + \yoffset}%
225 \edef\psgouryval{\the\tmply}}%
226 {\setlength{\tmply}{\psgoury\goyunit - .5\goyunit}%
227 \edef\psgouryval{\the\tmply}}%
228 %% uncomment the following line to get a visual bounding box
229 %% \psframe[linecolor=green,linewidth=0.4pt](\psgollxval,\psgollyval)(\psgourxval,\psgouryval)
230 \psclip{\psframe[linecolor=white,linewidth=0](\psgollxval,\psgollyval)(\psgourxval,\psgouryval)}%
231 \setlength{\tmply}{\value{boardsize}\goyunit + 0.5\goyunit}%
232 \setlength{\tmplx}{\value{boardsize}\goxunit + 0.5\goxunit}%
233 \addtolength{\tmply}{-1.5\goyunit}%
234 \addtolength{\tmplx}{-1.5\goxunit}%
235 \multips(0,0)(1,0){\value{boardsize}}{\psline[linewidth=0.2pt](0,0)(0,\tmply)}%
236 \multips(0,0)(0,1){\value{boardsize}}{\psline[linewidth=0.2pt](0,0)(\tmplx,0)}%
237 \psframe[linewidth=1pt](0,0)(\tmplx,\tmply)%
238 \ifthenelse{\boolean{withindices}}{%
239 \setcounter{gotmpc}{0}%
240 \xpositionmarks{gotmpc}{\value{boardsize}}%
241 \setcounter{gotmpc}{0}%
242 \ypositionmarks{gotmpc}{\value{boardsize}}%
243 }{\relax}%
244 \ifthenelse{\equal{\value{boardsize}}{19}}{%
245 \multips(3,3)(0,6){3}{\pscircle[fillstyle=solid,fillcolor=black](0,0){.15\goxunit}}%
246 \multips(9,3)(0,6){3}{\pscircle[fillstyle=solid,fillcolor=black](0,0){.15\goxunit}}%
247 \multips(15,3)(0,6){3}{\pscircle[fillstyle=solid,fillcolor=black](0,0){.15\goxunit}}%
248 }{\relax}%
249 \begin{gomoves}%
251 {\end{gomoves}%
252 \endpsclip%
253 \end{pspicture}%
255 \newenvironment{psgoboard}[1][19]{%
256 \begin{psgopartialboard}[#1]{(0,0)(#1,#1)}%
258 \end{psgopartialboard}%
261 \newenvironment{psgopartialboard*}[2][19]{%
262 \setboolean{withindices}{false}%
263 \begin{psgopartialboard}[#1]{#2}%
264 }{\end{psgopartialboard}}
266 \newenvironment{psgoboard*}[1][19]{%
267 \begin{psgopartialboard*}[#1]{(0,0)(#1,#1)}%
269 \end{psgopartialboard*}%
272 \newcommand{\nomark}{\relax}%
273 \newcommand{\factor}{0.28284271247461901}% = 2/5 * sin(1/4 * pi)
274 \newcommand{\markma}{%
275 \psline[linewidth=1.4pt](-\factor,-\factor)(\factor,\factor)%
276 \psline[linewidth=1.4pt](-\factor,\factor)(\factor,-\factor)%
278 \newcommand{\marktr}{%
279 \rput(0,-0.3\goxunit){\pstriangle(-0.66\goxunit,0.66\goxunit)}%
281 \newcommand{\markcr}{%
282 \pscircle(0,0){0.33\goxunit}%
284 \newcommand{\marksq}{%
285 \psframe(-0.33\goxunit,-0.33\goxunit)(0.33\goxunit,0.33\goxunit)%
287 \newcommand{\marklb}[1]{%
288 \rput(0,0){\golabelformat{#1}}%
290 \newcommand{\marksl}{%
291 \psframe[fillstyle=solid,fillcolor=gray,linecolor=gray](-0.22\goxunit,-0.22\goxunit)(0.22\goxunit,0.22\goxunit)%
293 \newcommand{\markdd}{%
294 \psframe[dimen=middle,fillstyle=vlines,hatchsep=2pt,hatchwidth=0.2pt,hatchangle=\hatchangle,linestyle=none]%
295 (-0.5\goxunit,-0.5\goyunit)(0.5\goxunit,0.5\goyunit)%
297 \newcommand{\stone}[2][\relax]{%
298 \setlength{\tmply}{-0.5\goxunit + 0.5ex}%
299 \raisebox{\tmply}{\psset{unit=\goxunit}\begin{pspicture}(-0.5,-0)(0.5,1)%
300 \pscircle[fillstyle=solid,fillcolor=#2](0,0.5){0.5}%
301 \ifthenelse{\equal{#2}{black}}%
302 {\rput(0,0.5){{\psset{linecolor=white}\color{white}\golabelformat{#1}}}}%
303 {\rput(0,0.5){{\psset{linecolor=black}\color{black}\golabelformat{#1}}}}%
304 \end{pspicture}}}