181 Commits

Author SHA1 Message Date
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
701cd045b3 Completion flashes were occasionally failing to be cleaned up if a
subsequent move animation began during them. Tracked this to
overenthusiastic use of clip() and fixed it.

[originally from svn r5766]
2005-05-11 13:03:17 +00:00
751d7a2524 solve_game() is passed the _initial_ game state, not the most recent
one; so we can't just set `ret->completed = ret->movecount' and hope
it's been set to something other than zero. Instead, we set both
move counts to 1, which is entirely arbitrary but works.

This fixes a subtle bug with the Solve feature: if you pressed
Solve, then disturbed the grid, then brought it back to the solved
state by making more forward moves (rather than using Undo), then
the first time you did this the `Moves since auto-solve' status line
would reset to zero.

[originally from svn r5759]
2005-05-07 16:07:26 +00:00
6336dbf208 Add 3x3 Trivial to the presets list, and make it the default.
[originally from svn r5757]
2005-05-07 12:35:04 +00:00
944997d2f9 Aha, here's a nice easy way to generate really hard puzzles. Added
the missing fifth difficulty level to Solo: `Unreasonable', in which
even set-based reasoning is insufficient and there's no alternative
but to guess a number and backtrack if it didn't work. (Solutions
are still guaranteed unique, however.) In fact it now seems to take
less time to generate a puzzle of this grade than `Advanced'!

[originally from svn r5756]
2005-05-07 12:30:29 +00:00
b35bedd60c Fix outdated comment
[originally from svn r5744]
2005-05-04 13:17:45 +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
38c1f9b702 The Twiddle shuffling algorithm was theoretically parity-unbalanced:
it performed a fixed number of shuffling moves, and on each one it
had a 2/3 chance of flipping the permutation parity and a 1/3 chance
of keeping it the same. Markov analysis shows that over a run of
1500-odd shuffle moves this will end up being an undetectably small
actual bias in the parity of the generated grid, but it offends my
sense of pedantry nonetheless so here's a small change to make the
number of shuffling moves itself have randomly chosen parity. The
parity of generated grids should now be _exactly_ 50:50.

[originally from svn r5742]
2005-05-04 12:52:51 +00:00
1c77e0df94 markup typo
[originally from svn r5739]
2005-05-04 12:24:16 +00:00
b32b4f8763 I've changed my mind. For the benefit of users with slower
computers, let's save the Solo and Pattern grids at generation time
and regurgitate them when asked to solve, rather than doing all the
work over again.

[originally from svn r5737]
2005-05-02 16:59:50 +00:00
cf7988afb3 Fix line endings when pasting on Windows.
[originally from svn r5736]
2005-05-02 16:37:20 +00:00
82b8e2faf5 Forgot to mention that you can undo a Solve operation.
[originally from svn r5734]
2005-05-02 13:27:59 +00:00
c2273f2718 Ahem. The `Solve' option in orientable Twiddle needs to correct the
orientations as well as the order!

[originally from svn r5733]
2005-05-02 13:22:25 +00:00
d8cc157c55 Silly (but harmless) typo.
[originally from svn r5732]
2005-05-02 13:18:24 +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
aea7b61815 Oops; forgot to check in the copy-to-clipboard option for Windows.
[originally from svn r5730]
2005-05-02 10:55:32 +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
3f9d88f3e7 It's actually vitally important, it turns out, to have all of the
`Cut', `Copy' and `Paste' items in the Edit menu of an OS X
application - because there's nothing else that enables the keyboard
cut/copy/paste shortcuts in an edit box! OS X Puzzles can now have
game IDs pasted into it, which it previously couldn't.

[originally from svn r5728]
2005-05-02 09:42:09 +00:00
28f655c821 The addition of a `Copy' menu item on OS X was really beginning to
strain my unconventional menu organisation, so I've reverted to
having `File' and `Edit' menus like everyone else.

[originally from svn r5727]
2005-05-01 14:05:03 +00:00
850a70a03c Copy-to-clipboard for Rectangles.
[originally from svn r5726]
2005-05-01 13:51:46 +00:00
cb413f837b Copy-to-clipboard facility for Fifteen, Sixteen and Twiddle.
[originally from svn r5725]
2005-05-01 13:22:44 +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
5649e20ef2 Remove outdated comment :-)
[originally from svn r5722]
2005-05-01 10:57:47 +00:00
6aca542184 I think Windows fonts look better in bold as well.
[originally from svn r5721]
2005-05-01 10:57:23 +00:00
90db70378e Fix game IDs, which I broke in the orientability change. Also
introduce a sensible game ID notation for orientable games, and
finally (*blush*) turn the orientability triangles back the right
way up.

[originally from svn r5718]
2005-04-30 14:50:33 +00:00
9b870146f7 After brainstorming with Gareth, we've decided that this is a much
simpler and better way to indicate tile orientation than those
colour bars.

[originally from svn r5717]
2005-04-30 14:38:20 +00:00
d40b3172fe Bah, and of course there's a TODO comment I forgot to remove.
[originally from svn r5714]
2005-04-30 14:14:37 +00:00
d35f64096d Twiddle now has an additional mode in which tile orientation
matters. This mode is hard enough to scare the wossnames out of me,
but that's no reason not to put it in anyway!

[originally from svn r5713]
2005-04-30 14:14:14 +00:00
f5ae256b77 Pango-derived fonts seem to generally look better if I ask for them
in bold.

[originally from svn r5709]
2005-04-30 13:11:22 +00:00
3be19aed94 New puzzle: `twiddle', generalised from a random door-unlocking
gadget in Metroid Prime 2.

[originally from svn r5708]
2005-04-30 12:54:22 +00:00
79a77d53e1 Added a `--generate' command-line option in the GTK port of every
puzzle, to make it construcct puzzle IDs and output them on stdout.
Also checked in print.py, a script which reads puzzle IDs on stdin
and produces PostScript output. With these, you can generate pages
of Pattern, Rectangles and Solo puzzles to take on trains with you.

[originally from svn r5707]
2005-04-29 17:07:19 +00:00
d55d0b53f3 Correct block coordinate display when standalone solver shows its
working.

[originally from svn r5706]
2005-04-29 08:11:01 +00:00
df133c2297 Aha, even better: a Makefile hack that causes auto-detection of GTK
2 and fallback to GTK 1.2.

[originally from svn r5705]
2005-04-28 12:50:56 +00:00
3d4f276f1f Fix inconsistent vertical centring of text in GTK (and update Solo's
todo list, which complained about this because Solo was the only
puzzle noticeably affected).

[originally from svn r5694]
2005-04-27 19:44:34 +00:00
37a0c1af6a Patches for GTK 2. Puzzles already _built_ under GTK 2, but now it
builds better:
 - the GTK makefile now defines $(GTK_CONFIG) which you can
   override, so you can build for GTK 2 with no makefile-editing
   simply by running `make GTK_CONFIG="pkg_config gtk+-2.0"'
 - we use Pango to find appropriate fonts, which means the text in
   the puzzles actually (gasp!) adapts its size to the
   circumstances. Unfortunately, I've been unable to do this
   portably without depending on _either_ a Pango function that
   isn't present in older versions _or_ the underlying window system
   being X11; I'd appreciate someone doing better.

[originally from svn r5693]
2005-04-27 19:39:20 +00:00
8b31b4606c Command-line solver was dividing up non-square puzzles the wrong way
round.

[originally from svn r5691]
2005-04-27 16:59:18 +00:00
4ba97c64fe Pattern also contains an internal solver, so here's a command-line
interface to it just in case it comes in handy.

[originally from svn r5686]
2005-04-27 11:13:33 +00:00
37ad6698a5 The command-line solver's difficulty gradings now use the same
terminology as the puzzle GUI.

[originally from svn r5683]
2005-04-26 17:03:56 +00:00
070fb537cf Implement the remaining modes of reasoning in nsolve, and thus
enable configurable puzzle difficulty. I'm only generating grids up
to Times level (complicated non-recursive analysis but guessing
never required); I wouldn't object to providing a Telegraph
difficulty level (guessing required) but it turns out to be very
hard indeed to generate at random. I might still add it later
(probably under the name `Unreasonable' :-) if I can think of an
efficient way to find them.

[originally from svn r5682]
2005-04-26 11:19:00 +00:00