 !   - going up costs 5 points
 !   - going down costs 1 point
 !   - going left or right costs 2 points
+
+<<
+
+TUPLE: maze < astar ;
 
 : reachable? ( pos -- ? )
     first2 [ 2 * 5 + ] [ 2 + ] bi* $[

! Non-existing path from s to g -- all positions must have been considered
[ f 26 ] [ { 1 7 } test1 length ] unit-test

<<

! Look for a path between A and C. The best path is A --> D --> C. C will be placed
! in the open set early because B will be examined first. This checks that the evaluation
! of C is correctly replaced in the open set.

!     A ---> D ---------> E ---> F
!       (2)       (1)       (1)

<<

! In this version, we will use the quotations-aware version through <astar>.

: n ( pos -- neighbours )
    $[ { "ABD" "BC" "C" "DCE" "ECF" } [ unclip swap 2array ] map >hashtable ] at ;

