As the title says, the square Go board is easy to draw with lots of Go board packages, such as igo or psgo. But there is no way to draw a non square Go board support. How do I draw rectangular Go boards?

I have found a paper that draw these Go boards, but don't know how it was done...

The paper is:

van der Werf, Erik CD, and Mark HM Winands. "Solving Go for rectangular boards." Icga Journal 32.2 (2009): 77-88.

  • 1
    Welcome to TeX.Se Please post an MWE showing what you've tried – Thorbjørn E. K. Christensen Apr 4 at 9:38
  • the igo package is not currently in my LaTeX distrubution, but As far as I can tell, you wan't to redefine the places where the goban is defined. I think you wan't to change the command \gobansize{n} to \gobansize{n}{m} To draw a rectangular board. – Thorbjørn E. K. Christensen Apr 4 at 9:48
  • looking at the source I see that igo is plain TeX, I have no idea how to create an optional argument to have non-square go boards. – Thorbjørn E. K. Christensen Apr 4 at 9:52
  • I think the best way is to use psgo as it seems like it has the ability to draw the boards you wan't just not a way of doing it for the end user. – Thorbjørn E. K. Christensen Apr 4 at 10:05

This is really easy to do using tikz. Here is a really quick mock-up of a macro \GoBoard for drawing beads on a go board to produce:

enter image description here

The syntax for the macro is:

 \GoBoard[x-dim][y-dim]{list of white pieces}{list of black pieces}

where the lists of white and black pieces are comma separated lists of coordinates. The y-dimension of the board is optional, defaulting to the x-dimension. The image above was drawn using

\GoBoard{7}[6]{(2,1),(2,2),(2,3),(2,4),(3,4),(4,3),(5,3),(5,2),(5,1)}
           {(3,1),(3,2),(3,3),(4,4),(5,4),(6,4),(6,3),(6,2),(6,1)}

There is almost no styling in the code below, but it would be easy to add this, for example, by consulting the comprehensive tikz manual.

Here is the full MWE:

\documentclass{article}
\usepackage{tikz}
\usepackage{xparse}

% \GoBoard[x-dim][y-dim]{list of white pieces}{list of black pieces}
\NewDocumentCommand\GoBoard{ m O{#1} m m}{%
  \begin{tikzpicture}[
        white/.style={ball color=white},% add styling to suit your tastes
        black/.style={ball color=black}
     ]
     % first draw the grid
     \foreach \x in {0,...,#1} {
       \draw[thick](\x,0)--++(0,#2);
     }
     \foreach \y in {0,...,#2} {
       \draw[thick](0,\y)--++(#1,0);
     }
     % now draw the white pieces
     \foreach \wh in {#3} {
       \shade[white] \wh circle (5mm);
     }
     % now draw the black pieces
     \foreach \bl in {#4} {
       \shade[black] \bl circle (5mm);
     }
  \end{tikzpicture}%
}
\begin{document}

\GoBoard{7}[6]{(2,1),(2,2),(2,3),(2,4),(3,4),(4,3),(5,3),(5,2),(5,1)}
           {(3,1),(3,2),(3,3),(4,4),(5,4),(6,4),(6,3),(6,2),(6,1)}

\end{document}
  • That is exactly what I need, thanks! – qwerty Apr 5 at 4:48

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.