695b6be363Chris Emerson observed the same status-bar flicker under GTK as I did under Windows, so here's his patch (blatantly copied from my own fix in windows.c :-).
Simon Tatham
2005-06-01 06:54:14 +00:00
7905d6dc07Typo in click bounds checking.
Simon Tatham
2005-06-01 06:47:55 +00:00
a50a65120cBetter mouse button handling in Mines: - middle button now also triggers the clear-around-square action - a special-case handler in midend_process_key() arranges that the left button always trumps the right button if both are pressed together, meaning that Windows Minesweeper players used to pressing L+R to clear around a square should still be able to do so without any strange behaviour. (The latter touches all game backends, yet again, to add a field to the game structure which is zero in everything except Mines.)
Simon Tatham
2005-05-31 18:38:01 +00:00
437b69542fBah, and remove the TODO item. As usual.
Simon Tatham
2005-05-31 18:25:06 +00:00
4a9db8a002Now _this_ is what Undo ought to be doing in a Minesweeper clone. Rather than revealing the entire mine layout when you die, we now only reveal the one mine that killed you. You can then Undo and continue playing, without having spoiled the rest of the grid for yourself. The number of times you've died is counted in the status line (and is not reduced by Undo :-).
Simon Tatham
2005-05-31 18:24:39 +00:00
739609cec2Aha! It turns out, after a bit of failure-mode profiling, that when the Mines unique grid generator fails at high mine densities it is _almost always_ for the same reason, and it also turns out that this reason is one which can be addressed. So here's an enhancement to mineperturb() which enables Mines to generate a grid at (as far as I can tell) any mine density you like, up to and including w*h-9 mines. At densities of 1 in 2 or thereabouts the grids start to look rather strange, but it can at least generate them without hanging.
Simon Tatham
2005-05-31 18:09:28 +00:00
c11f9ff173valgrind spotted this array underrun. I wonder if this might have been causing some of Verity's nonreproducible weirdnesses.
Simon Tatham
2005-05-31 17:46:22 +00:00
274423eaf8Oops! A trivial typo in obfuscate_bitmap() made the obfuscation function rather less uniform-looking than I'd intended. I _thought_ it looked a bit fishy, but had assumed it was just the human tendency to see patterns where none exist. Now fixed, and some real test vectors confirm that this time the obfuscation function is actually what I intended it to be.
Simon Tatham
2005-05-31 17:09:39 +00:00
0b5ee8f3e7`Solve' operation is relatively simple in Mines.
Simon Tatham
2005-05-31 13:02:26 +00:00
1d9ed93af6Apparently a number of Windows programs like to use ^Y as a keyboard shortcut for Redo. I wasn't doing anything else with it, so why not?
Simon Tatham
2005-05-31 12:41:18 +00:00
b78667ecffDocument the mouse control method for Cube.
Jacob Nevins
2005-05-31 12:12:47 +00:00
a029c2095dMove definition of PI into puzzles.h. If nothing else, the definition in cube.c had a typo :)
Jacob Nevins
2005-05-31 12:03:25 +00:00
caee305b47Mouse-based interface for Cube: you left-click anywhere on the grid and it moves the polyhedron in the general direction of the mouse pointer. (I had this in my initial throwaway Python implementation of this game, but never reimplemented it in this version. It's harder with triangles, but not too much harder.)
Simon Tatham
2005-05-31 11:43:51 +00:00
4a3c26ff14Emma Garside suggested that it would be nice to have a different background colour for covered and uncovered squares in Mines, since otherwise you have to distinguish them by the edge highlights alone. So here one is; it's not _very_ different (it just looked odd if it was any darker than this), but anyone who wants a bigger difference can reconfigure it using the MINES_COLOUR_1 environment variable.
Simon Tatham
2005-05-31 11:20:24 +00:00
0c7f777ecbImproved the limited shuffle mechanism in Sixteen and Twiddle. They were already making sure that no shuffle move was the precise inverse of the previous one, or contributed to repeating the previous one so many times as to turn it into effectively fewer moves (doing the same rotation three times in Twiddle, or shifting a row by more than half its length in Sixteen). However, they were only checking against the _last_ move, which meant that in any situation where there were completely disjoint move spaces (4x4n2 Twiddle, or any Sixteen at all) it was still possible to have A then B then inv(A) occurring in the shuffle, leading to an unnecessarily easy game.
Simon Tatham
2005-05-31 11:19:11 +00:00
412344ff9aFix a couple of robustness issues.
Simon Tatham
2005-05-31 08:56:33 +00:00
2698fc9e9eGTK misfires timers at inconvenient moments, sometimes causing a new puzzle of a different size to be redrawn before the pixmap is resized, and since backends never redraw already-drawn stuff this is a problem. Was biting me when I entered a Mines game ID of a different size than the current settings into the Specific box.
Simon Tatham
2005-05-31 08:50:42 +00:00
ee429c13cdChris's patch to stop Mines depending on char being signed.
Simon Tatham
2005-05-30 22:33:34 +00:00
e4328b9081Added an interactive' flag to new_game_desc(), which toggles Mines between on the one hand generating indeterminate game descriptions awaiting the initial click, and on the other hand generating concrete ones which have had their initial click. This makes mines --generate' do something useful.
Simon Tatham
2005-05-30 18:41:40 +00:00
3c6b77c93b`Copy' operation for Mines.
Simon Tatham
2005-05-30 18:24:06 +00:00
0e5380b96dConstrain mine count to be at most the largest number of mines we can guarantee to fit into the grid!
Simon Tatham
2005-05-30 17:57:45 +00:00
90560462c4First cut at a game timer. Yet another backend function which indicates whether a particular game state should have the timer going (for Mines the initial indeterminate state does not have this property, and neither does a dead or won state); a midend function that optionally (on request from the game) prepends a timer to the front of the status bar text; some complicated midend timing code.
Simon Tatham
2005-05-30 16:15:34 +00:00
7ddaa1382fD'oh, there's always one. Remove first-click stuff from the todo list.
Simon Tatham
2005-05-30 13:11:05 +00:00
0564c4c4d0Mines now follows the conventional approach of offering a completely blank grid until you make the first click; to ensure solubility, it does not generate the mine layout until that click, and then ensures it is solvable starting from that position.
Simon Tatham
2005-05-30 13:10:37 +00:00
7ff09fbba1Neat idea from Gareth: if you put a % on the end of the mine count in the Custom dialog box, it'll treat it as a mine density.
Simon Tatham
2005-05-30 12:24:31 +00:00
6e7421a3baNit: "warning: extra tokens at end of #endif directive"
Jacob Nevins
2005-05-30 11:49:08 +00:00
6b9e690c89Initial checkin of my Minesweeper clone, which uses a solver during grid generation to arrange a mine layout that never requires guessing.
Simon Tatham
2005-05-30 10:08:27 +00:00
0f423f0b3aInfrastructure change: game_anim_length and game_flash_length now both get passed a pointer to the game_ui. This means that if they need to note down information for the redraw function about what _type_ of flash or animation is required, they now have somewhere to do so.
Simon Tatham
2005-05-30 07:55:27 +00:00
8fa365a7b4Add a limited-shuffle mode like that added to Sixteen and Twiddle in r5769, for completeness.
Jacob Nevins
2005-05-28 23:45:43 +00:00
c8362f0a94Add the ability to use the Rectangles solver for actually solving puzzles, rather than just doing its nondeterministic number placement thing. This enables the use of the `Solve' menu option on externally entered game IDs, provided of course that they aren't _too_ difficult.
Simon Tatham
2005-05-28 08:04:29 +00:00
c82820e55bAdd support for Jacob's new cursor-key modifier flags in the OS X frontend.
Simon Tatham
2005-05-26 17:12:04 +00:00
a0f376efbdSorted out the barriers/corners trouble left by r5844. No wonder Jacob wasn't able to find a satisfactory fix: the whole area was a horrid mess. Fortunately, the reason it was a horrid mess was because the Net drawing routines predated the introduction of clip() in the frontend interface, and it turns out that clip() makes it possible to do all this more easily and better. So, a complete rearchitecting of barrier corners: the corner flags in the barriers' array are now gone (and good riddance), and corner information is computed on the fly so as to take into account the moving grid edges. In the process I've also updated the corner mechanism so that a barrier corner' (really endpoint) is drawn at the end of _every_ barrier, not just where two meet. This has changed the appearance of a single isolated barrier, to what I would have wanted it to look like in the first place but achieving it without clip() was just too fiddly.
Simon Tatham
2005-05-26 17:03:51 +00:00
3dc0fce9b8Since the split into random and descriptive IDs, the section on game seeds has been mostly covered by the main documentation or otherwise moot.
Jacob Nevins
2005-05-26 16:57:19 +00:00
865e8ad6caAdd origin-shifting (Shift+cursors) and source-shifting (Ctrl+cursors) to Net. (Adding modifier+cursors handling has had minor knock-on effects on the other puzzles, so that they can continue to ignore modifiers.)
Jacob Nevins
2005-05-26 13:40:38 +00:00
a1be37343cSupport for `pencil marks' in Solo, by right-clicking and typing a number. Many thanks to Chris Thomas, for helping with the detailed UI design by means of testing an endless series of prototypes.
Simon Tatham
2005-05-25 11:09:43 +00:00
5409c27b4fMention NetWalk and update comment
Jacob Nevins
2005-05-24 20:28:38 +00:00
49fdcd1ed4Avoid leading zeroes on internally generated random seeds, _just_ in case they confuse anyone who expects the same seed without the leading zero to be equivalent.
Simon Tatham
2005-05-23 12:02:37 +00:00
80aa8bafb1I'm sick of `--generate' giving the same answers if you run it twice in one second. Switched the Unix get_random_seed() to using gettimeofday() rather than time().
Simon Tatham
2005-05-23 11:15:39 +00:00
916ad91298The GTK `--generate' option didn't validate the game parameters. It does now.
Simon Tatham
2005-05-23 11:13:39 +00:00
9c54e18f0bNet hangs if you ask it for a 2xn or nx2 wrapping puzzle with a unique solution. This, it turns out, is because there is literally no such thing. Protective constraint added to validate_params(), with a proof in a comment alongside.
Simon Tatham
2005-05-23 11:03:52 +00:00
3266a0e7baAesthetic improvements, mostly suggested by Gareth.
Simon Tatham
2005-05-22 13:35:13 +00:00
466e9d21a7Forgot to add print.py to the source archive. Ahem.
Simon Tatham
2005-05-22 12:45:39 +00:00
ba3247bb92Another tweak to the solver to make it handle blank tiles correctly. The previous checkin stopped it choking on them, but it didn't actually manage to _deduce_ that all the edges bordering them had to be closed. Now it does better.
Simon Tatham
2005-05-22 12:14:39 +00:00
0066cdd62aSpecial case in dead-end checking which prevents the solver falling over on a grid containing a 0 (completely blank) tile. This can't happen in self-generated grids, but can happen if you type in a grid from another Net implementation. Previously, the solver would notice (technically correctly!) that a completely blank tile connects to no other tiles and thus forms an isolated subgraph, and would therefore complain that no orientation of that tile could possibly yield a valid solution...
Simon Tatham
2005-05-22 11:45:20 +00:00
fc3f16b364The Net solver now makes use of barrier information when applied to a typed-in grid.
Simon Tatham
2005-05-22 11:15:03 +00:00
d45d94d355It occurred to me yesterday that Net could perfectly well be played on paper, so here's a routine to print it out.
Simon Tatham
2005-05-22 11:06:25 +00:00
8ddfc3904bEnsure that an old random seed isn't left around for the user to see when a descriptive ID has been specified. Fix tiny memory leak.
Jacob Nevins
2005-05-21 22:07:48 +00:00
f3ba6f8bceCleanups: - fix documentation of Net's unique solution option (should have tested before last checkin) - make unique solutions optional in Rectangles too (same reasons) - tidy up various issues in parameter encoding in both games.
Simon Tatham
2005-05-21 13:39:23 +00:00
862e25c90bSolution uniqueness for Net. Can be disabled on request (but is enabled by default), since ambiguous sections in grids can present additional interesting challenges. I think uniqueness is a better default, though.
Simon Tatham
2005-05-21 13:23:26 +00:00
5810785da1Move IDM_ABOUT so that it doesn't overlap the presets space! Ahem.
Simon Tatham
2005-05-20 12:30:37 +00:00
93b955d5eeCunning way to ensure unique solutions in generated Rectangles puzzles. I generate the grid of rectangles as normal, but before I place the numbers I run it through a non-deterministic solver algorithm which tries to do as much as it can with as little information about where the numbers are going to be. The solver itself narrows down the number placement when it runs out of steam, but does so as little as possible. Once it reaches a state where it has ensured solubility, and then the generation algorithm chooses random number placement from whatever's left.
Simon Tatham
2005-05-19 16:17:03 +00:00
b1c0d665bdIf you paste in a random seed with different ephemeral parameters from the currently configured ones, and then bring the Random Seed box back up, the wrong parameters get shown, and the resulting random seed is incorrect for the current game.
Simon Tatham
2005-05-18 17:41:53 +00:00
4670313f6fRectangles random seed IDs shouldn't bother stating the expansion factor if it's zero.
Simon Tatham
2005-05-18 17:28:48 +00:00
cf9e6e81eb--version.
Simon Tatham
2005-05-18 17:27:16 +00:00
981b831c21It's a good idea to validate presets received from the environment.
Simon Tatham
2005-05-18 17:25:30 +00:00
90e42d4cdeMove the colour configuration into midend.c so that it becomes cross-platform, and rename the environment variables so that they follow the puzzle name. Should allow a static environment configuration for each puzzle. Also introduced a <game>_PRESETS variable for people whose favourite configuration isn't on the Type menu by default.
Simon Tatham
2005-05-18 09:04:47 +00:00
1304e07d74Standalone solvers were broken by my recent API changes.
Simon Tatham
2005-05-18 08:34:01 +00:00
58eb0551d4Update doc for recent changes in Restart behaviour.
Jacob Nevins
2005-05-17 18:04:12 +00:00
0e197efe44After much thought, I've decided that Restart' on r is not a particularly useful keypress, particularly given how easy it is to confuse it with Redo'. So both r and ^R are now Redo, and Restart is relegated to being a menu-only option.
Simon Tatham
2005-05-17 17:20:08 +00:00
f3a2773802Null-terminate generated Net/Netslide descriptive game IDs.
Jacob Nevins
2005-05-17 12:02:30 +00:00
4b02ebae71Keyboard shortcuts for Twiddle: abcdABCD in line with the notation Gareth and I have been using to analyse the game, and also the number pad. They don't work sensibly for all sizes, but they'll be handy for the most common ones.
Simon Tatham
2005-05-17 11:53:42 +00:00
b77d727eb4Just for Gareth: a means of overriding individual game colour settings using environment variables. GTK frontend only, because this is an unsupported (and unprincipled) hack.
Simon Tatham
2005-05-17 11:47:33 +00:00
c9f05ca3c0`Restart' is now an undo-able action: it appends a move to the end of the undo list rather than destroying it. Partly this is because accidental restarts are a real pain, and partly because it allows you to compare the initial to the current state by restart-then-undo which is handy in some puzzles.
Simon Tatham
2005-05-17 11:46:55 +00:00
0913f94a98comment c'n'p error
Jacob Nevins
2005-05-17 11:00:15 +00:00
6c3f422ddeCube's dup_game() function was missing a field. Oops.
Simon Tatham
2005-05-17 10:59:47 +00:00
2534ec5d69The game IDs for Net (and Netslide) have always been random seeds rather than literal grid descriptions, which has always faintly annoyed me because it makes it impossible to type in a grid from another source. However, Gareth pointed out that short random-seed game descriptions are useful, because you can read one out to someone else without having to master the technology of cross- machine cut and paste, or you can have two people enter the same random seed simultaneously in order to race against each other to complete the same puzzle. So both types of game ID seem to have their uses.
Simon Tatham
2005-05-16 18:57:09 +00:00
aa1185f3f5Missed a vital semicolon off the Cygwin version.c makefile fragment.
Simon Tatham
2005-05-15 11:12:05 +00:00
3dfeadd738Er, except that I already had a makedist.sh. Transferred new version code into that!
Simon Tatham
2005-05-15 10:58:09 +00:00
1add9dcc1bAdded automatic determination of the SVN revision number if a build takes place in a checked-out copy. Also added mkunxarc.sh which does the same version determination before building its archive.
Simon Tatham
2005-05-15 10:52:23 +00:00
c05b4697a8Introduce a versioning mechanism, and an `About' box in all front ends. Versioning will be done solely by Subversion revision number, since development on these puzzles is very incremental and gradual and there don't tend to be obvious points to place numbered releases.
Simon Tatham
2005-05-15 10:31:11 +00:00
68d27f0526I've had two complaints that Solo ought to recognise the numeric keypad. The reason it doesn't is because front ends were carefully translating the numeric keypad into 8-way directional keys for the benefit of Cube. Therefore, a policy change: - front ends process the numeric keypad by sending MOD_NUM_KEYPAD | '3' and similar - front ends running on a platform with Num Lock SHOULD do this _irrespective_ of the state of Num Lock - back ends do whatever they see fit with numeric keypad keys. Result: the numeric keypad now works in Solo, and also works in OS X Cube (which it previously didn't because I forgot to implement that bit of the front end!).
Simon Tatham
2005-05-12 18:25:57 +00:00
8f1c713735The two Rubik-like puzzles, Sixteen and Twiddle, now support an additional configuration parameter, which is the number of shuffle moves. By default the grid will be fully shuffled so that you need a general solution algorithm to untangle it, but if you prefer you can request a grid which has had (say) precisely four moves made on it, and then attempt to exactly reverse those four moves.
Simon Tatham
2005-05-11 20:38:10 +00:00
18a8df1b9dBah. Try the r5766 fix again, this time without the typo.
Simon Tatham
2005-05-11 18:49:42 +00:00
701cd045b3Completion flashes were occasionally failing to be cleaned up if a subsequent move animation began during them. Tracked this to overenthusiastic use of clip() and fixed it.
Simon Tatham
2005-05-11 13:03:17 +00:00
751d7a2524solve_game() is passed the _initial_ game state, not the most recent one; so we can't just set `ret->completed = ret->movecount' and hope it's been set to something other than zero. Instead, we set both move counts to 1, which is entirely arbitrary but works.
Simon Tatham
2005-05-07 16:07:26 +00:00
6336dbf208Add 3x3 Trivial to the presets list, and make it the default.
Simon Tatham
2005-05-07 12:35:04 +00:00
944997d2f9Aha, here's a nice easy way to generate really hard puzzles. Added the missing fifth difficulty level to Solo: Unreasonable', in which even set-based reasoning is insufficient and there's no alternative but to guess a number and backtrack if it didn't work. (Solutions are still guaranteed unique, however.) In fact it now seems to take less time to generate a puzzle of this grade than Advanced'!
Simon Tatham
2005-05-07 12:30:29 +00:00
b35bedd60cFix outdated comment
Jacob Nevins
2005-05-04 13:17:45 +00:00
2621183246Allow for trailing '\0' in game_text_format() in various games.
Jacob Nevins
2005-05-04 12:56:04 +00:00
38c1f9b702The Twiddle shuffling algorithm was theoretically parity-unbalanced: it performed a fixed number of shuffling moves, and on each one it had a 2/3 chance of flipping the permutation parity and a 1/3 chance of keeping it the same. Markov analysis shows that over a run of 1500-odd shuffle moves this will end up being an undetectably small actual bias in the parity of the generated grid, but it offends my sense of pedantry nonetheless so here's a small change to make the number of shuffling moves itself have randomly chosen parity. The parity of generated grids should now be _exactly_ 50:50.
Simon Tatham
2005-05-04 12:52:51 +00:00
1c77e0df94markup typo
Jacob Nevins
2005-05-04 12:24:16 +00:00
b32b4f8763I've changed my mind. For the benefit of users with slower computers, let's save the Solo and Pattern grids at generation time and regurgitate them when asked to solve, rather than doing all the work over again.
Simon Tatham
2005-05-02 16:59:50 +00:00
cf7988afb3Fix line endings when pasting on Windows.
Simon Tatham
2005-05-02 16:37:20 +00:00
82b8e2faf5Forgot to mention that you can undo a Solve operation.
Simon Tatham
2005-05-02 13:27:59 +00:00
c2273f2718Ahem. The `Solve' option in orientable Twiddle needs to correct the orientations as well as the order!
Simon Tatham
2005-05-02 13:22:25 +00:00
d8cc157c55Silly (but harmless) typo.
Simon Tatham
2005-05-02 13:18:24 +00:00
4f7b65de2eAdded an automatic `Solve' feature to most games. This is useful for various things: - if you haven't fully understood what a game is about, it gives you an immediate example of a puzzle plus its solution so you can understand it - in some games it's useful to compare your solution with the real one and see where you made a mistake - in the rearrangement games (Fifteen, Sixteen, Twiddle) it's handy to be able to get your hands on a pristine grid quickly so you can practise or experiment with manoeuvres on it - it provides a good way of debugging the games if you think you've encountered an unsolvable grid!
Simon Tatham
2005-05-02 13:17:10 +00:00
aea7b61815Oops; forgot to check in the copy-to-clipboard option for Windows.
Simon Tatham
2005-05-02 10:55:32 +00:00
9e240e45dfIntroduce the concept of a `game_aux_info' structure. This is constructed at the same time as an internally generated game seed, so that it can preserve any interesting information known by the program at generation time but not physically contained within the text of the game seed itself. (Such as, for example, the solution.) Currently not used for anything yet, but it will be.
Simon Tatham
2005-05-02 10:12:26 +00:00
3f9d88f3e7It's actually vitally important, it turns out, to have all of the Cut', Copy' and `Paste' items in the Edit menu of an OS X application - because there's nothing else that enables the keyboard cut/copy/paste shortcuts in an edit box! OS X Puzzles can now have game IDs pasted into it, which it previously couldn't.
Simon Tatham
2005-05-02 09:42:09 +00:00
28f655c821The addition of a Copy' menu item on OS X was really beginning to strain my unconventional menu organisation, so I've reverted to having File' and `Edit' menus like everyone else.
Simon Tatham
2005-05-01 14:05:03 +00:00
850a70a03cCopy-to-clipboard for Rectangles.
Simon Tatham
2005-05-01 13:51:46 +00:00
cb413f837bCopy-to-clipboard facility for Fifteen, Sixteen and Twiddle.
Simon Tatham
2005-05-01 13:22:44 +00:00
791940b043Introduced a new function in every game which formats a game_state as text. This is used by front ends to implement copy-to-clipboard. Currently the function does nothing (and is disabled) in every game except Solo, but it's a start.
Simon Tatham
2005-05-01 12:53:41 +00:00
e72931bfe2I can never remember what that `TRUE' means in the game structure definitions, so let's move it so that it's just next to the functions it relates to. This also opens the way for me to add more booleans next to other functions without getting confused as to which is which.
Simon Tatham
2005-05-01 11:07:13 +00:00
5649e20ef2Remove outdated comment :-)
Simon Tatham
2005-05-01 10:57:47 +00:00
6aca542184I think Windows fonts look better in bold as well.
Simon Tatham
2005-05-01 10:57:23 +00:00
90db70378eFix game IDs, which I broke in the orientability change. Also introduce a sensible game ID notation for orientable games, and finally (*blush*) turn the orientability triangles back the right way up.
Simon Tatham
2005-04-30 14:50:33 +00:00
9b870146f7After brainstorming with Gareth, we've decided that this is a much simpler and better way to indicate tile orientation than those colour bars.
Simon Tatham
2005-04-30 14:38:20 +00:00
d40b3172feBah, and of course there's a TODO comment I forgot to remove.
Simon Tatham
2005-04-30 14:14:37 +00:00