Use a better heuristic
parent
0e35c883ae
commit
adcf50514c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue