logicpuzzle

A LaTeX style file for typesetting logic puzzles

User Tools

Site Tools


slitherlink

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

slitherlink [2015/09/06 09:52] (current)
Line 1: Line 1:
 +<​markdown>​
 +Slitherlink
 +===========
  
 +The puzzle
 +----------
 +
 +Draw a closed line into the grid. This line must be on the existing dashed lines, but do not have to go through all grid points. If numbers are present in the grid cells, they indicate how many sides of the cell are touched by the line. The line must not touch or cross itself. Here’s a little self-explanatory example:
 +
 +![Slitherlink](http://​i.imgur.com/​pdxmfF3.png)
 +
 +    \begin{center}
 +      \begin{slitherlink}
 +        \setbigcell{1}{1}{4}
 +        \slitherlinkcell{1}{3}{3}
 +        \slitherlinkcell{3}{1}{3}
 +        \slitherlinkcell{3}{3}{0}
 +        \slitherlinkcell{3}{4}{3}
 +        \slitherlinkcell{4}{4}{2}
 +        \slitherlinkcell{5}{1}{0}
 +        \slitherlinkcell{5}{2}{2}
 +      \end{slitherlink}
 +      \hspace{1.5cm}
 +      \begin{slitherlink}
 +        \setbigcell{1}{1}{4}
 +        \slitherlinkcell{1}{3}{3}
 +        \slitherlinkcell{3}{1}{3}
 +        \slitherlinkcell{3}{3}{0}
 +        \slitherlinkcell{3}{4}{3}
 +        \slitherlinkcell{4}{4}{2}
 +        \slitherlinkcell{5}{1}{0}
 +        \slitherlinkcell{5}{2}{2}
 +        \framearea{black}{\tikzpath{3}{1}{8,​8,​4,​4,​8,​6,​6,​8,​6,​2,​
 +                                          6,​6,​2,​4,​2,​4,​2,​4}}
 +      \end{slitherlink}
 +    \end{center}
 +
 +Options
 +-------
 +
 ++ `rows (5)`
 +defines the number of rows in the grid
 +
 ++ `columns (5)`
 +specifies the number of columns in the grid
 +
 ++ `width (5.2cm)`
 +sets the width of the minipage, in which the grid is typeset
 +
 ++ `scale (1)`
 +scales the size of the grid in the minipage
 +
 ++ `fontsize (Large)`
 +specifies the size of the numbers next to the grid. Here, the usual LaTeX sizes are used. Possible values: tiny, scriptsize, footnotesize,​ small, normalsize, large, **Large**, LARGE, huge, Huge
 +
 ++ `title ()`
 +sets the title of a puzzle
 +
 ++ `titleindent (0cm)`
 +defines the indent of the title
 +
 ++ `titlewidth (5.2cm)`
 +specifies the width of the box the title is set in
 +
 ++ `bgcolor ()`
 +sets the background color of the grid
 +
 ++ `counterstyle (none)`
 +defines the counter style. Predefined styles: **none**, left, right
 +
 ++ `cvoffset (-23pt)`
 +sets the vertical offset of the counters in the margin
 +
 +Environments
 +------------
 +
 +###​slitherlink
 +
 +    \begin{slitherlink}
 +
 +    \end{slitherlink}
 +
 +The environment `slitherlink` 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.
 +
 +###​puzzlebackground
 +
 +    \begin{puzzlebackground}
 +
 +    \end{puzzlebackground}
 +
 +The `puzzlebackground` environment allows you to place elements behind the main layer. This
 +is for example usefull for the `\fillarea` command.
 +
 +###​puzzleforeground
 +
 +    \begin{puzzleforeground}
 +
 +    \end{puzzleforeground}
 +
 +The `puzzleforeground` environment allows you to place elements in front of the main layer.
 +This is for example usefull for the `\framearea` command.
 +
 +Commands
 +--------
 +
 +### In the grid and around
 +
 +#### slitherlinkcell
 +
 +`\slitherlinkcell{column}{row}{number}`
 +
 +The command sets the `{number}` of the grid cell `{column}{row}`.
 +
 +#### setbigcell
 +
 +`\setbigcell[fontsize]{column}{row}{number}`
 +
 +With the `\setbigcell` command, you can set `number` into a big (`2x2`) cell as central node. The optional argument `fontsize` is set to ’Huge’ by default.
 +
 +#### setrow
 +
 +`\setrow{row}{csv list}`
 +
 +The command sets the contents of `{row}`. It expects a comma-separated list.
 +
 +#### setcolumn
 +
 +`\setcolumn{column}{csv list}`
 +
 +The command sets the contents of `{column}`.
 +
 +#### framearea
 +
 +`\framearea{color}{\tikz path}`
 +
 +The command frames the area given by `{\tikz path}` with color `{color}`. The reference for coordinates is the bottom left corner of the cell.
 +
 +`\framearea{green}{(2,​2)--(2,​3)--(3,​3)--(3,​2)--(2,​2)}`
 +
 +This command will color the frame of the grid cell `(2,2)` green. You should consider using this command in the `puzzleforeground` environment.
 +
 +#### tikzpath
 +
 +`\tikzpath{column}{row}{csv list}`
 +
 +With the `\tikzpath` command, you can easily construct a `\tikz` path. You just need to define a starting point (bottom left corner) and a `csv list` with direction indicators relative to the current position.
 +
 +-----
 +
 +    7: up left       8: up            9: up right
 +    4: left          5: no change ​    6: right
 +    1: down left     2: down          3: down right
 +
 +-----
 +
 +    \framearea{green}{\tikzpath{2}{2}{8,​6,​2,​4}}
 +
 +This command will frame grid cell `(2,2)` green.
 +
 +Presentation
 +------------
 +
 +###​Presentation
 +
 +#### definecounterstyle
 +
 +The command allows you to define your own styles. For example, the style `left` is defined as follows:
 +
 +    \definecounterstyle{left}{
 +      \begingroup\reversemarginpar\marginnote{
 +      \tikz\node[shape=rectangle,​fill=yellow!40,​inner sep=7pt,
 +                 ​draw,​rounded corners=3pt,​thick]
 +      {\Huge\puzzlecounter};​}[\LP@cvoffset]\endgroup}
 +    }
 +
 +To typeset the counter into the margin we use the command `\marginnote`. We need to use the command `\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 `\puzzlecounter` in a `\tikz` node with a vertical offset set with the option `cvoffset`.
 +
 +#### puzzlecounter
 +
 +`\puzzlecounter`
 +
 +The command provides the counter in textual form to use it for example in `\definecounterstyle`.
 +
 +#### titleformat
 +
 +`\titleformat{format}`
 +
 +With the command `\titleformat`,​ you can define the format of the title. By default, the definition is as follows:
 +
 +`\titleformat{\centering\Large\color{blue}}`
 +
 +###​Miscellaneous
 +
 +#### slitherlinksetup
 +
 +`\slitherlinksetup{options}`
 +
 +With the command `slitherlinksetup` you can reset the options with global scope.
 +
 +#### setpuzzlecounter
 +
 +`\setpuzzlecounter{number}`
 +
 +With the command `\setpuzzlecounter`,​ you can reset the puzzle counter, for example before the solutions.
 +
 +Examples & Solutions
 +--------------------
 +
 +You can download application examples and their solutions from the [project page](https://​bitbucket.org/​kleberj/​logicpuzzle/​). The puzzles are originally licensed under
 +[CC-BY-NC-SA](http://​creativecommons.org/​licenses/​by-nc-sa/​3.0/​).
 +
 +![qrcode](http://​imgur.com/​KAunnuS.png)
 +
 +</​markdown>​
slitherlink.txt · Last modified: 2015/09/06 09:52 (external edit)