simon-git: puzzles (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Fri May 5 07:28:30 BST 2017


TL;DR:
  23a5372 Fix infinite-loop bug in Loopy's autofollow feature.

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2017-05-05 07:28:30

commit 23a537243b935207ac8a418b9980bacb4e8e6d59
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=23a537243b935207ac8a418b9980bacb4e8e6d59;hp=9972f35b27cadd6a49f2ec57f2ec07e4fa373341
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 5 07:09:22 2017 +0100

    Fix infinite-loop bug in Loopy's autofollow feature.
    
    Thanks to Glen Sawyer for reporting it. This is surely a consequence
    of separating interpret_move from execute_move - if I'd done things in
    the more obvious way, then this bug would never have happened, because
    once the autofollow code had gone once round the loop it would find
    that the starting edge was no longer in the same state it was looking
    for. But since we don't start changing the states of edges until
    execute_move(), it's possible for interpret_move() to go round and
    round a cycle for ever.
    
    Fortunately, it can _only_ happen if the edge you clicked on was part
    of a loop which is the whole of its connected component - i.e. every
    vertex in the cycle has degree 2 - and therefore we don't need O(N)
    space to detect it (e.g. by recording whether each edge has been
    visited already), but instead we can simply check if we've come back
    to the starting edge.

 loopy.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)



More information about the tartarus-commits mailing list