Commits

Anonymous committed 45c776f

mc player can now play with white too

  • Participants
  • Parent commits 0bf358f

Comments (0)

Files changed (1)

mills/ai_montecarlo.ml

 
 let find_best player state moves move millcheck playouts turns =
   let nplayouts = playouts / List.length moves in
+  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 lst best score = match lst with
     | [] -> best
     | candidate:: rest ->
         end;
         end_of_turn s;
         let cscore = (estimate s 0 nplayouts turns) in
-        if cscore > score then select rest candidate cscore
+        if better cscore score then select rest candidate cscore
         else select rest best score
   in
-  select moves (List.hd moves) min_int
+  select moves (List.hd moves) init
 
 let player = object (self)
   val playouts = 15000