let boundeddfsearch ~start ~childgen ~goaltest ~combinator ~depth =
let rec search start depth akku =
(*check if we already have reached a goal*)
if goaltest start then
combinator start true akku
else
(* maybe we have reached the maximun depth*)
if depth = 0 then
None
else
(
(* generate all the childs and loop over them*)
let childs = childgen start in
let path = combinator start false akku in
let rec loop childs =
match childs with
child :: childs ->
(* recursive call until we find a goal, or exceed the depth *)
let res = search child (depth-1) path in
if res = None then
loop childs
else
res
| [] -> None
in
loop childs
)
in
search start depth None