730 Commits

Author SHA1 Message Date
4a3c26ff14 Emma Garside suggested that it would be nice to have a different
background colour for covered and uncovered squares in Mines, since
otherwise you have to distinguish them by the edge highlights alone.
So here one is; it's not _very_ different (it just looked odd if it
was any darker than this), but anyone who wants a bigger difference
can reconfigure it using the MINES_COLOUR_1 environment variable.

[originally from svn r5876]
2005-05-31 11:20:24 +00:00
0c7f777ecb Improved the limited shuffle mechanism in Sixteen and Twiddle. They
were already making sure that no shuffle move was the precise
inverse of the previous one, or contributed to repeating the
previous one so many times as to turn it into effectively fewer
moves (doing the same rotation three times in Twiddle, or shifting a
row by more than half its length in Sixteen). However, they were
only checking against the _last_ move, which meant that in any
situation where there were completely disjoint move spaces (4x4n2
Twiddle, or any Sixteen at all) it was still possible to have A then
B then inv(A) occurring in the shuffle, leading to an unnecessarily
easy game.

Now both shuffle routines keep separate track of all
_non-overlapping_ recent moves, and will avoid inverting any move
which hasn't had another move overlap it since it was made. This
should reduce the incidence of too-easy limited shuffle games,
although it can't be prevented _entirely_ (since, if nothing else,
it's always possible to increase the shuffle limit past the maximum
group radius).

[originally from svn r5875]
2005-05-31 11:19:11 +00:00
412344ff9a Fix a couple of robustness issues.
[originally from svn r5873]
2005-05-31 08:56:33 +00:00
2698fc9e9e GTK misfires timers at inconvenient moments, sometimes causing a new
puzzle of a different size to be redrawn before the pixmap is
resized, and since backends never redraw already-drawn stuff this is
a problem. Was biting me when I entered a Mines game ID of a
different size than the current settings into the Specific box.

[originally from svn r5872]
2005-05-31 08:50:42 +00:00
ee429c13cd Chris's patch to stop Mines depending on char being signed.
[originally from svn r5871]
2005-05-30 22:33:34 +00:00
e4328b9081 Added an `interactive' flag to new_game_desc(), which toggles Mines
between on the one hand generating indeterminate game descriptions
awaiting the initial click, and on the other hand generating
concrete ones which have had their initial click. This makes `mines
--generate' do something useful.

[originally from svn r5869]
2005-05-30 18:41:40 +00:00
3c6b77c93b `Copy' operation for Mines.
[originally from svn r5868]
2005-05-30 18:24:06 +00:00
0e5380b96d Constrain mine count to be at most the largest number of mines we
can guarantee to fit into the grid!

[originally from svn r5867]
2005-05-30 17:57:45 +00:00
90560462c4 First cut at a game timer. Yet another backend function which
indicates whether a particular game state should have the timer
going (for Mines the initial indeterminate state does not have this
property, and neither does a dead or won state); a midend function
that optionally (on request from the game) prepends a timer to the
front of the status bar text; some complicated midend timing code.

It's not great. It's ugly; it's probably slightly inaccurate; it's
got no provision for anyone but the game author decreeing whether a
game is timed or not. But Mines can't be taken seriously without a
timer, so it's a start.

[originally from svn r5866]
2005-05-30 16:15:34 +00:00
7ddaa1382f D'oh, there's always one. Remove first-click stuff from the todo list.
[originally from svn r5863]
2005-05-30 13:11:05 +00:00
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