sgt/puzzles
18 years agoAlter the `Octagon' board preset so that instead of presenting you
simon [Sat, 9 Jul 2005 10:19:41 +0000 (10:19 +0000)]
Alter the `Octagon' board preset so that instead of presenting you
with the obvious central hole it presents you with a randomly chosen
one of twelve other holes. The reason is, the central-hole starting
position is provably insoluble (proof given in comments), so instead
we pick from the ones that are actually possible.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6083 cda61777-01e9-0310-a592-d414129be87e

18 years agoMissing quit on error was leading to an assertion failure on some
simon [Wed, 6 Jul 2005 21:24:28 +0000 (21:24 +0000)]
Missing quit on error was leading to an assertion failure on some
types of incorrectly formatted save file.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6079 cda61777-01e9-0310-a592-d414129be87e

18 years agoMove various printf()s after declarations.
jacob [Wed, 6 Jul 2005 20:10:03 +0000 (20:10 +0000)]
Move various printf()s after declarations.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6078 cda61777-01e9-0310-a592-d414129be87e

18 years agoUnify the two solvers in Solo. nsolve has now had recursion
simon [Wed, 6 Jul 2005 18:36:20 +0000 (18:36 +0000)]
Unify the two solvers in Solo. nsolve has now had recursion
capability added to it, to be used only when all else fails, and is
simply called `solver'. This means that:

 - solving of 5x5 Trivial grids using the `Solve' function, which
   previously hung for ages because rsolve happened to take a wrong
   turning at the start, is now zippy
 - solosolver doesn't require the confusing -r and -n options
 - solosolver can show its working even for Unreasonable grids.

Unfortunately, the new unified solver still isn't suitable for grid
generation. After it proved to be so much faster at solving 5x5s, I
hoped to be able to substitute it for rsolve during generation and
gain additional speed in 5x5 generation too; but no luck, because
it's slower _per recursion level_, and although during solving it
makes up for this by needing very few levels, there is a lot of
_unavoidable_ recursion during generation, especially at 5x5. A
hybrid strategy which starts off with rsolve and switches to the
unified solver at a critical point proved unsatisfactory as well,
because the critical point changes depending on the vagaries of the
recursion and can't be pinpointed easily. So rsolve is still in
there, only renamed `gridgen' because that's now all it's good for.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6077 cda61777-01e9-0310-a592-d414129be87e

18 years agoRefactoring from James H: the highlight and lowlight colour setup
simon [Wed, 6 Jul 2005 18:27:40 +0000 (18:27 +0000)]
Refactoring from James H: the highlight and lowlight colour setup
common to Fifteen, Sixteen, Twiddle and Pegs is now a utility
function in misc.c.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6076 cda61777-01e9-0310-a592-d414129be87e

18 years agoSome patches from James H:
simon [Wed, 6 Jul 2005 11:06:17 +0000 (11:06 +0000)]
Some patches from James H:
 - reinstate the initialisation of ds->w and ds->h in guess.c, which
   I'd accidentally removed during game_size() refactoring
 - reorganise Net's interpret_move() so that my uncommitted patch
   for drag-based UI (which he uses on the Palm port) will apply
   more easily
 - the interpret_move() changes make it easy to have a single move
   type which rotates a tile by 180 degrees, so this is now provided
   via the `F' key (but there's no spare button available to provide
   it via the mouse).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6070 cda61777-01e9-0310-a592-d414129be87e

18 years agoRevert the code that assumed that incoming parameters used a random generation
jacob [Tue, 5 Jul 2005 21:40:29 +0000 (21:40 +0000)]
Revert the code that assumed that incoming parameters used a random generation
scheme in r6068, since this messed up the non-permanency of the non-limited
parameter.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6069 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd a `full' parameter to validate_params(), analogous to the one in
jacob [Tue, 5 Jul 2005 21:27:19 +0000 (21:27 +0000)]
Add a `full' parameter to validate_params(), analogous to the one in
encode_params(). This is necessary for cases where generation-time parameters
that are normally omitted from descriptive IDs can place restrictions on other
parameters; in particular, when the default value of a relevant generation-time
parameter is not the one used to generate the descriptive ID, validation could
reject self-generated IDs (e.g., Net `5x2w:56182ae7c2', and some cases in
`Pegs').

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6068 cda61777-01e9-0310-a592-d414129be87e

18 years agoEnhancements to mkfiles.pl and Recipe to arrange for the auxiliary
simon [Tue, 5 Jul 2005 19:40:32 +0000 (19:40 +0000)]
Enhancements to mkfiles.pl and Recipe to arrange for the auxiliary
command-line programs (solosolver, patternsolver, mineobfusc) to be
built as part of the normal Makefiles. This means mkfiles.pl now has
the capability to compile a source file more than once with
different #defines. Also, fixes for those auxiliary programs and one
fix in midend.c which the Borland compiler objected to while I was
testing its makefile generation.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6066 cda61777-01e9-0310-a592-d414129be87e

18 years agoIt's been a new year for a while now.
jacob [Tue, 5 Jul 2005 19:38:27 +0000 (19:38 +0000)]
It's been a new year for a while now.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6065 cda61777-01e9-0310-a592-d414129be87e

18 years agorevert supposed typo -- I have no brain
jacob [Tue, 5 Jul 2005 19:12:56 +0000 (19:12 +0000)]
revert supposed typo -- I have no brain

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6064 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd HACKING to main doc build.
jacob [Tue, 5 Jul 2005 19:11:51 +0000 (19:11 +0000)]
Add HACKING to main doc build.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6063 cda61777-01e9-0310-a592-d414129be87e

18 years agotypo
jacob [Tue, 5 Jul 2005 19:10:26 +0000 (19:10 +0000)]
typo

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6062 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd a completion flash when you get down to a single peg.
jacob [Tue, 5 Jul 2005 18:57:34 +0000 (18:57 +0000)]
Add a completion flash when you get down to a single peg.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6061 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd `pegs' to svn:ignore.
simon [Tue, 5 Jul 2005 18:14:03 +0000 (18:14 +0000)]
Add `pegs' to svn:ignore.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6060 cda61777-01e9-0310-a592-d414129be87e

18 years agoRefactored the game_size() interface, which was getting really
simon [Tue, 5 Jul 2005 18:13:31 +0000 (18:13 +0000)]
Refactored the game_size() interface, which was getting really
unpleasant and requiring lots of special cases to be taken care of
by every single game. The new interface exposes an integer `tile
size' or `scale' parameter to the midend and provides two much
simpler routines: one which computes the pixel window size given a
game_params and a tile size, and one which is given a tile size and
must set up a drawstate appropriately. All the rest of the
complexity is handled in the midend, mostly by binary search, so
grubby special cases only have to be dealt with once.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6059 cda61777-01e9-0310-a592-d414129be87e

18 years agoJames Harvey points out a missing ifdef.
simon [Tue, 5 Jul 2005 12:03:56 +0000 (12:03 +0000)]
James Harvey points out a missing ifdef.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6058 cda61777-01e9-0310-a592-d414129be87e

18 years agoClarify that diagonal moves are not permitted in Pegs.
jacob [Mon, 4 Jul 2005 21:07:40 +0000 (21:07 +0000)]
Clarify that diagonal moves are not permitted in Pegs.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6057 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd WinHelp topic.
jacob [Mon, 4 Jul 2005 20:06:35 +0000 (20:06 +0000)]
Add WinHelp topic.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6056 cda61777-01e9-0310-a592-d414129be87e

18 years agoThere's always one. Forgot to add Pegs to `make install'.
simon [Mon, 4 Jul 2005 19:55:10 +0000 (19:55 +0000)]
There's always one. Forgot to add Pegs to `make install'.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6054 cda61777-01e9-0310-a592-d414129be87e

18 years agoDocumentation for Pegs.
simon [Mon, 4 Jul 2005 19:53:36 +0000 (19:53 +0000)]
Documentation for Pegs.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6053 cda61777-01e9-0310-a592-d414129be87e

18 years agoPeg Solitaire implementation, complete with a random board
simon [Mon, 4 Jul 2005 19:42:55 +0000 (19:42 +0000)]
Peg Solitaire implementation, complete with a random board
generator. The generator is lacking in almost any kind of finesse,
but it produces puzzles which at least _I_ find plausibly puzzling.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6052 cda61777-01e9-0310-a592-d414129be87e

18 years agoDocument keyboard controls for Flip
jacob [Mon, 4 Jul 2005 14:35:14 +0000 (14:35 +0000)]
Document keyboard controls for Flip

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6051 cda61777-01e9-0310-a592-d414129be87e

18 years agoFix bounds checking for Flip cursor control.
jacob [Mon, 4 Jul 2005 11:21:50 +0000 (11:21 +0000)]
Fix bounds checking for Flip cursor control.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6050 cda61777-01e9-0310-a592-d414129be87e

18 years agoJames H's patch for a keyboard-controlled cursor in Flip.
simon [Sun, 3 Jul 2005 14:49:00 +0000 (14:49 +0000)]
James H's patch for a keyboard-controlled cursor in Flip.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6049 cda61777-01e9-0310-a592-d414129be87e

18 years agoAllow game backends to use even special keystrokes such as N and Q;
simon [Sun, 3 Jul 2005 11:45:49 +0000 (11:45 +0000)]
Allow game backends to use even special keystrokes such as N and Q;
they will only be processed as special by the midend if unwanted by
the backend. This causes 5x5 Solo to become just about playable,
because you can now click in a square and type `n'. However, typing
`n' when a square is not selected will revert to the normal
behaviour of starting a new game.

(This isn't particularly ideal, I know, but it's better than
nothing.)

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6048 cda61777-01e9-0310-a592-d414129be87e

18 years agodraw_polygon() and draw_circle() have always had a portability
simon [Sun, 3 Jul 2005 09:35:29 +0000 (09:35 +0000)]
draw_polygon() and draw_circle() have always had a portability
constraint: because some front ends interpret `draw filled shape' to
mean `including its boundary' while others interpret it to mean `not
including its boundary' (and X seems to vacillate between the two
opinions as it moves around the shape!), you MUST NOT draw a filled
shape only. You can fill in one colour and outline in another, you
can fill or outline in the same colour, or you can just outline, but
just filling is a no-no.

This leads to a _lot_ of double calls to these functions, so I've
changed the interface. draw_circle() and draw_polygon() now each
take two colour arguments, a fill colour (which can be -1 for none)
and an outline colour (which must be valid). This should simplify
code in the game back ends, while also reducing the possibility for
coding error.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6047 cda61777-01e9-0310-a592-d414129be87e

18 years agoJames Harvey points out that entering an invalid game ID can affect
simon [Fri, 1 Jul 2005 16:50:49 +0000 (16:50 +0000)]
James Harvey points out that entering an invalid game ID can affect
the current midend state even if you don't subsequently enter a
valid one. Reorganise midend_game_id_int() so that (just like
midend_deserialise()) it does all its error checking before altering
anything in the midend's persistent data, so that it either succeeds
completely or fails before doing anything at all.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6045 cda61777-01e9-0310-a592-d414129be87e

18 years agoPrevent drags from being started outside the playing area, which was
simon [Thu, 30 Jun 2005 18:11:41 +0000 (18:11 +0000)]
Prevent drags from being started outside the playing area, which was
causing invalid move descriptions to be returned from
interpret_move() and then failing an assertion when execute_move()
refused them.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6044 cda61777-01e9-0310-a592-d414129be87e

18 years agoPreset names retrieved from the environment must be dupstr()ed. How
simon [Thu, 30 Jun 2005 18:11:02 +0000 (18:11 +0000)]
Preset names retrieved from the environment must be dupstr()ed. How
did I miss this before? It just caused a segfault for me, which is
entirely fair enough, but I've no idea why it didn't fail before!

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6043 cda61777-01e9-0310-a592-d414129be87e

18 years agoLoad and Save are now supported on all three desktop platforms, and
simon [Thu, 30 Jun 2005 18:00:37 +0000 (18:00 +0000)]
Load and Save are now supported on all three desktop platforms, and
documented. (This means the GTK temporary dependency on an
environment variable is now gone.)

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6042 cda61777-01e9-0310-a592-d414129be87e

18 years agoGeneral robustness patch from James Harvey:
simon [Thu, 30 Jun 2005 09:07:00 +0000 (09:07 +0000)]
General robustness patch from James Harvey:
 - most game_size() functions now work in doubles internally and
   round to nearest, meaning that they have less tendency to try to
   alter a size they returned happily from a previous call
 - couple of fiddly fixes (memory leaks, precautionary casts in
   printf argument lists)
 - midend_deserialise() now constructs an appropriate drawstate,
   which I can't think how I overlooked myself since I _thought_ I
   went through the entire midend structure field by field!

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6041 cda61777-01e9-0310-a592-d414129be87e

18 years agoAttempting to begin a drag from (i.e. just click on) the hint pegs
simon [Thu, 30 Jun 2005 08:25:47 +0000 (08:25 +0000)]
Attempting to begin a drag from (i.e. just click on) the hint pegs
for a past guess caused strangeness up to and including segfault,
thanks to bad bounds checking. Well spotted John Sullivan.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6040 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd a cast whose absence was causing a (-Werror-exacerbated) compile
simon [Wed, 29 Jun 2005 16:32:53 +0000 (16:32 +0000)]
Add a cast whose absence was causing a (-Werror-exacerbated) compile
warning on OS X.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6037 cda61777-01e9-0310-a592-d414129be87e

18 years agoValidation of random-state-type game descriptions was broken. This
simon [Wed, 29 Jun 2005 12:19:08 +0000 (12:19 +0000)]
Validation of random-state-type game descriptions was broken. This
meant that a Mines game saved before the first click had taken place
could not be successfully reloaded.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6036 cda61777-01e9-0310-a592-d414129be87e

18 years agoWhen serialising this game, it's probably better to keep the
simon [Wed, 29 Jun 2005 08:20:49 +0000 (08:20 +0000)]
When serialising this game, it's probably better to keep the
half-finished guess in the game_ui rather than throwing it away.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6033 cda61777-01e9-0310-a592-d414129be87e

18 years agoMake peg removal accessible from the keyboard.
jacob [Tue, 28 Jun 2005 18:10:20 +0000 (18:10 +0000)]
Make peg removal accessible from the keyboard.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6032 cda61777-01e9-0310-a592-d414129be87e

18 years agoNew {en,de}code_ui functions should be static. Oops.
simon [Tue, 28 Jun 2005 17:43:50 +0000 (17:43 +0000)]
New {en,de}code_ui functions should be static. Oops.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6031 cda61777-01e9-0310-a592-d414129be87e

