321 Commits

Author SHA1 Message Date
cdb8433c0a Another function pair required for serialisation; these ones save
and restore anything vitally important in the game_ui. Most of the
game_ui is expected to be stuff about cursor positions and currently
active mouse drags, so it absolutely _doesn't_ want to be preserved
over a serialisation; but one or two things would be disorienting or
outright wrong to reset, such as the Net origin position and the
Mines death counter.

[originally from svn r6026]
2005-06-28 07:33:49 +00:00
08410651e0 Annoying special cases for Mines.
Firstly, the `Restart' function now reconstructs an initial game
state from the game description rather than dup_game(states[0]).
This means that Restart in a game of Mines restarts to just _after_
the initial click, so you can resume the puzzle-solving part without
having to remember where you placed that click.

Secondly, the midend now contains a second `private' game desc,
which is guaranteed to actually reconstruct the initial game_state
correctly (which Mines's publicly visible game descs tend not to,
since they describe a state which has already had the first click).
This should make serialising of Mines more sensible.

[originally from svn r6025]
2005-06-28 06:59:27 +00:00
76d50e6905 Re-architecting of the game backend interface. make_move() has been
split into two functions. The first, interpret_move(), takes all the
arguments that make_move() used to get and may have the usual side
effects of modifying the game_ui, but instead of returning a
modified game_state it instead returns a string description of the
move to be made. This string description is then passed to a second
function, execute_move(), together with an input game_state, which
is responsible for actually producing the new state. (solve_game()
also returns a string to be passed to execute_move().)

The point of this is to work towards being able to serialise the
whole of a game midend into a byte stream such as a disk file, which
will eventually support save and load functions in the desktop
puzzles, as well as restoring half-finished games after a quit and
restart in James Harvey's Palm port. Making each game supply a
convert-to-string function for its game_state format would have been
an unreliable way to do this, since those functions would not have
been used in normal play, so they'd only have been tested when you
actually tried to save and load - a recipe for latent bugs if ever I
heard one. This way, you won't even be able to _make_ a move if
execute_move() doesn't work properly, which means that if you can
play a game at all I can have pretty high confidence that
serialising it will work first time.

This is only the groundwork; there will be more checkins to come on
this theme. But the major upheaval should now be done, and as far as
I can tell everything's still working normally.

[originally from svn r6024]
2005-06-27 19:34:54 +00:00
7cb29412c1 Fix GTK casts to restore correct compilation on GTK 2.0 after r6022.
[originally from svn r6023]
[r6022 == e1c84c9a4ea9e74c128c28a77ea08336350991e3]
2005-06-26 13:12:34 +00:00
e1c84c9a4e Under Gtk 1.2 (at least on Debian woody), a config or preset change that would
otherwise not cause the window size to change caused it to become very small
indeed. This change from Simon fixes that behaviour; I haven't tested it with
Gtk 2.

[originally from svn r6022]
2005-06-26 12:54:08 +00:00
258293a82a Add debugging support.
[originally from svn r6018]
2005-06-25 17:24:03 +00:00
7f7583d7f4 Further additions to the Guess docs.
[originally from svn r6014]
2005-06-25 13:52:52 +00:00
185d999b6b Make the keyboard-control cursors visible whenever a keyboard control is
activated.

[originally from svn r6013]
2005-06-25 13:43:45 +00:00
a0d0c7e795 The AngleArc() function that was being used to draw circles on Windows turns
out to be unsupported on the Win9x/Me series. Use Arc() instead (tested on
Win98 and Win2K).

[originally from svn r6012]
2005-06-25 13:24:19 +00:00
6e79ff9df5 Couple of presets.
[originally from svn r6011]
2005-06-24 16:35:42 +00:00
b873c87c37 More patches from James Harvey: enforce a maximum brightness in the
background colour (to ensure white pegs show up against it), and
convert the keyboard-control cursor into a rectangle when it's over
the hint pegs (otherwise it looks rather silly for numbers of pegs
above 4).

