TransWikia.com

What package for board game that's not chess and is closer to othello?

TeX - LaTeX Asked on September 4, 2021

I’d like to typeset a board game that (visually speaking) is closer to Othello — because it uses round stones. The package othelloboard is almost perfect. My main concern is that I need a different board. The board I need doesn’t contain the corners, to cite one difference and that’s almost the only difference: just remove the corners. But there’s one more difference: the first and last rows and file should be a tiny bit detached from the 6×6 inner board. (That’s less important than removing the corners.)

So I’m looking for a package that lets me choose which squares belong to the board and also let me separate ranks and rows by small distance so as to create this visual-detachment.

I think the ideal thing for me would be make changes to the othelloboard package so that I can redesign the board and apply a separation to the "outer ring" of the "inner 6×6 board". Because for everything else I need, othelloboard seems to be perfect.

Is there a package that’s just perfect for this request or should I really go along with othelloboard and change its source code to fix my needs? Thank you.

One Answer

The MWE below shows a modification of the othelloboard package to remove the corner fields and to separate the outer rows and columns from the inner 6x6 board with a thick line.

I opted not to change the actual position of the outer rows and columns because that would require a full rewrite of everything in the package that has to do with drawing at specific coordinates (which would amount to a very large number of changes).

Apart from the grid drawing also the two environments othelloboard and othelloboardnorefs needed to be changed, because the original definition draws a frame around the board (which is actually not necessary because the outer lines are also drawn in the grid).

MWE:

documentclass{article}
usepackage{othelloboard}

