514 Commits

Author SHA1 Message Date
56e01e54fa New puzzle: `Light Up', by James H.
Also in this checkin (committed by mistake - I meant to do it
separately), a behind-the-scenes change to Slant to colour the two
non-touching classes of diagonals in different colours. Both colours
are set to black by default, but configuration by way of
SLANT_COLOUR_* can distinguish them if you want.

[originally from svn r6164]
2005-08-04 19:14:10 +00:00
20b1a77244 Environment-based configuration wasn't sensibly usable in games with
spaces in the name. Fixed. (One day I really must get round to
turning this into a proper config mechanism.)

[originally from svn r6163]
2005-08-04 18:09:48 +00:00
dc74c8b93d Patch from James H: tinker with the presets on SLOW_SYSTEMs.
[originally from svn r6162]
2005-08-04 17:08:26 +00:00
2e214d740c Bug fix from James H: solve_game() was returning error messages in
the return value rather than in *error. In the old days type-
checking would have caught this, but now of course they're the same
type.

[originally from svn r6161]
2005-08-04 17:07:51 +00:00
e55838bc9b I am COMPLETELY GORMLESS. The Solo grid generator, when eliminating
clues from a filled grid, was using the algorithm

 - loop over the whole grid looking for a clue (or symmetry group of
   clues) which can be safely removed
 - remove it
 - loop over the whole grid again, and so on.

This was due to my vague feeling that removing one clue might affect
whether another can be removed. Of course this can happen - two
clues can be alternative ways of deducing the same vital fact so
that removing one makes the other necessary - but what _can't_
happen is for removing one clue to make another _become_ removable,
since you can only do that by _adding_ information. In other words,
after testing a clue and determining that it can't be removed, you
never need to test it again. Thus, a much simpler algorithm is

 - loop over the possible clues (or symmetry groups) _once_, in a
   random order
 - for each clue (group), if it is removable, remove it.

This still guarantees to leave the grid in a state where no further
clues can be removed, but it greatly cuts down puzzle generation
time and also simplifies the code. I am a fool for not having
spotted this in three and a half months!

[originally from svn r6160]
2005-08-04 11:16:10 +00:00
414330d9ad Cleanups from James H: a few missing statics, a precautionary cast
or two, a debugging fix, a couple of explicit initialisations of
variables that were previously read uninitialised, and a fix for a
whopping great big memory leak in Slant owing to me having
completely forgotten to write free_game().

[originally from svn r6159]
2005-08-03 12:44:51 +00:00
c212a1b5eb Slant uses the same generation strategy as Solo, despite not having
the property which devel.but claimed to be the reason why that
strategy works. A bit of thought revealed what the _real_ reason is
why this strategy works in some puzzles and not others, so I've
rewritten the paragraph to be more accurate.

[originally from svn r6158]
2005-08-03 11:06:16 +00:00
727a18a5a0 Bah! There's _always_ one. Display glitch corrected.
[originally from svn r6156]
2005-08-02 23:24:03 +00:00
afe80030e4 New puzzle: `Slant', picked from the Japanese-language section of
nikoli.co.jp (which has quite a few puzzles that they don't seem to
have bothered to translate into English).

Minor structural change: the disjoint set forest code used in the
Net solver has come in handy again, so I've moved it out into its
own module dsf.c.

[originally from svn r6155]
2005-08-02 23:16:46 +00:00
207c847553 Various cleanups and clarifications to devel.but; some from Richard
B and some from me. Also an additional utility function
`random_copy' from Richard B, which he says is useful in a new
puzzle he's working on and which seems likely to come in handy again
at some point.

[originally from svn r6153]
2005-08-01 11:27:01 +00:00
e6132341c4 New end-game approach to Black Box. Instead of revealing the ball
positions immediately when you make an error, the game now reveals
as little information as is necessary to prove you wrong (including
none - if an existing laser path you know about is inconsistent with
your guesses, the game will just point it out and tell you nothing
new!) and you can try again. Errors are counted in much the same way
as deaths in Mines.

[originally from svn r6152]
2005-07-31 14:56:18 +00:00
ef36a4232c missing i' in \e'
[originally from svn r6151]
2005-07-29 23:05:10 +00:00
e37c2c0ad2 One more fix from Ben H. Also switched round the arena colour
selection in the redraw function, so that locked squares are no
longer displayed once the game is at an end. (It looked untidy and
disorienting for lighter-coloured locked squares to suddenly become
darker when the box was opened. You can still flip back and forth to
your previous game state using undo/redo if you want to compare the
results against your lock pattern.)

[originally from svn r6150]
2005-07-29 16:45:52 +00:00
14ad9d832e Various fixes and cleanups suggested by Ben Hutchings:
- clarified wording of messages in validate_params(), including in
   particular a correction from `< 255' to `<= 255'
 - fixed random_upto() in game generation which caused the maximum
   number of balls never to be used when there was uncertainty
 - fixed widespread miscalculation of rectangular-array indices
   (multiplication by h instead of w, which would have broken
   non-square grids rather profoundly)
 - corrected an ANSI namespace violation
 - removed real functionality from the inside of assert()
   statements, so that the game should still work when compiled
   -DNDEBUG
 - couple of unnecessary linear-time loops removed.

[originally from svn r6149]
2005-07-29 12:07:10 +00:00
b0adb79178 Ben Hutchings reports that gcc 4 gives an optimiser warning because
it can't tell that one branch of a particular switch is always
taken. Adding a default clause with an automatic assertion failure
apparently fixes it.

[originally from svn r6148]
2005-07-29 11:34:02 +00:00
178a86197b Patches from Ben Hutchings to fix failures of sscanf error checking.
[originally from svn r6147]
2005-07-29 11:24:55 +00:00
19c9453b5c Tweak a paragraph after discussion with Simon.
[originally from svn r6144]
2005-07-29 08:20:40 +00:00
f44e4acd4a Shiny new developer documentation to replace the old sketchy HACKING
guide.

[originally from svn r6142]
2005-07-28 17:12:18 +00:00
cc06b70328 The very core of cross() is capable of suffering integer overflow on
large puzzles. Resort to hand-hacked 64-bit arithmetic for doing dot
products; everything else remains in `long' for the moment.

(Ideally I'd auto-detect the presence of `long long' and use it in
place of my cheap plastic imitation where possible, but since I
currently don't have a configure mechanism that'll have to wait.)

[originally from svn r6137]
2005-07-24 10:39:33 +00:00
3b5711c6a5 Another diagnostic mode for Untangle: if compiled with
`-DSHOW_CROSSINGS', it will show each edge in red if it is crossed
by anything, and in black otherwise. Distracting and not
particularly useful during play, but occasionally handy for
debugging cross().

[originally from svn r6136]
2005-07-24 10:09:04 +00:00
4da39de282 (GTK only so far) Allow the argument passed to a game binary to be
either a game ID or a save file name. (The former takes priority,
because you can usually find a synonym for the latter, such as by
prepending `./' or `$PWD/'.)

[originally from svn r6135]
2005-07-24 10:05:11 +00:00
0a798c7484 Solve animation (currently only in Untangle) was failing to set
me->anim_pos to zero, meaning that if it happened immediately after
a completion flash then anim_pos would start off half way through
its run.

[originally from svn r6127]
2005-07-22 12:07:56 +00:00
bed038e17f The `Solve' operation now rotates and/or reflects the solution grid
to bring it as close as possible to the current game state. This
means that if you request `Solve' after solving a puzzle yourself,
with the intention of finding out how similar your solution is to
the program's, then you will mostly see the differences in _shape_
rather than those being masked by the fact that yours happened to be
the other way up.

[originally from svn r6126]
2005-07-22 11:55:50 +00:00
a605a17d05 James H profiled the new Same Game grid generator and discovered it
was spending 60% of its time in shuffle(). The purpose of the
shuffle() call was to go through a largish array in random order
until we found an element that worked, so there's no actual need to
shuffle the whole array every time and I only did it out of
laziness. So I now pick a random element each time I go round the
loop, meaning I save a lot of shuffling effort whenever the loop
terminates early (which is often). I get about a factor of two speed
improvement from this small change.

[originally from svn r6125]
2005-07-22 11:06:57 +00:00
6bce285027 Until now, Same Game has been the only puzzle in this collection
which is unable to guarantee that every grid it generates can be
solved. So I'm eliminating that exception: this checkin contains a
more sophisticated grid generator which does guarantee solubility.
It's a bit slow (most noticeably on the 15x10c3 preset), and the
quality of the generated grids is slightly weird (a tendency toward
small regions rather than large sweeping areas of contiguous
colour); however, I'm willing to see the latter as a feature for
now, since making the game more challenging while simultaneously
guaranteeing it to be possible sounds like an all-round win to me.

From now on I'm raising my standards for contributions to this
collection. I made this fix to Same Game because I heard a user
_automatically assume_ that any puzzle in my collection would not be
so uncouth as to generate an impossible grid; as of this checkin
that's actually true, and I intend to maintain that standard of
quality henceforth.

(Guaranteeing a _unique_ solution is more of an optional extra,
since there are many games for which it isn't a meaningful concept
or isn't particularly desirable. Which is not to say that _some_
games wouldn't be of unacceptably low quality if they failed to
guarantee uniqueness; it depends on the game.)

[originally from svn r6124]
2005-07-21 18:06:31 +00:00
d2d4b07e15 I've been meaning to do this for ages: all the Makefiles now give
$(XFLAGS) _after_ $(CFLAGS) on the compiler command lines, meaning
that you can provide options in XFLAGS on the makefile which will
override the ones in CFLAGS. For example, `make XFLAGS=-O0' to make
debugging easier.

[originally from svn r6123]
2005-07-21 17:26:46 +00:00
11ce8d7abd Sync with website
[originally from svn r6122]
2005-07-20 23:35:43 +00:00
1ff15ba8ad The Untangle completion flash was weedy and anaemic; beef it up a
bit. In particular, it now flashes between _two_ specially picked
colours (white and mid-grey), meaning that it should be visible even
if your default background colour is white; and it also flashes
twice rather than once.

[originally from svn r6121]
2005-07-20 11:05:35 +00:00
0df586e23a Some attempt to explain Dominosa for those unfamiliar with dominos. (Not sure
I've succeeded.)

[originally from svn r6120]
2005-07-19 19:33:49 +00:00
910aa99e6e Another fix from Chris: Guess's allow-blanks mode wasn't allowing
blanks...

[originally from svn r6118]
2005-07-18 19:07:36 +00:00
6d96375736 Fix to Chris's patch in r6106 (also from Chris).
[originally from svn r6117]
[r6106 == a31934f233581da07153af6b4ee717f1e63387dd]
2005-07-18 18:54:06 +00:00
0e68ad82a9 Switch Untangle to using long' rather than int' in its internal
rationals, for the sake of 16-bit-int platforms such as Palm. Thanks
to James H.

[originally from svn r6114]
2005-07-17 17:12:21 +00:00
e33a57b703 Quite a few instances of the Cardinal Error of Ctype were turned up
by a grep I just did. Oops.

[originally from svn r6113]
2005-07-17 17:10:11 +00:00
8ac92e8607 Two tiny cleanup patches from James H.
[originally from svn r6111]
2005-07-17 14:49:13 +00:00
782a4f3fec Get rid of the malloc in shuffle(), by defining a subfunction
memswap() which declares a fixed-size buffer on the stack and uses
it multiple times if necessary.

[originally from svn r6107]
2005-07-17 12:12:16 +00:00
a31934f233 Patch from Chris Emerson: rather than dynamically calling
get_correct() at (among other things) every redraw, we call it once
at the creation of a new game_state to save CPU.

[originally from svn r6106]
2005-07-17 11:15:50 +00:00
9e5d23e783 Black Box: fix "reveal" button location, explain what's meant by the
`firing range'

[originally from svn r6105]
2005-07-17 10:33:40 +00:00
257288773f Use \q{} and \by in Black Box docs.
[originally from svn r6104]
2005-07-17 10:13:41 +00:00
a1dc27e43a I keep forgetting to do things when adding a new puzzle, so here's a
checklist.

[originally from svn r6103]
2005-07-17 09:35:01 +00:00
9d4be786a7 Bah, there's always one: failed to `svn add' blackbox.c itself!
[originally from svn r6101]
2005-07-17 08:46:00 +00:00
e12017b291 Another game from James H: `Black Box'.
[originally from svn r6100]
2005-07-17 08:44:18 +00:00
931a7ca45f Cleanups and memory leak fixes from James H.
[originally from svn r6099]
2005-07-16 20:06:37 +00:00
e7d6c0aa33 Sanity-checking patch from Phil Bordelon: since Solo can't cope with
more than 36 distinct symbols (it runs out of alphanumerics), check
this in validate_params. I hate to do this, since I like puzzle
sizes to at least be open-ended in _principle_, but in this case
there's a fundamental UI limitation which won't be fixed by getting
a faster CPU.

[originally from svn r6098]
2005-07-16 20:02:15 +00:00
a8a903db47 New puzzle: `Untangle', cloned (with the addition of random grid
generation) from a simple but rather fun Flash game I saw this
morning.

Small infrastructure change for this puzzle: while most game
backends find the midend's assumption that Solve moves are never
animated to be a convenience absolving them of having to handle the
special case themselves, this one actually needs Solve to be
animated. Rather than break that convenience for the other puzzles,
I've introduced a flag bit (which I've shoved in mouse_priorities
for the moment, shamefully without changing its name).

[originally from svn r6097]
2005-07-16 19:51:53 +00:00
c5edffdd2c Improve speed of grid generation: I've found something simple I can
do during construction which massively increases (by over a factor
of four with default parameters) the probability that any given
randomly generated grid will be uniquely solvable.

[originally from svn r6096]
2005-07-15 16:43:02 +00:00
606eb3f0f2 Add Dominosa printout support.
[originally from svn r6094]
2005-07-14 22:50:58 +00:00
ee09498a41 Cleanups to Solo:
- use the new `shuffle' utility function in a couple of places
 - remove the random_state parameter from solver(). It was there
   because I initially wanted to use the same solver for grid
   generation, but since I had to abandon that plan the solver now
   doesn't have any need for randomness at all.

[originally from svn r6093]
2005-07-14 18:15:23 +00:00
69410c7961 New puzzle: Dominosa.
[originally from svn r6091]
2005-07-14 17:42:01 +00:00
bb63d0d399 Introduce a `shuffle' utility function.
[originally from svn r6090]
2005-07-14 17:37:05 +00:00
3d2c442bc4 game_timing_state() now has access to the game_ui. This means that
whether the timer is currently going is no longer solely dependent
on the current game_state: it can be dependent on more persistent
information stored in the game_ui. In particular, Mines now freezes
the timer permanently once you complete a grid for the first time,
so that you can then backtrack through your solution process without
destroying the information about how long it took you the first time
through.

[originally from svn r6088]
2005-07-10 10:17:13 +00:00