30 Commits

Author SHA1 Message Date
f3ba6f8bce Cleanups:
- fix documentation of Net's unique solution option (should have
   tested before last checkin)
 - make unique solutions optional in Rectangles too (same reasons)
 - tidy up various issues in parameter encoding in both games.

[originally from svn r5818]
2005-05-21 13:39:23 +00:00
93b955d5ee Cunning way to ensure unique solutions in generated Rectangles
puzzles. I generate the grid of rectangles as normal, but before I
place the numbers I run it through a non-deterministic solver
algorithm which tries to do as much as it can with as little
information about where the numbers are going to be. The solver
itself narrows down the number placement when it runs out of steam,
but does so as little as possible. Once it reaches a state where it
has ensured solubility, and then the generation algorithm chooses
random number placement from whatever's left.

Occasionally it paints itself into a corner and can't ensure a
unique solution no matter what happens; in that situation we just
have to give up, generate a fresh grid, and try again.

[originally from svn r5809]
2005-05-19 16:17:03 +00:00
4670313f6f Rectangles random seed IDs shouldn't bother stating the expansion
factor if it's zero.

[originally from svn r5807]
2005-05-18 17:28:48 +00:00
2534ec5d69 The game IDs for Net (and Netslide) have always been random seeds
rather than literal grid descriptions, which has always faintly
annoyed me because it makes it impossible to type in a grid from
another source. However, Gareth pointed out that short random-seed
game descriptions are useful, because you can read one out to
someone else without having to master the technology of cross-
machine cut and paste, or you can have two people enter the same
random seed simultaneously in order to race against each other to
complete the same puzzle. So both types of game ID seem to have
their uses.

Therefore, here's a reorganisation of the whole game ID concept.
There are now two types of game ID: one has a parameter string then
a hash then a piece of arbitrary random seed text, and the other has
a parameter string then a colon then a literal game description. For
most games, the latter is identical to the game IDs that were
previously valid; for Net and Netslide, old game IDs must be
translated into new ones by turning the colon into a hash, and
there's a new descriptive game ID format.

Random seed IDs are not guaranteed to be portable between software
versions (this is a major reason why I added version reporting
yesterday). Descriptive game IDs have a longer lifespan.

As an added bonus, I've removed the sections of documentation
dealing with game parameter encodings not shown in the game ID
(Rectangles expansion factor, Solo symmetry and difficulty settings
etc), because _all_ parameters must be specified in a random seed ID
and therefore users can easily find out the appropriate parameter
string for any settings they have configured.

[originally from svn r5788]
2005-05-16 18:57:09 +00:00
2621183246 Allow for trailing '\0' in game_text_format() in various games.
[originally from svn r5743]
2005-05-04 12:56:04 +00:00
4f7b65de2e Added an automatic `Solve' feature to most games. This is useful for
various things:
 - if you haven't fully understood what a game is about, it gives
   you an immediate example of a puzzle plus its solution so you can
   understand it
 - in some games it's useful to compare your solution with the real
   one and see where you made a mistake
 - in the rearrangement games (Fifteen, Sixteen, Twiddle) it's handy
   to be able to get your hands on a pristine grid quickly so you
   can practise or experiment with manoeuvres on it
 - it provides a good way of debugging the games if you think you've
   encountered an unsolvable grid!

[originally from svn r5731]
2005-05-02 13:17:10 +00:00
9e240e45df Introduce the concept of a `game_aux_info' structure. This is
constructed at the same time as an internally generated game seed,
so that it can preserve any interesting information known by the
program at generation time but not physically contained within the
text of the game seed itself. (Such as, for example, the solution.)
Currently not used for anything yet, but it will be.

[originally from svn r5729]
2005-05-02 10:12:26 +00:00
850a70a03c Copy-to-clipboard for Rectangles.
[originally from svn r5726]
2005-05-01 13:51:46 +00:00
791940b043 Introduced a new function in every game which formats a game_state
as text. This is used by front ends to implement copy-to-clipboard.
Currently the function does nothing (and is disabled) in every game
except Solo, but it's a start.

