1705 Commits

Author SHA1 Message Date
c3285318e6 Reworked draw_path_hint 2015-05-26 22:04:25 +01:00
9def49ae9a Factored out a portion of game_redraw 2015-05-26 22:04:16 +01:00
486d2c8a76 Towers: you can now mark clues done 2015-05-22 08:18:53 +01:00
7c52202bc4 Split out the text color portion of draw_tile 2015-05-22 08:18:45 +01:00
a614347a3e Cleaned up execute_move a little 2015-05-22 08:18:33 +01:00
80c1a69329 Add the 'make test' target to Makefile.am too.
Now I don't have to annoyingly switch over to the GTK makefile.
2015-05-18 16:41:06 +01:00
fb0ff8c338 Add sorting-order buttons to the benchmark output.
Since I'm committed to HTML5ish Javascript already, that shouldn't be
too much of an inconvenience.
2015-05-18 16:39:12 +01:00
894921015d Move the benchmarking logic out into a script.
It's a pain having it in a rule in Makefile.gtk, which isn't even the
recommended makefile these days - it can't be re-run conveniently, and
there's no way to parametrise it. Now it can be run no matter which
makefile you're using, and it lets you narrow down to a subset of
games (though not presets). Other options could easily be added.
2015-05-18 16:17:49 +01:00
f49c7f530c Handle replacing an existing arrow 2015-05-11 11:05:36 +01:00
3627111c52 Fix the extra arrow hanging around while moving the opposite existing arrow 2015-05-11 11:05:36 +01:00
bef1b2c59b Mark some arguments constant 2015-05-11 10:46:12 +01:00
3768ed65f2 Fix the issue with adding only one arrow when the other end was already white 2015-05-11 10:46:12 +01:00
83318d4218 Add/remove the opposite arrow when you let go 2015-05-11 10:46:12 +01:00
4fa5df1cba Draw the opposite arrow only while dragging 2015-05-11 10:15:02 +01:00
774395d373 Moved all function declarations to the top of the file 2015-05-11 10:14:57 +01:00
155607b768 Use the game_state and space typedefs 2015-05-11 10:14:53 +01:00
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