508 Commits

Author SHA1 Message Date
23ab000b7b Cleanup: rename random_init() to random_new(), because it actually
_allocates_ a random_state rather than just initialising one passed
in by the caller.

[originally from svn r6412]
2005-10-22 16:27:54 +00:00
4faecc7726 New puzzle from James H: `Bridges', another Nikoli job.
[originally from svn r6409]
2005-10-21 08:07:31 +00:00
6ea453c95f Miscellaneous fixes. Correct a comparison of y with w causing
assertion failures in portrait-type grids; retire an unused array in
the game generation function (my original generation strategy needed
it, but the final one didn't); correct a typo; further restrict the
generable sizes of game and include a special case for 4x4dt to
prevent a tight loop.

[originally from svn r6405]
2005-10-17 18:41:05 +00:00
f9168d6003 Just noticed a longhand shuffling operation which I must have missed
when I converted them all into calls to shuffle().

[originally from svn r6404]
2005-10-17 18:32:24 +00:00
5f16a29d4c Janes H provides a small workaround for a Palm tools bug.
[originally from svn r6403]
2005-10-15 16:03:14 +00:00
3bee86241c Small error in solver diagnostics.
[originally from svn r6402]
2005-10-15 15:01:40 +00:00
e841ab4367 Revamp of the control mechanism to permit drag- as well as
click-based control. Only used for right-dragging to clear a large
area to NONTENT.

[originally from svn r6400]
2005-10-14 12:23:41 +00:00
669bb81f08 New puzzle: `Tents'. Requires a potentially shared algorithms module
maxflow.c. Also in this checkin, fixes to the OS X and GTK back ends
to get ALIGN_VNORMAL right. This is the first time I've used it! :-)

[originally from svn r6390]
2005-10-13 18:30:24 +00:00
29afca3ef9 loopy_diffnames[] isn't used, and provokes a warning on OS X.
[originally from svn r6389]
2005-10-13 18:27:57 +00:00
2bef4dfb50 Yikes! I've only just noticed that this copy of tree234.c was still
using unwrappered malloc/free, leaving plenty of openings for out-
of-memory segfaults. Switch to using Puzzles's memory management,
which I should have done right at the start but can only assume I
forgot about.

[originally from svn r6388]
2005-10-12 17:57:40 +00:00
7e57366a57 r6384 didn't go quite far enough. In fact, a grid square which
differs between oldstate and state in only the hint bit should not
have a flip animation even if hints_active is TRUE. Flip animations
should only happen for tiles which are changing their primary state.
(Put like that, it seems so obvious.)

Test case which demonstrates this fix to be right and r6384 to be
wrong: 3x3:101000000000000000000,300 . Hit Solve immediately and
then click on the red-highlighted squares.

[originally from svn r6385]
[r6384 == dd175e490a197026210ba4432eec6236971c6173]
2005-10-10 17:22:33 +00:00
dd175e490a Fixes for handling human-entered Flip games. The clicked-on square
always got a flip animation even when it wasn't one of the ones
being turned, and a square with no effect at all was still counting
as a move.

Since it's an invariant of Flip's internal generator that every
square includes itself as an effect, this never comes up in auto-
generated games.

[originally from svn r6384]
2005-10-10 16:31:26 +00:00
813cd5e3bf Richard Earnshaw points out that if you enter an out-of-range number
in the game description, the solver will fail to notice it and
overrun an array leading to assertion failure, silent wrong answers
or (in extreme cases) segfaults. Hence, validate_desc() now spots
them and kicks them out.

[originally from svn r6383]
2005-10-10 16:29:58 +00:00
8a8474a311 Use game_set_size() to set up the temporary drawstate in
game_print(), wherever feasible. This fixes a specific bug in Loopy
(James H's new field ds->linewidth wasn't being set up, leading to
corrupted print output), but I've made the change in all affected
files because it also seems like a generally good idea to encourage
it for future games, to prevent other problems of this type.

There is one slight snag, which is that Map _can't_ do this because
its game_set_size() also initialises a blitter. I could fix this by
abstracting the common parts of Map's game_set_size() out into a
subfunction called by game_set_size() and also called directly by
game_print(); alternatively, I could introduce a means of
determining whether a `drawing *' was for screen or printing use.
Not sure which yet.

[originally from svn r6340]
2005-09-23 12:50:51 +00:00
733e3c6bc7 Fix very strange indentation issue!
[originally from svn r6339]
2005-09-23 12:43:42 +00:00
71966d06a2 Bug fix from James H: prevent LINEWIDTH ever reaching zero.
[originally from svn r6331]
2005-09-18 17:00:07 +00:00
c8145f3bba Another optimisation patch from Mike, which (among other things)
eliminates gratuitous duplication of the solver state every time it
goes round the main loop, in favour of the usual type of
`done_something' flag.

[originally from svn r6322]
2005-09-18 12:09:16 +00:00
8730242870 Optimisation patch from Mike: remember which squares we've entirely
finished dealing with, and don't do them again on the next loop.

[originally from svn r6312]
2005-09-15 18:09:27 +00:00
a5891971c1 Patch from Mike: fix an array indexing error in the clue
highlighting, and adjust the presets.

[originally from svn r6303]
2005-09-13 18:34:12 +00:00
c389f623f6 Patch from Mike:
- remove the backtracking `Hard' level, on the grounds that it was
   incredibly slow and not really usable.
 - introduce an `Easy' difficulty level below the standard one; many
   people seem to find this puzzle unusually hard, so an easy level
   is particularly helpful.
 - highlight unfulfillable clue squares (but not yet any other types
   of obvious error).

[originally from svn r6299]
2005-09-12 17:13:26 +00:00
a8980f3736 I am again gormless! When I overhauled Solo's grid generator in
r6160, I completely failed to ensure that generated grids were _at
most_ the required difficulty. It appears to have been only random
chance that prevented a request for a Trivial puzzle from producing
Extreme. Here's a one-line fix.

[originally from svn r6298]
[r6160 == e55838bc9b0d173ca539d0cfe714495b5c12b9dd]
2005-09-12 17:09:29 +00:00
f07576f49e I found a slightly odd-looking line of code in this file a few days
ago, and nearly changed it to the obvious thing. After some thought,
though, I've decided the `bug' is better off unfixed, and added a
comment explaining why.

[originally from svn r6293]
2005-09-12 12:38:58 +00:00
f71630073f Minor improvement to initial loop generation.
[originally from svn r6292]
2005-09-11 18:05:23 +00:00
6bbcf248aa Oops; left some rogue diagnostics in.
[originally from svn r6291]
2005-09-11 14:53:39 +00:00
3d3d00991a Run the final solution-reduction pass in both directions, since
Gareth managed to find an example (10x8#458168771440033 in r6289)
where running it in only one direction failed to eliminate an
obviously redundant piece of path.

[originally from svn r6290]
[r6289 == b25fcc3f2621b0b41f3ae7cdabe57ed07f62d2c2]
2005-09-11 14:22:32 +00:00
b25fcc3f26 Solve function for Inertia, using what's essentially an approximate
TSP algorithm.

[originally from svn r6289]
2005-09-11 12:40:49 +00:00
08c8cf370e Marginally greater robustness in the face of solve_game() failing to
return an error message.

[originally from svn r6288]
2005-09-11 11:57:24 +00:00
efda6cff49 Completely rewrite the loop-detection algorithm used to check game
completion, _again_. In r6174 I changed it from dsf to conventional
graph theory so that it could actually highlight loops as opposed to
just discovering that one existed. Unfortunately, yesterday I
discovered a fundamental graph-theoretic error in the latter
algorithm: if you had two entirely separate loops connected by a
single path, the path would be highlighted as well as the loops.

Therefore, I've reverted to the original dsf technique, combined
with a subsequent pass to trace around each loop discovered. This
version seems to do a better job of only highlighting the actual
loops.

[originally from svn r6283]
[r6174 == 2bd8e241a93165a99f5e2c4a2dd9c3b3b1e3c6f3]
2005-09-10 09:39:29 +00:00
72989cdf1d Patch from James H which initialises a couple of Windows API object
handles to NULL before accidentally trying to use them for anything.

[originally from svn r6282]
2005-09-10 08:31:22 +00:00
f8d1183c7a I arranged that dying after the game was already completed didn't
increment the deaths counter. In doing so, I incorrectly handled the
borderline case, so that a death incurred _in the act_ of collecting
the final gem also didn't increment the deaths counter. Now it does.

[originally from svn r6277]
2005-09-06 22:28:04 +00:00
aec9667f00 Take the Windows taskbar into account when deciding on the maximum
size of the puzzle window. This has involved some _completely
stupid_ window manipulation: in order to figure out in advance how
big I want my main window to be, I first have to _create_ the status
bar so I know how tall it is; but since I can't reparent it into my
main window after I've created it, I then have to throw that status
bar away and create a new one. *sigh*

[originally from svn r6276]
2005-09-06 18:49:18 +00:00
7096df54de Various patches from Ben H: a fix for an outdated comment, a couple
of spurious ps_printf() arguments removed, and an error check in the
`make install' target.

[originally from svn r6275]
2005-09-05 17:21:05 +00:00
56ff3647e2 I've dithered a bit in the past about whether or not it's allowable
to call game_set_size() twice on the same drawstate. Finally, a
definite decision: it isn't. Accordingly, midend.c arranges never to
do so, the devel docs state that puzzles may enforce by assertion
that it never happens, and the four puzzles which care (i.e. use
blitters) do so.

[originally from svn r6274]
2005-09-05 17:18:03 +00:00
fd1735170e Patch from Ton van Overbeek to fix a small memory leak in
midend_solve().

[originally from svn r6271]
2005-09-04 12:53:27 +00:00
fe65b2efbd Patch from Ton van Overbeek to correct Loopy's misplaced line ends
at small tile sizes.

[originally from svn r6270]
2005-09-04 12:46:19 +00:00
dd7c1c983c Another global environment-variable override across all games. This
one is <game>_TILESIZE, adjusting the game's default size. I
anticipate that this will probably _mostly_ be useful for debugging.

[originally from svn r6269]
2005-09-04 12:40:23 +00:00
6ee8a4d71e Couple of minor updates to restore accuracy.
[originally from svn r6268]
2005-09-04 12:31:04 +00:00
41b9855da9 Patches from James H. The usual stuff (memory leak fixes and 16-bit
cleanliness), plus he's enlarged the pencil-mark circles from
TILESIZE/8 to TILESIZE/7. Makes no difference at all (thanks to
integer division) when TILESIZE is the default of 20, but presumably
helps at some other tile sizes. Fine by me.

[originally from svn r6265]
2005-09-03 18:32:58 +00:00
d7c12b3122 Someone points out that the Solo text formatter would be a lot
better if it marked empty cells with something other than a space.
So here's a three-bit change to turn it into a dot :-)

[originally from svn r6261]
2005-09-02 13:40:16 +00:00
8d4b62c9bd Stop Light Up from eating system keypresses, which it was previously
doing whenever the cursor was active.

[originally from svn r6258]
2005-09-01 17:25:06 +00:00
bd5606ae74 Optimiser placation.
[originally from svn r6257]
2005-09-01 12:17:14 +00:00
643f468255 Palm fixes for Loopy from James H: a #ifdef SLOW_SYSTEM, and an
int/long fix.

[originally from svn r6256]
2005-09-01 12:00:55 +00:00
04e26aaa7b James H's memory leak fixes to Inertia.
[originally from svn r6255]
2005-09-01 11:59:51 +00:00
94b36c11e0 James H has implemented a new `Tricky' difficulty level in Light Up:
a non-recursive level above Easy, which therefore moves the
recursive Hard mode further up still. Play-testing suggests that in
fact Tricky is often _harder_ than the old Hard mode, since the
latter had limited depth of recursion and would therefore spot
complex deductions only if it happened to start a recursion on the
right square; Tricky may be limited in the sophistication of its
complex deductions, but it never misses one, so its puzzles tend to
be hard all over.

Also in this checkin, a new source file `nullfe.c', containing all
the annoying stub functions required to make command-line solvers
link successfully. James wrote this for (the new) lightupsolver, and
I've used it to simplify the other stand-alone solvers.

[originally from svn r6254]
2005-09-01 11:57:56 +00:00
6992530a85 Ability to drag pencil marks around.
[originally from svn r6250]
2005-08-31 19:27:41 +00:00
c70312f8a8 Terribly cunning approach to making the pencil marks look nicer,
thanks to Gareth.

[originally from svn r6248]
2005-08-31 17:34:47 +00:00
7b08221952 Debian requires -lm, where Red Hat didn't.
[originally from svn r6247]
2005-08-31 16:59:51 +00:00
068a092cd5 Ahem; forgot about recursion. Recursive solving now shows its
working as well.

[originally from svn r6245]
2005-08-31 12:43:14 +00:00
f2ff444fca Now that Map has some seriously complex deductions, it's about time
it had a command-line solver. In order to do this, I've had to
expose the internal region numbering because the solver has to have
some way to state which region it means; and in any case it's also
useful to have human-visible region numbering so that two people can
discuss a puzzle they're solving together. So pressing L during play
now toggles the display of region numbers; and `mapsolver' uses
those same numbers when showing its working and its solutions.

[originally from svn r6244]
2005-08-31 12:17:01 +00:00
121f664b62 Forcing chains in Map give rise to a new `Hard' difficulty level.
Also implemented the Map analogue of Solo's pencil marks, to make
this mode more playable.

[originally from svn r6240]
2005-08-30 19:42:45 +00:00