simon-svn: puzzles: simon

Commits to Tartarus CVS repository. tartarus-commits at lists.tartarus.org
Wed Sep 17 17:43:36 BST 2008


SVN root:       svn://svn.tartarus.org/sgt
Changes by:     simon
Revision:       8187
Date:           2008-09-17 17:43:36 +0100 (Wed, 17 Sep 2008)

Log message (16 lines):
Yet another complete rewrite of Slant's loop detection during
gameplay. Having tried methods based on using the slashes to define
a dsf on grid vertices, and also methods based on tracing round the
loops using conventional (non-dsf-based) graph theory, it occurred
to me the other day that there's a far simpler technique involving
connectivity. A loop is precisely that which causes the playing area
to become disconnected; so what we do now is to go through and build
a dsf describing connectedness of the _area_ of the grid rather than
the vertices. That divides the area into its maximal connected
components, and then we can trivially identify every edge that's
part of a loop by noticing that it separates two nonequivalent
pieces of space. The resulting algorithm is half the size of the old
one, and it's much easier to be confident of its correctness.

(Having said which, there will doubtless turn out to be an
embarrassing bug in it, but I haven't found it yet.)

Modified files:
U   puzzles/slant.c

Links:
http://svn.tartarus.org/sgt/?rev=8187&view=rev
http://svn.tartarus.org/sgt/puzzles/slant.c?rev=8187&r1=8186&r2=8187



More information about the tartarus-commits mailing list