Use a better heuristic

db4
Samuel Tardieu 2010-03-06 14:37:35 +01:00
parent 0e35c883ae
commit adcf50514c
1 changed files with 4 additions and 1 deletions

View File

@ -34,11 +34,14 @@ IN: astar.tests
4array
[ reachable? ] filter ;
: heuristic ( from to -- cost )
v- [ abs ] [ + ] map-reduce ;
: cost ( from to -- cost )
2dup [ first ] bi@ = [ [ second ] bi@ > 1 5 ? ] [ 2drop 2 ] if ;
: test1 ( to -- path considered )
{ 1 1 } swap [ neighbours ] [ cost ] [ distance ] <astar> [ find-path ] [ considered ] bi ;
{ 1 1 } swap [ neighbours ] [ cost ] [ heuristic ] <astar> [ find-path ] [ considered ] bi ;
>>
! Existing path from s to f