18 years agoActually implemented the serialise/deserialise functions in
simon [Tue, 28 Jun 2005 17:05:05 +0000 (17:05 +0000)]
Actually implemented the serialise/deserialise functions in
midend.c. Also I've added an experimental front end in gtk.c only:
`Save' and `Load' options on the Game menu, which don't even show up
unless you define the magic environment variable
PUZZLES_EXPERIMENTAL_SAVE. Once I'm reasonably confident that the
whole edifice is plausibly stable, I'll take that out and turn it
into a supported feature (and also implement it in OS X and Windows
and write documentation).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6030 cda61777-01e9-0310-a592-d414129be87e

18 years agoMore serialisation changes: the game_aux_info structure has now been
simon [Tue, 28 Jun 2005 11:14:09 +0000 (11:14 +0000)]
More serialisation changes: the game_aux_info structure has now been
retired, and replaced with a simple string. Most of the games which
use it simply encode the string in the same way that the Solve move
will also be encoded, i.e. solve_game() simply returns
dupstr(aux_info). Again, this is a better approach than writing
separate game_aux_info serialise/deserialise functions because doing
it this way is self-testing (the strings are created and parsed
during the course of any Solve operation at all).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6029 cda61777-01e9-0310-a592-d414129be87e

18 years agoRogue diagnostic!
simon [Tue, 28 Jun 2005 08:35:55 +0000 (08:35 +0000)]
Rogue diagnostic!

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6028 cda61777-01e9-0310-a592-d414129be87e

18 years agoMove a rogue declaration to the top of its block.
simon [Tue, 28 Jun 2005 08:06:56 +0000 (08:06 +0000)]
Move a rogue declaration to the top of its block.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6027 cda61777-01e9-0310-a592-d414129be87e

18 years agoAnother function pair required for serialisation; these ones save
simon [Tue, 28 Jun 2005 07:33:49 +0000 (07:33 +0000)]
Another function pair required for serialisation; these ones save
and restore anything vitally important in the game_ui. Most of the
game_ui is expected to be stuff about cursor positions and currently
active mouse drags, so it absolutely _doesn't_ want to be preserved
over a serialisation; but one or two things would be disorienting or
outright wrong to reset, such as the Net origin position and the
Mines death counter.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6026 cda61777-01e9-0310-a592-d414129be87e

18 years agoAnnoying special cases for Mines.
simon [Tue, 28 Jun 2005 06:59:27 +0000 (06:59 +0000)]
Annoying special cases for Mines.

Firstly, the `Restart' function now reconstructs an initial game
state from the game description rather than dup_game(states[0]).
This means that Restart in a game of Mines restarts to just _after_
the initial click, so you can resume the puzzle-solving part without
having to remember where you placed that click.

Secondly, the midend now contains a second `private' game desc,
which is guaranteed to actually reconstruct the initial game_state
correctly (which Mines's publicly visible game descs tend not to,
since they describe a state which has already had the first click).
This should make serialising of Mines more sensible.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6025 cda61777-01e9-0310-a592-d414129be87e

18 years agoRe-architecting of the game backend interface. make_move() has been
simon [Mon, 27 Jun 2005 19:34:54 +0000 (19:34 +0000)]
Re-architecting of the game backend interface. make_move() has been
split into two functions. The first, interpret_move(), takes all the
arguments that make_move() used to get and may have the usual side
effects of modifying the game_ui, but instead of returning a
modified game_state it instead returns a string description of the
move to be made. This string description is then passed to a second
function, execute_move(), together with an input game_state, which
is responsible for actually producing the new state. (solve_game()
also returns a string to be passed to execute_move().)

The point of this is to work towards being able to serialise the
whole of a game midend into a byte stream such as a disk file, which
will eventually support save and load functions in the desktop
puzzles, as well as restoring half-finished games after a quit and
restart in James Harvey's Palm port. Making each game supply a
convert-to-string function for its game_state format would have been
an unreliable way to do this, since those functions would not have
been used in normal play, so they'd only have been tested when you
actually tried to save and load - a recipe for latent bugs if ever I
heard one. This way, you won't even be able to _make_ a move if
execute_move() doesn't work properly, which means that if you can
play a game at all I can have pretty high confidence that
serialising it will work first time.

This is only the groundwork; there will be more checkins to come on
this theme. But the major upheaval should now be done, and as far as
I can tell everything's still working normally.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6024 cda61777-01e9-0310-a592-d414129be87e

18 years agoFix GTK casts to restore correct compilation on GTK 2.0 after r6022.
simon [Sun, 26 Jun 2005 13:12:34 +0000 (13:12 +0000)]
Fix GTK casts to restore correct compilation on GTK 2.0 after r6022.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6023 cda61777-01e9-0310-a592-d414129be87e

18 years agoUnder Gtk 1.2 (at least on Debian woody), a config or preset change that would
jacob [Sun, 26 Jun 2005 12:54:08 +0000 (12:54 +0000)]
Under Gtk 1.2 (at least on Debian woody), a config or preset change that would
otherwise not cause the window size to change caused it to become very small
indeed. This change from Simon fixes that behaviour; I haven't tested it with
Gtk 2.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6022 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd debugging support.
jacob [Sat, 25 Jun 2005 17:24:03 +0000 (17:24 +0000)]
Add debugging support.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6018 cda61777-01e9-0310-a592-d414129be87e

18 years agoFurther additions to the Guess docs.
jacob [Sat, 25 Jun 2005 13:52:52 +0000 (13:52 +0000)]
Further additions to the Guess docs.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6014 cda61777-01e9-0310-a592-d414129be87e

18 years agoMake the keyboard-control cursors visible whenever a keyboard control is
jacob [Sat, 25 Jun 2005 13:43:45 +0000 (13:43 +0000)]
Make the keyboard-control cursors visible whenever a keyboard control is
activated.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6013 cda61777-01e9-0310-a592-d414129be87e

18 years agoThe AngleArc() function that was being used to draw circles on Windows turns
jacob [Sat, 25 Jun 2005 13:24:19 +0000 (13:24 +0000)]
The AngleArc() function that was being used to draw circles on Windows turns
out to be unsupported on the Win9x/Me series. Use Arc() instead (tested on
Win98 and Win2K).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6012 cda61777-01e9-0310-a592-d414129be87e

18 years agoCouple of presets.
simon [Fri, 24 Jun 2005 16:35:42 +0000 (16:35 +0000)]
Couple of presets.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6011 cda61777-01e9-0310-a592-d414129be87e

18 years agoMore patches from James Harvey: enforce a maximum brightness in the
simon [Fri, 24 Jun 2005 16:35:27 +0000 (16:35 +0000)]
More patches from James Harvey: enforce a maximum brightness in the
background colour (to ensure white pegs show up against it), and
convert the keyboard-control cursor into a rectangle when it's over
the hint pegs (otherwise it looks rather silly for numbers of pegs
above 4).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6010 cda61777-01e9-0310-a592-d414129be87e

18 years agoFix another display/UI glitch which triggered if you filled a row
simon [Fri, 24 Jun 2005 12:30:30 +0000 (12:30 +0000)]
Fix another display/UI glitch which triggered if you filled a row
(so that the hint pegs lit up as `ready') and then pressed Undo: the
markable flag would remain set and the redrawing wouldn't darken the
pegs again.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6009 cda61777-01e9-0310-a592-d414129be87e

18 years agoTurn off the keyboard-control cursor when the user reverts to mouse
simon [Fri, 24 Jun 2005 11:13:08 +0000 (11:13 +0000)]
Turn off the keyboard-control cursor when the user reverts to mouse
control.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6008 cda61777-01e9-0310-a592-d414129be87e

18 years agoChange the preprocessor symbol `DEBUG' to `DEBUGGING', since the
simon [Fri, 24 Jun 2005 11:05:43 +0000 (11:05 +0000)]
Change the preprocessor symbol `DEBUG' to `DEBUGGING', since the
former is automatically defined by Cygwin.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6007 cda61777-01e9-0310-a592-d414129be87e

18 years agoMy background-erasing changes in r5996/r5997 caused trouble with the
simon [Fri, 24 Jun 2005 11:03:20 +0000 (11:03 +0000)]
My background-erasing changes in r5996/r5997 caused trouble with the
keyboard-control cursors, and when I tried to fix those more
wallpaper bubbles popped up elsewhere. Here's what I think is a
proper fix: a comprehensive overhaul of the redraw code such that,
instead of tracking the cursor positions explicitly in the
drawstate, we instead track for each peg position whether or not a
cursor is currently displayed at that position. So cursor erasing
and cursor drawing become part of the main draw loop rather than a
separate bit on the end.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6006 cda61777-01e9-0310-a592-d414129be87e

18 years agoArray overflow fix from James Harvey.
simon [Thu, 23 Jun 2005 23:11:59 +0000 (23:11 +0000)]
Array overflow fix from James Harvey.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6005 cda61777-01e9-0310-a592-d414129be87e

18 years agoMake the `hold marker' in Guess accessible from the keyboard (`H' key, for want
jacob [Thu, 23 Jun 2005 22:01:17 +0000 (22:01 +0000)]
Make the `hold marker' in Guess accessible from the keyboard (`H' key, for want
of a better idea).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6004 cda61777-01e9-0310-a592-d414129be87e

18 years agoFactual and other corrections/additions to the Guess docs.
jacob [Thu, 23 Jun 2005 21:47:55 +0000 (21:47 +0000)]
Factual and other corrections/additions to the Guess docs.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6003 cda61777-01e9-0310-a592-d414129be87e

18 years agoReinstate WinHelp topic now we have a manual chapter.
jacob [Thu, 23 Jun 2005 21:37:05 +0000 (21:37 +0000)]
Reinstate WinHelp topic now we have a manual chapter.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6002 cda61777-01e9-0310-a592-d414129be87e