[originally from svn r5724]
2005-05-01 12:53:41 +00:00
e72931bfe2 I can never remember what that `TRUE' means in the game structure
definitions, so let's move it so that it's just next to the
functions it relates to. This also opens the way for me to add more
booleans next to other functions without getting confused as to
which is which.

[originally from svn r5723]
2005-05-01 11:07:13 +00:00
cc54553226 Rather than each game backend file exporting a whole load of
functions and a couple of variables, now each one exports a single
structure containing a load of function pointers and said variables.
This should make it easy to support platforms on which it's sensible
to compile all the puzzles into a single monolithic application. The
two existing platforms are still one-binary-per-game.

[originally from svn r5126]
2005-01-17 13:48:57 +00:00
ae63b8010b Remove extraneous underscores at start and end of Rectangles seeds.
[originally from svn r4473]
2004-08-17 11:51:20 +00:00
daac529a9e After discussion with Simon, the game redraw functions are now passed a new
argument `dir' which tells them whether this redraw is due to an undo, rather
than have them second-guess it from game state.
Note that none of the actual games yet take advantage of this; so it hasn't
been tested in anger (although it has been inspected by debugging).

[originally from svn r4469]
2004-08-16 16:29:54 +00:00
58769376e5 Robustness in the face of a completely configurable expansion factor.
[originally from svn r4464]
2004-08-16 13:10:07 +00:00
d58d5c11d5 Fold in the expanded-grid mechanism for generating different kinds
of puzzle. Configurable option, turned off by default, and not
propagated in game IDs (though you can explicitly specify it in
command-line parameters, and the docs explain how).

[originally from svn r4461]
2004-08-16 12:42:11 +00:00
137c1d7bbd Added a help file, mostly thanks to Jacob.
[originally from svn r4460]
2004-08-16 12:23:56 +00:00
fc862ce0f2 Fix a memory leak.
[originally from svn r4239]
2004-05-22 13:07:23 +00:00
350683b253 Introduce routines in each game module to encode a set of game
parameters as a string, and decode it again. This is used in
midend.c to prepend the game parameters to the game seed, so that
copying out of the Specific box is sufficient to completely specify
the game you were playing.
Throughout development of these games I have referred to `seed'
internally, and `game ID' externally. Now there's a measurable
difference between them! :-)

[originally from svn r4231]
2004-05-19 11:57:09 +00:00
ba076fbdb2 Fix `visible' calculation (again).
[originally from svn r4223]
2004-05-12 18:54:16 +00:00
3c2a320143 Ahem. Seed validation was completely broken.
[originally from svn r4222]
2004-05-12 18:53:47 +00:00
1ea3c92c17 During redraws, I now do corner analysis centrally, which enables me
to maintain the `visible' array accurately and hence actually switch
it on. This prevents us having to redraw the entire playing area on
any move, which means really big grids are now sensibly playable
without display lag.

[originally from svn r4221]
2004-05-12 18:45:11 +00:00
3f9e52dae2 Remove vestigial code from the previous attempt at clever grid
generation. Grid generation should now be orders of magnitude faster
at large sizes.

[originally from svn r4220]
2004-05-12 18:28:11 +00:00
0579ca1005 Fiddle with the coordinate system to see if I can improve user
experience.

[originally from svn r4219]
2004-05-12 12:33:03 +00:00
87aec91b37 Flash on completion. Two people actually complained! :-)
[originally from svn r4218]
2004-05-12 12:32:27 +00:00
3ccdce2f6c Missing draw_update call.
[originally from svn r4216]
2004-05-11 23:22:08 +00:00
8a67b0ed2c Cosmetic fixes for Windows.
[originally from svn r4212]
2004-05-11 18:46:10 +00:00
eb8a374d0d We should turn off the dragging variables in the UI _whenever_
`enddrag' is TRUE, not just when the end of the drag was within a
sensible range.

[originally from svn r4210]
2004-05-11 18:32:48 +00:00
e5d773604f Rectangles is now actually playable, since I've used the new UI
feature to arrange a mechanism that allows you to draw a whole
rectangle at a time by dragging rather than having to click each
edge individually.

[originally from svn r4209]
2004-05-11 18:29:49 +00:00
180802b362 Framework alteration: we now support a `game_ui' structure in
addition to the `game_state'. The new structure is intended to
contain ephemeral data pertaining to the game's user interface
rather than the actual game: things stored in the UI structure are
not restored in an Undo, for example.
make_move() is passed the UI to modify as it wishes; it is now
allowed to return the _same_ game_state it was passed, to indicate
that although no move has been made there has been a UI operation
requiring a redraw.

[originally from svn r4207]
2004-05-11 17:44:30 +00:00
a1c88470a3 Added a new game, `Rectangles', taken from nikoli.co.jp.
[originally from svn r4206]
2004-05-11 17:06:50 +00:00