% redefinition to remove frame around board
renewenvironment{othelloboard}[1]%
{renewcommand{scalefactor}{#1} begin{lrbox}{fmboard}begin{picture}(192,192)resetalldisccolours othellogrid gridrefs}
{end{picture} end{lrbox} scalebox{scalefactor}{begin{picture}(208,208)(-16,0) usebox{fmboard} end{picture}}}

renewenvironment{othelloboardnorefs}[1]%
{renewcommand{scalefactor}{#1} begin{lrbox}{fmboard}begin{picture}(192,192)resetalldisccolours othellogrid}
{end{picture} end{lrbox} scalebox{scalefactor}{begin{picture}(192,192)(0,0) usebox{fmboard} end{picture}}}

% redefinition of grid
renewcommand{othellogrid}{%
% outside lines, shorter to cut off corners
begingroup % start of linethickness scope
linethickness{0.8mm}
put(0,24){line(0,1){144}}   % bottom left to top left
put(192,24){line(0,1){144}} % top right to bottom right
put(24,0){line(1,0){144}}   % bottom left to bottom right
put(24,192){line(1,0){144}} % top left to top right
% inside lines
% lines around the 6x6 inner board
put(24,0){line(0,1){192}}
put(168,0){line(0,1){192}}
put(0,24){line(1,0){192}}
put(0,168){line(1,0){192}}
endgroup % end of linethickness scope
% other inner lines
put(48,0){line(0,1){192}}
put(72,0){line(0,1){192}}
put(96,0){line(0,1){192}}
put(120,0){line(0,1){192}}
put(144,0){line(0,1){192}}
put(0,48){line(1,0){192}}
put(0,72){line(1,0){192}}
put(0,96){line(1,0){192}}
put(0,120){line(1,0){192}}
put(0,144){line(1,0){192}}
}

begin{document}
begin{othelloboard}{1}
othelloarrayfirstrow   {0}{0}{0}{0}{0}{0}{0}{0}
othelloarraysecondrow  {0}{0}{2}{0}{0}{0}{0}{0}
othelloarraythirdrow   {0}{1}{2}{2}{2}{0}{0}{0}
othelloarrayfourthrow  {0}{1}{2}{1}{2}{1}{0}{0}
othelloarrayfifthrow   {0}{0}{2}{2}{1}{1}{0}{0}
othelloarraysixthrow   {0}{0}{2}{1}{1}{1}{0}{0}
othelloarrayseventhrow {0}{0}{0}{0}{0}{0}{0}{0}
othelloarrayeighthrow  {0}{0}{0}{0}{0}{0}{0}{0}
end{othelloboard}
end{document}

Result:

enter image description here


Edit: a filled square can be printed using a rule of 24pt width and height. With a double for-loop (for example using the forloop package) you can draw a checkered board. To separate the inner board from the outer rows and columns (the thick line is hard to see with the checkered squares) you can draw a gray rectangle around the inner squares.

MWE:

documentclass{article}
usepackage{othelloboard}
usepackage{forloop}
usepackage{xcolor}

% redefinition to remove frame around board
renewenvironment{othelloboard}[1]%
{renewcommand{scalefactor}{#1} begin{lrbox}{fmboard}begin{picture}(192,192)resetalldisccolours othellogrid gridrefs}
{end{picture} end{lrbox} scalebox{scalefactor}{begin{picture}(208,208)(-16,0) usebox{fmboard} end{picture}}}

renewenvironment{othelloboardnorefs}[1]%
{renewcommand{scalefactor}{#1} begin{lrbox}{fmboard}begin{picture}(192,192)resetalldisccolours othellogrid}
{end{picture} end{lrbox} scalebox{scalefactor}{begin{picture}(192,192)(0,0) usebox{fmboard} end{picture}}}

% some variables for checkered board loops
newcounter{xsquare}
newcounter{ysquare}
newcounter{shiftsquare}
newcounter{skipsquare}

% redefinition of grid
renewcommand{othellogrid}{%
% outside lines, shorter to cut off corners
begingroup % start of linethickness scope
linethickness{0.8mm}
put(0,24){line(0,1){144}}   % bottom left to top left
put(192,24){line(0,1){144}} % top right to bottom right
put(24,0){line(1,0){144}}   % bottom left to bottom right
put(24,192){line(1,0){144}} % top left to top right
% inside lines
put(24,0){line(0,1){192}}
put(168,0){line(0,1){192}}
put(0,24){line(1,0){192}}
put(0,168){line(1,0){192}}
endgroup % end of linethickness scope
put(48,0){line(0,1){192}}
put(72,0){line(0,1){192}}
put(96,0){line(0,1){192}}
put(120,0){line(0,1){192}}
put(144,0){line(0,1){192}}
put(0,48){line(1,0){192}}
put(0,72){line(1,0){192}}
put(0,96){line(1,0){192}}
put(0,120){line(1,0){192}}
put(0,144){line(1,0){192}}
%
% double for loop for checkered board
% loop rows
forloop[24]{ysquare}{0}{value{ysquare}<192}{%
% shift or shift back one square after every row
ifnumvalue{shiftsquare}=0setcounter{shiftsquare}{24}elsesetcounter{shiftsquare}{0}fi
% loop columns
forloop[48]{xsquare}{value{shiftsquare}}{value{xsquare}<192}{%
% check for skipping corners
setcounter{skipsquare}{0}
% bottom right corner
ifnumvalue{ysquare}=0ifnumvalue{xsquare}=168%
setcounter{skipsquare}{1}fifi
% top left corner
ifnumvalue{ysquare}=168ifnumvalue{xsquare}=0%
setcounter{skipsquare}{1}fifi
% draw black square if not one of the two corners
ifnumvalue{skipsquare}=0%
put(thexsquare,theysquare){rule{24pt}{24pt}}%
fi
}% end loop columns
}% end loop rows
% gray frame around inner board
begingroup
color{gray}
linethickness{1.2mm}
put(24,24){line(0,1){144}}
put(168,24){line(0,1){144}}
put(24,24){line(1,0){144}}
put(24,168){line(1,0){144}}
endgroup
}

begin{document}
begin{othelloboard}{1}
othelloarrayfirstrow   {0}{0}{0}{0}{0}{0}{0}{0}
othelloarraysecondrow  {0}{0}{2}{0}{0}{0}{0}{0}
othelloarraythirdrow   {0}{1}{2}{2}{2}{0}{0}{0}
othelloarrayfourthrow  {0}{1}{2}{1}{2}{1}{0}{0}
othelloarrayfifthrow   {0}{0}{2}{2}{1}{1}{0}{0}
othelloarraysixthrow   {0}{0}{2}{1}{1}{1}{0}{0}
othelloarrayseventhrow {0}{0}{0}{0}{0}{0}{0}{0}
othelloarrayeighthrow  {0}{0}{0}{0}{0}{0}{0}{0}
end{othelloboard}
end{document}

Result:

enter image description here

If you also want to put pieces on black squares then you can modify the code that is used for drawing pieces (blackdisc and whitedisc) to use colors other than plain black and white. Below I've used dark gray and off-white with two circles around the pieces.

definecolor{offwhite}{RGB}{255,255,244}
definecolor{dimgray}{RGB}{42,42,42}
renewcommand{blackdisc}{linethickness{0.5mm}color{dimgray}circle*{19}color{gray}circle{19.4}linethickness{0.2mm}circle{15}}
renewcommand{whitedisc}{linethickness{0.5mm}color{offwhite}circle*{19}color{gray}circle{19.4}linethickness{0.2mm}circle{15}}

enter image description here

Correct answer by Marijn on September 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP