Memory leak and type safety fixes from James H.
[sgt/puzzles] / puzzles.but
index 9949da4..9013006 100644 (file)
@@ -20,6 +20,8 @@
 
 \define{by} \u00D7{x}
 
 
 \define{by} \u00D7{x}
 
+\define{dash} \u2013{-}
+
 This is a collection of small one-player puzzle games.
 
 \copyright This manual is copyright 2004-5 Simon Tatham. All rights
 This is a collection of small one-player puzzle games.
 
 \copyright This manual is copyright 2004-5 Simon Tatham. All rights
@@ -43,16 +45,15 @@ both, and have more recently done a port to Mac OS X as well. When I
 find (or perhaps invent) further puzzle games that I like, they'll
 be added to this collection and will immediately be available on
 both platforms. And if anyone feels like writing any other front
 find (or perhaps invent) further puzzle games that I like, they'll
 be added to this collection and will immediately be available on
 both platforms. And if anyone feels like writing any other front
-ends - PocketPC, Mac OS pre-10, or whatever it might be - then all
-the games in this framework will immediately become available on
-another platform as well.
+ends \dash PocketPC, Mac OS pre-10, or whatever it might be \dash
+then all the games in this framework will immediately become
+available on another platform as well.
 
 
-The actual games in this collection were mostly not my invention; I
-saw them elsewhere, and rewrote them in a form that was more
-convenient for me. I do not claim credit, in general, for inventing
-the rules of any of these puzzles; all I claim is authorship of the
-code (or at least those parts of the code that weren't contributed
-by other people!).
+The actual games in this collection were mostly not my invention; they
+are re-implementations of existing game concepts within my portable
+puzzle framework. I do not claim credit, in general, for inventing the
+rules of any of these puzzles. (I don't even claim authorship of all
+the code; some of the puzzles have been submitted by other authors.)
 
 This collection is distributed under the \i{MIT licence} (see
 \k{licence}). This means that you can do pretty much anything you like
 
 This collection is distributed under the \i{MIT licence} (see
 \k{licence}). This means that you can do pretty much anything you like
@@ -844,11 +845,11 @@ partial deductions about the \e{set} of squares a number could be in
 eventually have to make a guess, and then backtrack if it turns out
 to be wrong.
 
 eventually have to make a guess, and then backtrack if it turns out
 to be wrong.
 
-Generating difficult puzzles is itself difficult: if you select
-\q{Intermediate} or \q{Advanced} difficulty, Solo may have to make
-many attempts at generating a puzzle before it finds one hard enough
-for you. Be prepared to wait, especially if you have also configured
-a large puzzle size.
+Generating difficult puzzles is itself difficult: if you select one
+of the higher difficulty levels, Solo may have to make many attempts
+at generating a puzzle before it finds one hard enough for you. Be
+prepared to wait, especially if you have also configured a large
+puzzle size.
 
 
 \C{mines} \i{Mines}
 
 
 \C{mines} \i{Mines}
@@ -960,11 +961,6 @@ Removing a region causes the rest of the grid to shuffle up:
 blocks that are suspended will fall down (first), and then empty
 columns are filled from the right. 
 
 blocks that are suspended will fall down (first), and then empty
 columns are filled from the right. 
 
-The game generator does not try to guarantee soluble grids;
-it will, however, ensure that there are at least 2 squares of each 
-colour on the grid at the start (and will forbid custom grids for which
-that would be impossible).
-
 Same Game was contributed to this collection by James Harvey.
 
 \H{samegame-controls} \i{Same Game controls}
 Same Game was contributed to this collection by James Harvey.
 
 \H{samegame-controls} \i{Same Game controls}
@@ -1010,6 +1006,23 @@ any points at all. With the alternative \q{(n-1)^2} system, regions of
 two squares score a point each, and larger regions score relatively
 more points.
 
 two squares score a point each, and larger regions score relatively
 more points.
 
+\dt \e{Ensure solubility}
+
+\dd If this option is ticked (the default state), generated grids
+will be guaranteed to have at least one solution.
+
+\lcont{
+
+If you turn it off, the game generator will not try to guarantee
+soluble grids; it will, however, still ensure that there are at
+least 2 squares of each colour on the grid at the start (since a
+grid with exactly one square of a given colour is \e{definitely}
+insoluble). Grids generated with this option disabled may contain
+more large areas of contiguous colour, leading to opportunities for
+higher scores; they can also take less time to generate.
+
+}
+
 
 \C{flip} \i{Flip}
 
 
 \C{flip} \i{Flip}
 
