1339 Commits

Author SHA1 Message Date
6684bec60c Always use ret instead of state in execute_move 2015-05-11 10:14:48 +01:00
7cf1e1f83e Fixed a typo in a comment 2015-05-11 10:14:44 +01:00
52a0f3c32a Special-case right-dragging of a numbered cell off the grid.
Chris Boyle reports that if you right-drag a numbered cell off the
grid, _all_ numbered cells (except the immutable initial clues) get
reset to blank, because this is treated as an attempt to erase a whole
chain of linked cells (of the form a,a+1,...,a_k) and the cells with
definite numbers are all treated as 'chain 0'.

In that situation, I now substitute the same behaviour you'd get by
left-dragging the numbered cell off the board, i.e. erase _just_ that
cell and not the whole of the rest of the puzzle.

(The previous unintended behaviour was a UI action you surely never
want - and Chris also reports that due to the Android front end's way
of representing right-drags, it's especially easy to hit by mistake.)
2015-05-09 15:38:48 +01:00
7f64f4a50e Sort out abs/fabs confusion.
My Mac has just upgraded itself to include a version of clang which
warns if you use abs() on a floating-point value, or fabs() on an
integer. Fixed the two occurrences that came up in this build (and
which were actual build failures, because of -Werror), one in each
direction.

I think both were benign. The potentially dangerous one was using abs
in place of fabs in grid_find_incentre(), because that could actually
lose precision, but I think that function had plenty of precision to
spare (grid point separation being of the order of tens of pixels) so
nothing should have gone seriously wrong with the old code.
2015-04-10 07:58:26 +01:00
10460d1bc7 Add Tracks to the automake makefile's "install" target.
Each game's .R file should append the binary to $(GAMES) in both the
'am' and 'gtk' makefiles, but presumably due to copy-and-paste from an
out-of-date version, tracks.R only did 'gtk'.

Also clarified CHECKLST.txt in the hope that I won't miss that again.
2015-03-25 18:23:39 +00:00
195217a480 Fix a compile warning on ARM.
Aapo Rantalainen points out that comparing 'char c' against zero gives
rise to gcc's "comparison is always false" warning, which escalates to
an error under -Werror.

This is one of those situations where the warning is doing more harm
than good, but here's a rephrasing which casts to unsigned so that
both negative numbers and positive out-of-range ones can be caught by
the same comparison.
2015-03-24 19:20:03 +00:00
05b533d1f8 Update README after the switch to autoconf.
A user just pointed out that it still (and now falsely) claims that
mkfiles.pl directly generates a usable Unix Makefile.
2015-03-15 08:50:53 +00:00
ffe0aa6a11 Fix a build failure on x32 (time_t printfs).
As that architecture has 64-bit time_t but only 32-bit longs, printf format
causes a warning.  Enter -Werror...
2015-03-09 18:03:20 +00:00
f1e68fb516 Turn <image> tag into <img>.
Not sure how I managed to write the former by mistake, but I didn't
notice because browsers didn't immediately complain. Still, James
Harvey points out, it ought to be turned into the actually
standards-compliant spelling of the tag. Ahem.
2015-02-08 22:52:20 +00:00
362bf8d450 New puzzle from James Harvey: 'Tracks'. 2015-02-08 16:23:32 +00:00
bd0a357047 Remove a lingering bashism in makedist.sh.
A load of source files in the icons subdirectory were being left out
of the distribution tarball because I tried to include them using a
combined wildcard and bash brace expansion - but makedist cites
/bin/sh, so can't get away with bashisms. Expanded the braces.
2015-01-17 08:49:28 +00:00
cca302c01b Improve the Flood solver.
Previously it simply chose every move based on the static evaluation
function 'minimise the pair (longest shortest-path to any square,
number of squares at that distance)'. Now it looks three moves ahead
recursively, and I've also adjusted the evaluation function to tie-
break based on the number of squares brought to distance zero (i.e.
actually in control).

