chiark / gitweb /
sgt-puzzles.git
8 years agoFactored out some of the color logic for the clues
Kevin Lyles [Mon, 8 Jun 2015 21:20:58 +0000 (16:20 -0500)]
Factored out some of the color logic for the clues

8 years agoRemoved DS_FULL (it wasn't used)
Kevin Lyles [Mon, 8 Jun 2015 20:48:03 +0000 (15:48 -0500)]
Removed DS_FULL (it wasn't used)

8 years agoUpdated name/size of clues_done in Towers
Kevin Lyles [Tue, 26 May 2015 00:46:24 +0000 (19:46 -0500)]
Updated name/size of clues_done in Towers

8 years agoUndead: you can now mark clues as done
Kevin Lyles [Tue, 26 May 2015 00:46:24 +0000 (19:46 -0500)]
Undead: you can now mark clues as done

8 years agoReworked draw_path_hint
Kevin Lyles [Tue, 26 May 2015 00:46:24 +0000 (19:46 -0500)]
Reworked draw_path_hint

8 years agoFactored out a portion of game_redraw
Kevin Lyles [Tue, 26 May 2015 00:46:24 +0000 (19:46 -0500)]
Factored out a portion of game_redraw

8 years agoTowers: you can now mark clues done
Kevin Lyles [Wed, 13 May 2015 04:23:52 +0000 (23:23 -0500)]
Towers: you can now mark clues done

8 years agoSplit out the text color portion of draw_tile
Kevin Lyles [Sat, 16 May 2015 18:51:34 +0000 (13:51 -0500)]
Split out the text color portion of draw_tile

8 years agoCleaned up execute_move a little
Kevin Lyles [Sat, 16 May 2015 18:51:34 +0000 (13:51 -0500)]
Cleaned up execute_move a little

8 years agoAdd the 'make test' target to Makefile.am too.
Simon Tatham [Mon, 18 May 2015 15:41:06 +0000 (16:41 +0100)]
Add the 'make test' target to Makefile.am too.

Now I don't have to annoyingly switch over to the GTK makefile.

8 years agoAdd sorting-order buttons to the benchmark output.
Simon Tatham [Mon, 18 May 2015 15:39:12 +0000 (16:39 +0100)]
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.

8 years agoMove the benchmarking logic out into a script.
Simon Tatham [Mon, 18 May 2015 15:17:49 +0000 (16:17 +0100)]
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.

8 years agoHandle replacing an existing arrow
Kevin Lyles [Sun, 10 May 2015 00:16:24 +0000 (19:16 -0500)]
Handle replacing an existing arrow

8 years agoFix the extra arrow hanging around while moving the opposite existing arrow
Kevin Lyles [Sun, 10 May 2015 00:11:02 +0000 (19:11 -0500)]
Fix the extra arrow hanging around while moving the opposite existing arrow

8 years agoMark some arguments constant
Kevin Lyles [Sun, 10 May 2015 02:05:18 +0000 (21:05 -0500)]
Mark some arguments constant

8 years agoFix the issue with adding only one arrow when the other end was already white
Kevin Lyles [Sat, 9 May 2015 23:51:00 +0000 (18:51 -0500)]
Fix the issue with adding only one arrow when the other end was already white

8 years agoAdd/remove the opposite arrow when you let go
Kevin Lyles [Sun, 3 May 2015 15:46:07 +0000 (10:46 -0500)]
Add/remove the opposite arrow when you let go

8 years agoDraw the opposite arrow only while dragging
Kevin Lyles [Sun, 3 May 2015 15:46:07 +0000 (10:46 -0500)]
Draw the opposite arrow only while dragging

8 years agoMoved all function declarations to the top of the file
Kevin Lyles [Sat, 9 May 2015 23:51:00 +0000 (18:51 -0500)]
Moved all function declarations to the top of the file

8 years agoUse the game_state and space typedefs
Kevin Lyles [Sun, 10 May 2015 02:36:44 +0000 (21:36 -0500)]
Use the game_state and space typedefs

8 years agoAlways use ret instead of state in execute_move
Kevin Lyles [Sun, 3 May 2015 17:40:14 +0000 (12:40 -0500)]
Always use ret instead of state in execute_move

8 years agoFixed a typo in a comment
Kevin Lyles [Sun, 3 May 2015 17:40:14 +0000 (12:40 -0500)]
Fixed a typo in a comment

8 years agoSpecial-case right-dragging of a numbered cell off the grid.
Simon Tatham [Sat, 9 May 2015 14:35:10 +0000 (15:35 +0100)]
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.)

9 years agoSort out abs/fabs confusion.
Simon Tatham [Fri, 10 Apr 2015 06:55:16 +0000 (07:55 +0100)]
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.

9 years agoAdd Tracks to the automake makefile's "install" target.
Simon Tatham [Wed, 25 Mar 2015 18:23:39 +0000 (18:23 +0000)]
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.

9 years agoFix a compile warning on ARM.
Simon Tatham [Tue, 24 Mar 2015 19:20:03 +0000 (19:20 +0000)]
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.

9 years agoUpdate README after the switch to autoconf.
Simon Tatham [Sun, 15 Mar 2015 08:50:53 +0000 (08:50 +0000)]
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.

9 years agoFix a build failure on x32 (time_t printfs).
Adam Borowski [Mon, 9 Mar 2015 06:58:10 +0000 (07:58 +0100)]
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...

9 years agoTurn <image> tag into <img>.
Simon Tatham [Sun, 8 Feb 2015 22:52:20 +0000 (22:52 +0000)]
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.

9 years agoNew puzzle from James Harvey: 'Tracks'.
Simon Tatham [Sun, 8 Feb 2015 16:23:32 +0000 (16:23 +0000)]
New puzzle from James Harvey: 'Tracks'.

9 years agoRemove a lingering bashism in makedist.sh.
Simon Tatham [Sat, 17 Jan 2015 08:49:28 +0000 (08:49 +0000)]
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.

9 years agoImprove the Flood solver.
Simon Tatham [Thu, 15 Jan 2015 20:21:05 +0000 (20:21 +0000)]
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.

9 years agoRemove some lingering HTML markup.
Simon Tatham [Tue, 13 Jan 2015 20:59:54 +0000 (20:59 +0000)]
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.

9 years agoAnd one more whitespace fix.
Simon Tatham [Tue, 13 Jan 2015 20:46:00 +0000 (20:46 +0000)]
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.

9 years agoCouple of fixes to the new web-page mechanism.
Simon Tatham [Tue, 13 Jan 2015 20:30:40 +0000 (20:30 +0000)]
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.

9 years agoScript to autogenerate pieces of the web page.
Simon Tatham [Tue, 13 Jan 2015 20:04:18 +0000 (20:04 +0000)]
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.

9 years agoPut the game summaries from the website into gamedesc.txt.
Simon Tatham [Tue, 13 Jan 2015 19:54:46 +0000 (19:54 +0000)]
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.

9 years agoRevise the Flood preset list.
Simon Tatham [Tue, 13 Jan 2015 19:31:29 +0000 (19:31 +0000)]
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.

9 years agoHandle the space bar in the Javascript front end.
Simon Tatham [Tue, 13 Jan 2015 19:19:05 +0000 (19:19 +0000)]
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.

9 years agoNew puzzle: 'Flood'.
Simon Tatham [Mon, 12 Jan 2015 19:51:19 +0000 (19:51 +0000)]
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.

9 years agoUpdate the new-puzzle checklist for git.
Simon Tatham [Mon, 12 Jan 2015 19:44:31 +0000 (19:44 +0000)]
Update the new-puzzle checklist for git.

Replace references to svn:ignore and 'svn add' with the git
equivalents.

9 years agoAdd OS X metadata to make Puzzles.app searchable in Spotlight.
Simon Tatham [Thu, 8 Jan 2015 14:10:15 +0000 (14:10 +0000)]
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.

9 years agoFix puzzle window resize behaviour on Unity.
Simon Tatham [Sun, 4 Jan 2015 18:03:36 +0000 (18:03 +0000)]
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.

9 years agoFix homology bug (!) in Net's loop highlighter.
Simon Tatham [Mon, 29 Dec 2014 10:11:47 +0000 (10:11 +0000)]
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 .

9 years agoError-highlight loops in Net.
Simon Tatham [Sun, 28 Dec 2014 12:19:50 +0000 (12:19 +0000)]
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.

9 years agoPermit selecting a diagonal of squares at once in Group.
Simon Tatham [Thu, 18 Dec 2014 09:48:02 +0000 (09:48 +0000)]
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.

9 years agoFix two compile warnings in emcc.c.
Simon Tatham [Sun, 30 Nov 2014 17:00:45 +0000 (17:00 +0000)]
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.

9 years agoRemove another erroneous GINT_TO_POINTER.
Simon Tatham [Sat, 29 Nov 2014 10:39:00 +0000 (10:39 +0000)]
Remove another erroneous GINT_TO_POINTER.

This one shouldn't have been there at all - it had a pointer argument
already, not an int.

9 years agoUse the compile flag -std=c89 in place of -ansi.
Simon Tatham [Sat, 29 Nov 2014 10:29:29 +0000 (10:29 +0000)]
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.

9 years agoFix a GINT_TO_POINTER that was back to front.
Simon Tatham [Sat, 29 Nov 2014 10:24:05 +0000 (10:24 +0000)]
Fix a GINT_TO_POINTER that was back to front.

Spotted by clang, which I just tried building this codebase with out
of curiosity.

9 years agoChange the policy for parsing underspecified params strings.
Simon Tatham [Sat, 29 Nov 2014 10:23:12 +0000 (10:23 +0000)]
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.

9 years agoRemove an inappropriate assertion in validation context.
Simon Tatham [Wed, 26 Nov 2014 21:25:02 +0000 (21:25 +0000)]
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.

9 years agoFix a decoding bug in Solo block-structure descriptions.
Simon Tatham [Wed, 26 Nov 2014 19:27:35 +0000 (19:27 +0000)]
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).

9 years agoFix error highlighting of closed subgraphs in Bridges.
Simon Tatham [Wed, 29 Oct 2014 21:41:38 +0000 (21:41 +0000)]
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.

9 years agoSome more .gitignore updates.
Simon Tatham [Mon, 27 Oct 2014 21:58:10 +0000 (21:58 +0000)]
Some more .gitignore updates.

Ignore a few things that turn up in the icons subdirectory.

9 years agoAdd a .gitignore, now this project is in git.
Simon Tatham [Sat, 25 Oct 2014 14:27:27 +0000 (15:27 +0100)]
Add a .gitignore, now this project is in git.

9 years agoStop using NSApp in the OS X front end.
Simon Tatham [Mon, 20 Oct 2014 17:43:38 +0000 (17:43 +0000)]
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]

9 years agoFix antialiasing artifacts around edges of Bridges islands.
Simon Tatham [Tue, 7 Oct 2014 21:22:53 +0000 (21:22 +0000)]
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]

9 years agoProvide a static version.h for development builds.
Simon Tatham [Sat, 27 Sep 2014 14:51:02 +0000 (14:51 +0000)]
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]

9 years agoRemove the MD5-based manifest file system.
Simon Tatham [Wed, 24 Sep 2014 10:33:22 +0000 (10:33 +0000)]
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]

