]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix comparison to avoid infinite loop with zero cost paths
authorAlfredo Beaumont <alfredo.beaumont@gmail.com>
Sun, 30 Jan 2011 19:50:55 +0000 (20:50 +0100)
committerAlfredo Beaumont <alfredo.beaumont@gmail.com>
Sun, 30 Jan 2011 19:51:07 +0000 (20:51 +0100)
extra/path-finding/path-finding.factor

index 4b11616c201c91633e48f66bf0b63e9feb9b17f0..1f6b4f5cc6424ba5112280a5a20c886e97fe2a45 100644 (file)
@@ -40,7 +40,7 @@ TUPLE: (astar) astar goal origin in-open-set open-set ;
 
 : ?set-g ( origin node astar -- )
     [ cost-through ] 3keep [ swap ] 2dip
-    3dup astar>> g>> at [ 1/0. ] unless* > [ 4drop ] [ set-g ] if ;
+    3dup astar>> g>> at [ 1/0. ] unless* >= [ 4drop ] [ set-g ] if ;
 
 : build-path ( target astar -- path )
     [ over ] [ over [ [ origin>> at ] keep ] dip ] produce 2nip reverse ;