The result isn't an unconditional improvement on the old solver; in a
test run based on 'flood --generate 1000 12x12c6m0#12345' I found that
57 out of 1000 grids tested now had longer solutions. However, about
three quarters had shorter ones, and solutions are more than a move
shorter on average.
2015-01-15 20:36:19 +00:00
202e7fecfd Remove some lingering HTML markup.
It was getting conscientiously escaped by the new webpage.pl :-) but
in any case it's better to have the puzzle descriptions be plain text
usable in any context.
2015-01-13 20:59:54 +00:00
3f651b25c7 And one more whitespace fix.
It's a pain having to commit each of these separately in order to test
the script, but there we go. Should be working now.
2015-01-13 20:46:00 +00:00
603409d092 Couple of fixes to the new web-page mechanism.
I missed some spaces in the autogenerated <span>s, and I generated the
web page components including unfinished puzzles by mistake.
2015-01-13 20:30:40 +00:00
7cf7e37d65 Script to autogenerate pieces of the web page.
This should simplify the process of adding a new puzzle, by automating
the part where I have to manually edit index.html separately from the
main build step.
2015-01-13 20:04:18 +00: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
f39681ab41 Revise the Flood preset list.
The ones I started with were a bit under-varied and over-orthogonal.
Get rid of some of the more pointless things like 16x16 with lots of
extra moves, and add some with different colour counts. While I'm
here, make the menu descriptions nicer.
2015-01-13 19:31:29 +00:00
d31eff1483 Handle the space bar in the Javascript front end.
I wasn't passing it through at all, causing CURSOR_SELECT2 dependent
keyboard UI not to be reachable.
2015-01-13 19:19:05 +00:00
201b32983b New puzzle: 'Flood'.
Based on a web game I saw a few years ago, and dashed off this weekend
after I thought of a way to write a good (though not quite optimal)
heuristic solver, here's a random little thing not quite in the same
line as the most usual kind of Puzzles fare: instead of making you
scratch your head to find any move to make at all, it's easy to find
solutions in principle, and the challenge comes from having to do so
within a move limit.
2015-01-12 19:51:19 +00:00
b2f8f5fb57 Update the new-puzzle checklist for git.
Replace references to svn:ignore and 'svn add' with the git
equivalents.
2015-01-12 19:51:07 +00:00
70b26db85a Add OS X metadata to make Puzzles.app searchable in Spotlight.
Thanks to Stephen Norman for most of the work, particularly working
out what all the metadata had to be in the first place. This patch is
mostly his work, and all I've done is fiddle with the plumbing that
gets the right version number into the right places.
2015-01-09 19:05:25 +00:00
8f8333a351 Fix puzzle window resize behaviour on Unity.
Unity hijacks the menu bar and prevents it from appearing in the main
puzzle window. And we wait for the menu bar to appear before reducing
the puzzle drawing area's size request. These two behaviours go
together badly.

Fixed by detecting the extra GTK property that the Unity patches
invented, and using that to know whether to expect the menu bar to
show up at all.
2015-01-04 18:11:28 +00:00
79874f18e4 Fix homology bug (!) in Net's loop highlighter.
I unthinkingly transplanted into Net the same loop-finding algorithm
used in Loopy and Slant, which identifies the connected components
into which the grid lines divide the plane, and marks an edge as part
of a loop iff it separates two different components. This works fine
for a planar graph, but in Net's wrapping mode, it's possible to have
loops which do not have this property - e.g. a loop can go off the top
of the grid and back on the bottom to join up with itself, and then
it _doesn't_ disconnect the surface into two components.

(In principle, this kind of problem can turn up in any topological
space with a non-trivial H_1 homology group, which is why it fails on
the torus to which Net's wrapping mode corresponds, but not on the
plane or sphere. I think it's forgivable that I hadn't expected
homology to be the cause of any bug in practical code ever!)