9 years agoRemove dependencies on Subversion.
Simon Tatham [Wed, 24 Sep 2014 10:33:21 +0000 (10:33 +0000)]
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]

9 years agoImprove connectedness-error highlighting in Singles.
Simon Tatham [Sun, 21 Sep 2014 15:33:01 +0000 (15:33 +0000)]
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]

9 years agoImprove connectedness-error highlighting in Range.
Simon Tatham [Tue, 9 Sep 2014 14:20:10 +0000 (14:20 +0000)]
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]

9 years agoFix vertically misaligned text in Javascript puzzles.
Simon Tatham [Sat, 21 Jun 2014 17:40:29 +0000 (17:40 +0000)]
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]

10 years agoChange our method of calling main() in emccpre.js.
Simon Tatham [Sun, 20 Apr 2014 08:47:27 +0000 (08:47 +0000)]
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]

10 years agoAdd a missing #include.
Simon Tatham [Sun, 20 Apr 2014 08:47:25 +0000 (08:47 +0000)]
Add a missing #include.

[originally from svn r10179]

10 years agoReinstate the Mac OS build step.
Simon Tatham [Sun, 30 Mar 2014 15:19:30 +0000 (15:19 +0000)]
Reinstate the Mac OS build step.

Now I've got a working Mac, I can build it again.

[originally from svn r10167]

10 years agoFix the Automake makefile for automake 1.14.
Simon Tatham [Sat, 22 Feb 2014 18:19:05 +0000 (18:19 +0000)]
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]

10 years agoContinue the tradition of only remembering to update the copyright year
Jacob Nevins [Thu, 16 Jan 2014 01:03:58 +0000 (01:03 +0000)]
Continue the tradition of only remembering to update the copyright year
every other year.

[originally from svn r10116]

10 years agoPosition the monster counts more sensibly.
Simon Tatham [Tue, 7 Jan 2014 18:21:24 +0000 (18:21 +0000)]
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]

10 years agoFix a printf 64-bit-cleanness error.
Simon Tatham [Thu, 28 Nov 2013 18:32:29 +0000 (18:32 +0000)]
Fix a printf 64-bit-cleanness error.

