let astar'' cave dst (visited : hash_from_pos_to_int)
(waiting : heap_of_pos_cost_dist) (dist : distance_function) =
let (src,cost,_) = MutBinHeap.pop waiting in
IntPairHash.replace visited src cost;
if src = dst
then raise (Exception_intpairhash visited)
else
((List.iter
(fun (x,y) ->
if Cave.get cave x y != Cave.WALL
&& not (IntPairHash.exists visited (x,y))
&& (try
let (_,cost',_) = MutBinHeap.getpos waiting (x,y) in
cost < cost'
with _ -> true)
then (MutBinHeap.replace waiting
((x,y), cost+1, dist (x,y) dst)))
(Cave.neighbour_coords src));
(visited, waiting))