61 Commits

Author SHA1 Message Date
a7dc17c425 Rework the preset menu system to permit submenus.
To do this, I've completely replaced the API between mid-end and front
end, so any downstream front end maintainers will have to do some
rewriting of their own (sorry). I've done the necessary work in all
five of the front ends I keep in-tree here - Windows, GTK, OS X,
Javascript/Emscripten, and Java/NestedVM - and I've done it in various
different styles (as each front end found most convenient), so that
should provide a variety of sample code to show downstreams how, if
they should need it.

I've left in the old puzzle back-end API function to return a flat
list of presets, so for the moment, all the puzzle backends are
unchanged apart from an extra null pointer appearing in their
top-level game structure. In a future commit I'll actually use the new
feature in a puzzle; perhaps in the further future it might make sense
to migrate all the puzzles to the new API and stop providing back ends
with two alternative ways of doing things, but this seemed like enough
upheaval for one day.
2017-04-26 21:51:23 +01:00
e3a8e64812 Put the game summaries from the website into gamedesc.txt.
More sensible to bring all the pieces of per-puzzle descriptive text
together into one place, so they can be easily reused everywhere
they're needed.
2015-01-13 19:54:46 +00:00
822243de1b Permit selecting a diagonal of squares at once in Group.
When filling in a cyclic subgroup or one of its cosets, I've often
found I wanted to set an entire diagonal to the same thing at once
(usually SW-NE, but the other way round too in non-abelian groups),
and it's a pain having to do that to each square individually.
Restricting multiple selection to diagonals makes it easy to get the
selection I really wanted.
2014-12-18 09:59:53 +00:00
3a35ed2195 Fix a printf 64-bit-cleanness error.
[originally from svn r10098]
2013-11-28 18:32:29 +00:00
cdc1224233 Fix an edge case of divider-obsoletion in Group.
When you drag group elements around, previous dividers are meant to
dissolve whenever the same two elements are no longer on each side of
it. One case in which this didn't happen was that of dragging an
element from the left of a divider to the far right column - the
divider became invisible, but would then startlingly reappear if you
drag that element back to the left of whatever it was left of before.

[originally from svn r10051]
2013-10-09 20:44:51 +00:00
96626d9c10 Faintly highlight the leading diagonal of Group's grid.
This makes it easier to spot elements whose square is known, which is
useful in turn for identifying subgroups.

[originally from svn r10050]
2013-10-09 20:44:50 +00:00
c06792c076 Add a mechanism to the automake system to allow 'make install' to only
install the actual games, not the auxiliary binaries or nullgame.

[originally from svn r9887]
2013-06-30 10:16:57 +00:00
c4ec358d6e Remove spurious "unfinished/" that appeared at the start of the
unfinished puzzles' gamedesc.txt lines due to a Perl error. Ahem.

[originally from svn r9861]
2013-06-08 16:55:33 +00:00
5dda5cf1d0 Rename wingames.lst to gamedesc.txt, and add a couple of extra fields
to it giving each game's "internal" name (as seen in the source file,
.R etc) and also a brief description of the game. The idea of the
latter is that it should be usable as a comment field in .desktop
files and similar.

[originally from svn r9858]
2013-06-08 16:29:15 +00:00
251b21c418 Giant const patch of doom: add a 'const' to every parameter in every
puzzle backend function which ought to have it, and propagate those
consts through to per-puzzle subroutines as needed.

I've recently had to do that to a few specific parameters which were
being misused by particular puzzles (r9657, r9830), which suggests
that it's probably a good idea to do the whole lot pre-emptively
before the next such problem shows up.

[originally from svn r9832]
[r9657 == 3b250baa02a7332510685948bf17576c397b8ceb]
[r9830 == 0b93de904a98f119b1a95d3a53029f1ed4bfb9b3]
2013-04-13 10:37:32 +00:00
0b93de904a Add 'const' to the game_params arguments in validate_desc and
new_desc. Oddities in the 'make test' output brought to my attention
that a few puzzles have been modifying their input game_params for
various reasons; they shouldn't do that, because that's the
game_params held permanently by the midend and it will affect
subsequent game generations if they modify it. So now those arguments
are const, and all the games which previously modified their
game_params now take a copy and modify that instead.

