220 Commits

Author SHA1 Message Date
0564c4c4d0 Mines now follows the conventional approach of offering a completely
blank grid until you make the first click; to ensure solubility, it
does not generate the mine layout until that click, and then ensures
it is solvable starting from that position.

This has involved three infrastructure changes:

 - random.c now offers functions to encode and decode an entire
   random_state as a string
 - each puzzle's new_game() is now passed a pointer to the midend
   itself, which most of them ignore
 - there's a function in the midend which a game can call back to
   _rewrite_ its current game description.

So Mines now has two entirely separate forms of game ID. One
contains the generation-time parameters (n and unique) plus an
encoding of a random_state; the other actually encodes the grid once
it's been generated, and also contains the initial click position.
When called with the latter, new_game() does plausibly normal stuff.
When called with the former, it notes down all the details and waits
until the first square is opened, and _then_ does the grid
generation and updates the game description in the midend. So if,
_after_ your first click, you decide you want to share this
particular puzzle with someone else, you can do that fine.

Also in this checkin, the mine layout is no longer _copied_ between
all the game_states on the undo chain. Instead, it's in a separate
structure and all game_states share a pointer to it - and the
structure is reference-counted to ensure deallocation.

[originally from svn r5862]
2005-05-30 13:10:37 +00:00
7ff09fbba1 Neat idea from Gareth: if you put a % on the end of the mine count
in the Custom dialog box, it'll treat it as a mine density.

[originally from svn r5861]
2005-05-30 12:24:31 +00:00
6e7421a3ba Nit: "warning: extra tokens at end of #endif directive"
[originally from svn r5860]
2005-05-30 11:49:08 +00:00
6b9e690c89 Initial checkin of my Minesweeper clone, which uses a solver during
grid generation to arrange a mine layout that never requires guessing.

[originally from svn r5859]
2005-05-30 10:08:27 +00:00
0f423f0b3a Infrastructure change: game_anim_length and game_flash_length now
both get passed a pointer to the game_ui. This means that if they
need to note down information for the redraw function about what
_type_ of flash or animation is required, they now have somewhere to
do so.

[originally from svn r5858]
2005-05-30 07:55:27 +00:00
8fa365a7b4 Add a limited-shuffle mode like that added to Sixteen and Twiddle in r5769,
for completeness.

[originally from svn r5854]
[r5769 == 8f1c713735316422cfe041400ccc49999d563d8b]
2005-05-28 23:45:43 +00:00
c8362f0a94 Add the ability to use the Rectangles solver for actually solving
puzzles, rather than just doing its nondeterministic number
placement thing. This enables the use of the `Solve' menu option on
externally entered game IDs, provided of course that they aren't
_too_ difficult.

[originally from svn r5852]
2005-05-28 08:04:29 +00:00
c82820e55b Add support for Jacob's new cursor-key modifier flags in the OS X frontend.
[originally from svn r5847]
2005-05-26 17:12:04 +00:00
a0f376efbd Sorted out the barriers/corners trouble left by r5844. No wonder
Jacob wasn't able to find a satisfactory fix: the whole area was a
horrid mess. Fortunately, the reason it was a horrid mess was
because the Net drawing routines predated the introduction of clip()
in the frontend interface, and it turns out that clip() makes it
possible to do all this more easily and better. So, a complete
rearchitecting of barrier corners: the corner flags in the
`barriers' array are now gone (and good riddance), and corner
information is computed on the fly so as to take into account the
moving grid edges. In the process I've also updated the corner
mechanism so that a barrier `corner' (really endpoint) is drawn at
the end of _every_ barrier, not just where two meet. This has
changed the appearance of a single isolated barrier, to what I would
have wanted it to look like in the first place but achieving it
without clip() was just too fiddly.

[originally from svn r5846]
[r5844 == 865e8ad6ca3d83ad2a585ceeb1809e9f68c18a20]
2005-05-26 17:03:51 +00:00
3dc0fce9b8 Since the split into random and descriptive IDs, the section on game seeds has
been mostly covered by the main documentation or otherwise moot.

[originally from svn r5845]
2005-05-26 16:57:19 +00:00
865e8ad6ca Add origin-shifting (Shift+cursors) and source-shifting (Ctrl+cursors) to Net.
(Adding modifier+cursors handling has had minor knock-on effects on the other
puzzles, so that they can continue to ignore modifiers.)

(An unfortunate side effect of this is some artifacts in exterior barrier
drawing; notably, a disconnected corner can now appear at the corner of the
grid under some circumstances. I haven't found a satisfactory way round
this yet.)

[originally from svn r5844]
2005-05-26 13:40:38 +00:00
a1be37343c Support for `pencil marks' in Solo, by right-clicking and typing a
number. Many thanks to Chris Thomas, for helping with the detailed
UI design by means of testing an endless series of prototypes.