@@ -1197,12 +1210,12 @@ time (but always one that is known to have a solution).
 
 \cfg{winhelp-topic}{games.dominosa}
 
 
 \cfg{winhelp-topic}{games.dominosa}
 
-A normal set of dominoes - that is, one instance of every (unordered)
-pair of numbers from 0 to 6 - has been arranged irregularly into a
-rectangle; then the number in each square has been written down and
-the dominoes themselves removed. Your task is to reconstruct the
-pattern by arranging the set of dominoes to match the provided array
-of numbers.
+A normal set of dominoes \dash that is, one instance of every
+(unordered) pair of numbers from 0 to 6 \dash has been arranged
+irregularly into a rectangle; then the number in each square has
+been written down and the dominoes themselves removed. Your task is
+to reconstruct the pattern by arranging the set of dominoes to match
+the provided array of numbers.
 
 This puzzle is widely credited to O. S. Adler, and takes part of its
 name from those initials.
 
 This puzzle is widely credited to O. S. Adler, and takes part of its
 name from those initials.
@@ -1378,11 +1391,22 @@ When an appropriate number of balls have been guessed a button will
 appear at the top-left corner of the grid; clicking that will mark
 your guesses. 
 
 appear at the top-left corner of the grid; clicking that will mark
 your guesses. 
 
-Once marked, correctly-placed balls are displayed as filled black
-circles.  Incorrectly-placed balls are displayed as filled black
-circles with red crosses, and missing balls are filled red circles.
-In addition, a red circle marks any laser you had already fired
-which is not consistent with your ball layout, and red text marks
+If you click the \q{mark} button and your guesses are not correct,
+the game will show you as little information as possible to
+demonstrate this to you, so you can try again. If your ball
+positions are not consistent with the laser paths you already know
+about, one laser path will be circled to indicate that it proves you
+wrong. If your positions match all the existing laser paths but are
+still wrong, one new laser path will be revealed (written in red)
+which is not consistent with your current guesses.
+
+If you decide to give up completely, you can select Solve to reveal
+the actual ball positions. At this point, correctly-placed balls
+will be displayed as filled black circles; incorrectly-placed balls
+are displayed as filled black circles with red crosses, and missing
+balls are filled red circles. In addition, a red circle marks any
+laser you had already fired which is not consistent with your ball
+layout (just as when you press the mark button), and red text marks
 any laser you \e{could} have fired in order to distinguish your ball
 layout from the right one.
 
 any laser you \e{could} have fired in order to distinguish your ball
 layout from the right one.
 
@@ -1408,11 +1432,281 @@ using a different number to the original solution is still acceptable,
 if all the laser inputs and outputs match.
 
 
 if all the laser inputs and outputs match.
 
 