[originally from svn r9830]
2013-04-12 17:11:49 +00:00
0e8a375814 Forgot to add the new 'const' in the unfinished subdirectory. Oops.
[originally from svn r9659]
2012-09-10 18:05:54 +00:00
b16eece9fc New puzzle! Or rather, new-ish, because this one has been lying around
in the 'unfinished' directory for a while, and has now been finished
up thanks to James Harvey putting in some effort and galvanising me to
put in the rest. This is 'Pearl', an implementation of Nikoli's 'Masyu'.

The code in Loopy that generates a random loop along grid edges to use
as the puzzle solution has been abstracted out into loopgen.[ch] so
that Pearl can use it for its puzzle solutions too. I've also
introduced a new utility module called 'tdq' (for 'to-do queue').

[originally from svn r9379]
2012-01-22 14:14:26 +00:00
c4e486c2a1 In Group, the keyboard-controlled cursor should respect user
rearrangement of the rows and columns.

[originally from svn r9372]
2011-12-21 13:46:48 +00:00
73daff3937 Changed my mind about midend_is_solved: I've now reprototyped it as
midend_status(), and given it three return codes for win, (permanent)
loss and game-still-in-play. Depending on what the front end wants to
use it for, it may find any or all of these three states worth
distinguishing from each other.

(I suppose a further enhancement might be to add _non_-permanent loss
as a fourth distinct status, to describe situations in which you can't
play further without pressing Undo but doing so is not completely
pointless. That might reasonably include dead-end situations in Same
Game and Pegs, and blown-self-up situations in Mines and Inertia.
However, I haven't done this at present.)

[originally from svn r9179]
2011-06-19 13:43:35 +00:00
2efc77d2fd Fix warnings generated by gcc 4.6.0 about variables set but not
thereafter read. Most of these changes are just removal of pointless
stuff or trivial reorganisations; one change is actually substantive,
and fixes a bug in Keen's clue selection (the variable 'bad' was
unreferenced not because I shouldn't have set it, but because I
_should_ have referenced it!).

[originally from svn r9164]
2011-05-04 18:22:14 +00:00
980880be1f Add a function to every game backend which indicates whether a game
state is in a solved position, and a midend function wrapping it.

(Or, at least, a situation in which further play is pointless. The
point is, given that game state, would it be a good idea for a front
end that does that sort of thing to proactively provide the option to
start a fresh game?)

[originally from svn r9140]
2011-04-02 16:19:12 +00:00
b2e4437d5b Another UI feature for Group: now you can click between two legend
elements to toggle thick lines in the grid. Helps to delineate
subgroups and cosets, so it's easier to remember what you can
legitimately fill in by associativity.

(I should really stop fiddling with this game's UI; it's far too silly.)

[originally from svn r9084]
2011-02-08 22:13:18 +00:00
540716194d Fix error highlighting after table rearrangement.
[originally from svn r9076]
2011-01-09 11:30:09 +00:00
48f6bfa474 Add the ability to reorder the rows and columns in Group. It becomes
much easier to keep track of things if, once you've identified a
cyclic subgroup, you can move it into a contiguous correctly ordered
block.

[originally from svn r9075]
2011-01-08 15:53:25 +00:00
f1ad38971c Memory leak fixes from Jonas Koelker.
[originally from svn r9001]
2010-09-20 10:36:44 +00:00
795ef3c137 Some minor fixes to the unfinished Pearl solver:
- move critical correctness checks out of diagnostic ifdefs (ahem)
 - move declarations to before conditionally compiled code (we don't
   build in C99 mode round here)
 - tidy up an unsightly blank line while I'm here.

