Yet another complete rewrite of Slant's loop detection during
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 17 Sep 2008 16:43:36 +0000 (16:43 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 17 Sep 2008 16:43:36 +0000 (16:43 +0000)
commitf5512c77d88ccc7a7e1f7bd3a6ae0e5d3765ea05
treebc00e110de2db6450e076075292d7ab05ef0cf87
parent6bb2af847d3bad4f2a544ad7a428f7063fd1991a
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.)

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@8187 cda61777-01e9-0310-a592-d414129be87e
slant.c