[originally from svn r10098]

10 years agoFix an edge case of divider-obsoletion in Group.
Simon Tatham [Wed, 9 Oct 2013 20:44:51 +0000 (20:44 +0000)]
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]

10 years agoFaintly highlight the leading diagonal of Group's grid.
Simon Tatham [Wed, 9 Oct 2013 20:44:50 +0000 (20:44 +0000)]
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]

10 years agoDocument 'Unique rows and columns' option in Unruly, plus formatting tweaks
Jacob Nevins [Thu, 29 Aug 2013 09:27:34 +0000 (09:27 +0000)]
Document 'Unique rows and columns' option in Unruly, plus formatting tweaks
elsewhere.

[originally from svn r10035]

10 years agoFix a failure to warn about non-unique rows/columns in non-square Unruly grids, repor...
Jacob Nevins [Tue, 30 Jul 2013 20:18:14 +0000 (20:18 +0000)]
Fix a failure to warn about non-unique rows/columns in non-square Unruly grids, reported in Debian bug #718354.

[originally from svn r9976]

10 years agoStop using a zero precision specifier with sprintf ("%.0d") to cause
Simon Tatham [Fri, 5 Jul 2013 21:54:45 +0000 (21:54 +0000)]
Stop using a zero precision specifier with sprintf ("%.0d") to cause
zero to be generated as the empty string rather than "0". Instead, do
the job by the obvious approach of not calling sprintf at all if the
number is zero. Works around a bug in Emscripten's C library, whose
sprintf doesn't correctly handle that corner case.

[originally from svn r9893]

10 years agoMake svn-based version identification still work in VPATH builds.
Simon Tatham [Tue, 2 Jul 2013 07:04:04 +0000 (07:04 +0000)]
Make svn-based version identification still work in VPATH builds.

[originally from svn r9891]

10 years agoFix small bugs in the automake construction which were preventing the
Simon Tatham [Tue, 2 Jul 2013 06:48:26 +0000 (06:48 +0000)]
Fix small bugs in the automake construction which were preventing the
revision number from being automatically baked into the automake-built
binaries.

[originally from svn r9890]

10 years agoAdd a check in the new configure script to enable lots of gcc warning
Simon Tatham [Sun, 30 Jun 2013 10:51:31 +0000 (10:51 +0000)]
Add a check in the new configure script to enable lots of gcc warning
flags if gcc is in use - but _only_ if they don't lead to problems in
a test compile which includes all the system and GTK headers I'm going
to want. Ubuntu 13.04 includes a version of Pango which breaks at
-Werror -pedantic, so I can't unconditionally enable all the warning
flags I might want without breaking the build in ways beyond my
control.

[originally from svn r9888]

10 years agoAdd a mechanism to the automake system to allow 'make install' to only
Simon Tatham [Sun, 30 Jun 2013 10:16:57 +0000 (10:16 +0000)]
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]

10 years agoSupport building via autoconf and automake. mkfiles.pl now outputs a
Simon Tatham [Sun, 30 Jun 2013 08:58:45 +0000 (08:58 +0000)]
Support building via autoconf and automake. mkfiles.pl now outputs a
Makefile.am, and there's a new mkauto.sh which builds a corresponding
configure script.

The old makefile has been renamed from 'Makefile' to 'Makefile.gtk',
indicating that the intended new _default_ approach is to use the
autoconf world. Makefile.gtk is provided as an emergency fallback in
case anything fails with the new stuff that used to work with it.

The new configure script does not support the same $(BINPREFIX) system
as the old Makefile did. However, as I understand it, it should be
possible to configure using --program-prefix="sgt-" (for example) and
then the binaries should all be renamed appropriately at install time.

The Makefile.am is quite painful. The Puzzles codebase relies heavily
on compiling individual object files multiple times with different the
cpp flags per build deliverable (program or library) and not per
source file. Solution: anything built with non-default compile options
has to go in its own little library. But that doesn't work either in
the general case, because as soon as you have more than one such
library linked into an application, Unix ld semantics bite you if the
objects in the libraries both refer to each other. So I ended up
building all those little libraries but not _using_ them - instead the
link commands for the programs needing those objects refer to the
objects directly, under the silly names that automake gives them.
(That's less fragile than it sounds, because it does _document_ the
names of the intermediate object files. But still, yuck.)

[originally from svn r9886]

