[Toss-devel-svn] SF.net SVN: toss:[1390] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
From: <luk...@us...> - 2011-03-25 02:06:57
|
Revision: 1390 http://toss.svn.sourceforge.net/toss/?rev=1390&view=rev Author: lukaszkaiser Date: 2011-03-25 02:06:51 +0000 (Fri, 25 Mar 2011) Log Message: ----------- Avoid too fast terminal unfolding. Modified Paths: -------------- trunk/Toss/Play/GameTree.ml trunk/Toss/Play/Play.ml trunk/Toss/Server/Server.ml Modified: trunk/Toss/Play/GameTree.ml =================================================================== --- trunk/Toss/Play/GameTree.ml 2011-03-25 00:23:06 UTC (rev 1389) +++ trunk/Toss/Play/GameTree.ml 2011-03-25 02:06:51 UTC (rev 1390) @@ -60,7 +60,8 @@ (* Abstract game tree unfolding function, calls argument functions for work. *) let rec unfold_abstract ?(timeout=fun () -> false) ?(depth=0) game ~info_terminal ~info_leaf ~info_node ~choice = function - | Terminal _ -> raise Not_found + | Terminal _ -> + if !debug_level > 0 then print_endline "Terminal Unfold"; raise Not_found | Leaf (state, player, info) -> if timeout() then raise Not_found; let moves = Move.list_moves game state in Modified: trunk/Toss/Play/Play.ml =================================================================== --- trunk/Toss/Play/Play.ml 2011-03-25 00:23:06 UTC (rev 1389) +++ trunk/Toss/Play/Play.ml 2011-03-25 02:06:51 UTC (rev 1390) @@ -19,9 +19,15 @@ let maximax_depth_choice ab stop_vals dp game cur_state player info children = let mval child = (node_values (snd child)).(player), node_info (snd child) in - let cmp c1 c2 = + let cmp_raw c1 c2 = let (v1, d1), (v2, d2) = mval c1, mval c2 in if v1 > v2 then 1 else if v2 > v1 then -1 else d1 - d2 in + let cmp c1 c2 = + match snd c1, snd c2 with + | Terminal _, Terminal _ -> cmp_raw c1 c2 + | Terminal _, _ -> -1 + | _, Terminal _ -> 1 + | _, _ -> cmp_raw c1 c2 in let res = Aux.random_elem (Aux.array_argfind_all_max cmp children) in if !debug_level > 2 then print_endline (Structure.str (state (snd children.(res))).Arena.struc); @@ -63,9 +69,11 @@ let maximax_unfold_choose count game state heur = let ab = Heuristic.is_constant_sum heur in (* TODO: payoffs as well! *) if !debug_level > 0 then Printf.printf "Using Alpha-Beta: %B\n%!" ab; + if !debug_level > 3 then + Array.iter (fun h -> Array.iter Formula.print_real h) heur; let t = init game state (fun _ _ _ -> 0) heur in let u = unfold_maximax_upto ~ab count game heur t in if !debug_level > 0 then Printf.printf "Timeout %f%!" (Unix.gettimeofday() -. !timeout); - if !debug_level > 1 then print_endline (str string_of_int u); + if !debug_level > 2 then print_endline (str string_of_int u); choose_move game u Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-03-25 00:23:06 UTC (rev 1389) +++ trunk/Toss/Server/Server.ml 2011-03-25 02:06:51 UTC (rev 1390) @@ -311,7 +311,7 @@ game_modified := false; play := Some p; play_state := Some ps; playclock := playcl; - g_heur := Some (Heuristic.default_heuristic + g_heur := Some (Heuristic.default_heuristic ~struc:(snd !state).Arena.struc ~advr:4. (fst !state)); "HTTP/1.0 200 OK\r\nContent-type: text/acl\r\nContent-length: 5" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |