eab3699a64Documentation for Pegs.
Simon Tatham
2005-07-04 19:53:36 +00:00
97e93dbfffPeg Solitaire implementation, complete with a random board generator. The generator is lacking in almost any kind of finesse, but it produces puzzles which at least _I_ find plausibly puzzling.
Simon Tatham
2005-07-04 19:42:55 +00:00
aae029926fDocument keyboard controls for Flip
Jacob Nevins
2005-07-04 14:35:14 +00:00
5c48a59462Fix bounds checking for Flip cursor control.
Jacob Nevins
2005-07-04 11:21:50 +00:00
6989217624James H's patch for a keyboard-controlled cursor in Flip.
Simon Tatham
2005-07-03 14:49:00 +00:00
85a29743efAllow game backends to use even special keystrokes such as N and Q; they will only be processed as special by the midend if unwanted by the backend. This causes 5x5 Solo to become just about playable, because you can now click in a square and type n'. However, typing n' when a square is not selected will revert to the normal behaviour of starting a new game.
Simon Tatham
2005-07-03 11:45:49 +00:00
64e114cce1draw_polygon() and draw_circle() have always had a portability constraint: because some front ends interpret draw filled shape' to mean including its boundary' while others interpret it to mean `not including its boundary' (and X seems to vacillate between the two opinions as it moves around the shape!), you MUST NOT draw a filled shape only. You can fill in one colour and outline in another, you can fill or outline in the same colour, or you can just outline, but just filling is a no-no.
Simon Tatham
2005-07-03 09:35:29 +00:00
8dd7ee3007James Harvey points out that entering an invalid game ID can affect the current midend state even if you don't subsequently enter a valid one. Reorganise midend_game_id_int() so that (just like midend_deserialise()) it does all its error checking before altering anything in the midend's persistent data, so that it either succeeds completely or fails before doing anything at all.
Simon Tatham
2005-07-01 16:50:49 +00:00
091fe57e0fPrevent drags from being started outside the playing area, which was causing invalid move descriptions to be returned from interpret_move() and then failing an assertion when execute_move() refused them.
Simon Tatham
2005-06-30 18:11:41 +00:00
8f670292a7Preset names retrieved from the environment must be dupstr()ed. How did I miss this before? It just caused a segfault for me, which is entirely fair enough, but I've no idea why it didn't fail before!
Simon Tatham
2005-06-30 18:11:02 +00:00
6f47baddf9Load and Save are now supported on all three desktop platforms, and documented. (This means the GTK temporary dependency on an environment variable is now gone.)
Simon Tatham
2005-06-30 18:00:37 +00:00
118abb4fc9General robustness patch from James Harvey: - most game_size() functions now work in doubles internally and round to nearest, meaning that they have less tendency to try to alter a size they returned happily from a previous call - couple of fiddly fixes (memory leaks, precautionary casts in printf argument lists) - midend_deserialise() now constructs an appropriate drawstate, which I can't think how I overlooked myself since I _thought_ I went through the entire midend structure field by field!
Simon Tatham
2005-06-30 09:07:00 +00:00
101324af67Attempting to begin a drag from (i.e. just click on) the hint pegs for a past guess caused strangeness up to and including segfault, thanks to bad bounds checking. Well spotted John Sullivan.
Simon Tatham
2005-06-30 08:25:47 +00:00
0494e94c4aAdd a cast whose absence was causing a (-Werror-exacerbated) compile warning on OS X.
Simon Tatham
2005-06-29 16:32:53 +00:00
074f11edc4Validation of random-state-type game descriptions was broken. This meant that a Mines game saved before the first click had taken place could not be successfully reloaded.
Simon Tatham
2005-06-29 12:19:08 +00:00
238a6d08feWhen serialising this game, it's probably better to keep the half-finished guess in the game_ui rather than throwing it away.
Simon Tatham
2005-06-29 08:20:49 +00:00
1c896ef18bMake peg removal accessible from the keyboard.
Jacob Nevins
2005-06-28 18:10:20 +00:00
ea172a0460New {en,de}code_ui functions should be static. Oops.
Simon Tatham
2005-06-28 17:43:50 +00:00
7011028b17Actually implemented the serialise/deserialise functions in midend.c. Also I've added an experimental front end in gtk.c only: Save' and Load' options on the Game menu, which don't even show up unless you define the magic environment variable PUZZLES_EXPERIMENTAL_SAVE. Once I'm reasonably confident that the whole edifice is plausibly stable, I'll take that out and turn it into a supported feature (and also implement it in OS X and Windows and write documentation).
Simon Tatham
2005-06-28 17:05:05 +00:00
89fdc09c29More serialisation changes: the game_aux_info structure has now been retired, and replaced with a simple string. Most of the games which use it simply encode the string in the same way that the Solve move will also be encoded, i.e. solve_game() simply returns dupstr(aux_info). Again, this is a better approach than writing separate game_aux_info serialise/deserialise functions because doing it this way is self-testing (the strings are created and parsed during the course of any Solve operation at all).
Simon Tatham
2005-06-28 11:14:09 +00:00
6c9beb697bRogue diagnostic!
Simon Tatham
2005-06-28 08:35:55 +00:00
263a39e7e5Move a rogue declaration to the top of its block.
Simon Tatham
2005-06-28 08:06:56 +00:00
cdb8433c0aAnother 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.
Simon Tatham
2005-06-28 07:33:49 +00:00
08410651e0Annoying special cases for Mines.
Simon Tatham
2005-06-28 06:59:27 +00:00
76d50e6905Re-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().)
Simon Tatham
2005-06-27 19:34:54 +00:00
7cb29412c1Fix GTK casts to restore correct compilation on GTK 2.0 after r6022.
Simon Tatham
2005-06-26 13:12:34 +00:00
e1c84c9a4eUnder 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.
Jacob Nevins
2005-06-26 12:54:08 +00:00
258293a82aAdd debugging support.
Jacob Nevins
2005-06-25 17:24:03 +00:00
7f7583d7f4Further additions to the Guess docs.
Jacob Nevins
2005-06-25 13:52:52 +00:00
185d999b6bMake the keyboard-control cursors visible whenever a keyboard control is activated.
Jacob Nevins
2005-06-25 13:43:45 +00:00
a0d0c7e795The 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).
Jacob Nevins
2005-06-25 13:24:19 +00:00
6e79ff9df5Couple of presets.
Simon Tatham
2005-06-24 16:35:42 +00:00
b873c87c37More 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).
Simon Tatham
2005-06-24 16:35:27 +00:00
31d96181a8Fix 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.
Simon Tatham
2005-06-24 12:30:30 +00:00
029e8b85ceTurn off the keyboard-control cursor when the user reverts to mouse control.
Simon Tatham
2005-06-24 11:13:08 +00:00
5fc29f7717Change the preprocessor symbol DEBUG' to DEBUGGING', since the former is automatically defined by Cygwin.
Simon Tatham
2005-06-24 11:05:43 +00:00
249d345ed4My 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.
Simon Tatham
2005-06-24 11:03:20 +00:00
75225284c0Array overflow fix from James Harvey.
Simon Tatham
2005-06-23 23:11:59 +00:00
fda72b0f1eMake the hold marker' in Guess accessible from the keyboard (H' key, for want of a better idea).
Jacob Nevins
2005-06-23 22:01:17 +00:00
7199b42623Factual and other corrections/additions to the Guess docs.
Jacob Nevins
2005-06-23 21:47:55 +00:00
2dabe9458fReinstate WinHelp topic now we have a manual chapter.
Jacob Nevins
2005-06-23 21:37:05 +00:00
c8d2f420f0Credit James Harvey.
Simon Tatham
2005-06-23 19:01:01 +00:00
af052f2620James Harvey's extensions to Guess: a couple of extra game settings plus a manual chapter.
Simon Tatham
2005-06-23 18:50:58 +00:00
2ce863a76dAnd forgot to add guess to the Unix make install target! I need a list.
Simon Tatham
2005-06-23 18:05:19 +00:00
a46e326655Bah, not good enough. Extend those background erases by one more pixel.
Simon Tatham
2005-06-23 18:02:21 +00:00
3d58feb561Erase 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).
Simon Tatham
2005-06-23 17:43:43 +00:00
ebca9edc7bAllow 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.
Simon Tatham
2005-06-23 16:36:09 +00:00
1aed44db0bMust outline as well as filling circles, because not all platforms can be guaranteed to draw bare filled shapes the same way.
Simon Tatham
2005-06-23 12:55:47 +00:00
d781db11ddTwo 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.
Simon Tatham
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).
Simon Tatham
2005-06-23 09:14:19 +00:00
b909204392Introduce a front-end function to draw circles.
Simon Tatham
2005-06-23 08:24:52 +00:00
973ced1c7cThis TODO comment should have been taken out in r5913 :-)
Simon Tatham
2005-06-22 09:26:03 +00:00
b176767dfaNew 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.
Simon Tatham
2005-06-22 08:30:31 +00:00
64fbdf60eeAdd WinHelp topic
Jacob Nevins
2005-06-21 11:16:36 +00:00
6dcbacc258Patch 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.
Simon Tatham
2005-06-21 08:15:53 +00:00
c98230dedfConversation 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.
Simon Tatham
2005-06-20 17:32:45 +00:00
0417e6335eJames Harvey's memory leak patch for Flip.
Simon Tatham
2005-06-19 21:49:53 +00:00
db88c9b9a4Redraw 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.
Simon Tatham
2005-06-19 14:33:06 +00:00
574250995eJust 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.
Simon Tatham
2005-06-18 08:52:50 +00:00
b0df75952bI've decided I didn't like the asymmetry of putting the solution markers in the top left of the square.
Simon Tatham
2005-06-18 08:46:33 +00:00
d74d3f26d8I'm sick of not having a `make install' target.
Simon Tatham
2005-06-18 08:36:52 +00:00
f22f31196bCorrect rogue chapter into a subheading.
Simon Tatham
2005-06-17 19:06:25 +00:00
5550660f13Solver for Flip.
Simon Tatham
2005-06-17 18:55:36 +00:00
f01f82105eInfrastructure 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.
Simon Tatham
2005-06-17 18:54:58 +00:00
32111ef901Animation.
Simon Tatham
2005-06-17 17:32:28 +00:00
347de40a2eAnother 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.
Simon Tatham
2005-06-17 17:16:49 +00:00
552b18a592An email conversation with Chuck Fresno turned up several forms of symmetry which were not implemented in Solo. Now they are.
Simon Tatham
2005-06-17 11:51:52 +00:00
f2e74bd091Clean 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.
Simon Tatham
2005-06-10 13:05:24 +00:00
ee059bc60cDisable shuffle overlap checking in the special case w=h=n.
Simon Tatham
2005-06-10 11:34:02 +00:00
363dadee0cOverzealous last-move tracking during shuffle was causing lockups on 2x2 grid generation.
Simon Tatham
2005-06-10 11:29:59 +00:00
98c90052c9Patch from James Harvey to rearrange the Same Game colours.
Simon Tatham
2005-06-10 11:27:26 +00:00
011d42df0dPatch 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.
Simon Tatham
2005-06-10 11:24:44 +00:00
a9d0f9ef35GDK 2.6, in its doubtless infinite wisdom, has decided that gdk_font_from_description() will no longer even _try_ to return a font matching the specified Pango font description; instead it will return `fixed' no matter what you do. Therefore, I've had to switch to using Pango proper for Puzzles text rendering, rather than just using Pango for font selection.
Simon Tatham
2005-06-09 18:29:11 +00:00
0747ab856bRemove debug output.
Jacob Nevins
2005-06-08 09:20:35 +00:00
c7c3058b8bAdd Windows help topic
Jacob Nevins
2005-06-07 21:05:29 +00:00
6e0c4003ccTweaks and more complete documentation for Same Game.
Jacob Nevins
2005-06-07 21:03:14 +00:00
b1e706bf7eInteger overflow in game_size(). Oops.
Simon Tatham
2005-06-07 20:44:14 +00:00
8add7421dfChris Emerson points out that gtk_window_resize() isn't in GTK 1.2. Work around it the same way I did in PuTTY.
Simon Tatham
2005-06-07 20:25:25 +00:00
c27235cc51James Harvey's patch to support keyboard control in Same Game.
Simon Tatham
2005-06-07 20:22:25 +00:00
f3ee3c8c51Forgot to add Same Game to the big list for OS X.
Simon Tatham
2005-06-07 20:22:08 +00:00
fba6fc61ebJames Harvey (again) points out an array underrun in the new clash-checking code in Solo. (valgrind confirms it.)
Simon Tatham
2005-06-07 19:07:58 +00:00
0eb40587ebAnother James Harvey patch. This one introduces a new button code called `CURSOR_SELECT', intended for platforms which have a fire button to go with their cursor keys. (Apparently some Palms do.) CURSOR_SELECT is not bound to anything on any of the current three platforms, and therefore no game may rely on it being available. This checkin adds it in Net as a synonym for 'a', the keyboard-based rotate-left command.
Simon Tatham
2005-06-07 19:04:52 +00:00
0bcdb7aa03James Harvey has contributed an implementation of `Same Game', also known as ksame (KDE) and Same GNOME (GNOME).
Simon Tatham
2005-06-07 19:01:36 +00:00
02035753f8All the games in this collection have always defined their graphics in terms of a constant TILE_SIZE (or equivalent). Here's a surprisingly small patch which switches this constant into a run-time variable.
Simon Tatham
2005-06-07 17:57:50 +00:00
69f7e7f8f5Introduce a new game backend function (there seem to have been a lot of these recently) whose job is to update a game_ui to be consistent with a new game_state. This is called by midend.c in every situation where the current game_state changes _other_ than as a result of make_move (Undo, Redo, Restart, Solve).
Simon Tatham
2005-06-06 11:21:36 +00:00
57b3982c83Small UI bug: LEFT_RELEASEs were being thrown away completely if their coordinates were outside the playing area. Clearly no actual move should be made in that situation, but we do at least need to sort out any highlighted squares from the prior dragging operations.
Simon Tatham
2005-06-04 17:51:49 +00:00
852bddabbbRevamp pencil mark placement and sizing. Pencil marks are now sized and positioned according to how many there are in the cell, rather than how many distinct digits there are in the entire puzzle. This means that 4x4 Solo can now be played with pencil marks without _too_ much difficulty; the marks will still get a bit crowded if you have more than 12 in the same square, but with luck that shouldn't happen often, and as long as you're down in the 2-9 range things should be entirely legible.
Simon Tatham
2005-06-04 12:32:40 +00:00
454e566df6James Harvey requested that puzzles not use DEBUG as a preprocessor symbol for enabling diagnostics, presumably because in his Palm port it means something else as well. He sent this patch to switch Net and Netslide over to using GENERATION_DIAGNOSTICS, in the fashion of the newer games.
Simon Tatham
2005-06-04 09:59:03 +00:00
402408125eColin Watson suggests that Alt-click (or Option-click) could usefully be equivalent to right-clicking on platforms other than OS X; in particular, it's useful if you're running Linux on Apple hardware such as PowerBook which inherently has only one button. So here's the fix for GTK, and Windows as well (the latter for completeness and consistency, not because I can actually think of any reason somebody might be running Windows on one-button hardware).
Simon Tatham
2005-06-03 12:27:29 +00:00
41ebdb29c6Unique solubility in Mines means that you can massively increase the mine density without (as you would with a conventional random grid generator) rendering the game completely unplayable. High mine densities are really good fun, and the point of the presets menu is to provide people with pre-tested good settings and things they might not have thought to try for themselves; so here are three additional presets with high densities.
Simon Tatham
2005-06-03 12:10:32 +00:00
c6b5afe9c1Standalone compilation mode which turns mines.c into a little utility to convert descriptive game IDs containing mine bitmaps between obfuscated and cleartext. Might be handy for anyone planning to design custom levels to send to friends (mines spelling out `Happy Birthday', that sort of thing), as someone suggested to me today :-)
Simon Tatham
2005-06-02 16:34:37 +00:00
ad2ec32e1cFix various departures from C found by `gcc -ansi -pedantic'. I haven't checked in Makefile changes to enable this, but I'll at least fix the specific problems it found when enabled as a one-off.
Simon Tatham
2005-06-02 08:14:14 +00:00
09c396b8a8min()/max() macros conflict with ones defined by Windows (or at least MinGW) headers; but MIN()/MAX() conflict with glib. Let's keep the lower-case ones, and assume that any provided by the system have the obvious semantics.
Jacob Nevins
2005-06-01 22:56:20 +00:00
55a3d377b1Fix Richard's patch so that it's actually C :-/
Simon Tatham
2005-06-01 18:57:28 +00:00
f46086ab6dAnother highlighting patch from Richard Boulton: immediately flag any actual clashes (duplicate numbers in a row, column or block) in red. This is a non-privileged deduction: it doesn't compare against a known solution or consult a solver. It simply indicates reasons why (no superset of) the current grid would cause the completion flash to go off.
Simon Tatham
2005-06-01 18:33:25 +00:00
50edaa578bMiscellaneous fixes from James Harvey's PalmOS porting work: - fixed numerous memory leaks (not Palm-specific) - corrected a couple of 32-bit-int assumptions (vital for Palm but generally a good thing anyway) - lifted a few function pointer types into explicit typedefs (neutral for me but convenient for the source-munging Perl scripts he uses to deal with Palm code segment rules) - lifted a few function-level static arrays into global static arrays (neutral for me but apparently works round a Palm tools bug) - a couple more presets in Rectangles (so that Palm, or any other slow platform which can't handle the larger sizes easily, can still have some variety available) - in Solo, arranged a means of sharing scratch space between calls to nsolve to prevent a lot of redundant malloc/frees (gives a 10% speed increase even on existing platforms)
Simon Tatham
2005-06-01 17:47:56 +00:00
ad3abd9867Arrange that random seeds are as harmonised as they can reasonably be between interactive and batch use.
Simon Tatham
2005-06-01 12:46:27 +00:00
b8197684f3I've proved that a grid dimension of 2 is capable of irretrievably hanging the grid generator and that there's no way to fix it. Therefore, lower limit of 3 squares in each direction, which will upset envelope-pushers everywhere but doesn't destroy any actually interesting puzzles.
Simon Tatham
2005-06-01 12:42:30 +00:00
42a2d7d61cGareth points out that the recess highlights around the outside of the grid, in all games that have them, are drawn incorrectly when the grid is not square. Fixed.
Simon Tatham
2005-06-01 07:22:21 +00:00
5b5fc1417bPatches from Richard B for Solo: - prevent highlighting a clue square at all - enable easier switching between highlight types by not requiring a left-click highlight to be left-click-cancelled before right-clicking, and vice versa - fix bit-rot in -DSTANDALONE_SOLVER Also one of mine: - replicate Richard's -DSTANDALONE_SOLVER fix in Pattern, where it was also broken.
Simon Tatham
2005-06-01 07:01:32 +00:00