10 years agoAdjust the build script to turn the NestedVM build into a delegation,
Simon Tatham [Thu, 27 Jun 2013 21:17:04 +0000 (21:17 +0000)]
Adjust the build script to turn the NestedVM build into a delegation,
so that not every machine on which I want to run the full Puzzles
build will have to have a local NestedVM installation.

[originally from svn r9882]

10 years agoRemove stray bashisms from the NestedVM makefile.
Simon Tatham [Wed, 19 Jun 2013 19:21:36 +0000 (19:21 +0000)]
Remove stray bashisms from the NestedVM makefile.

[originally from svn r9872]

10 years agoRemove spurious "unfinished/" that appeared at the start of the
Simon Tatham [Sat, 8 Jun 2013 16:55:33 +0000 (16:55 +0000)]
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]

10 years agoAdd comment to remind myself (and anyone else) how to refresh the XFCE
Simon Tatham [Sat, 8 Jun 2013 16:53:57 +0000 (16:53 +0000)]
Add comment to remind myself (and anyone else) how to refresh the XFCE
menu.

[originally from svn r9860]

10 years agoScript to read the new gamedesc.txt and create .desktop files. My
Simon Tatham [Sat, 8 Jun 2013 16:50:28 +0000 (16:50 +0000)]
Script to read the new gamedesc.txt and create .desktop files. My
immediate intention is to run this locally so that my XFCE main menu
acquires shortcuts for my locally compiled puzzle binaries, but I
expect the script could probably be adapted for systemwide
distribution use if any distribution hasn't already done this job in
their own way by now.

[originally from svn r9859]

10 years agoRename wingames.lst to gamedesc.txt, and add a couple of extra fields
Simon Tatham [Sat, 8 Jun 2013 16:29:15 +0000 (16:29 +0000)]
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]

10 years agoFix grid generation crashes at Penrose 3x3 sizes. What seemed to be
Simon Tatham [Fri, 10 May 2013 17:56:00 +0000 (17:56 +0000)]
Fix grid generation crashes at Penrose 3x3 sizes. What seemed to be
happening was that at the point of calling grid_make_consistent, the
grid had no faces or vertices, probably because grid_trim_vigorously
had removed them all, causing grid_make_consistent to try to allocate
a negative amount of memory and die in snewn.

Fixed by detecting this case in new_desc_penrose and retrying until
generation is successful. (It wasn't happening 100% of the time, just
_most_ of the time.) The same verification step is also used in
validate_desc_penrose in case a user manages to manually construct a
set of parameters leading to this failure mode.

[originally from svn r9840]

10 years agoCorrect the comment at the top of unruly.c, which is out of date as of
Simon Tatham [Sun, 5 May 2013 22:27:20 +0000 (22:27 +0000)]
Correct the comment at the top of unruly.c, which is out of date as of
r9837.

[originally from svn r9838]
[r9837 == 2f7831bb1626d82baff706e507d61a820ad84df1]

10 years agoNew configuration option in Unruly, to enable a mode in which no two
Simon Tatham [Sun, 5 May 2013 20:21:50 +0000 (20:21 +0000)]
New configuration option in Unruly, to enable a mode in which no two
rows are permitted to have exactly the same pattern, and likewise
columns. (A row and a column can match, though.) This rule is
sometimes used, but not always; http://www.binarypuzzle.com/ in
particular has it (as a user just pointed out).

Since the filled-grid-generation stage of Unruly is implemented by
repeatedly choosing a square and then calling the solver to fill in
all its consequences, simply adding a solver mode conditional on this
flag is sufficient to do the whole of the interesting part of the job.

[originally from svn r9837]

11 years agoD'oh, forgot to adjust devel.but for the const changes.
Simon Tatham [Sat, 13 Apr 2013 10:51:53 +0000 (10:51 +0000)]
D'oh, forgot to adjust devel.but for the const changes.

[originally from svn r9835]

11 years agoGiant const patch of doom: add a 'const' to every parameter in every
Simon Tatham [Sat, 13 Apr 2013 10:37:32 +0000 (10:37 +0000)]
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]

11 years agoFix a memory management bug in Filling: in some situations its
Simon Tatham [Sat, 13 Apr 2013 10:37:27 +0000 (10:37 +0000)]
Fix a memory management bug in Filling: in some situations its
solve_game() was returning its aux parameter un-dupstr()ed, which is
wrong. Also clarified the developer docs on that function to make it
clearer that the returned string should be dynamic.

[originally from svn r9831]

11 years agoAdd 'const' to the game_params arguments in validate_desc and
Simon Tatham [Fri, 12 Apr 2013 17:11:49 +0000 (17:11 +0000)]
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]