Fixed by inventing yet another dsf-based loop-finding algorithm, this
one based on tracing round the outside of connected components of the
graph. It's still not _fully_ general, in that this one still depends
on the graph being drawn on an orientable surface (so it'll need
another rewrite if I ever add Mobius strip or Klein bottle modes for
Net...), but it's fairly simple to state and implement, and detects
loops that the previous implementation did not, such as the one in the
starting position of 3x3w:1a39ac6a8 .
2014-12-29 10:11:47 +00:00
546fbe6774 Error-highlight loops in Net.
Loops are detected using the same dsf technique I ended up using in
Slant, and highlighted in red (whether or not the connected component
they belong to is currently powered).

Should make life a little bit easier for someone who's filled in most
of the grid to a nice uniform cyan and finds one piece left over - now
they have some idea where to start looking for their mistake.

We also take care not to generate any loops in the starting position,
on grounds of politeness (don't accuse the user of a mistake before
they've even had a chance to make one).

Loop detection does not contribute to the code that decides whether
the puzzle is complete, because there's no need - if all squares are
connected together, then there can't be any loops anyway, by graph
theory.
2014-12-28 13:15:31 +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
5b367167af Fix two compile warnings in emcc.c.
Reported by a user, who didn't say what version of Emscripten they
were using but it must not be the same as mine.
2014-11-30 17:00:45 +00:00
f806528a30 Remove another erroneous GINT_TO_POINTER.
This one shouldn't have been there at all - it had a pointer argument
already, not an int.
2014-11-29 10:39:00 +00:00
2fe0667f51 Use the compile flag -std=c89 in place of -ansi.
This is probably slightly nicer anyway, in that it specifies exactly
_which_ ANSI standard I'm talking about; but the main reason for
making the change is that it means I can now build the Unix puzzles
with clang.

It's not that clang doesn't _support_ -ansi; it accepts it just fine
on any command line that's actually doing some compiling. But on a
link-only command line, i.e. with only object files as input and no
sources, clang emits the annoying warning "argument unused during
compilation: '-ansi", and if you have -Werror as well then that
warning becomes an error.

You'd think there would be some makefile flags variable I could
nonetheless put -ansi in, but apparently not - automake passes CFLAGS
to both compiles and to link-only commands.

And you'd also think that surely I should be able to work around this
by having my configure.ac do a test link and stop trying to use that
option if it didn't work - especially since configure.ac already tests
a bunch of compile options to make sure they don't object to system
header files, after the time I found that a GTK header was
incompatible with my usual -Werror. But in fact, if I change that
AC_COMPILE_IFELSE to an AC_LINK_IFELSE, autoconf generates a single
compile-and-link command line, and hence does not expose the problem
using -ansi on link-only command lines.

Fortunately, -std=c89 does not generate this same warning from clang.
I don't know why not - surely the two options are more or less
equivalent - but it makes my build work again for the moment.
2014-11-29 10:29:29 +00:00
69ab4b2205 Fix a GINT_TO_POINTER that was back to front.
Spotted by clang, which I just tried building this codebase with out
of curiosity.
2014-11-29 10:24:05 +00:00
f781937d0d Change the policy for parsing underspecified params strings.
In conversation with a user last week, it emerged that the command
'solo --generate 1 9jk#12345' was giving a different game from the one
it gave when I ran it, and it turns out that this is because I've set
SOLO_DEFAULT=7jxdi in my environment to make GUI Solo automatically
start up in my (current) favourite mode. And the difficulty setting
from that parameter string was being reused to fill in the unspecified
difficulty slot in the '9jk', so that the same params string was being
interpreted differently by our two machines.

This is certainly wrong - the whole point of random seed strings like
that is to be interpreted the same way everywhere. But it's a side
effect of something I did do on purpose, for people switching back and
forth between playing randomly generated games and playing a game id
pasted (or typed) in from elsewhere. So this fix, with a giant comment
explaining it, I _think_ should retain the behaviour I originally
wanted while getting rid of the behaviour I didn't.
2014-11-29 10:23:12 +00:00
078d3c0a6d Remove an inappropriate assertion in validation context.
spec_to_dsf() should not report invalid input by failing an assertion,
because one of the contexts it's called from is validate_desc(), in
which the whole point is to present a useful error message to the user
before getting to the point where an assertion might go off at all.

Game description 5j:c1_5o4_3c,c___aba___cca_a_a_aca now fails
validation cleanly, where previously it would trigger this bug.
2014-11-26 21:25:02 +00:00
d7a4c52937 Fix a decoding bug in Solo block-structure descriptions.
Due to a copy-and-paste error, I was accidentally treating 'y' as the
special-case character which puts no 1 bit after the run of 0s, which
should have been 'z'. Game id 9jk#12345-5994 failed an assertion as a
result (because it generates a y which was accidentally treated as
special).
2014-11-26 19:27:35 +00:00
4a8edc65bb Fix error highlighting of closed subgraphs in Bridges.
When I did the recent rewrite of the Bridges drawing code, I spotted
and replicated the code in game_redraw that set G_WARN at redraw time
on an island with unsatisfiable clues, but didn't spot the code
elsewhere (e.g. map_group_check) which might have set G_WARN ahead of
time, so I failed to check for that. As a result, if you join some
islands together into a subgraph with no further room for expansion
(e.g. connect a pair of 1s together, or a pair of 2s with a double
bridge) then all the bridges in that subgraph light up red but the
islands themselves forget to.

Trivial one-line fix.
2014-10-29 21:41:38 +00:00
3017455259 Some more .gitignore updates.
Ignore a few things that turn up in the icons subdirectory.
2014-10-27 21:58:10 +00:00
8b62420aa4 Add a .gitignore, now this project is in git. 2014-10-25 15:27:27 +01:00
74a97a1efb Stop using NSApp in the OS X front end.
As of OS X 10.10 (Yosemite), this causes a compile failure, which
according to the Internet is because NSApp is a generic 'id'
(Objective-C's answer to void *), which causes the compiler to select
the wrong method for [NSApp setDelegate:...] and give a spurious type
warning.

Fixed by using [NSApplication sharedApplication] throughout, or
rather, calling that once at startup and assigning the result into my
own global variable which will do as an NSApp replacement.

[originally from svn r10286]
2014-10-20 17:43:38 +00:00
b1158d4dcf Fix antialiasing artifacts around edges of Bridges islands.
When an island changes colour (because it becomes locked or
highlighted, or goes back to plain COL_FOREGROUND from one of those
states), we were just redrawing a filled circle over the previous one,
which only really worked before antialiasing was introduced.

Fixed by reworking the entire drawing edifice to be grid-square based,
so that every grid square is either redrawn in full or left alone.
Grid squares come in two types - island and bridge - but a bridge
square can have neighbouring islands overlap into it, and the bridges
entering an island overlap the island square too, so we end up with
quite a large collection of bitfields describing each square's
contents, and some care must be taken to draw each square in the right
order.

[originally from svn r10282]
2014-10-07 21:22:53 +00:00
1ba20eddba Provide a static version.h for development builds.
I forgot to add this in last week's versioning revamp, meaning that
dev builds straight from source control would fail for lack of
version.h because Buildscr is the only thing that knows how to create
it. Other projects that I restructured this way come with a static
version of version.h so that local builds can still work; I forgot
that in this one.

[originally from svn r10274]
2014-09-27 14:51:02 +00:00
64ceaf03b3 Remove the MD5-based manifest file system.
A long time ago, it seemed like a good idea to arrange that binaries
of my puzzles would automatically cease to identify themselves as a
particular upstream version number if any changes were made to the
source code, so that if someone made a local tweak and distributed the
result then I wouldn't get blamed for the results. Since then I've
decided the whole idea is more trouble than it's worth, so I'm
retiring it completely.

[originally from svn r10264]
2014-09-24 10:33:22 +00:00
2ebbdbf2a5 Remove dependencies on Subversion.
I'm going through all my projects and reworking them to avoid
depending on the monotonic integer-valued source control revision
identifier provided by Subversion, so I can migrate everything to git
without my builds and versioning breaking.

Puzzles's version number is now of the form YYYYMMDD.vvvvvv, where
vvvvvv is some string of source control information (currently still
the SVN-style "rNNNNN", but free to change in future). The date
provides monotonicity between my official automated builds, and the
second component is the one I'll be most interested in when people
send bug reports.

[originally from svn r10263]
2014-09-24 10:33:21 +00:00
bc930a1214 Improve connectedness-error highlighting in Singles.
Using exactly the same policy as I did for Range the other day: if
multiple regions exist, then one is taken to be canonical and all the
others are marked as errors.

[originally from svn r10233]
2014-09-21 15:33:01 +00:00
ac6fd11dda Improve connectedness-error highlighting in Range.
The previous approach of scanning the grid by depth-first search was
fine for deciding whether it was connected, but not so good for
pointing out where the mistake was in the grid. Replaced that code
with a dsf-based version, which identifies all connected components so
that an easy followup pass can highlight all but the largest as
erroneous.

[originally from svn r10223]
2014-09-09 14:20:10 +00:00
ff8a9fbc54 Fix vertically misaligned text in Javascript puzzles.
When I constructed my test canvas to measure the vertical extent of a
text string for ALIGN_VCENTRE, I forgot to ensure that the 'width'
variable was an integer, as a result of which the loop over canvas
pixels kept trying to use fractional array indices and returning
undefined :-)

[originally from svn r10196]
2014-06-21 17:40:29 +00:00
a7ddd63375 Change our method of calling main() in emccpre.js.
I've just upgraded to emcc 1.16.0, in which something fiddly has
happened to the semantics of Module.run() vs noInitialRun - now
setting the latter seems to cause the former to do everything except
calling main(), and then refuse to ever do anything again. So now I
have to use Module.callMain() in place of Module.run() when I finally
do get round to wanting to call main().

[originally from svn r10180]
2014-04-20 08:47:27 +00:00
5e637af243 Add a missing #include.
[originally from svn r10179]
2014-04-20 08:47:25 +00:00
fd392c8e74 Reinstate the Mac OS build step.
Now I've got a working Mac, I can build it again.

[originally from svn r10167]
2014-03-30 15:19:30 +00:00
bcf1c96573 Fix the Automake makefile for automake 1.14.
This is a combination of PuTTY r10142 and the relevant pieces of
r10141: we now enable the 'subdir-objects' mode in Makefile.am, and
stop using $(subdir) in source file paths.

(As a consequence of the latter the automake machinery now cannot live
anywhere but at the top level of the source tree, but since that's
where it was already, this is less of an upheaval here than it was for
PuTTY!)

[originally from svn r10146]
[r10141 == a947c49bec36957cb5d38e1dc2e22dc0e3465849 in putty repository]
[r10142 == 0da225829234744b1141aea3a7c54ad7d74679a7 in putty repository]
2014-02-22 18:19:05 +00:00
580f9059e3 Continue the tradition of only remembering to update the copyright year
every other year.

[originally from svn r10116]
2014-01-16 01:03:58 +00:00
f41f4c0cc8 Position the monster counts more sensibly.
Now they're centred within the spare grid cell at the top of the
playing area, rather than being too far down so that the bottoms of
the monster drawings collide with the background of the path clues at
large magnification. Also, while I'm here, I've simplified the code
that draws the monster counts, by moving duplicated parts out of the
branches of the 'if'.

(In fact, almost all of this patch is cleanup; the only substantive
change is the one that changes dy from TILESIZE/2 to TILESIZE/4.)

[originally from svn r10108]
2014-01-07 18:21:24 +00:00