From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/hexgame/README | 5 ++ macros/latex/contrib/hexgame/hexgame.pdf | Bin 0 -> 33071 bytes macros/latex/contrib/hexgame/hexgame.sty | 97 ++++++++++++++++++++++++++++++ macros/latex/contrib/hexgame/hexgame.tex | 98 +++++++++++++++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 macros/latex/contrib/hexgame/README create mode 100644 macros/latex/contrib/hexgame/hexgame.pdf create mode 100644 macros/latex/contrib/hexgame/hexgame.sty create mode 100644 macros/latex/contrib/hexgame/hexgame.tex (limited to 'macros/latex/contrib/hexgame') diff --git a/macros/latex/contrib/hexgame/README b/macros/latex/contrib/hexgame/README new file mode 100644 index 0000000000..22fa8163f2 --- /dev/null +++ b/macros/latex/contrib/hexgame/README @@ -0,0 +1,5 @@ +Hex is a mathematical game invented by the Danish mathematician Piet Hein +and independently by the mathematician John Nash. This package defines a new +environment that enables the user to draw such a game in a trivial way. + +This package is under the LaTeX Project Public License version 1.2 or later. \ No newline at end of file diff --git a/macros/latex/contrib/hexgame/hexgame.pdf b/macros/latex/contrib/hexgame/hexgame.pdf new file mode 100644 index 0000000000..b471541a37 Binary files /dev/null and b/macros/latex/contrib/hexgame/hexgame.pdf differ diff --git a/macros/latex/contrib/hexgame/hexgame.sty b/macros/latex/contrib/hexgame/hexgame.sty new file mode 100644 index 0000000000..97a7d71e5d --- /dev/null +++ b/macros/latex/contrib/hexgame/hexgame.sty @@ -0,0 +1,97 @@ +%% +%% This is file `hexgame.sty', +%% +%% -------------------------------------------------------------------------- +%% +%% This file 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. +%% +%% File: hexgame.sty Copyright (C) 2006 Meron Brouwer (meron.brouwer@gmail.com) +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{hexgame} + [2006/08/01 v1.0 `hexgame' package] +\RequirePackage{pstcol} +\RequirePackage{pst-poly} +\RequirePackage{calc} +\RequirePackage{ifthen} +\newlength\halfhexheight +\setlength\halfhexheight{0.866025404cm} +\newlength\halfhexwidth +\setlength\halfhexwidth{1cm} +\newlength\hexgameboxwidth +\setlength\hexgameboxwidth{0.45\textwidth} +\newlength\hexgameheight +\newlength\halfhexgameheight +\newlength\hexgamewidth +\newlength\halfhexgamewidth +\newlength\startpointx +\newlength\startpointy +\newsavebox\hexgamebox +\definecolor{playerone}{rgb}{0,0, .8} +\definecolor{playertwo}{rgb}{0.8,0,0} +\newcounter{hexboardsize} +\newenvironment{hexgame}[1] + {\psset{unit=1cm,PstPicture=false} + \setcounter{hexboardsize}{#1} + \setlength\hexgamewidth{(#1\halfhexwidth*2)+(#1\halfhexwidth)+(\halfhexwidth)} + \setlength\hexgameheight{(#1\halfhexheight*2)+(\halfhexheight)} + \setlength\halfhexgameheight{0.5\hexgameheight} + \setlength\halfhexgamewidth{0.5\hexgamewidth} + \setlength\startpointx{0.5\hexgamewidth} + \setlength\startpointy{1.5\halfhexheight} + \begin{lrbox}{\hexgamebox} + \begin{pspicture}(\the\hexgamewidth,\the\hexgameheight)% + \psframe[fillstyle=solid,fillcolor=playerone,linewidth=0.8pt](0,0)(\the\halfhexgamewidth,\the\halfhexgameheight) + \psframe[fillstyle=solid,fillcolor=playerone,linewidth=0.8pt](\the\halfhexgamewidth,\the\halfhexgameheight)(\the\hexgamewidth,\the\hexgameheight) + \psframe[fillstyle=solid,fillcolor=playertwo,linewidth=0.8pt](0,\the\hexgameheight)(\the\halfhexgamewidth,\the\halfhexgameheight) + \psframe[fillstyle=solid,fillcolor=playertwo,linewidth=0.8pt](\the\halfhexgamewidth,\the\halfhexgameheight)(\the\hexgamewidth,0) + \psdiamond(\the\halfhexgamewidth,\the\halfhexgameheight)(\the\halfhexgamewidth,\the\halfhexgameheight) + \multirput(\the\startpointx,\the\startpointy)(1.5cm,\halfhexheight){#1}{ + \multirput(0,0)(-1.5cm,\halfhexheight){#1}{\PstHexagon[linewidth=0.5pt,unit=1cm,fillstyle=solid,fillcolor=white]}}} + {\end{pspicture} + \end{lrbox} + \psscaleboxto(\the\hexgameboxwidth,0){\usebox{\hexgamebox}}} +\newlength\refpointx +\newlength\refpointy +\newlength\nexthexx +\newlength\nexthexy +\newcounter{stepcounter} +\newcounter{modulocounter} +\newcounter{squaredboardsize} +\newcommand\colorhex[2]{\setcounter{stepcounter}{\value{hexboardsize}} + \setcounter{modulocounter}{#1} + \setcounter{squaredboardsize}{\value{hexboardsize}*\value{hexboardsize}} + \ifthenelse{#1>\value{squaredboardsize}}{\PackageWarning{hexgame}{Number to big}}{ + \setlength\refpointx{\startpointx} + \addtolength{\refpointx}{0.5mm} + \setlength\refpointy{\startpointy} + \whiledo{\value{stepcounter}<#1}{\addtocounter{stepcounter}{\value{hexboardsize}} + \addtolength{\refpointx}{-1.5\halfhexwidth} + \addtolength{\refpointy}{\halfhexheight} + \addtocounter{modulocounter}{-\value{hexboardsize}}} + \setlength\nexthexx{(\refpointx)+1.5\halfhexwidth*((\value{modulocounter})-1)} + \setlength\nexthexy{(\refpointy)+\halfhexheight*((\value{modulocounter})-1)} + \rput(\the\nexthexx,\the\nexthexy){\PstHexagon[linewidth=0.5pt,unit=1cm,fillstyle=solid,fillcolor=#2]}}} +\newcommand\labelhex[2]{\setcounter{stepcounter}{\value{hexboardsize}} + \setcounter{modulocounter}{#1} + \setcounter{squaredboardsize}{\value{hexboardsize}*\value{hexboardsize}} + \ifthenelse{#1>\value{squaredboardsize}}{\PackageWarning{hexgame}{Number to big}}{ + \setlength\refpointx{\startpointx} + \addtolength{\refpointx}{0.5mm} + \setlength\refpointy{\startpointy} + \whiledo{\value{stepcounter}<#1}{\addtocounter{stepcounter}{\value{hexboardsize}} + \addtolength{\refpointx}{-1.5\halfhexwidth} + \addtolength{\refpointy}{\halfhexheight} + \addtocounter{modulocounter}{-\value{hexboardsize}}} + \setlength\nexthexx{(\refpointx)+1.5\halfhexwidth*((\value{modulocounter})-1)} + \setlength\nexthexy{(\refpointy)+\halfhexheight*((\value{modulocounter})-1)} + \rput(\the\nexthexx,\the\nexthexy){\textbf{\large #2}}}} +%% +%% End of file `hexgame.sty'. + + diff --git a/macros/latex/contrib/hexgame/hexgame.tex b/macros/latex/contrib/hexgame/hexgame.tex new file mode 100644 index 0000000000..3e2088abf9 --- /dev/null +++ b/macros/latex/contrib/hexgame/hexgame.tex @@ -0,0 +1,98 @@ +\documentclass{article} +% +% Use the following packages ------------ +\usepackage{hexgame} +% Paper definitions --------------------- +\setlength\paperheight {297mm}% +\setlength\paperwidth {210mm}% +\setlength\textwidth {165mm}% +\setlength\evensidemargin {-4mm}% +\setlength\oddsidemargin {-4mm}% +\setlength\topmargin {-12mm}% +\setlength\headheight {6mm}% +\setlength\headsep {4mm}% +\setlength\textheight {254mm} +\setlength\parindent {0mm} +\setlength\parskip {\baselineskip} +\setlength\unitlength {1mm} +\pagestyle{empty} +\begin{document} +\begin{center} + \textbf{\Huge hexgame.sty} + + Meron Brouwer \\ + (meron.brouwer@gmail.com)\\ + \today +\end{center} + +\section{Introduction} +Hex is a mathematical game invented by the Danish mathematician Piet Hein and independently by the mathematician John Nash. This package defines a new +environment that enables the user to draw such a game in a trivial way. + +\section{Usage} +The package defines a new environment and two new commands. The environment is used to draw the board, the commands are used to color the hexagons or label them. + + \begin{minipage}{80mm} + \verb+\begin{hexgame}{5}+ \\ + \verb+ \colorhex{2}{playerone}+ \\ + \verb+ \colorhex{4}{playertwo}+ \\ + \verb+ \colorhex{6}{playertwo}+ \\ + \verb+ \colorhex{25}{playerone}+ \\ + \verb+ \labelhex{23}{37}+\\ + \verb+\end{hexgame}+ + \end{minipage} + \begin{minipage}{85mm} + \begin{hexgame}{5} + \colorhex{2}{playerone} + \colorhex{4}{playertwo} + \colorhex{6}{playertwo} + \colorhex{25}{playerone} + \labelhex{23}{37} + \end{hexgame} + \end{minipage} + +The hexagons are numbered from $1$ to $n^2$, starting at the bottom one. The argument after \verb+\begin{hexgame}+ gives $n$. When coloring a hexagon, the first argument gives which hexagon needs to be colored, the second argument defines the player that colored the hexagon. When labeling, the second argument will be printed in the hexagon. + +\section{Variables to set} +Although everything is already defined the following variables can be reset by the user + +\begin{itemize} + \item \verb+ \setlength\hexgameboxwidth{0.45\textwidth}+ \\ + This length gives the width the hexgame. All games are scaled to this width. + \item \verb+ \definecolor{playerone}{rgb}{0,0, .8}+ \\ + playerone is a color, in this case set to blue. Use the same if you would like + this player to be a different color. See the pstricks manual for more information. + \item \verb+ \definecolor{playertwo}{rgb}{0.8,0,0}+ \\ + Same as playerone. +\end{itemize} + +\begin{center} +\begin{hexgame}{3} + \colorhex{2}{playerone} + \colorhex{4}{playerone} + \colorhex{6}{playertwo} + \colorhex{9}{playertwo} + \labelhex{8}{6} + \labelhex{9}{7} +\end{hexgame} +\begin{hexgame}{16} + \colorhex{2}{playerone} + \colorhex{4}{playerone} + \colorhex{6}{playerone} + \colorhex{3}{playertwo} + \colorhex{12}{playertwo} + \colorhex{11}{playertwo} + \colorhex{23}{playertwo} + \colorhex{41}{playertwo} + \colorhex{19}{playertwo} + \colorhex{51}{playertwo} + \labelhex{51}{4} +\end{hexgame} +\end{center} +\end{document} + + + + + + -- cgit v1.2.3