11 years agoPatch from Rogier Goossens to speed up the Pattern solver.
Simon Tatham [Fri, 12 Apr 2013 16:28:55 +0000 (16:28 +0000)]
Patch from Rogier Goossens to speed up the Pattern solver.

do_recurse() now prunes early whenever it encounters a branch of the
search tree inconsistent with existing grid data (rather than the
previous naive approach of proceeding to enumerate all possibilities
anyway and then ruling them out one by one); do_recurse also tries to
split the row up into independent sections where possible; finally the
main solver loop (all three copies of which have now been factored out
into a new solve_puzzle function), instead of simply looping round and
round over all the rows and columns, heuristically looks at the ones
most changed since the last time deduction was attempted on them, on
the basis that that will probably yield the most information the
fastest.

[originally from svn r9828]

11 years agoAdjust Keen's grid generation to constrain the maximum size of clue
Simon Tatham [Fri, 12 Apr 2013 16:28:53 +0000 (16:28 +0000)]
Adjust Keen's grid generation to constrain the maximum size of clue
blocks, because 'make test' showed up very large blocks as an
occasional slowdown factor in game generation (takes too long to
iterate over all possibilities). This is a good idea in any case,
because really big multiplicative clue numbers have trouble fitting in
the square.

[originally from svn r9827]

11 years agoApply some optimisation to Undead's get_unique() function, which was
Simon Tatham [Fri, 12 Apr 2013 16:28:52 +0000 (16:28 +0000)]
Apply some optimisation to Undead's get_unique() function, which was
not only enumerating all possible arrangements of monsters along a
sight-line in O(3^n) time, but also allocated memory for them all and
then does a quadratic-time loop over that list to find arrangements
with a unique visibility count from both ends. Spotted by the new
'make test', which observed that 7x7dn#517035041807425 took 45 seconds
to generate.

This revised version still does the initial O(3^n) enumeration, which
can probably be got rid of as well with a bit more thought, but it now
doesn't allocate nearly so much memory and it spots uniques
efficiently. The above random seed now generates the same game ID in
less than a second, which drops this puzzle off the 'make test' hit
list of things most obviously needing speedup.

[originally from svn r9826]

11 years agoIntroduce some extra testing and benchmarking command-line options to
Simon Tatham [Thu, 11 Apr 2013 12:51:06 +0000 (12:51 +0000)]
Introduce some extra testing and benchmarking command-line options to
the GTK front end, plus a 'make test' target in the GTK makefile which
uses them to automatically generate 100 puzzles for each game at each
preset configuration, test-run them back through the solver without
their aux_info to ensure that can cope, and produce an HTML box plot
of game generation times for each preset.

As part of this work I've removed the TESTSOLVE mechanism from r9549,
since the new --test-solve option does the same thing better (in that
when something goes wrong it prints the random seed that caused the
problem).

[originally from svn r9825]
[r9549 == 5a095b8a08fa9f087b93c86aea0fa027138b028d]

11 years agoRevamp the triangular grid generation in Loopy, which I've been
Simon Tatham [Thu, 11 Apr 2013 12:51:05 +0000 (12:51 +0000)]
Revamp the triangular grid generation in Loopy, which I've been
meaning to revisit for a while. The new version generates more nicely
symmetric grids (best at even heights, but still improved even at odd
heights), and avoids any 'ears' on the grid (triangles at the corners
connected to only one other triangle, which tend to be boringly easy
places to start solving).

I've reused the grid-description-string mechanism invented for the
Penrose tilings as a versioning mechanism for the triangular grids, so
that old game descriptions should still be valid, and new triangular-
grid game descriptions begin with an "0_" prefix to indicate that they
are based on the new-style construction.

[originally from svn r9824]

11 years agoSplit Untangle's background colour into two. COL_BACKGROUND is still
Simon Tatham [Sun, 7 Apr 2013 10:44:56 +0000 (10:44 +0000)]
Split Untangle's background colour into two. COL_BACKGROUND is still
defined the same way and used to draw the normal background of the
puzzle, but there's a new slightly darker COL_SYSBACKGROUND which is
not used for anything at all in the puzzle backend but which occupies
colour slot #0 so that the system will use it to fill around the
playable area if the puzzle is imprecisely resized.

This doesn't _sensibly fix_ the annoyance in Untangle where a non-
square window gives rise to unusable dead space, but it at least works
around it by making the dead space obviously something to stay away
from.

[originally from svn r9823]