[originally from svn r8969]
2010-06-27 11:17:27 +00:00
6776b0afba Oops. Uncomment the difficulty exceptions! (Also add another
constraint in validate_params.)

[originally from svn r8824]
2010-01-09 17:21:36 +00:00
2500531423 Proof that check_errors() is sufficient.
[originally from svn r8813]
2010-01-05 23:40:42 +00:00
dd4c8ceb1f Refer to group elements by letters instead of numbers, in keeping
with usual abstract group notation. In puzzles with a clear
identity, it's called e.

[originally from svn r8812]
2010-01-05 23:40:41 +00:00
a7b220ff9a Add an even more evil (!) game mode, in which it's not made
immediately obvious which element of the group is the identity - at
least two elements including the identity have their rows and
columns completely blanked.

[originally from svn r8810]
2010-01-05 19:52:52 +00:00
66a6a930c5 Yikes! Fix a misaimed 'sizeof' which I only got away with because
ints and pointers are usually the same size.

[originally from svn r8809]
2010-01-05 18:51:42 +00:00
79bb9c00b3 Couple of missing 'static's.
[originally from svn r8801]
2010-01-01 19:41:59 +00:00
c91471e6c1 New puzzle in 'unfinished'. Essentially, Sudoku for group theorists:
you are given a partially specified Cayley table of a small finite
group, and must fill in all the missing entries using both Sudoku-
style deductions (minus the square block constraint) and the group
axioms. I've just thrown it together in about five hours by cloning-
and-hacking from Keen, as much as anything else to demonstrate that
the new latin.c interface really does make it extremely easy to
write new Latin square puzzles.

It's not really _unfinished_, as such, but it is just too esoteric
(not to mention difficult) for me to feel entirely comfortable with
adding it to the main puzzle collection. I can't bring myself to
throw it away, though, and who knows - perhaps a university maths
department might find it a useful teaching tool :-)

[originally from svn r8800]
2009-12-30 16:53:36 +00:00
6328483bb4 Bring the unfinished .R files into line with the current conventions.
[originally from svn r8395]
2009-01-06 23:21:42 +00:00
b2f1b324fe Patch from Lee Dowling to implement mouse control in Sokoban, along
pretty much the same lines as Cube and Inertia.

[originally from svn r8301]
2008-11-16 15:47:55 +00:00
33be388d41 Take out some lurking "nullgame" holdovers from unfinished puzzle
source files, in case they cause trouble. Spotted by Lee Dowling.

[originally from svn r8300]
2008-11-16 15:42:32 +00:00
fe1b91ac49 Since the lack of this has caused portability issues in the past:
add "-ansi -pedantic" to the main Unix makefile, and clean up a few
minor problems pointed out thereby.

[originally from svn r8175]
2008-09-13 18:25:19 +00:00
a7431c0b7c New infrastructure feature. Games are now permitted to be
_conditionally_ able to format the current puzzle as text to be sent
to the clipboard. For instance, if a game were to support playing on
a square grid and on other kinds of grid such as hexagonal, then it
might reasonably feel that only the former could be sensibly
rendered in ASCII art; so it can now arrange for the "Copy" menu
item to be greyed out depending on the game_params.

To do this I've introduced a new backend function
(can_format_as_text_now()), and renamed the existing static backend
field "can_format_as_text" to "can_format_as_text_ever". The latter
will cause compile errors for anyone maintaining a third-party front
end; if any such person is reading this, I apologise to them for the
inconvenience, but I did do it deliberately so that they'd know to
update their front end.

As yet, no checked-in game actually uses this feature; all current
games can still either copy always or copy never.

[originally from svn r8161]
2008-09-06 09:27:56 +00:00
c6b1d4472b Correction from James H: sqrt(0) shouldn't occur any more than
sqrt(1) should.

[originally from svn r8108]
2008-07-05 22:07:35 +00:00
4322b90cbb More operations and bug fixes from James H.
[originally from svn r8107]
2008-07-05 15:40:43 +00:00
1df94d233a James H has helpfully provided yet more silly operators for the -A
mode. I think some user-defined ruleset configuration options are
now required...

