let debug_opt s =
let (f'', foundf) =
(match s.path_opt_alg with
| 0 -> ((fun _ (x,_,_,_) _ -> (x,[],[],[])),
fun _ _ _ _ _ -> ([],[],[],[]))
| 1 -> (PathFinding.path_opt'', PathFinding.path_opt_good_foundf)
| _ -> (PathFinding.path_opt'', PathFinding.path_opt_fast_foundf)) in
let rec loop (seen, notseen, tocheck, havechecked) = match notseen with
| [] -> ()
| _ ->
let drawline window src dst =
List.iter (fun (x,y) -> waddstr window x y "+")
(Geometry.line src dst);
ignore (PathFinding.lineofsight src dst
(fun (x,y) ->
if Cave.get s.cave x y != Cave.WALL
then (waddstr window x y "+"; true)
else (waddstr window x y "|"; false))); () in
s.path <- seen @ (List.rev notseen);
my_draw s;
debug_opt_legend s;
(try
drawline s.window_cave (List.hd notseen) (List.hd tocheck);
(match (List.hd tocheck) with
| (x,y) -> waddstr s.window_cave x y "O");
(match (List.hd notseen) with
| (x,y) -> waddstr s.window_cave x y "O")
with _ -> ());
refresh s;
match getch () with
| "q" -> ()
| _ -> loop (f'' s.cave (seen, notseen, tocheck, havechecked)
foundf)
in
let old_path_opt_alg = s.path_opt_alg in
s.path_opt_alg <- 0;
set_path s;
loop (PathFinding.path_opt' s.cave s.path);
s.path_opt_alg <- old_path_opt_alg;
set_path s