From a6e172e3d342febd499eb436ed28604c66fdffd0 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 11 Mar 2010 19:51:02 +0100 Subject: [PATCH] tex: Diagrams for characteristic patterns --- tex/gostyle.tex | 65 +++++++++++- tex/psgo.sty | 304 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 368 insertions(+), 1 deletion(-) create mode 100644 tex/psgo.sty diff --git a/tex/gostyle.tex b/tex/gostyle.tex index 12085c7..b66e022 100644 --- a/tex/gostyle.tex +++ b/tex/gostyle.tex @@ -41,6 +41,9 @@ \usepackage{threeparttable} +\usepackage{psgo} +\setgounit{0.4cm} + \usepackage{algorithm} \usepackage{algorithmic} %\usepackage{algpseudocode} @@ -407,6 +410,15 @@ $d(x,y) = |\delta x| + |\delta y| + \max(|\delta x|, |\delta y|)$ defines a circle-like structure on the Go board square grid. \cite{SpatPat} } are matched. +Pattern vectors representing these features contain information on +played shape as well as basic representation of tactical dynamics +--- threats to capture stones, replying to last move, or ignoring +opponent's move elsewhere to return to an urgent local situation. +The shapes most frequently correspond to opening moves +(either in empty corners and sides, or as part of {\em joseki} +--- commonly played sequences) characteristic for a certain +strategic aim. + \subsection{Implementation} We have implemented the data extraction by making use of the pattern @@ -928,6 +940,50 @@ Eigenval. & $\tau$ & $\omega$ & $\alpha$ & $\theta$ & Year \\ \end{tabular} \end{table} +\begin{table}[!t] +% increase table row spacing, adjust to taste +\renewcommand{\arraystretch}{1.3} +\caption{Characteristic Patterns of PCA Dimensions} +\label{fig:style_ptterns} +\centering +% Some packages, such as MDW tools, offer better commands for making tables +% than the plain LaTeX2e tabular which is used here. +\begin{tabular}{|cccc|} +\hline +PCA1 top & +\begin{psgopartialboard*}{(8,1)(12,6)} +\stone[\marktr]{black}{k}{4} +\end{psgopartialboard*} & +\begin{psgopartialboard*}{(3,1)(5,6)} +\stone{white}{d}{3} +\stone[\marktr]{black}{d}{5} +\end{psgopartialboard*} & +\begin{psgopartialboard*}{(5,1)(10,6)} +\stone{white}{f}{3} +\stone[\marktr]{black}{j}{4} +\end{psgopartialboard*} \\ +$0.447 \cdot$ & $0.274$ & $0.086$ & $0.083$ \\ +& side extension or \par 4--4 corner opening & high corner approach & high distant pincer \\ +PCA1 bot. & +\begin{psgopartialboard*}{(3,1)(7,6)} +\stone{white}{d}{4} +\stone[\marktr]{black}{f}{3} +\end{psgopartialboard*} & +\begin{psgopartialboard*}{(3,1)(7,6)} +\stone{white}{c}{6} +\stone{black}{d}{4} +\stone[\marktr]{black}{f}{3} +\end{psgopartialboard*} & +\begin{psgopartialboard*}{(3,1)(7,6)} +\stone{black}{d}{4} +\stone[\marktr]{black}{f}{3} +\end{psgopartialboard*} \\ +$0.447 \cdot$ & $-0.399$ & $-0.399$ & $-0.177$ \\ +& low corner approach & low corner reply & low corner enclosure \\ +\hline +\end{tabular} +\end{table} + It is immediately obvious both from the measured $r$ and visual observation that by far the most significant vector corresponds very well @@ -946,8 +1002,15 @@ In other PCA dimensions correspond well to to identify and name, but there certainly is some influence of the styles on the patterns; the found correlations are presented in table \ref{fig:style_r}. (Larger absolute value means better linear correspondence.) + We also list the characteristic spatial patterns of the PCA dimension -extremes (table \ref{fig:style_patterns}). +extremes (table \ref{fig:style_patterns}) --- however, naive inference +of characteristic patterns based on projection matrix coefficients +does not work well, better methods will have to be researched.% +\footnote{For example, as one of highly ranked ``Takemiya's'' PCA1 patterns, +3,3 corner opening was generated, completely inappropriately; +it reflects some weak ordering in bottom half of the dimension, +not global ordering within the dimension.} We have not found significant correspondence for the style aspects representing aggressiveness and novelty of play; this means either diff --git a/tex/psgo.sty b/tex/psgo.sty new file mode 100644 index 0000000..15bd255 --- /dev/null +++ b/tex/psgo.sty @@ -0,0 +1,304 @@ +%% psgo.sty +%% Copyright 2004, 2003,2001 V. Bos +% +% This program may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.2 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.2 or later is part of all distributions of LaTeX +% version 1999/12/01 or later. +% +% This program consists of the files: +% +% psgo.sty +% psgomanual.tex +% psgomanual.ps +% +% RCS-ID: $Id: psgo.sty,v 1.7 2004/02/24 10:20:11 vbos Exp $ +% +\NeedsTeXFormat{LaTeX2e}% +\ProvidesPackage{psgo}[2008/09/04, v0.17] +\message{`PSGO', <2008/09/04>, v0.17} +\RequirePackage{pstricks,pst-node,calc,ifthen} + +\newcommand{\psgo}{\textsf{psgo}} +\newsavebox{\stmarkbox} +\newcounter{gomove} +\setcounter{gomove}{-1} +\newcounter{boardsize} +\newboolean{blackmove} +\setboolean{blackmove}{true} +\newcommand{\toggleblackmove}{% + \ifthenelse{\boolean{blackmove}}{\setboolean{blackmove}{false}}{\setboolean{blackmove}{true}}% +} +\newlength{\goxunit} +\newlength{\goyunit} +\newcommand{\setgounit}[1]{\setlength{\goxunit}{#1}\setlength{\goyunit}{1.115\goxunit}} +\setgounit{0.6cm} +\newcommand{\hatchangle}{-42.5} +\newlength{\tmplx} +\newlength{\tmply} +\newlength{\tmpxa}% +\newlength{\tmpxb}% +\newlength{\tmpya}% +\newlength{\tmpyb}% +\newcounter{gotmpc} +\newcommand{\pointbox}[1]{\raisebox{-0.5\height+0.5\depth}[0pt][0pt]{\makebox[0pt]{#1}}} +\newcommand{\golabelformat}[1]{{\sffamily #1}} +\newcommand{\goxposition}[1]{% + \ifx#1a 0\else% + \ifx#1b 1\else% + \ifx#1c 2\else% + \ifx#1d 3\else% + \ifx#1e 4\else% + \ifx#1f 5\else% + \ifx#1g 6\else% + \ifx#1h 7\else% + \ifx#1j 8\else% + \ifx#1k 9\else% + \ifx#1l 10\else% + \ifx#1m 11\else% + \ifx#1n 12\else% + \ifx#1o 13\else% + \ifx#1p 14\else% + \ifx#1q 15\else% + \ifx#1r 16\else% + \ifx#1s 17\else% + \ifx#1t 18\else% + \relax% + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% +}% +\newcommand{\goyposition}[1]{% + \ifnum#1=1 0\else% + \ifnum#1=2 1\else% + \ifnum#1=3 2\else% + \ifnum#1=4 3\else% + \ifnum#1=5 4\else% + \ifnum#1=6 5\else% + \ifnum#1=7 6\else% + \ifnum#1=8 7\else% + \ifnum#1=9 8\else% + \ifnum#1=10 9\else% + \ifnum#1=11 10\else% + \ifnum#1=12 11\else% + \ifnum#1=13 12\else% + \ifnum#1=14 13\else% + \ifnum#1=15 14\else% + \ifnum#1=16 15\else% + \ifnum#1=17 16\else% + \ifnum#1=18 17\else% + \ifnum#1=19 18\else% + \relax% + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% +}% + +\newenvironment{gomoves}{% + \newcommand{\mdd}[4]{% + \setlength{\tmpxa}{\goxposition{##1}\goxunit}\addtolength{\tmpxa}{-0.5\goxunit}% + \setlength{\tmpxb}{\goxposition{##3}\goxunit}\addtolength{\tmpxb}{0.5\goxunit}% + \setlength{\tmpya}{\goyposition{##2}\goyunit}\addtolength{\tmpya}{-0.5\goyunit}% + \setlength{\tmpyb}{\goyposition{##4}\goyunit}\addtolength{\tmpyb}{0.5\goyunit}% + \psframe[dimen=middle,fillstyle=vlines,hatchsep=2pt,hatchwidth=0.2pt,hatchangle=\hatchangle,linestyle=none]% + (\tmpxa,\tmpya)(\tmpxb,\tmpyb)% + }% + \newcommand{\placesymbol}[3]{% + \ifthenelse{\value{boardsize} > \goxposition{##2}% + \and \value{boardsize} > \goyposition{##3}}{% + \rput(\goxposition{##2},\goyposition{##3}){##1}% + }{}% + }% + \newcommand{\markpos}[3]{\placesymbol{\psframebox[dimen=inner,fillcolor=white,fillstyle=solid,linestyle=none,boxsep=false,framesep=0.3\goxunit]{##1}}{##2}{##3}}% + \newcommand{\blackstone}[3][\relax]{% + \placesymbol{\pscircle[linewidth=0.4pt,fillstyle=solid,fillcolor=black](0,0){0.5\goxunit}% + {\psset{linecolor=white,fillcolor=white,hatchcolor=gray}\color{white}##1}}{##2}{##3}% + }% + \newcommand{\whitestone}[3][\relax]{% + \placesymbol{\pscircle[linewidth=0.4pt,fillstyle=solid,fillcolor=white](0,0){0.5\goxunit}% + {\psset{linecolor=black,fillcolor=black,hatchcolor=gray}\color{black}##1}}{##2}{##3}% + }% + \renewcommand{\stone}[4][\nomark{\relax}]{% +% \def\stmark{\raisebox{-0.5\height+0.5\depth}[0.5\totalheight][0.5\totalheight]{\makebox[0pt]{##1}}}% + \def\stmark{\pointbox{##1}} + \ifthenelse{\equal{##2}{black}}% + {\blackstone[\stmark]{##3}{##4}}% + {\whitestone[\stmark]{##3}{##4}}% + }% + \newcommand{\move}{\@ifstar{\movestar}{\movenostar}}% + \newcommand{\movestar}[3][\nomark]{% + \ifthenelse{\boolean{blackmove}}% + {\stone[##1]{black}{##2}{##3}}% + {\stone[##1]{white}{##2}{##3}}% + \toggleblackmove% + }% + \newcommand{\movenostar}[3][\nomark]{% + \refstepcounter{gomove}% + \ifthenelse{\boolean{blackmove}}% + {\stone[##1\rput(0,0){\golabelformat{\thegomove}}]{black}{##2}{##3}}% + {\stone[##1\rput(0,0){\golabelformat{\thegomove}}]{white}{##2}{##3}}% + \toggleblackmove% + }% + \newcommand{\pass}{\@ifstar{\passstar}{\passnostar}}% + \newcommand{\passstar}{\toggleblackmove}% + \newcommand{\passnostar}{\refstepcounter{gomove}\toggleblackmove}% + \newcommand{\goline}[4]{\psline[linewidth=1.4pt,linecolor=black,linestyle=solid]% + (\goxposition{##1},\goyposition{##2})(\goxposition{##3},\goyposition{##4})% + }% + \newcommand{\goarrow}[4]{\psline[linewidth=1.4pt,linecolor=black,linestyle=solid,arrowscale=1.5]% + {->}% + (\goxposition{##1},\goyposition{##2})(\goxposition{##3},\goyposition{##4})% + }% + }{}% +\newcommand{\xpositionmarks}[2]{% + \whiledo{\value{#1} < #2}{% + \rput[t](\value{#1},-\goyunit){% + \addtocounter{#1}{1}% + \ifthenelse{\value{#1} > 8}% + {\addtocounter{#1}{1}\golabelformat{\Alph{#1}}\addtocounter{#1}{-1}}% + {\golabelformat{\Alph{#1}}}% + \addtocounter{#1}{-1}}% + \setlength{\tmply}{#2\goyunit}% + \rput[B](\value{#1},\tmply){% + \addtocounter{#1}{1}% + \ifthenelse{\value{#1} > 8}% + {\addtocounter{#1}{1}\golabelformat{\Alph{#1}}\addtocounter{#1}{-1}}% + {\golabelformat{\Alph{#1}}}% + \addtocounter{#1}{-1}}% + \stepcounter{#1}% + }% + }% +\newcommand{\ypositionmarks}[2]{% + \whiledo{\value{#1} < #2}{% + \addtocounter{#1}{1}% + \edef\ypos{\arabic{#1}}% + \addtocounter{#1}{-1}% + \rput[r](-\goxunit,\value{#1}){\golabelformat{\ypos}}% + \setlength{\tmplx}{#2\goxunit}% + \rput[l](\tmplx,\value{#1}){\golabelformat{\ypos}}% + \stepcounter{#1}% + }% + }% + +\def\psgosetboardsizes(#1,#2)(#3,#4){% + \def\psgollx{#1}% + \def\psgolly{#2}% + \ifthenelse{#3 > \value{boardsize}}{\def\psgourx{\value{boardsize}}}{\def\psgourx{#3}}% + \ifthenelse{#4 > \value{boardsize}}{\def\psgoury{\value{boardsize}}}{\def\psgoury{#4}}% +} +\newboolean{withindices}% +\setboolean{withindices}{true}% +\newenvironment{psgopartialboard}[2][19]{% + \setcounter{boardsize}{#1}% + \psgosetboardsizes#2% + \psset{xunit=\goxunit,yunit=\goyunit}% + \ifthenelse{\boolean{withindices}}% + {\def\xoffset{2\goxunit}\def\yoffset{2\goyunit}}% + {\def\xoffset{.5\goxunit}\def\yoffset{.5\goyunit}}% + \ifthenelse{\psgollx = 1 \or \psgollx < 1}% + {\def\psgollxval{-\xoffset}}% + {\setlength{\tmplx}{\psgollx\goxunit - 1\goxunit}\edef\psgollxval{\the\tmplx}}% + \ifthenelse{\psgolly = 1 \or \psgolly < 1}% + {\def\psgollyval{-\yoffset}}% + {\setlength{\tmply}{\psgolly\goyunit - 1\goyunit}\edef\psgollyval{\the\tmply}}% + \ifthenelse{\psgourx = \value{boardsize} \or \psgourx > \value{boardsize}}% + {\setlength{\tmplx}{\value{boardsize}\goxunit - \goxunit + \xoffset}% + \edef\psgourxval{\the\tmplx}}% + {\def\psgourxval{\psgourx\goxunit}}% + \ifthenelse{\psgoury = \value{boardsize} \or \psgoury > \value{boardsize}}% + {\setlength{\tmply}{\value{boardsize}\goyunit - \goyunit + \yoffset}% + \edef\psgouryval{\the\tmply}}% + {\def\psgouryval{\psgoury\goyunit}}% + \begin{pspicture}(\psgollxval,\psgollyval)(\psgourxval,\psgouryval)% + \ifthenelse{\psgollx = 1 \or \psgollx < 1}% + {\def\psgollxval{-\xoffset}}% + {\setlength{\tmplx}{\psgollx\goxunit - 1.5\goxunit}\edef\psgollxval{\the\tmplx}}% + \ifthenelse{\psgolly = 1 \or \psgolly < 1}% + {\def\psgollyval{-\yoffset}}% + {\setlength{\tmply}{\psgolly\goyunit - 1.5\goyunit}\edef\psgollyval{\the\tmply}}% + \ifthenelse{\psgourx = \value{boardsize} \or \psgourx > \value{boardsize}}% + {\setlength{\tmplx}{\value{boardsize}\goxunit - \goxunit + \xoffset}% + \edef\psgourxval{\the\tmplx}}% + {\setlength{\tmplx}{\psgourx\goxunit - .5\goxunit}% + \edef\psgourxval{\the\tmplx}}% + \ifthenelse{\psgoury = \value{boardsize} \or \psgoury > \value{boardsize}}% + {\setlength{\tmply}{\value{boardsize}\goyunit - \goyunit + \yoffset}% + \edef\psgouryval{\the\tmply}}% + {\setlength{\tmply}{\psgoury\goyunit - .5\goyunit}% + \edef\psgouryval{\the\tmply}}% + %% uncomment the following line to get a visual bounding box + %% \psframe[linecolor=green,linewidth=0.4pt](\psgollxval,\psgollyval)(\psgourxval,\psgouryval) + \psclip{\psframe[linecolor=white,linewidth=0](\psgollxval,\psgollyval)(\psgourxval,\psgouryval)}% + \setlength{\tmply}{\value{boardsize}\goyunit + 0.5\goyunit}% + \setlength{\tmplx}{\value{boardsize}\goxunit + 0.5\goxunit}% + \addtolength{\tmply}{-1.5\goyunit}% + \addtolength{\tmplx}{-1.5\goxunit}% + \multips(0,0)(1,0){\value{boardsize}}{\psline[linewidth=0.2pt](0,0)(0,\tmply)}% + \multips(0,0)(0,1){\value{boardsize}}{\psline[linewidth=0.2pt](0,0)(\tmplx,0)}% + \psframe[linewidth=1pt](0,0)(\tmplx,\tmply)% + \ifthenelse{\boolean{withindices}}{% + \setcounter{gotmpc}{0}% + \xpositionmarks{gotmpc}{\value{boardsize}}% + \setcounter{gotmpc}{0}% + \ypositionmarks{gotmpc}{\value{boardsize}}% + }{\relax}% + \ifthenelse{\equal{\value{boardsize}}{19}}{% + \multips(3,3)(0,6){3}{\pscircle[fillstyle=solid,fillcolor=black](0,0){.15\goxunit}}% + \multips(9,3)(0,6){3}{\pscircle[fillstyle=solid,fillcolor=black](0,0){.15\goxunit}}% + \multips(15,3)(0,6){3}{\pscircle[fillstyle=solid,fillcolor=black](0,0){.15\goxunit}}% + }{\relax}% + \begin{gomoves}% + }% + {\end{gomoves}% + \endpsclip% + \end{pspicture}% + }% +\newenvironment{psgoboard}[1][19]{% + \begin{psgopartialboard}[#1]{(0,0)(#1,#1)}% +}{% + \end{psgopartialboard}% +} + +\newenvironment{psgopartialboard*}[2][19]{% + \setboolean{withindices}{false}% + \begin{psgopartialboard}[#1]{#2}% +}{\end{psgopartialboard}} + +\newenvironment{psgoboard*}[1][19]{% + \begin{psgopartialboard*}[#1]{(0,0)(#1,#1)}% +}{% + \end{psgopartialboard*}% +} + +\newcommand{\nomark}{\relax}% +\newcommand{\factor}{0.28284271247461901}% = 2/5 * sin(1/4 * pi) +\newcommand{\markma}{% + \psline[linewidth=1.4pt](-\factor,-\factor)(\factor,\factor)% + \psline[linewidth=1.4pt](-\factor,\factor)(\factor,-\factor)% + } +\newcommand{\marktr}{% + \rput(0,-0.3\goxunit){\pstriangle(-0.66\goxunit,0.66\goxunit)}% + }% +\newcommand{\markcr}{% + \pscircle(0,0){0.33\goxunit}% + } +\newcommand{\marksq}{% + \psframe(-0.33\goxunit,-0.33\goxunit)(0.33\goxunit,0.33\goxunit)% + } +\newcommand{\marklb}[1]{% + \rput(0,0){\golabelformat{#1}}% + }% +\newcommand{\marksl}{% + \psframe[fillstyle=solid,fillcolor=gray,linecolor=gray](-0.22\goxunit,-0.22\goxunit)(0.22\goxunit,0.22\goxunit)% + }% +\newcommand{\markdd}{% + \psframe[dimen=middle,fillstyle=vlines,hatchsep=2pt,hatchwidth=0.2pt,hatchangle=\hatchangle,linestyle=none]% + (-0.5\goxunit,-0.5\goyunit)(0.5\goxunit,0.5\goyunit)% + }% +\newcommand{\stone}[2][\relax]{% + \setlength{\tmply}{-0.5\goxunit + 0.5ex}% + \raisebox{\tmply}{\psset{unit=\goxunit}\begin{pspicture}(-0.5,-0)(0.5,1)% + \pscircle[fillstyle=solid,fillcolor=#2](0,0.5){0.5}% + \ifthenelse{\equal{#2}{black}}% + {\rput(0,0.5){{\psset{linecolor=white}\color{white}\golabelformat{#1}}}}% + {\rput(0,0.5){{\psset{linecolor=black}\color{black}\golabelformat{#1}}}}% + \end{pspicture}}} -- 2.11.4.GIT