[originally from svn r5842]
2005-05-25 11:09:43 +00:00
5409c27b4f Mention NetWalk and update comment
[originally from svn r5841]
2005-05-24 20:28:38 +00:00
49fdcd1ed4 Avoid leading zeroes on internally generated random seeds, _just_ in
case they confuse anyone who expects the same seed without the
leading zero to be equivalent.

[originally from svn r5838]
2005-05-23 12:02:37 +00:00
80aa8bafb1 I'm sick of `--generate' giving the same answers if you run it twice
in one second. Switched the Unix get_random_seed() to using
gettimeofday() rather than time().

[originally from svn r5837]
2005-05-23 11:15:39 +00:00
916ad91298 The GTK `--generate' option didn't validate the game parameters. It
does now.

[originally from svn r5836]
2005-05-23 11:13:39 +00:00
9c54e18f0b Net hangs if you ask it for a 2xn or nx2 wrapping puzzle with a
unique solution. This, it turns out, is because there is literally
no such thing. Protective constraint added to validate_params(),
with a proof in a comment alongside.

If you really want a 2xn or nx2 wrapping puzzle, you can still have
one if you turn uniqueness off.

[originally from svn r5835]
2005-05-23 11:03:52 +00:00
3266a0e7ba Aesthetic improvements, mostly suggested by Gareth.
[originally from svn r5833]
2005-05-22 13:35:13 +00:00
466e9d21a7 Forgot to add print.py to the source archive. Ahem.
[originally from svn r5830]
2005-05-22 12:45:39 +00:00
ba3247bb92 Another tweak to the solver to make it handle blank tiles correctly.
The previous checkin stopped it choking on them, but it didn't
actually manage to _deduce_ that all the edges bordering them had to
be closed. Now it does better.

[originally from svn r5829]
2005-05-22 12:14:39 +00:00
0066cdd62a Special case in dead-end checking which prevents the solver falling
over on a grid containing a 0 (completely blank) tile. This can't
happen in self-generated grids, but can happen if you type in a grid
from another Net implementation. Previously, the solver would notice
(technically correctly!) that a completely blank tile connects to no
other tiles and thus forms an isolated subgraph, and would therefore
complain that no orientation of that tile could possibly yield a
valid solution...

[originally from svn r5828]
2005-05-22 11:45:20 +00:00
fc3f16b364 The Net solver now makes use of barrier information when applied to
a typed-in grid.

[originally from svn r5827]
2005-05-22 11:15:03 +00:00
d45d94d355 It occurred to me yesterday that Net could perfectly well be played
on paper, so here's a routine to print it out.

[originally from svn r5826]
2005-05-22 11:06:25 +00:00
8ddfc3904b Ensure that an old random seed isn't left around for the user to see when a
descriptive ID has been specified.
Fix tiny memory leak.

[originally from svn r5825]
2005-05-21 22:07:48 +00:00
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
862e25c90b Solution uniqueness for Net. Can be disabled on request (but is
enabled by default), since ambiguous sections in grids can present
additional interesting challenges. I think uniqueness is a better
default, though.

[originally from svn r5816]
2005-05-21 13:23:26 +00:00
5810785da1 Move IDM_ABOUT so that it doesn't overlap the presets space! Ahem.
[originally from svn r5814]
2005-05-20 12:30:37 +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
b1c0d665bd If you paste in a random seed with different ephemeral parameters
from the currently configured ones, and then bring the Random Seed
box back up, the wrong parameters get shown, and the resulting
random seed is incorrect for the current game.

At least, it was, until this checkin.

[originally from svn r5808]
2005-05-18 17:41:53 +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
cf9e6e81eb --version.
[originally from svn r5806]
2005-05-18 17:27:16 +00:00
981b831c21 It's a good idea to validate presets received from the environment.
[originally from svn r5805]
2005-05-18 17:25:30 +00:00
90e42d4cde Move the colour configuration into midend.c so that it becomes
cross-platform, and rename the environment variables so that they
follow the puzzle name. Should allow a static environment
configuration for each puzzle. Also introduced a <game>_PRESETS
variable for people whose favourite configuration isn't on the Type
menu by default.

[originally from svn r5801]
2005-05-18 09:04:47 +00:00
1304e07d74 Standalone solvers were broken by my recent API changes.
[originally from svn r5800]
2005-05-18 08:34:01 +00:00
58eb0551d4 Update doc for recent changes in Restart behaviour.
[originally from svn r5799]
2005-05-17 18:04:12 +00:00
0e197efe44 After much thought, I've decided that `Restart' on r is not a
particularly useful keypress, particularly given how easy it is to
confuse it with `Redo'. So both r and ^R are now Redo, and Restart
is relegated to being a menu-only option.

[originally from svn r5796]
2005-05-17 17:20:08 +00:00
f3a2773802 Null-terminate generated Net/Netslide descriptive game IDs.
[originally from svn r5794]
2005-05-17 12:02:30 +00:00
4b02ebae71 Keyboard shortcuts for Twiddle: abcdABCD in line with the notation
Gareth and I have been using to analyse the game, and also the
number pad. They don't work sensibly for all sizes, but they'll be
handy for the most common ones.

[originally from svn r5793]
2005-05-17 11:53:42 +00:00
b77d727eb4 Just for Gareth: a means of overriding individual game colour
settings using environment variables. GTK frontend only, because
this is an unsupported (and unprincipled) hack.

[originally from svn r5792]
2005-05-17 11:47:33 +00:00
c9f05ca3c0 `Restart' is now an undo-able action: it appends a move to the end
of the undo list rather than destroying it. Partly this is because
accidental restarts are a real pain, and partly because it allows
you to compare the initial to the current state by restart-then-undo
which is handy in some puzzles.

In order to do this, I've introduced an additional per-entry field
in the undo list in the midend, which tracks which states were
created by `unusual' operations (Solve and Restart). The midend
takes care of suppressing animation and completion flashes during
transitions between a `special' state and its predecessor, relieving
the game backends of having to do it individually.

(This probably means I could remove some complexity in the
flash_time() functions in most backends, but I haven't done that in
this checkin.)

[originally from svn r5791]
2005-05-17 11:46:55 +00:00
0913f94a98 comment c'n'p error
[originally from svn r5790]
2005-05-17 11:00:15 +00:00
6c3f422dde Cube's dup_game() function was missing a field. Oops.
[originally from svn r5789]
2005-05-17 10:59:47 +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
aa1185f3f5 Missed a vital semicolon off the Cygwin version.c makefile fragment.
[originally from svn r5784]
2005-05-15 11:12:05 +00:00
3dfeadd738 Er, except that I already had a makedist.sh. Transferred new version
code into that!

[originally from svn r5783]
2005-05-15 10:58:09 +00:00
1add9dcc1b Added automatic determination of the SVN revision number if a build
takes place in a checked-out copy. Also added mkunxarc.sh which does
the same version determination before building its archive.

[originally from svn r5782]
2005-05-15 10:52:23 +00:00
c05b4697a8 Introduce a versioning mechanism, and an `About' box in all front
ends. Versioning will be done solely by Subversion revision number,
since development on these puzzles is very incremental and gradual
and there don't tend to be obvious points to place numbered
releases.

[originally from svn r5781]
2005-05-15 10:31:11 +00:00
68d27f0526 I've had two complaints that Solo ought to recognise the numeric
keypad. The reason it doesn't is because front ends were carefully
translating the numeric keypad into 8-way directional keys for the
benefit of Cube. Therefore, a policy change:
 - front ends process the numeric keypad by sending MOD_NUM_KEYPAD |
   '3' and similar
 - front ends running on a platform with Num Lock SHOULD do this
   _irrespective_ of the state of Num Lock
 - back ends do whatever they see fit with numeric keypad keys.
Result: the numeric keypad now works in Solo, and also works in OS X
Cube (which it previously didn't because I forgot to implement that
bit of the front end!).

[originally from svn r5774]
2005-05-12 18:25:57 +00:00
8f1c713735 The two Rubik-like puzzles, Sixteen and Twiddle, now support an
additional configuration parameter, which is the number of shuffle
moves. By default the grid will be fully shuffled so that you need a
general solution algorithm to untangle it, but if you prefer you can
request a grid which has had (say) precisely four moves made on it,
and then attempt to exactly reverse those four moves.

Currently this feature is only available from the Custom box, and
not in any presets.

[originally from svn r5769]
2005-05-11 20:38:10 +00:00
18a8df1b9d Bah. Try the r5766 fix again, this time without the typo.
[originally from svn r5767]
[r5766 == 701cd045b36f9be1b0b8cfb74d9c191cb5813e98]
2005-05-11 18:49:42 +00:00