[originally from svn r8092]
2008-06-24 20:58:35 +00:00
49a077728f An option to enable a debugging mode for the BFS.
[originally from svn r8091]
2008-06-23 17:34:56 +00:00
3633fec8ae New -A mode permitting even madder operators, and also -m to try to
print all possible paths to a value. The latter has a lot of
de-duplication left to be done, due to multiple evaluation orders.

[originally from svn r8061]
2008-06-09 18:28:03 +00:00
93103eeca4 Substantial reworking of Solo so that it implements both Sudoku-X
(require both main diagonals to have one of every digit in addition
to all the usual constraints) and Jigsaw Sudoku (replace the array
of rectangular sub-blocks with the sub-blocks being random
polyominoes). To implement the latter, I've moved my `divvy.c'
library routine out of the `unfinished' subdirectory.

Jigsaw mode is currently an undocumented feature: you enable it by
setting the rows parameter to 1 (and the columns parameter to your
desired grid size, which unlike normal Sudoku can be anything you
like including a prime number). The reason it's undocumented is
because generation times are not yet reliably short: sometimes
generating a jigsaw-type puzzle can hang for hours and still get
nowhere. (The algorithm should terminate in principle, but not in
any time you're prepared to wait.) I _think_ I know how to solve
this, but have yet to try it. Until then, jigsaw mode will remain a
hidden feature.

Printing of X-type puzzles is also substandard at present, because
the current print-colour API replaces the desired light shading of
the X-cells with heavy diagonal hatching. I plan to adjust the API
imminently to address this.

[originally from svn r7974]
2008-04-07 15:56:42 +00:00
a603318eec A rigorous proof. Totally unimportant to the code, but I didn't want
to lose it :-)

[originally from svn r7703]
2007-08-25 17:46:13 +00:00
f228c5ef00 Fix an inaccurate comment.
[originally from svn r7702]
2007-08-25 15:50:33 +00:00
cb0901306d I've just realised that my deliberate avoidance of non-simply
connected polyominoes actually causes a loss of generality for
sufficiently large k. I hadn't previously noticed, because you need
k to be (I think) at least 23 and none of my potential applications
require anything nearly that large. Add some discussion of this.

[originally from svn r7701]
2007-08-25 15:32:41 +00:00
c746f6d0e3 Commit my work so far on a generator for Nikoli's `Block Puzzle'. It
works, but it's slow, and the puzzles are currently at a relatively
low level of difficulty. Also this is a generator only: no UI yet
(because I'm waiting to see if I can make the generator practical
before bothering to write the rest).

[originally from svn r7700]
2007-08-25 14:10:49 +00:00
4ff90bd47f Ahem. Finishing writing the comment _before_ checkin is generally sensible.
[originally from svn r7694]
2007-08-18 13:32:56 +00:00
4c1e3ca7cb Allow a 1-omino to be completely destroyed and recreated in an
arbitrary unclaimed square. This cures the most common cause of
generation failures (covering a large area in dominoes was the most
difficult case, and would fail even if the large area was 1xn!); the
failure rate is now sufficiently low under all circumstances I've
found that I'm willing to just loop until I get a success.

[originally from svn r7693]
2007-08-18 13:30:13 +00:00
333d57bf6e Better test-mode diagnostics.
[originally from svn r7691]
2007-08-18 11:19:29 +00:00
cc54c09413 A piece of library code which constructs a random division of a
rectangle into equally sized ominoes. I have a couple of potential
applications for this, but none I've actually implemented yet, so
for the moment it's living in `unfinished'.

[originally from svn r7690]
2007-08-18 10:07:29 +00:00
d9c4a9b659 Optimiser placation.
[originally from svn r7625]
2007-06-29 09:45:44 +00:00
e6116563bd More forgiving selection of dragging targets.
[originally from svn r7574]
2007-05-12 13:13:39 +00:00