let debug_path s =
       let (f,f') = 
         (match s.alg with
            | 0 -> (PathFinding.dijkstra', PathFinding.dijkstra'')
            | 1 -> (PathFinding.astar', PathFinding.astar'')
            | _ -> (PathFinding.greedy_astar', PathFinding.greedy_astar'')) in
       let dist = get_dist_alg s.dist_alg in
       let rec loop (visited, waiting) =
         try
           let print_num waiting n =
             try
               (let ((x,y),_,_) = MutBinHeap.get waiting n in
                  waddstr s.window_cave x y (sprintf "%i" n))
             with | _ -> ()
           in
           let print_cloud waiting =
             let rec loop n = 
               if n >= waiting.MutBinHeap.last
               then ()
               else ((match MutBinHeap.get waiting n with 
                          ((x,y),_,_) -> waddstr s.window_cave x y "9");
                     loop (n+1))
                     in
                 loop 0
             in
               my_draw s;
               debug_path_legend s;
               print_cloud waiting;
               print_num waiting 8;
               print_num waiting 7;
               print_num waiting 6;
               print_num waiting 5;
               print_num waiting 4;
               print_num waiting 3;
               print_num waiting 2;
               print_num waiting 1;
               print_num waiting 0;
             IntPairHash.iter
               (fun (x,y) v -> waddstr s.window_cave x y "+") visited;
             refresh s;
             match getch () with 
               | "q" -> ()
               | _ -> loop (f' s.cave s.dst visited waiting dist)
         with
           | PathFinding.Exception_intpairhash visited ->
               s.path <-
                 (PathFinding.path s.src s.dst
                    visited)
       in
         loop (f s.cave s.src s.dst)