summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-02-24 22:51:32 +0000
committerKarl Berry <karl@freefriends.org>2013-02-24 22:51:32 +0000
commit0219257c1cda008db95d3b429139b8e0613c2044 (patch)
tree93d55263e91988738f35b416099784a0a9182bdb
parenta3c0a64b48a59420321a3e0f3279daf232b2bcc5 (diff)
battleship (24feb13)
git-svn-id: svn://tug.org/texlive/trunk@29220 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/battleship/CHANGES16
-rw-r--r--Master/texmf-dist/doc/latex/battleship/README22
-rw-r--r--Master/texmf-dist/doc/latex/battleship/battleship.pdfbin75083 -> 82593 bytes
-rw-r--r--Master/texmf-dist/doc/latex/battleship/battleship.tex131
-rw-r--r--Master/texmf-dist/doc/latex/battleship/manifest.txt1
-rw-r--r--Master/texmf-dist/tex/latex/battleship/battleship.sty227
-rw-r--r--Master/texmf-dist/tex/latex/battleship/logicpuzzle.sty176
7 files changed, 413 insertions, 160 deletions
diff --git a/Master/texmf-dist/doc/latex/battleship/CHANGES b/Master/texmf-dist/doc/latex/battleship/CHANGES
index 72fcddffa39..d9bafc783e9 100644
--- a/Master/texmf-dist/doc/latex/battleship/CHANGES
+++ b/Master/texmf-dist/doc/latex/battleship/CHANGES
@@ -1,3 +1,19 @@
+-- battleship.sty (v1.2) --
+
+19/02/2013 implemented \classicgame [jk]
+ for drawing game sheets for classic Battleship
+
+18/02/2013 implemented option title [jk]
+ -> \titleformat
+
+18/02/2013 implemented option counterstyle [jk]
+ -> \puzzlecounter, \setpuzzlecounter
+ \definecounterstyle
+
+17/02/2013 implemented option bgcolor [jk]
+
+17/02/2013 moved code base for logic puzzles into logicpuzzle.sty [jk]
+
-- battleship.sty (v1.1) --
12/02/2013 added \placewater [jk]
diff --git a/Master/texmf-dist/doc/latex/battleship/README b/Master/texmf-dist/doc/latex/battleship/README
index 941e5abc6e0..33265b42220 100644
--- a/Master/texmf-dist/doc/latex/battleship/README
+++ b/Master/texmf-dist/doc/latex/battleship/README
@@ -6,19 +6,13 @@ of ship segments in the respective columns and rows.
License: LPPL
-Changes in v1.1:
+Changes in v1.2:
-- added \placeship
- place a complete ship at (column,row) in direction {V|H}
- with length (length)
+- added options title, counterstyle and bgcolor
+ -> \puzzlecounter, \setpuzzlecounter,
+ \definecounterstyle, \titleformat
+
+- added \classicgame
+ drawing game sheets for classic Battleship
-- added \placewater
- puts a water marker into the grid
-
-- added \placeisland
- puts an island with random outline into the grid
-
-- renamed \ship -> \placesegment
-
-- added \battleshipsetup
- resetting global options \ No newline at end of file
+- moved logic puzzle code base to logicpuzzle.sty \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/battleship/battleship.pdf b/Master/texmf-dist/doc/latex/battleship/battleship.pdf
index fe67f807ed3..8a2cc7819bc 100644
--- a/Master/texmf-dist/doc/latex/battleship/battleship.pdf
+++ b/Master/texmf-dist/doc/latex/battleship/battleship.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/battleship/battleship.tex b/Master/texmf-dist/doc/latex/battleship/battleship.tex
index acf15a6a2fd..e05a6a8baec 100644
--- a/Master/texmf-dist/doc/latex/battleship/battleship.tex
+++ b/Master/texmf-dist/doc/latex/battleship/battleship.tex
@@ -16,11 +16,11 @@
sbindent=0.6cm,sbwidth=3.4cm]{battleship}%
\usepackage{hyperref}
%
-\makeatletter
\setlength{\headheight}{1.1\baselineskip}%
%
\hypersetup{colorlinks=true,urlcolor=NavyBlue,linkcolor=NavyBlue,citecolor=CornflowerBlue,naturalnames=true,hypertexnames=false}%
-\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny,basicstyle=\ttfamily\small,frame=single,backgroundcolor=\color{LightGoldenrodYellow},keywordstyle=\color{Blue},emph={mathstyle,style}, emphstyle=\color{Tomato},emph={[2]rows,columns,width,shipcolor,fontsize,scale,sbindent,sbwidth,sbshipscale},emphstyle={[2]\color{SeaGreen}},morekeywords={battleship,,placeship,placesegment,ship,shipH,shipV,shipbox,Ship,ShipC,ShipL,ShipR,ShipB,ShipT,[,]}}
+\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny,basicstyle=\ttfamily\small,frame=single,backgroundcolor=\color{LightGoldenrodYellow},keywordstyle=\color{Blue},emph={mathstyle,style}, emphstyle=\color{Tomato},emph={[2]rows,columns,width,shipcolor,fontsize,scale,sbindent,sbwidth,sbshipscale},emphstyle={[2]\color{SeaGreen}},morekeywords={titleformat,definecounterstyle,marginnote,tikz,node,puzzlecounter,color,battleship,,placeship,placesegment,ship,shipH,shipV,shipbox,Ship,ShipC,ShipL,ShipR,ShipB,ShipT,[,]}}
+\makeatletter
\renewcommand{\maketitle}%
{%
\thispagestyle{empty}%
@@ -124,7 +124,7 @@ sbindent=0.6cm,sbwidth=3.4cm]{battleship}%
\newcommand*\mco[1]{\mbox{\LANGLE\itshape#1\RANGLE}\index{#1, class option value}\index{class option value>#1}}%
%
\renewcommand\@biblabel[1]{\makebox[1.5cm][l]{[#1]}}
-\renewcommand*\l@subsection{\@dottedtocline{2}{1.2em}{2.3em}}
+\renewcommand*\l@subsection{\@dottedtocline{2}{1.2em}{2.8em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{2.4em}{3.7em}}
\makeatother
%
@@ -135,10 +135,9 @@ sbindent=0.6cm,sbwidth=3.4cm]{battleship}%
\title{\filename}%
\Subtitle{A style file for typesetting Battleship logic puzzles}%
\author{Josef Kleber}
-\Fileversion{v1.1}
+\Fileversion{v1.2}
\Refline{\href{mailto:josef.kleber@gmx.de}{\texttt{josef.kleber@gmx.de}}\\\href{https://bitbucket.org/kleberj/battleship/}{\texttt{https://bitbucket.org/kleberj/battleship/}}}
\maketitle
-
\tableofcontents
\clearpage
@@ -147,42 +146,44 @@ sbindent=0.6cm,sbwidth=3.4cm]{battleship}%
Try to find the positions of the ships listed below the puzzle. The numbers on the side of the puzzle reveals how many ship segments can be found in the rows and columns. All remaining fields indicate 'water'. Consider the following rules: The ships are arranged horizontally and vertically. No ship touches another ship at any point, not even diagonally. Here's a little self-explanatory example:
\begin{center}
-\begin{battleship}
-\placesegment{4}{1}{\ShipR}
-\shipH{4,1,2,2,2}
-\shipV{3,1,4,0,3}
-\shipbox{3,3,2,2,1}
-\end{battleship}
-\hspace{1cm}
-\begin{battleship}
-\placeship{V}{1}{1}{3}
-\placeship{H}{1}{5}{2}
-\placeship{H}{3}{1}{2}
-\placeship{H}{3}{3}{3}
-\placeship{H}{5}{5}{1}
-\shipH{4,1,2,2,2}
-\shipV{3,1,4,0,3}
-\end{battleship}
+ \begin{battleship}
+ \placesegment{4}{1}{\ShipR}
+ \shipH{4,1,2,2,2}
+ \shipV{3,1,4,0,3}
+ \shipbox{3,3,2,2,1}
+ \end{battleship}
+ \hspace{1cm}
+ \begin{battleship}
+ \placeship{V}{1}{1}{3}
+ \placeship{H}{1}{5}{2}
+ \placeship{H}{3}{1}{2}
+ \placeship{H}{3}{3}{3}
+ \placeship{H}{5}{5}{1}
+ \shipH{4,1,2,2,2}
+ \shipV{3,1,4,0,3}
+ \end{battleship}
\end{center}
\bigskip
\begin{lstlisting}
-\begin{battleship}
-\placesegment{4}{1}{\ShipR}
-\shipH{4,1,2,2,2}
-\shipV{3,1,4,0,3}
-\shipbox{3,3,2,2,1}
-\end{battleship}
-\hspace{1cm}
-\begin{battleship}
-\placeship{V}{1}{1}{3}
-\placeship{H}{1}{5}{2}
-\placeship{H}{3}{1}{2}
-\placeship{H}{3}{3}{3}
-\placeship{H}{5}{5}{1}
-\shipH{4,1,2,2,2}
-\shipV{3,1,4,0,3}
-\end{battleship}
+\begin{center}
+ \begin{battleship}
+ \placesegment{4}{1}{\ShipR}
+ \shipH{4,1,2,2,2}
+ \shipV{3,1,4,0,3}
+ \shipbox{3,3,2,2,1}
+ \end{battleship}
+ \hspace{1cm}
+ \begin{battleship}
+ \placeship{V}{1}{1}{3}
+ \placeship{H}{1}{5}{2}
+ \placeship{H}{3}{1}{2}
+ \placeship{H}{3}{3}{3}
+ \placeship{H}{5}{5}{1}
+ \shipH{4,1,2,2,2}
+ \shipV{3,1,4,0,3}
+ \end{battleship}
+\end{center}
\end{lstlisting}
\clearpage
\section{Options}
@@ -198,6 +199,12 @@ With the option \styleoption{width}, you can set the width of the minipage, in w
With the option \styleoption{scale}, you can scale the size of the grid in the minipage.
\subsection[\texttt{fontsize}]{\styleoption{fontsize} (\underline{\texttt{Large}})}
With the option \styleoption{fontsize}, you can specify the size of the numbers next to the grid. Here, the usual \LaTeX\ sizes are used. Possible values: \texttt{tiny}, \texttt{scriptsize}, \texttt{footnotesize}, \texttt{small}, \texttt{normalsize}, \texttt{large}, \underline{\texttt{Large}}, \texttt{LARGE}, \texttt{huge}, \texttt{Huge})
+\subsection[\texttt{title}]{\styleoption{title} (\underline{\texttt{\{\}}})}
+With the option \styleoption{title}, you can specify the title of a puzzle.
+\subsection[\texttt{counterstyle}]{\styleoption{counterstyle} (\underline{\texttt{none}}),left,right}
+With the option \styleoption{counterstyle}, you can define the counter style.
+\subsection[\texttt{bgcolor}]{\styleoption{bgcolor} (\underline{\texttt{\{\}}})}
+With the option \styleoption{bgcolor}, you can set the background color of the grid.
\subsection[\texttt{sbindent}]{\styleoption{sbindent} (\underline{\texttt{0.75cm}})}
With the option \styleoption{sbindent}, you can define the indent of the ship box below the grid.
\subsection[\texttt{sbwidth}]{\styleoption{sbwidth} (\underline{\texttt{5.15cm}})}
@@ -208,9 +215,10 @@ With the option \styleoption{sbshipscale}, you can scale the size of the ships i
\subsection{\texttt{battleship}}
The \env{battleship} environment\marginnote{\hbadness=10000\RaggedLeft\scriptsize\envb{battleship}\oarg{options}\\\dots\\\enve{battleship}} is the central core of the style file. With the optional argument of the environment, you can reset the options with local scope. Here, a blank grid is created that you can fill with ships using other commands.
\section{Commands}
-\subsection{\texttt{placeship}}
+\subsection{Ships, water, islands, ...}
+\subsubsection{\texttt{placeship}}
With the command \cs{placeship}\margcs{\cmd\placeship\{\marg{direction}\}\\\{\marg{column}\}\{\marg{row}\}\{\marg{length}\}} you can place complete ships in the grid. It expects the specification of the direction as horizontal (H) or vertical (V). Furthermore, it requires the starting coordinates and the length of the ship.
-\subsection{\texttt{placesegment}}
+\subsubsection{\texttt{placesegment}}
The command \cs{placesegment}\margcs{\cmd\placesegment\{\marg{column}\}\{\marg{row}\}\\\{\marg{ship segment}\}} is used for the placement of ship segments in the grid. In the mandatory argument \marg{ship segment}, you can use the following commands:
\begin{center}
@@ -220,20 +228,49 @@ The command \cs{placesegment}\margcs{\cmd\placesegment\{\marg{column}\}\{\marg{r
\cs{ShipB} & \scalebox{.5}{\ShipB} & \scalebox{.5}{\ShipT} & \cs{ShipT} \\
\end{tabular}
\end{center}
-\subsection{\texttt{ship}}
+\subsubsection{\texttt{ship}}
The command \cs{ship} was replaced by the \cs{placesegment} command. The command \cs{ship} is deprecated and should not be used longer. It may still be used, but it is not recommended.
-\subsection{\texttt{placewater}}
+\subsubsection{\texttt{placewater}}
With the command \cs{placewater}\margcs{\cmd\placewater\{\marg{column}\}\{\marg{row}\}} you can place water markers ( \raisebox{2pt}{\Water} ) in the grid.
-\subsection{\texttt{placeisland}}
+\subsubsection{\texttt{placeisland}}
With the command \cs{placeisland}\margcs{\cmd\placeisland\{\marg{column}\}\{\marg{row}\}} you can place islands ( \raisebox{-2pt}{\resizebox{!}{10pt}{\Island}} ) in the grid. The island outlines are created randomly: \raisebox{-2pt}{\resizebox{!}{10pt}{\Island}}, \raisebox{-2pt}{\resizebox{!}{10pt}{\Island}}, \raisebox{-2pt}{\resizebox{!}{10pt}{\Island}}, ...
-\subsection{\texttt{shipH}}
+\subsection{Presentation}
+\subsubsection{\texttt{shipH}}
The command \cs{shipH}\margcs{\cmd\shipH\{\marg{csv list}\}} typesets the horizontal numbers above the grid. It expects a comma-separated list as an argument.
-\subsection{\texttt{shipV}}
+\subsubsection{\texttt{shipV}}
The command \cs{shipV}\margcs{\cmd\shipV\{\marg{csv list}\}} typesets the vertical numbers beside the grid. It also expects a comma separated list.
-\subsection{\texttt{shipbox}}
+\subsubsection{\texttt{shipbox}}
The command \cs{shipbox}\margcs{\cmd\shipbox\{\marg{csv list}\}} defines the number and size of the ships, which are typeset under the grid.
-\subsection{\texttt{battleshipsetup}}
+\subsubsection{\texttt{definecounterstyle}}
+The command \cs{definecounterstyle}\margcs{\cmd\definecounterstyle\{\marg{name}\}\\\{\marg{definition}\}} allows you to define your own styles. For example, the style \texttt{left} is defined as follows:
+
+\begin{lstlisting}
+\definecounterstyle{left}{
+ \begingroup\reversemarginpar\marginnote{
+ \tikz\node[shape=rectangle,fill=yellow!40,inner sep=7pt,
+ draw,rounded corners=3pt,thick]
+ {\Huge\puzzlecounter};}[-23pt]\endgroup
+}
+\end{lstlisting}
+
+To typeset the counter into the margin we use the command \cmd\marginnote. We need to use the command \cmd\reversemarginpar\ to set the counter into the left margin. Of course, we must use this command in a group for local scope. Finally we use \cmd\puzzlecounter\ in a \cmd\tikz\ node with a vertical offset of 23 points.
+\subsubsection{\texttt{puzzlecounter}}
+The command \cs{puzzlecounter}\margcs{\cmd\puzzlecounter} provides the counter in textual form to use it for example in \cmd\definecounterstyle.
+\subsubsection{\texttt{titleformat}}
+With the command \cs{titleformat}\margcs{\cmd\titleformat\{\marg{format}\}}, you can define the format of the title. By default, the definition is as follows:
+
+\begin{lstlisting}
+\titleformat{\centering\Large\color{blue}}
+\end{lstlisting}
+\subsection{Miscellaneous}
+\subsubsection{\texttt{battleshipsetup}}
With the command \cs{battleshipsetup}\margcs{\cmd\battleshipsetup\{\marg{options}\}} you can reset the options with global scope.
+\subsubsection{\texttt{classicgame}}
+The command \cs{classicgame}\margcs{\cmd\classicgame\{\marg{csv list}\}} typesets a game sheet for playing classic Battleship. It expects a comma separated list with the number and sizes of the ships.
+\subsubsection{\texttt{setpuzzlecounter}}
+With the command \cs{setpuzzlecounter}\margcs{\cmd\setpuzzlecounter\{\marg{number}\}}, you can reset the puzzle counter, for example before the solutions.
\section{Examples \& Solutions}
-You\marginnote{\includegraphics[height=2cm]{qrcode.png}} can download application examples and their solutions from the \href{https://bitbucket.org/kleberj/battleship/}{project site}. The puzzles are originally licensed under \href{http://creativecommons.org/licenses/by-nc-sa/3.0/}{\ccbyncsa}.
+You\marginnote{\includegraphics[height=2cm]{qrcode.png}} can download application examples and their solutions from the \href{https://bitbucket.org/kleberj/battleship/}{project page}. The puzzles are originally licensed under \href{http://creativecommons.org/licenses/by-nc-sa/3.0/}{\ccbyncsa}.
+
+You can also download a \href{https://bitbucket.org/kleberj/battleship/downloads/classicsheet.pdf}{game sheet} for playing the classic Battleship.
\end{document}
diff --git a/Master/texmf-dist/doc/latex/battleship/manifest.txt b/Master/texmf-dist/doc/latex/battleship/manifest.txt
index a9506e78d60..1cac21bbfba 100644
--- a/Master/texmf-dist/doc/latex/battleship/manifest.txt
+++ b/Master/texmf-dist/doc/latex/battleship/manifest.txt
@@ -3,6 +3,7 @@ This work consists of the following files:
-- Styles --
+logicpuzzle.sty
battleship.sty
-- Documentation --
diff --git a/Master/texmf-dist/tex/latex/battleship/battleship.sty b/Master/texmf-dist/tex/latex/battleship/battleship.sty
index 2195ddb8e84..e7b106df3b1 100644
--- a/Master/texmf-dist/tex/latex/battleship/battleship.sty
+++ b/Master/texmf-dist/tex/latex/battleship/battleship.sty
@@ -23,15 +23,10 @@
% http://en.wikipedia.org/wiki/Battleship_%28puzzle%29
% http://de.wikipedia.org/wiki/Bimaru
%
-\ProvidesPackage{battleship}[2013/02/16 battleship.sty v1.1 - Josef Kleber (C) 2013]%
+\ProvidesPackage{battleship}[2013/02/23 battleship.sty v1.2 - Josef Kleber (C) 2013]%
%
-\RequirePackage{xkeyval}%
-\RequirePackage{ifthen}%
-\RequirePackage{ragged2e}%
-\RequirePackage{etoolbox}%
-\RequirePackage{tikz}%
-\usetikzlibrary{decorations.pathmorphing}
-\tikzstyle{island} = [fill=yellow!30,draw, decorate, decoration={random steps,segment length=2.7pt,amplitude=1.7pt}]
+\RequirePackage{logicpuzzle}%
+\tikzstyle{island} = [fill=yellow!30,draw, decorate, decoration={random steps,segment length=2.7pt,amplitude=1.7pt}]%
%
% options
\newcommand*\BS@width{6cm}%
@@ -39,18 +34,17 @@
\newcommand*\BS@rows{5}%
\newcommand*\BS@columns{5}%
\newcommand*\BS@scale{1}%
+\newcommand*\BS@bgcolor{}%
\newcommand*\BS@shipcolor{green}%
+\newcommand*\BS@title{}%
+\newcommand*\BS@titleindent{0.75cm}%
+\newcommand*\BS@titlewidth{5.15cm}%
\newcommand*\BS@SB@indent{0.75cm}%
\newcommand*\BS@SB@width{5.15cm}%
\newcommand*\BS@SB@shipboxscale{1}%
%
\newcounter{BS@rows}%
\newcounter{BS@columns}%
-\newcounter{BS@counti}%
-\newcounter{BS@countii}%
-\newcounter{BS@countiii}%
-\newcounter{BS@countiv}%
-\newcounter{BS@whiledo}%
%
\setcounter{BS@rows}{\BS@rows}%
\setcounter{BS@columns}{\BS@columns}%
@@ -77,9 +71,19 @@
\renewcommand*\BS@scale{#1}%
}%
%
+\define@key{battleship.sty}{counterstyle}[none]%
+{%
+ \renewcommand*\LP@counterstyle{#1}%
+}%
+%
+\define@key{battleship.sty}{bgcolor}[]%
+{%
+ \renewcommand*\BS@bgcolor{#1}%
+}%
+%
\define@choicekey*{battleship.sty}{fontsize}[\BS@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]%
{%
- \ifcase\nr\relax
+ \ifcase\nr\relax%
\renewcommand*\BS@fontsize{\tiny}%
\or%
\renewcommand*\BS@fontsize{\scriptsize}%
@@ -107,6 +111,21 @@
\renewcommand*\BS@width{#1}%
}%
%
+\define@key{battleship.sty}{title}[]%
+{%
+ \renewcommand*\BS@title{#1}%
+}%
+%
+\define@key{battleship.sty}{titleindent}[0.75cm]%
+{%
+ \renewcommand*\BS@titleindent{#1}%
+}%
+%
+\define@key{battleship.sty}{titlewidth}[5.15cm]%
+{%
+ \renewcommand*\BS@titlewidth{#1}%
+}%
+%
\define@key{battleship.sty}{sbindent}[0.75cm]%
{%
\renewcommand*\BS@SB@indent{#1}%
@@ -142,9 +161,19 @@
\renewcommand*\BS@scale{#1}%
}%
%
+\define@key{battleship}{bgcolor}%
+{%
+ \renewcommand*\BS@bgcolor{#1}%
+}%
+%
+\define@key{battleship}{counterstyle}%
+{%
+ \renewcommand*\LP@counterstyle{#1}%
+}%
+%
\define@choicekey*{battleship}{fontsize}[\BS@fontsize\nr]{tiny,scriptsize,footnotesize,small,normalsize,large,Large,LARGE,huge,Huge}[Large]%
{%
- \ifcase\nr\relax
+ \ifcase\nr\relax%
\renewcommand*\BS@fontsize{\tiny}%
\or%
\renewcommand*\BS@fontsize{\scriptsize}%
@@ -172,6 +201,21 @@
\renewcommand*\BS@width{#1}%
}%
%
+\define@key{battleship}{title}%
+{%
+ \renewcommand*\BS@title{#1}%
+}%
+%
+\define@key{battleship}{titleindent}%
+{%
+ \renewcommand*\BS@titleindent{#1}%
+}%
+%
+\define@key{battleship}{titlewidth}%
+{%
+ \renewcommand*\BS@titlewidth{#1}%
+}%
+%
\define@key{battleship}{sbindent}%
{%
\renewcommand*\BS@SB@indent{#1}%
@@ -187,11 +231,10 @@
\renewcommand*\BS@SB@shipboxscale{#1}%
}%
%
-\ExecuteOptionsX{rows,columns,width,fontsize,shipcolor,scale,sbindent,sbwidth,sbshipscale}%
+\ExecuteOptionsX{rows,columns,width,fontsize,shipcolor,scale,bgcolor,counterstyle,title,titleindent,titlewidth,sbindent,sbwidth,sbshipscale}%
%
\ProcessOptionsX\relax%
%
-\newcommand*\BS@Pfive{.5}%
\gdef\BS@shipbox{}%
%
\newcommand*\Ship{\tikz[scale=\BS@scale]\draw[scale=.36,fill=\BS@shipcolor] (0,0) circle (1);}%
@@ -210,52 +253,6 @@
\newcommand*\@ShipL{\tikz\draw[scale=.144,fill=\BS@shipcolor](1,2)--(2,2)--(2,0)--(1,0) arc (270:90:1);}%
\newcommand*\@ShipR{\tikz\draw[scale=.144,fill=\BS@shipcolor](1,2)--(0,2)--(0,0)--(1,0) arc (270:450:1);}%
%
-\newcommand*\BS@shipparts[3]%
-{%
- \node at (#1\BS@Pfive,#2\BS@Pfive){\BS@fontsize#3};%
-}%
-%
-\newcommand*\BS@printpartsH[1]%
-{%
- \stepcounter{BS@counti}%
- \BS@shipparts{\arabic{BS@counti}}{\arabic{BS@countii}}{#1}%
-}%
-%
-\newcommand*\BS@printpartsV[1]%
-{%
- \stepcounter{BS@countii}%
- \BS@shipparts{\arabic{BS@counti}}{\arabic{BS@countii}}{#1}%
-}%
-%
-\newcommand*\BS@ingrid[2]%
-{%
- \setcounter{BS@countiii}{#1}% column
- \setcounter{BS@countiv}{#2}% row
- \ifnum\value{BS@countiii}<1%
- \PackageError{battleship}%
- {ship segment outside of the grid}%
- {You tried to set a ship segment at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (\BS@columns,\BS@rows)}%
- \fi%
- \ifnum\value{BS@countiv}<1%
- \PackageError{battleship}%
- {ship segment outside of the grid}%
- {You tried to set a ship segment at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (\BS@columns,\BS@rows)}%
- \fi%
- % BS@columns = \BS@columns + 1
- \stepcounter{BS@countiii}%
- \stepcounter{BS@countiv}%
- \ifnum\value{BS@countiii}>\value{BS@columns}%
- \PackageError{battleship}%
- {ship segment outside of the grid}%
- {You tried to set a ship segment at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (\BS@columns,\BS@rows)}%
- \fi%
- \ifnum\value{BS@countiv}>\value{BS@rows}%
- \PackageError{battleship}%
- {ship segment outside of the grid}%
- {You tried to set a ship segment at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (\BS@columns,\BS@rows)}%
- \fi%
-}%
-%
\newcommand*\BS@printship[1]%
{%
\ifthenelse{\equal{#1}{1}}{\scalebox{\BS@SB@shipboxscale}{\@Ship}\space\allowbreak}{}%
@@ -272,41 +269,37 @@
%
\newcommand*\BS@printshipbox[1]%
{% \expandafters needed because csv list is stored in macro
- \expandafter\forcsvlist\expandafter\BS@printship\expandafter{#1}
+ \expandafter\forcsvlist\expandafter\BS@printship\expandafter{#1}%
}%
%
\newcommand*\shipH[1]%
{%
- \setcounter{BS@countii}{\value{BS@rows}}%
- \setcounter{BS@counti}{0}%
- \forcsvlist\BS@printpartsH{#1}%
+ \LP@setcolumncontents{#1}{1}{\value{BS@rows}}{\BS@fontsize}%
}%
%
\newcommand*\shipV[1]%
{%
- \setcounter{BS@countii}{0}%
- \setcounter{BS@counti}{0}%
- \forcsvlist\BS@printpartsV{#1}%
+ \LP@setrowcontents{#1}{0}{1}{\BS@fontsize}%
}%
%
\newcommand*\placesegment[3]%
{%
- \BS@ingrid{#1}{#2}%
- \node at (#1\BS@Pfive,#2\BS@Pfive){#3};%
+ \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}%
+ \LP@setcellcontent{#1}{#2}{#3}%
}%
%
\let\ship\placesegment%
%
\newcommand*\placeisland[2]%
{%
- \BS@ingrid{#1}{#2}%
- \node at (#1\BS@Pfive,#2\BS@Pfive){\Island};%
+ \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}%
+ \LP@setcellcontent{#1}{#2}{\Island}%
}%
%
\newcommand*\placewater[2]%
{%
- \BS@ingrid{#1}{#2}%
- \node at (#1\BS@Pfive,#2\BS@Pfive){\Water};%
+ \LP@ingrid{#1}{#2}{\BS@columns}{\BS@rows}{battleship}%
+ \LP@setcellcontent{#1}{#2}{\Water}%
}%
%
\newcommand*\shipbox[2][]%
@@ -317,53 +310,54 @@
%
\newcommand*\placeship[4]%
{%
- \setcounter{BS@counti}{#4}% length
- \ifnum\value{BS@counti}<1%
+ \setcounter{LP@counti}{#4}% length
+ \ifnum\value{LP@counti}<1%
\PackageError{battleship}%
{ship length < 1}%
{The length of your ship should be at least 1}%
\fi%
- \ifnum\value{BS@counti}>10%
+ \ifnum\value{LP@counti}>10%
\PackageError{battleship}%
{ship length > 10}%
{The supported max length of ships is 10!}%
\fi%
- \ifnum\value{BS@counti}=1%
+ \ifnum\value{LP@counti}=1%
\placesegment{#2}{#3}{\Ship}%
\else%
- \setcounter{BS@whiledo}{\value{BS@counti}}%
- \addtocounter{BS@whiledo}{-2}% length of middle ship
+ \setcounter{LP@whiledo}{\value{LP@counti}}%
+ \addtocounter{LP@whiledo}{-2}% length of middle ship
\ifthenelse{\equal{#1}{V}}%
{%
\placesegment{#2}{#3}{\ShipB}%
- \setcounter{BS@countii}{#3}%
- \whiledo{\value{BS@whiledo}>0}%
+ \setcounter{LP@countii}{#3}%
+ \whiledo{\value{LP@whiledo}>0}%
{%
- \addtocounter{BS@whiledo}{-1}%
- \stepcounter{BS@countii}%
- \placesegment{#2}{\theBS@countii}{\ShipC}%
+ \addtocounter{LP@whiledo}{-1}%
+ \stepcounter{LP@countii}%
+ \placesegment{#2}{\theLP@countii}{\ShipC}%
}%
- \stepcounter{BS@countii}%
- \placesegment{#2}{\theBS@countii}{\ShipT}%
+ \stepcounter{LP@countii}%
+ \placesegment{#2}{\theLP@countii}{\ShipT}%
}%
{%
\ifthenelse{\equal{#1}{H}}%
{%
\placesegment{#2}{#3}{\ShipL}%
- \setcounter{BS@counti}{#2}%
- \whiledo{\value{BS@whiledo}>0}%
+ \setcounter{LP@counti}{#2}%
+ \whiledo{\value{LP@whiledo}>0}%
{%
- \addtocounter{BS@whiledo}{-1}%
- \stepcounter{BS@counti}%
- \placesegment{\theBS@counti}{#3}{\ShipC}%
+ \addtocounter{LP@whiledo}{-1}%
+ \stepcounter{LP@counti}%
+ \placesegment{\theLP@counti}{#3}{\ShipC}%
}%
- \stepcounter{BS@counti}%
- \placesegment{\theBS@counti}{#3}{\ShipR}%
+ \stepcounter{LP@counti}%
+ \placesegment{\theLP@counti}{#3}{\ShipR}%
}%
{\PackageError{battleship}%
{invalid direction (H/V)}%
{You can place your ship only\MessageBreak%
- horizontally (H) or vertically (V)!}}%
+ horizontally (H) or vertically (V)!}%
+ }%
}%
\fi%
}%
@@ -373,6 +367,35 @@
\setkeys{battleship.sty}{#1}%
}%
%
+\newcommand{\classicgame}[1]%
+{%
+ \begin{center}%
+ \begin{battleship}[rows=10,columns=10,width=6.5cm,title=Me,sbindent=0.65cm,titleindent=0.55cm,titlewidth=5.7cm,sbwidth=5.7cm,scale=0.59,fontsize=normalsize]%
+ \shipV{J,I,H,G,F,E,D,C,B,A}%
+ \shipH{1,2,3,4,5,6,7,8,9,10}%
+ \shipbox{#1}%
+ \end{battleship}%
+ \hspace{1cm}%
+ \begin{battleship}[rows=10,columns=10,width=6.5cm,title=Enemy,sbindent=0.65cm,titleindent=0.55cm,titlewidth=5.7cm,sbwidth=5.7cm,scale=0.59,fontsize=normalsize]%
+ \shipV{J,I,H,G,F,E,D,C,B,A}%
+ \shipH{1,2,3,4,5,6,7,8,9,10}%
+ \end{battleship}%
+ \end{center}%
+ \par\vspace{1cm}%
+ \begin{center}%
+ \begin{battleship}[rows=10,columns=10,width=6.5cm,title=Me,sbindent=0.65cm,titleindent=0.55cm,titlewidth=5.7cm,sbwidth=5.7cm,scale=0.59,fontsize=normalsize]%
+ \shipV{J,I,H,G,F,E,D,C,B,A}%
+ \shipH{1,2,3,4,5,6,7,8,9,10}%
+ \shipbox{#1}%
+ \end{battleship}%
+ \hspace{1cm}%
+ \begin{battleship}[rows=10,columns=10,width=6.5cm,title=Enemy,sbindent=0.65cm,titleindent=0.55cm,titlewidth=5.7cm,sbwidth=5.7cm,scale=0.59,fontsize=normalsize]%
+ \shipV{J,I,H,G,F,E,D,C,B,A}%
+ \shipH{1,2,3,4,5,6,7,8,9,10}%
+ \end{battleship}%
+ \end{center}%
+}%
+%
\newenvironment{battleship}[1][]%
{%
\setkeys{battleship}{#1}%
@@ -382,13 +405,19 @@
\stepcounter{BS@rows}%
\stepcounter{BS@columns}%
\begin{minipage}[t]{\BS@width}%
+ \ifthenelse{\equal{\BS@title}{}}%
+ {\par\enspace\par}% empty
+ {\enspace\par\noindent\hspace{\BS@titleindent}\parbox{\BS@titlewidth}{\strut\LP@titleformat\BS@title}\vspace{3mm}\par}%
\begin{tikzpicture}[scale=\BS@scale]%
- \draw[step=1cm] (1,1) grid (\value{BS@columns},\value{BS@rows});%
+ \LP@drawbackground{1}{1}{\BS@columns}{\BS@rows}{\BS@bgcolor}%
+ \LP@drawgrid{1}{1}{\BS@columns}{\BS@rows}{1cm}%
}%
{%
\end{tikzpicture}%
+ \LP@drawcounter{\LP@counterstyle}%
\par\hbadness=10000\medskip\noindent\hspace{\BS@SB@indent}\begin{minipage}{\BS@SB@width}{\hbadness=10000\RaggedRight\BS@printshipbox{\BS@shipbox}}\end{minipage}%
- \end{minipage}
+ \stepcounter{LP@puzzlecounter}%
+ \end{minipage}%
}%
%
\endinput% \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/battleship/logicpuzzle.sty b/Master/texmf-dist/tex/latex/battleship/logicpuzzle.sty
new file mode 100644
index 00000000000..0d408428934
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/battleship/logicpuzzle.sty
@@ -0,0 +1,176 @@
+%%
+%% Copyright (C) 2013 by:
+%% Josef Kleber
+%% <josef.kleber@gmx.de>
+%%
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 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.3 or later is part of all distributions of LaTeX version
+%% 2003/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "author-maintained".
+%%
+%% The Current Maintainer of this work is Josef Kleber.
+%%
+%% This work consists of all files listed in manifest.txt.
+%%
+\ProvidesPackage{logicpuzzle}[2013/02/23 logicpuzzle.sty v1.0 - Josef Kleber (C) 2013]%
+%
+\RequirePackage{xkeyval}%
+\RequirePackage{ifthen}%
+\RequirePackage{ragged2e}%
+\RequirePackage{etoolbox}%
+\RequirePackage{marginnote}%
+\RequirePackage{tikz}%
+\usetikzlibrary{decorations.pathmorphing}%
+%
+\newcounter{LP@counti}%
+\newcounter{LP@countii}%
+\newcounter{LP@countiii}%
+\newcounter{LP@countiv}%
+\newcounter{LP@whiledo}%
+\newcounter{LP@puzzlecounter}%
+\setcounter{LP@puzzlecounter}{1}%
+%
+\newcommand*\LP@counterstyle{none}%
+\newcommand*\LP@titleformat{}%
+%
+\newcommand*\LP@Pfive{.5}%
+%
+\newcommand*\LP@ingrid[5]%
+{%
+ \setcounter{LP@counti}{#1}% column
+ \setcounter{LP@countii}{#2}% row
+ \setcounter{LP@countiii}{#3}% max column
+ \setcounter{LP@countiv}{#4}% max row
+ %#5 style
+ %
+ \ifnum\value{LP@counti}<1%
+ \PackageError{#5}%
+ {element outside of the grid}%
+ {You tried to set an element at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (#3,#4)}%
+ \fi%
+ \ifnum\value{LP@countii}<1%
+ \PackageError{#5}%
+ {element outside of the grid}%
+ {You tried to set an element at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (#3,#4)}%
+ \fi%
+ \ifnum\value{LP@counti}>\value{LP@countiii}%
+ \PackageError{#5}%
+ {element outside of the grid}%
+ {You tried to set an element at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (#3,#4)}%
+ \fi%
+ \ifnum\value{LP@countii}>\value{LP@countiv}%
+ \PackageError{#5}%
+ {element outside of the grid}%
+ {You tried to set an element at (#1,#2),\MessageBreak which is outside the grid (1,1) .. (#3,#4)}%
+ \fi%
+}%
+%
+\newcommand*\titleformat[1]%
+{%
+ \renewcommand*\LP@titleformat{#1}%
+}%
+\titleformat{\centering\Large\color{blue}}%
+%
+\newcommand*\puzzlecounter{\theLP@puzzlecounter}%
+%
+\newcommand*\setpuzzlecounter[1]%
+{%
+ \setcounter{LP@puzzlecounter}{#1}%
+}%
+\newcommand*{\definecounterstyle}[2]%
+{%
+ \expandafter\gdef\csname LP@cs@#1\endcsname{#2}%
+}%
+%
+\definecounterstyle{none}{}%
+\definecounterstyle{left}{\begingroup\reversemarginpar\marginnote{\tikz\node[shape=rectangle,fill=yellow!40,inner sep=7pt,draw,rounded corners=3pt,thick]{\Huge\puzzlecounter};}[-23pt]\endgroup}%
+\definecounterstyle{right}{\marginnote{\tikz\node[shape=rectangle,fill=yellow!40,inner sep=7pt,draw,rounded corners=3pt,thick]{\Huge\puzzlecounter};}[-23pt]}%
+%
+% #1 grid x min
+% #2 grid y min
+% #3 grid x max
+% #4 grid y max
+% #5 step
+\newcommand*\LP@drawgrid[5]%
+{%
+ \setcounter{LP@counti}{#3}% max column
+ \setcounter{LP@countii}{#4}% max row
+ \stepcounter{LP@counti}%
+ \stepcounter{LP@countii}%
+ \draw[step=#5] (#1,#2) grid (\value{LP@counti},\value{LP@countii});%
+}%
+%
+% #1 grid x min
+% #2 grid y min
+% #3 grid x max
+% #4 grid y max
+% #5 bgcolor
+\newcommand*\LP@drawbackground[5]%
+{%
+ \ifthenelse{\equal{#5}{}}%
+ {}% no bgcolor
+ {%
+ \setcounter{LP@counti}{#3}% max column
+ \setcounter{LP@countii}{#4}% max row
+ \stepcounter{LP@counti}%
+ \stepcounter{LP@countii}%
+ \draw[fill=#5] (#1,#2) rectangle (\value{LP@counti},\value{LP@countii});%
+ }%
+}%
+%
+% #1 counterstyle
+\newcommand*\LP@drawcounter[1]%
+{%
+ \csname LP@cs@#1\endcsname%
+}%
+%
+% #1 column
+% #2 row
+% #3 content
+\newcommand*\LP@setcellcontent[3]%
+{%
+ \node at (#1\LP@Pfive,#2\LP@Pfive){#3};%
+}%
+%
+% #1 csv list
+% #2 column
+% #3 row
+% #4 fontsize
+\newcommand*\LP@setcolumncontents[4]%
+{%
+ \setcounter{LP@counti}{#2}%
+ \setcounter{LP@countii}{#3}%
+ \forcsvlist\LP@setcolumncontents@i{#4#1}%
+}%
+%
+\newcommand*\LP@setcolumncontents@i[1]%
+{%
+ \LP@setcellcontent{\arabic{LP@counti}}{\arabic{LP@countii}}{#1}%
+ \stepcounter{LP@counti}%
+}%
+%
+% #1 csv list
+% #2 column
+% #3 row
+% #4 fontsize
+\newcommand*\LP@setrowcontents[4]%
+{%
+ \setcounter{LP@counti}{#2}%
+ \setcounter{LP@countii}{#3}%
+ \forcsvlist\LP@setrowcontents@i{#4#1}%
+}%
+%
+\newcommand*\LP@setrowcontents@i[1]%
+{%
+ \LP@setcellcontent{\arabic{LP@counti}}{\arabic{LP@countii}}{#1}%
+ \stepcounter{LP@countii}%
+}%
+%
+\endinput% \ No newline at end of file