let dfsearch ~start ~childgen ~goaltest ~combinator =
let rec search start akku =
(* see if we have reached a goal*)
if goaltest start then
combinator start true akku
else
(
(* produce all children and descend their paths *)
let childs = childgen start in
let path = combinator start false akku in
let rec loop childs =
match childs with
child :: childs ->
let res = search child path in
(* Was this path successfull?*)
if res = None then
loop childs
else
res
| [] -> None
in
loop childs
)
in
search start None