18 years agoCredit James Harvey.
simon [Thu, 23 Jun 2005 19:01:01 +0000 (19:01 +0000)]
Credit James Harvey.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6000 cda61777-01e9-0310-a592-d414129be87e

18 years agoJames Harvey's extensions to Guess: a couple of extra game settings
simon [Thu, 23 Jun 2005 18:50:58 +0000 (18:50 +0000)]
James Harvey's extensions to Guess: a couple of extra game settings
plus a manual chapter.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5999 cda61777-01e9-0310-a592-d414129be87e

18 years agoAnd forgot to add guess to the Unix make install target! I need a list.
simon [Thu, 23 Jun 2005 18:05:19 +0000 (18:05 +0000)]
And forgot to add guess to the Unix make install target! I need a list.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5998 cda61777-01e9-0310-a592-d414129be87e

18 years agoBah, not good enough. Extend those background erases by one more
simon [Thu, 23 Jun 2005 18:02:21 +0000 (18:02 +0000)]
Bah, not good enough. Extend those background erases by one more
pixel.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5997 cda61777-01e9-0310-a592-d414129be87e

18 years agoErase backgrounds when drawing over an existing circle, for the
simon [Thu, 23 Jun 2005 17:43:43 +0000 (17:43 +0000)]
Erase backgrounds when drawing over an existing circle, for the
benefit of antialiasing platforms such as OS X. Also in this
checkin, fiddle with svn:ignore (there's a new puzzle binary).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5996 cda61777-01e9-0310-a592-d414129be87e

18 years agoAllow dragging of coloured pegs from previous guesses. Also
simon [Thu, 23 Jun 2005 16:36:09 +0000 (16:36 +0000)]
Allow dragging of coloured pegs from previous guesses. Also
reorganise the colours so there are fewer of those terribly
computery cyan and magenta shades, and more good old-fashioned
colours with simple names like orange and purple. Finally, change
the `right place' marking peg colour from red to black, in line with
at least _my_ old Mastermind set (I faintly suspect red marker pegs
of being an Americanism) and also so that the marker pegs and the
coloured pegs have no colours in common.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5995 cda61777-01e9-0310-a592-d414129be87e

18 years agoMust outline as well as filling circles, because not all platforms
simon [Thu, 23 Jun 2005 12:55:47 +0000 (12:55 +0000)]
Must outline as well as filling circles, because not all platforms
can be guaranteed to draw bare filled shapes the same way.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5994 cda61777-01e9-0310-a592-d414129be87e

18 years agoTwo small fixes: add some ceil() calls to stop the puzzle shrinking
simon [Thu, 23 Jun 2005 12:21:14 +0000 (12:21 +0000)]
Two small fixes: add some ceil() calls to stop the puzzle shrinking
every time I press N, and revert the help topic to NULL until some
documentation materialises.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5993 cda61777-01e9-0310-a592-d414129be87e

18 years ago`Guess', a Mastermind clone from James Harvey. This checkin also
simon [Thu, 23 Jun 2005 09:14:19 +0000 (09:14 +0000)]
`Guess', a Mastermind clone from James Harvey. This checkin also
introduces a few new utility functions in misc.c, one of which is
the bitmap obfuscator from Mines (which has therefore been moved out
of mines.c).

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5992 cda61777-01e9-0310-a592-d414129be87e

18 years agoIntroduce a front-end function to draw circles.
simon [Thu, 23 Jun 2005 08:24:52 +0000 (08:24 +0000)]
Introduce a front-end function to draw circles.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5991 cda61777-01e9-0310-a592-d414129be87e

18 years agoThis TODO comment should have been taken out in r5913 :-)
simon [Wed, 22 Jun 2005 09:26:03 +0000 (09:26 +0000)]
This TODO comment should have been taken out in r5913 :-)

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5988 cda61777-01e9-0310-a592-d414129be87e

18 years agoNew front end functions to save and restore a region of the puzzle
simon [Wed, 22 Jun 2005 08:30:31 +0000 (08:30 +0000)]
New front end functions to save and restore a region of the puzzle
bitmap. Can be used to implement sprite-like animations: for
example, useful for games that wish to implement a user interface
which involves dragging an object around the playing area.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5987 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd WinHelp topic
jacob [Tue, 21 Jun 2005 11:16:36 +0000 (11:16 +0000)]
Add WinHelp topic

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5984 cda61777-01e9-0310-a592-d414129be87e

18 years agoPatch from James Harvey in response to the new Rectangles grid
simon [Tue, 21 Jun 2005 08:15:53 +0000 (08:15 +0000)]
Patch from James Harvey in response to the new Rectangles grid
generator: (a) take out the `#ifdef SLOW_SYSTEM' because the new
generator is much more efficient, and (b) convert another int to
size_t to prevent the solver going negative in 16-bit ints as a
result.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5983 cda61777-01e9-0310-a592-d414129be87e

18 years agoConversation with Richard and Chris yesterday gave rise to a more
simon [Mon, 20 Jun 2005 17:32:45 +0000 (17:32 +0000)]
Conversation with Richard and Chris yesterday gave rise to a more
sensible means of generating an initial gridful of rectangles. This
was previously a stupidly non-scalable bit of the Rectangles puzzle
generator: it filled a ludicrously large array with every possible
rectangle that could go anywhere in the grid, picked one at random
and winnowed the list by removing anything that overlapped that one,
then repeated until the list was empty (and therefore the grid was
full except for remaining singleton squares). Total cost was O(N^4)
in both time and space; not pretty.

Richard and Chris's sensible alternative was to place each rectangle
by randomly choosing a so-far-uncovered _square_, and then picking a
random rectangle from the possible ones covering that square. This
means we only have to deal with a small fragment of the rectangle
list at any one time, and we don't have to store the whole lot in
memory; so it's _much_ faster and more scalable, and has virtually
no memory cost.

A side effect of this algorithmic change is that the probability
distribution has altered. When you line up all the possible
_rectangles_ and pick one at random, then obviously the small ones
are going to be in the majority since lots of small ones can fit
into the space taken up by any given big one. So the original
algorithm tends to favour fiddly grids full of lots of tiny
rectangles, which don't tend to be very interesting. But if you
first pick a square and then think about the rectangles that can
surround that square, the small ones are suddenly going to be in the
_minority_ because there are only two ways you can place (say) a 2x1
containing a given square compared to 36 ways you can place a 6x6.
So this algorithm favours more large rectangles, which I generally
consider to be an improvement.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5982 cda61777-01e9-0310-a592-d414129be87e

18 years agoJames Harvey's memory leak patch for Flip.
simon [Sun, 19 Jun 2005 21:49:53 +0000 (21:49 +0000)]
James Harvey's memory leak patch for Flip.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5980 cda61777-01e9-0310-a592-d414129be87e

18 years agoRedraw glitch: tiles marked black (at game-over time) were not
simon [Sun, 19 Jun 2005 14:33:06 +0000 (14:33 +0000)]
Redraw glitch: tiles marked black (at game-over time) were not
redrawn as non-black on undo. Introduce a new flag TILE_IMPOSSIBLE,
so that information about those black markers is cached in the
drawstate and we know when we have to erase them.

In the process I've removed the game_state argument completely from
the subfunction tile_redraw(), which gives me some confidence that
it isn't getting any _more_ privileged information out of it.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5979 cda61777-01e9-0310-a592-d414129be87e

18 years agoJust noticed yesterday that initial window sizing is broken on
simon [Sat, 18 Jun 2005 08:52:50 +0000 (08:52 +0000)]
Just noticed yesterday that initial window sizing is broken on
Windows for puzzles with status bars, because the initial call to
check_window_size is given the window size _without_ the status bar
and assumes that that has to be big enough for the whole thing
_with_ the status bar, so it shrinks everything by a little bit. So
now we resize the window to take account of the status bar before
calling check_window_size(), and the problem seems to have gone away.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5975 cda61777-01e9-0310-a592-d414129be87e

18 years agoI've decided I didn't like the asymmetry of putting the solution
simon [Sat, 18 Jun 2005 08:46:33 +0000 (08:46 +0000)]
I've decided I didn't like the asymmetry of putting the solution
markers in the top left of the square.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5974 cda61777-01e9-0310-a592-d414129be87e

18 years agoI'm sick of not having a `make install' target.
simon [Sat, 18 Jun 2005 08:36:52 +0000 (08:36 +0000)]
I'm sick of not having a `make install' target.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5973 cda61777-01e9-0310-a592-d414129be87e

18 years agoCorrect rogue chapter into a subheading.
simon [Fri, 17 Jun 2005 19:06:25 +0000 (19:06 +0000)]
Correct rogue chapter into a subheading.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5972 cda61777-01e9-0310-a592-d414129be87e

18 years agoSolver for Flip.
simon [Fri, 17 Jun 2005 18:55:36 +0000 (18:55 +0000)]
Solver for Flip.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5970 cda61777-01e9-0310-a592-d414129be87e

18 years agoInfrastructure change which I've been thinking about for a while:
simon [Fri, 17 Jun 2005 18:54:58 +0000 (18:54 +0000)]
Infrastructure change which I've been thinking about for a while:
the back end function solve_game() now takes the _current_
game_state in addition to the initial one.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5969 cda61777-01e9-0310-a592-d414129be87e

18 years agoAnimation.
simon [Fri, 17 Jun 2005 17:32:28 +0000 (17:32 +0000)]
Animation.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5968 cda61777-01e9-0310-a592-d414129be87e

18 years agoAnother new puzzle! This one isn't particularly deep or complex
simon [Fri, 17 Jun 2005 17:16:49 +0000 (17:16 +0000)]
Another new puzzle! This one isn't particularly deep or complex
(solving it only requires matrix inversion over GF(2), whereas
several of the other puzzles in this collection are NP-complete in
principle), but it's a fun enough thing to play with and is
non-trivial to do in your head - especially on the hardest preset.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5967 cda61777-01e9-0310-a592-d414129be87e

18 years agoAn email conversation with Chuck Fresno turned up several forms of
simon [Fri, 17 Jun 2005 11:51:52 +0000 (11:51 +0000)]
An email conversation with Chuck Fresno turned up several forms of
symmetry which were not implemented in Solo. Now they are.

In the process I've completely retired symmetry_limit() on the
grounds that some of the new symmetries do not have a rectangular
base region; instead I determine the base region by going through
the grid and finding every square which is not transformed into a
lexicographically lower square by any symmetry operation. This means
that adding new symmetries is now _only_ a matter of encoding the
actual transformation rules.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5965 cda61777-01e9-0310-a592-d414129be87e

18 years agoClean up the behaviour of drags off the edge of the grid. These have
simon [Fri, 10 Jun 2005 13:05:24 +0000 (13:05 +0000)]
Clean up the behaviour of drags off the edge of the grid. These have
always been a convenient way to cancel a drag you decided was an
error, but now it's more obvious that this is the case.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5941 cda61777-01e9-0310-a592-d414129be87e

18 years agoDisable shuffle overlap checking in the special case w=h=n.
simon [Fri, 10 Jun 2005 11:34:02 +0000 (11:34 +0000)]
Disable shuffle overlap checking in the special case w=h=n.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5940 cda61777-01e9-0310-a592-d414129be87e

18 years agoOverzealous last-move tracking during shuffle was causing lockups on
simon [Fri, 10 Jun 2005 11:29:59 +0000 (11:29 +0000)]
Overzealous last-move tracking during shuffle was causing lockups on
2x2 grid generation.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5939 cda61777-01e9-0310-a592-d414129be87e

18 years agoPatch from James Harvey to rearrange the Same Game colours.
simon [Fri, 10 Jun 2005 11:27:26 +0000 (11:27 +0000)]
Patch from James Harvey to rearrange the Same Game colours.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5938 cda61777-01e9-0310-a592-d414129be87e

18 years agoPatch from Chris Emerson to add a status bar to Rectangles. Apart
simon [Fri, 10 Jun 2005 11:24:44 +0000 (11:24 +0000)]
Patch from Chris Emerson to add a status bar to Rectangles. Apart
from saying `Auto-solved' or `Completed', the main function of the
status bar is to track the current size of a rectangle you're
dragging out, which makes life much easier when trying to count up
large rectangles in 19x19 mode.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5937 cda61777-01e9-0310-a592-d414129be87e

18 years agoGDK 2.6, in its doubtless infinite wisdom, has decided that
simon [Thu, 9 Jun 2005 18:29:11 +0000 (18:29 +0000)]
GDK 2.6, in its doubtless infinite wisdom, has decided that
gdk_font_from_description() will no longer even _try_ to return a
font matching the specified Pango font description; instead it will
return `fixed' no matter what you do. Therefore, I've had to switch
to using Pango proper for Puzzles text rendering, rather than just
using Pango for font selection.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5936 cda61777-01e9-0310-a592-d414129be87e

18 years agoRemove debug output.
jacob [Wed, 8 Jun 2005 09:20:35 +0000 (09:20 +0000)]
Remove debug output.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5926 cda61777-01e9-0310-a592-d414129be87e

18 years agoAdd Windows help topic
jacob [Tue, 7 Jun 2005 21:05:29 +0000 (21:05 +0000)]
Add Windows help topic

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5923 cda61777-01e9-0310-a592-d414129be87e

18 years agoTweaks and more complete documentation for Same Game.
jacob [Tue, 7 Jun 2005 21:03:14 +0000 (21:03 +0000)]
Tweaks and more complete documentation for Same Game.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5922 cda61777-01e9-0310-a592-d414129be87e

18 years agoInteger overflow in game_size(). Oops.
simon [Tue, 7 Jun 2005 20:44:14 +0000 (20:44 +0000)]
Integer overflow in game_size(). Oops.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5921 cda61777-01e9-0310-a592-d414129be87e

18 years agoChris Emerson points out that gtk_window_resize() isn't in GTK 1.2.
simon [Tue, 7 Jun 2005 20:25:25 +0000 (20:25 +0000)]
Chris Emerson points out that gtk_window_resize() isn't in GTK 1.2.
Work around it the same way I did in PuTTY.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5920 cda61777-01e9-0310-a592-d414129be87e

18 years agoJames Harvey's patch to support keyboard control in Same Game.
simon [Tue, 7 Jun 2005 20:22:25 +0000 (20:22 +0000)]
James Harvey's patch to support keyboard control in Same Game.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5919 cda61777-01e9-0310-a592-d414129be87e

18 years agoForgot to add Same Game to the big list for OS X.
simon [Tue, 7 Jun 2005 20:22:08 +0000 (20:22 +0000)]
Forgot to add Same Game to the big list for OS X.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5918 cda61777-01e9-0310-a592-d414129be87e