+\C{slant} \i{Slant}
+
+\cfg{winhelp-topic}{games.slant}
+
+You have a grid of squares. Your aim is to draw a diagonal line
+through each square, and choose which way each line slants so that
+the following conditions are met:
+
+\b The diagonal lines never form a loop.
+
+\b Any point with a circled number has precisely that many lines
+meeting at it. (Thus, a 4 is the centre of a cross shape, whereas a
+zero is the centre of a diamond shape \dash or rather, a partial
+diamond shape, because a zero can never appear in the middle of the
+grid because that would immediately cause a loop.)
+
+Credit for this puzzle goes to \i{Nikoli} \k{nikoli-slant}.
+
+\B{nikoli-slant}
+\W{http://www.nikoli.co.jp/puzzles/39/index.htm}\cw{http://www.nikoli.co.jp/puzzles/39/index.htm}
+(in Japanese)
+
+
+\H{slant-controls} \i{Slant controls}
+
+\IM{Slant controls} controls, for Slant
+\IM{Slant controls} keys, for Slant
+\IM{Slant controls} shortcuts (keyboard), for Slant
+
+Left-clicking in a blank square will place a \cw{\\} in it (a line
+leaning to the left, i.e. running from the top left of the square to
+the bottom right). Right-clicking in a blank square will place a
+\cw{/} in it (leaning to the right, running from top right to bottom
+left).
+
+Continuing to click either button will cycle between the three
+possible square contents. Thus, if you left-click repeatedly in a
+blank square it will change from blank to \cw{\\} to \cw{/} back to
+blank, and if you right-click repeatedly the square will change from
+blank to \cw{/} to \cw{\\} back to blank. (Therefore, you can play
+the game entirely with one button if you need to.)
+
+(All the actions described in \k{common-actions} are also available.)
+
+\H{slant-parameters} \I{parameters, for Slant}Slant parameters
+
+These parameters are available from the \q{Custom...} option on the
+\q{Type} menu.
+
+\dt \e{Width}, \e{Height}
+
+\dd Size of grid in squares.
+
+\dt \e{Difficulty}
+
+\dd Controls the difficulty of the generated puzzle. At Hard level,
+you are required to do deductions based on knowledge of
+\e{relationships} between squares rather than always being able to
+deduce the exact contents of one square at a time. (For example, you
+might know that two squares slant in the same direction, even if you
+don't yet know what that direction is, and this might enable you to
+deduce something about still other squares.) Even at Hard level,
+guesswork and backtracking should never be necessary.
+
+
+\C{lightup} \i{Light Up}
+
+\cfg{winhelp-topic}{games.lightup}
+
+You have a grid of squares. Some are filled in black; some of the
+black squares are numbered. Your aim is to \q{light up} all the
+empty squares by placing light bulbs in some of them.
+
+Each light bulb illuminates the square it is on, plus all squares in
+line with it horizontally or vertically unless a black square is
+blocking the way.
+
+To win the game, you must satisfy the following conditions:
+
+\b All non-black squares are lit.
+
+\b No light is lit by another light.
+
+\b All numbered black squares have exactly that number of lights adjacent to
+   them (in the four squares above, below, and to the side).
+
+Non-numbered black squares may have any number of lights adjacent to them. 
+
+Credit for this puzzle goes to \i{Nikoli} \k{nikoli-lightup}.
+
+Light Up was contributed to this collection by James Harvey.
+
+\B{nikoli-lightup}
+\W{http://www.nikoli.co.jp/puzzles/32/index-e.htm}\cw{http://www.nikoli.co.jp/puzzles/32/index-e.htm}
+(beware of Flash)
+
+\H{lightup-controls} \i{Light Up controls}
+
+\IM{Light Up controls} controls, for Light Up
+\IM{Light Up controls} keys, for Light Up
+\IM{Light Up controls} shortcuts (keyboard), for Light Up
+
+Left-clicking in a non-black square will toggle the presence of a light
+in that square. Right-clicking in a non-black square toggles a mark there to aid
+solving; it can be used to highlight squares that cannot be lit, for example. 
+
+You may not place a light in a marked square, nor place a mark in a lit square.
+
+The game will highlight obvious errors in red. Lights lit by other
+lights are highlighted in this way, as are numbered squares which
+do not (or cannot) have the right number of lights next to them.
+  
+Thus, the grid is solved when all non-black squares have yellow
+highlights and there are no red lights.
+
+
+\H{lightup-parameters} \I{parameters, for Light Up}Light Up parameters
+
+These parameters are available from the \q{Custom...} option on the
+\q{Type} menu.
+
+\dt \e{Width}, \e{Height}
+
+\dd Size of grid in squares.
+
+\dt \e{%age of black squares}
+
+\dd Rough percentage of black squares in the grid.
+
+\lcont{
+
+This is a hint rather than an instruction. If the grid generator is
+unable to generate a puzzle to this precise specification, it will
+increase the proportion of black squares until it can.
+
+}
+
+\dt \e{Symmetry}
+
+\dd Allows you to specify the required symmetry of the black squares
+in the grid. (This does not affect the difficulty of the puzzles
+noticeably.)
+
+\dt \e{Difficulty}
+
+\dd \q{Easy} means that the puzzles should be soluble without
+backtracking or guessing, \q{Hard} means that some guesses will
+probably be necessary.
+
+
+\C{map} \i{Map}
+
+\cfg{winhelp-topic}{games.map}
+
+You are given a map consisting of a number of regions. Your task is
+to colour each region with one of four colours, in such a way that
+no two regions sharing a boundary have the same colour. You are
+provided with some regions already coloured, sufficient to make the
+remainder of the solution unique.
+
+Only regions which share a length of border are required to be
+different colours. Two regions which meet at only one \e{point}
+(i.e. are diagonally separated) may be the same colour.
+
+I believe this puzzle is original; I've never seen an implementation
+of it anywhere else. The concept of a four-colouring puzzle was
+suggested by Owen Dunn; credit must also go to Nikoli and to Verity
+Allan for inspiring the train of thought that led to me realising
+Owen's suggestion was a viable puzzle. Thanks also to Gareth Taylor
+for many detailed suggestions.
+
+
+\H{map-controls} \i{Map controls}
+
+\IM{Map controls} controls, for Map
+\IM{Map controls} keys, for Map
+\IM{Map controls} shortcuts (keyboard), for Map
+
+To colour a region, click on an existing region of the desired
+colour and drag that colour into the new region.
+
+(The program will always ensure the starting puzzle has at least one
+region of each colour, so that this is always possible!)
+
+If you need to clear a region, you can drag from an empty region, or
+from the puzzle boundary if there are no empty regions left.
+
+
+\H{map-parameters} \I{parameters, for Map}Map parameters
+
+These parameters are available from the \q{Custom...} option on the
+\q{Type} menu.
+
+\dt \e{Width}, \e{Height}
+
+\dd Size of grid in squares.
+
+\dt \e{Regions}
+
+\dd Number of regions in the generated map.
+
+\dt \e{Difficulty}
+
+\dd In \q{Easy} mode, there should always be at least one region
+whose colour can be determined trivially. In \q{Normal} mode, you
+will have to use more complex logic to deduce the colour of some
+regions. However, it will always be possible without having to
+guess or backtrack.
+
+
+\C{loopy} \i{Loopy}
+
+\cfg{winhelp-topic}{games.loopy}
+
+You are given a grid of dots. Your aim is to draw a single unbroken
+loop from dot to dot within the grid.
+
+Some of the square spaces between the dots contain numbers. These
+numbers indicate how many of the four edges of that square are part
+of the loop. The loop you draw must correctly satisfy all of these
+clues to be considered a correct solution.
+
+Credit for this puzzle goes to \i{Nikoli} \k{nikoli-loopy}.
+
+Loopy was contributed to this collection by Mike Pinna.
+
+\B{nikoli-loopy}
+\W{http://www.nikoli.co.jp/puzzles/3/index-e.htm}\cw{http://www.nikoli.co.jp/puzzles/3/index-e.htm}
+(beware of Flash)
+
+
+\H{loopy-controls} \i{Loopy controls}
+
+\IM{Loopy controls} controls, for Loopy
+\IM{Loopy controls} keys, for Loopy
+\IM{Loopy controls} shortcuts (keyboard), for Loopy
+
+Click the left mouse button between two dots to add a line segment
+connecting them. Click again to remove that line segment.
+
+If you are sure that a particular line segment is \e{not} part of
+the loop, you can click the right mouse button to add a small cross
+indicating this. Click again to remove the cross.
+
+
+\H{loopy-parameters} \I{parameters, for Loopy}Loopy parameters
+
+These parameters are available from the \q{Custom...} option on the
+\q{Type} menu.
+
+\dt \e{Width}, \e{Height}
+
+\dd Size of grid in squares.
+
+\dt \e{Recursion depth}
+
+\dd Determines how much guesswork and backtracking you will need to
+do to solve the puzzle. When this is set to zero (as it is for all
+of the \q{Easy} options in the menu), you should always be able to
+deduce the state of an edge without having to guess. If you increase
+it, you will have to guess more and more.
+
+\lcont{
+
+Setting a high value for this option is liable to consume a lot of
+CPU time and memory. Be warned!
+
+}
+
+
 \A{licence} \I{MIT licence}\ii{Licence}
 
 This software is \i{copyright} 2004-2005 Simon Tatham.
 
 \A{licence} \I{MIT licence}\ii{Licence}
 
 This software is \i{copyright} 2004-2005 Simon Tatham.
 
-Portions copyright Richard Boulton and James Harvey.
+Portions copyright Richard Boulton, James Harvey and Mike Pinna.
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation files
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation files