400 Commits

Author SHA1 Message Date
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
145301d0dc Change of policy on game_changed_state(). Originally, it was called
by the midend every time the game state changed _other_ than as a
result of make_move(), on the basis that when the game state changed
due to make_move() the game backend had probably noticed anyway.
However, when make_move() split up, this became more fiddly: if the
game_ui had to be updated based on some property of the final game
state, then execute_move() couldn't do it because it didn't have a
pointer to the game_ui, but it was fiddly to do it in
interpret_move() because that didn't directly have a copy of the
finished game state to examine. Same Game (the only game to be
affected) had to deal with this by actually having interpret_move()
_call_ execute_move() to construct a temporary new game state,
update the UI, and then throw it away.

So now, game_changed_state() is called _every_ time the current game
state changes, which means that if anything needs doing to the
game_ui as a result of examining the new game state, it can be done
there and save a lot of effort.

[originally from svn r6087]
2005-07-10 10:06:04 +00:00
ac36314b02 Subtle UI change to Mines. Although I mostly find the unified left-
button interface (same button to open a closed square or to clear
around an open one) to be a massive help, there is one circumstance
in which it frequently kills me: if I click down on an open square I
want to clear around, then the mouse pointer accidentally drifts
over on to the nearest closed square before I release, I'll end up
opening that square instead and (usually) dying. So this checkin
causes Mines to note which type of square I left-clicked on, and to
do nothing if the button release is on the other type.

[originally from svn r6086]
2005-07-10 09:27:08 +00:00
2ec5a51c35 Alter the `Octagon' board preset so that instead of presenting you
with the obvious central hole it presents you with a randomly chosen
one of twelve other holes. The reason is, the central-hole starting
position is provably insoluble (proof given in comments), so instead
we pick from the ones that are actually possible.

[originally from svn r6083]
2005-07-09 10:19:41 +00:00
d5fe59b25b Missing quit on error was leading to an assertion failure on some
types of incorrectly formatted save file.

[originally from svn r6079]
2005-07-06 21:24:28 +00:00
d7588e6048 Move various printf()s after declarations.
[originally from svn r6078]
2005-07-06 20:10:03 +00:00
6ea61aa98e Unify the two solvers in Solo. nsolve has now had recursion
capability added to it, to be used only when all else fails, and is
simply called `solver'. This means that:

 - solving of 5x5 Trivial grids using the `Solve' function, which
   previously hung for ages because rsolve happened to take a wrong
   turning at the start, is now zippy
 - solosolver doesn't require the confusing -r and -n options
 - solosolver can show its working even for Unreasonable grids.

Unfortunately, the new unified solver still isn't suitable for grid
generation. After it proved to be so much faster at solving 5x5s, I
hoped to be able to substitute it for rsolve during generation and
gain additional speed in 5x5 generation too; but no luck, because
it's slower _per recursion level_, and although during solving it
makes up for this by needing very few levels, there is a lot of
_unavoidable_ recursion during generation, especially at 5x5. A
hybrid strategy which starts off with rsolve and switches to the
unified solver at a critical point proved unsatisfactory as well,
because the critical point changes depending on the vagaries of the
recursion and can't be pinpointed easily. So rsolve is still in
there, only renamed `gridgen' because that's now all it's good for.

[originally from svn r6077]
2005-07-06 18:36:20 +00:00
753339737e Refactoring from James H: the highlight and lowlight colour setup
common to Fifteen, Sixteen, Twiddle and Pegs is now a utility
function in misc.c.

[originally from svn r6076]
2005-07-06 18:27:40 +00:00
d4001cbc0d Some patches from James H:
- reinstate the initialisation of ds->w and ds->h in guess.c, which
   I'd accidentally removed during game_size() refactoring
 - reorganise Net's interpret_move() so that my uncommitted patch
   for drag-based UI (which he uses on the Palm port) will apply
   more easily
 - the interpret_move() changes make it easy to have a single move
   type which rotates a tile by 180 degrees, so this is now provided
   via the `F' key (but there's no spare button available to provide
   it via the mouse).

[originally from svn r6070]
2005-07-06 11:06:17 +00:00
755d0c0b03 Revert the code that assumed that incoming parameters used a random generation
scheme in r6068, since this messed up the non-permanency of the non-limited
parameter.

[originally from svn r6069]
[r6068 == f3c95109c7b905f74b5f149eea21f68444c31ef7]
2005-07-05 21:40:29 +00:00
f3c95109c7 Add a `full' parameter to validate_params(), analogous to the one in
encode_params(). This is necessary for cases where generation-time parameters
that are normally omitted from descriptive IDs can place restrictions on other
parameters; in particular, when the default value of a relevant generation-time
parameter is not the one used to generate the descriptive ID, validation could
reject self-generated IDs (e.g., Net `5x2w:56182ae7c2', and some cases in
`Pegs').

[originally from svn r6068]
2005-07-05 21:27:19 +00:00
968828283b Enhancements to mkfiles.pl and Recipe to arrange for the auxiliary
command-line programs (solosolver, patternsolver, mineobfusc) to be
built as part of the normal Makefiles. This means mkfiles.pl now has
the capability to compile a source file more than once with
different #defines. Also, fixes for those auxiliary programs and one
fix in midend.c which the Borland compiler objected to while I was
testing its makefile generation.

[originally from svn r6066]
2005-07-05 19:40:32 +00:00
4763b712fd It's been a new year for a while now.
[originally from svn r6065]
2005-07-05 19:38:27 +00:00
68d0a346fd revert supposed typo -- I have no brain
[originally from svn r6064]
2005-07-05 19:12:56 +00:00
5ff23cd60e Add HACKING to main doc build.
[originally from svn r6063]
2005-07-05 19:11:51 +00:00