I searched for this a bit and could not find anything. I am "translating" an OCaml chess program to F#, both as a tool to understand how a Chess representation would work and to internalize, so to speak, F#'s way of doing things that is not OO.
These pieces of code are stumping me
set_signal sigint (Signal_handle (fun _ -> raise Interrupt));
and
set_signal sigint Signal_ignore;
Interrupt is an Exception defined earlier. Now I looked up what set_signal
does (here) but I cannot figure out exactly what is its purpose here, or how sigint
is defined at all. How can I replicate or imitate this behavior in F#.
If you want to see it in context, it is around line 532 in the OCaml source. This is the method in question:
let alpha_beta_deepening pos interval =
del_timer ();
let current_best = ref (alpha_beta_search pos 2) in (* alpha_beta_seach _ 2 can only return legal moves *)
((try
set_signal sigint (Signal_handle (fun _ -> raise Interrupt));
set_timer interval;
let rec loop i =
if i > max_depth then () else
let tmp = alpha_beta_search pos i in
current_best := tmp;
if (fst tmp) >= win (* we can checkmate *)
|| (fst tmp) <= -win (* we get checkmated anyway, deny the opponent extra time to think *)
then () else loop (i+1)
in loop 3;
set_signal sigint Signal_ignore;
del_timer ();
with Interrupt -> ());
set_signal sigint Signal_ignore;
del_timer ();
!current_best)