[originally from svn r6010]
2005-06-24 16:35:27 +00:00
31d96181a8 Fix another display/UI glitch which triggered if you filled a row
(so that the hint pegs lit up as `ready') and then pressed Undo: the
markable flag would remain set and the redrawing wouldn't darken the
pegs again.

[originally from svn r6009]
2005-06-24 12:30:30 +00:00
029e8b85ce Turn off the keyboard-control cursor when the user reverts to mouse
control.

[originally from svn r6008]
2005-06-24 11:13:08 +00:00
5fc29f7717 Change the preprocessor symbol DEBUG' to DEBUGGING', since the
former is automatically defined by Cygwin.

[originally from svn r6007]
2005-06-24 11:05:43 +00:00
249d345ed4 My background-erasing changes in r5996/r5997 caused trouble with the
keyboard-control cursors, and when I tried to fix those more
wallpaper bubbles popped up elsewhere. Here's what I think is a
proper fix: a comprehensive overhaul of the redraw code such that,
instead of tracking the cursor positions explicitly in the
drawstate, we instead track for each peg position whether or not a
cursor is currently displayed at that position. So cursor erasing
and cursor drawing become part of the main draw loop rather than a
separate bit on the end.

[originally from svn r6006]
[r5996 == 3d58feb561ef09cf977f710d69a3562529e23f0f]
[r5997 == a46e3266558eaf5cd18ac2a6322af65c196c3655]
2005-06-24 11:03:20 +00:00
75225284c0 Array overflow fix from James Harvey.
[originally from svn r6005]
2005-06-23 23:11:59 +00:00
fda72b0f1e Make the hold marker' in Guess accessible from the keyboard (H' key, for want
of a better idea).

[originally from svn r6004]
2005-06-23 22:01:17 +00:00
7199b42623 Factual and other corrections/additions to the Guess docs.
[originally from svn r6003]
2005-06-23 21:47:55 +00:00
2dabe9458f Reinstate WinHelp topic now we have a manual chapter.
[originally from svn r6002]
2005-06-23 21:37:05 +00:00
c8d2f420f0 Credit James Harvey.
[originally from svn r6000]
2005-06-23 19:01:01 +00:00
af052f2620 James Harvey's extensions to Guess: a couple of extra game settings
plus a manual chapter.

[originally from svn r5999]
2005-06-23 18:50:58 +00:00
2ce863a76d And forgot to add guess to the Unix make install target! I need a list.
[originally from svn r5998]
2005-06-23 18:05:19 +00:00
a46e326655 Bah, not good enough. Extend those background erases by one more
pixel.

[originally from svn r5997]
2005-06-23 18:02:21 +00:00
3d58feb561 Erase backgrounds when drawing over an existing circle, for the
benefit of antialiasing platforms such as OS X. Also in this
checkin, fiddle with svn:ignore (there's a new puzzle binary).

[originally from svn r5996]
2005-06-23 17:43:43 +00:00
ebca9edc7b Allow dragging of coloured pegs from previous guesses. Also
reorganise the colours so there are fewer of those terribly
computery cyan and magenta shades, and more good old-fashioned
colours with simple names like orange and purple. Finally, change
the `right place' marking peg colour from red to black, in line with
at least _my_ old Mastermind set (I faintly suspect red marker pegs
of being an Americanism) and also so that the marker pegs and the
coloured pegs have no colours in common.

[originally from svn r5995]
2005-06-23 16:36:09 +00:00
1aed44db0b Must outline as well as filling circles, because not all platforms
can be guaranteed to draw bare filled shapes the same way.

[originally from svn r5994]
2005-06-23 12:55:47 +00:00
d781db11dd Two small fixes: add some ceil() calls to stop the puzzle shrinking
every time I press N, and revert the help topic to NULL until some
documentation materialises.

[originally from svn r5993]
2005-06-23 12:21:14 +00:00
f862a227be `Guess', a Mastermind clone from James Harvey. This checkin also
introduces a few new utility functions in misc.c, one of which is
the bitmap obfuscator from Mines (which has therefore been moved out
of mines.c).

[originally from svn r5992]
2005-06-23 09:14:19 +00:00
b909204392 Introduce a front-end function to draw circles.
[originally from svn r5991]
2005-06-23 08:24:52 +00:00
973ced1c7c This TODO comment should have been taken out in r5913 :-)
[originally from svn r5988]
[r5913 == 02035753f817173a6861d1fc4bec437508cec42d]
2005-06-22 09:26:03 +00:00
b176767dfa New front end functions to save and restore a region of the puzzle
bitmap. Can be used to implement sprite-like animations: for
example, useful for games that wish to implement a user interface
which involves dragging an object around the playing area.

[originally from svn r5987]
2005-06-22 08:30:31 +00:00
64fbdf60ee Add WinHelp topic
[originally from svn r5984]
2005-06-21 11:16:36 +00:00
6dcbacc258 Patch from James Harvey in response to the new Rectangles grid
generator: (a) take out the `#ifdef SLOW_SYSTEM' because the new
generator is much more efficient, and (b) convert another int to
size_t to prevent the solver going negative in 16-bit ints as a
result.

[originally from svn r5983]
2005-06-21 08:15:53 +00:00
c98230dedf Conversation with Richard and Chris yesterday gave rise to a more
sensible means of generating an initial gridful of rectangles. This
was previously a stupidly non-scalable bit of the Rectangles puzzle
generator: it filled a ludicrously large array with every possible
rectangle that could go anywhere in the grid, picked one at random
and winnowed the list by removing anything that overlapped that one,
then repeated until the list was empty (and therefore the grid was
full except for remaining singleton squares). Total cost was O(N^4)
in both time and space; not pretty.

Richard and Chris's sensible alternative was to place each rectangle
by randomly choosing a so-far-uncovered _square_, and then picking a
random rectangle from the possible ones covering that square. This
means we only have to deal with a small fragment of the rectangle
list at any one time, and we don't have to store the whole lot in
memory; so it's _much_ faster and more scalable, and has virtually
no memory cost.

A side effect of this algorithmic change is that the probability
distribution has altered. When you line up all the possible
_rectangles_ and pick one at random, then obviously the small ones
are going to be in the majority since lots of small ones can fit
into the space taken up by any given big one. So the original
algorithm tends to favour fiddly grids full of lots of tiny
rectangles, which don't tend to be very interesting. But if you
first pick a square and then think about the rectangles that can
surround that square, the small ones are suddenly going to be in the
_minority_ because there are only two ways you can place (say) a 2x1
containing a given square compared to 36 ways you can place a 6x6.
So this algorithm favours more large rectangles, which I generally
consider to be an improvement.

[originally from svn r5982]
2005-06-20 17:32:45 +00:00
0417e6335e James Harvey's memory leak patch for Flip.
[originally from svn r5980]
2005-06-19 21:49:53 +00:00
db88c9b9a4 Redraw glitch: tiles marked black (at game-over time) were not
redrawn as non-black on undo. Introduce a new flag TILE_IMPOSSIBLE,
so that information about those black markers is cached in the
drawstate and we know when we have to erase them.

In the process I've removed the game_state argument completely from
the subfunction tile_redraw(), which gives me some confidence that
it isn't getting any _more_ privileged information out of it.

[originally from svn r5979]
2005-06-19 14:33:06 +00:00
574250995e Just noticed yesterday that initial window sizing is broken on
Windows for puzzles with status bars, because the initial call to
check_window_size is given the window size _without_ the status bar
and assumes that that has to be big enough for the whole thing
_with_ the status bar, so it shrinks everything by a little bit. So
now we resize the window to take account of the status bar before
calling check_window_size(), and the problem seems to have gone away.

[originally from svn r5975]
2005-06-18 08:52:50 +00:00
b0df75952b I've decided I didn't like the asymmetry of putting the solution
markers in the top left of the square.

[originally from svn r5974]
2005-06-18 08:46:33 +00:00
d74d3f26d8 I'm sick of not having a `make install' target.
[originally from svn r5973]
2005-06-18 08:36:52 +00:00
f22f31196b Correct rogue chapter into a subheading.
[originally from svn r5972]
2005-06-17 19:06:25 +00:00
5550660f13 Solver for Flip.
[originally from svn r5970]
2005-06-17 18:55:36 +00:00
f01f82105e Infrastructure change which I've been thinking about for a while:
the back end function solve_game() now takes the _current_
game_state in addition to the initial one.

[originally from svn r5969]
2005-06-17 18:54:58 +00:00
32111ef901 Animation.
[originally from svn r5968]
2005-06-17 17:32:28 +00:00
347de40a2e Another new puzzle! This one isn't particularly deep or complex
(solving it only requires matrix inversion over GF(2), whereas
several of the other puzzles in this collection are NP-complete in
principle), but it's a fun enough thing to play with and is
non-trivial to do in your head - especially on the hardest preset.

[originally from svn r5967]
2005-06-17 17:16:49 +00:00
552b18a592 An email conversation with Chuck Fresno turned up several forms of
symmetry which were not implemented in Solo. Now they are.

In the process I've completely retired symmetry_limit() on the
grounds that some of the new symmetries do not have a rectangular
base region; instead I determine the base region by going through
the grid and finding every square which is not transformed into a
lexicographically lower square by any symmetry operation. This means
that adding new symmetries is now _only_ a matter of encoding the
actual transformation rules.

[originally from svn r5965]
2005-06-17 11:51:52 +00:00
f2e74bd091 Clean up the behaviour of drags off the edge of the grid. These have
always been a convenient way to cancel a drag you decided was an
error, but now it's more obvious that this is the case.

[originally from svn r5941]
2005-06-10 13:05:24 +00:00
ee059bc60c Disable shuffle overlap checking in the special case w=h=n.
[originally from svn r5940]
2005-06-10 11:34:02 +00:00
363dadee0c Overzealous last-move tracking during shuffle was causing lockups on
2x2 grid generation.

[originally from svn r5939]
2005-06-10 11:29:59 +00:00
98c90052c9 Patch from James Harvey to rearrange the Same Game colours.
[originally from svn r5938]
2005-06-10 11:27:26 +00:00
011d42df0d Patch from Chris Emerson to add a status bar to Rectangles. Apart
from saying `Auto-solved' or `Completed', the main function of the
status bar is to track the current size of a rectangle you're
dragging out, which makes life much easier when trying to count up
large rectangles in 19x19 mode.

[originally from svn r5937]
2005-06-10 11:24:44 +00:00