Commits

Anonymous committed d129ebd

alphabeta can now play as white too

Comments (0)

Files changed (2)

mills/ai_alphabeta.ml

   and white = (get_count state White) in
   black - white
 
-let estimate_mc playouts state = Ai_montecarlo.estimate state 0 playouts 50
+let estimate_mc playouts state = Ai_montecarlo.estimate state 0 playouts 20
 
 let estimate_hybrid playouts state = 
   let e = estimate_basic state in
     let scores = List.map (score (estimate_hybrid nplayouts)) children in
     let after = Unix.gettimeofday() in
     Printf.eprintf "score time %f\n%!" (after -. before);
+
+    let better = if (get_turn state) mod 2 = 0 then (<) else (>) in
+    let init = if (get_turn state) mod 2 = 0 then max_int else min_int in    
     let rec select nodes scores selected score =
       if nodes = [] then selected
       else
         let n, s = (List.hd nodes), (List.hd scores) in
-        if s > score then select (List.tl nodes) (List.tl scores) n s
+        if better s score then select (List.tl nodes) (List.tl scores) n s
         else select (List.tl nodes) (List.tl scores) selected score
     in
-    select children scores (Node (state, lastmove, [])) min_int
+    select children scores (Node (state, lastmove, [])) init
   in
   
   object (self)
   Random.self_init ();
   let screen = init_sdl () in
   Image.load ();
-  mainloop screen Ai_montecarlo.player Ai_alphabeta.player
+  mainloop screen Ai_alphabeta.player Ai_random.player;
+   Sdltimer.delay 1500;