[Toss-devel-svn] SF.net SVN: toss:[1321] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2011-02-17 21:59:52
|
Revision: 1321
http://toss.svn.sourceforge.net/toss/?rev=1321&view=rev
Author: lukaszkaiser
Date: 2011-02-17 21:59:46 +0000 (Thu, 17 Feb 2011)
Log Message:
-----------
Change default heuristic to mix strength and the old default.
Modified Paths:
--------------
trunk/Toss/Play/Game.ml
trunk/Toss/Play/Game.mli
trunk/Toss/Server/Server.ml
Modified: trunk/Toss/Play/Game.ml
===================================================================
--- trunk/Toss/Play/Game.ml 2011-02-13 23:17:36 UTC (rev 1320)
+++ trunk/Toss/Play/Game.ml 2011-02-17 21:59:46 UTC (rev 1321)
@@ -1,3 +1,4 @@
+
(* -*- folded-file: t; -*- *)
(* Game-related definitions. The UCTS algorithm. *)
@@ -242,7 +243,7 @@
let default_adv_ratio = 2.0
-let default_heuristic ?struc advance_ratio
+let default_heuristic_old ?struc advance_ratio
{Arena.rules=rules; Arena.graph=graph} =
(* TODO: cache the default heuristic in game definition or state *)
let drules =
@@ -310,6 +311,15 @@
Formula.Times (Formula.Const (-1.), sum_all))) sums in
Array.map (fun _ -> heurs) game.Arena.graph
+
+let mix_heur h1 factor h2 =
+ Array.mapi (fun i a -> Array.mapi (fun j p ->
+ Formula.Plus (p, Formula.Times (Formula.Const factor, h2.(i).(j)))) a) h1
+
+let default_heuristic ?struc advr g =
+ mix_heur (default_heuristic_old ?struc advr g) 0.2 (fluents_heuristic g)
+
+
(* The UCB1-TUNED estimate, modified to extend to the zero- and
one-observation cases. *)
let ucb1_tuned ?(lower_bound=false)
Modified: trunk/Toss/Play/Game.mli
===================================================================
--- trunk/Toss/Play/Game.mli 2011-02-13 23:17:36 UTC (rev 1320)
+++ trunk/Toss/Play/Game.mli 2011-02-17 21:59:46 UTC (rev 1321)
@@ -214,9 +214,15 @@
play -> play_state -> (move * play_state) option
(** Various constructed heuristics. *)
+val mix_heur : Formula.real_expr array array -> float ->
+ Formula.real_expr array array -> Formula.real_expr array array
+
val default_heuristic : ?struc:Structure.structure -> float ->
Arena.game -> Formula.real_expr array array
+val default_heuristic_old : ?struc:Structure.structure -> float ->
+ Arena.game -> Formula.real_expr array array
+
val fluents_heuristic : Arena.game -> Formula.real_expr array array
Modified: trunk/Toss/Server/Server.ml
===================================================================
--- trunk/Toss/Server/Server.ml 2011-02-13 23:17:36 UTC (rev 1320)
+++ trunk/Toss/Server/Server.ml 2011-02-17 21:59:46 UTC (rev 1321)
@@ -525,37 +525,28 @@
print_heur_arr harr;) heur
;;
-let add_heur h1 factor h2 =
- Array.mapi (fun i a -> Array.mapi (fun j p ->
- Formula.Plus (p, Formula.Times (Formula.Const factor, h2.(i).(j)))) a) h1
-;;
-
let run_test n depth1 depth2 =
let (horizon, heur_adv_ratio) = (Some 400, 2.0) in
let struc = !state.Arena.struc in
let game = !state.Arena.game in
let heur1 =
if (!heur_val_white1 = "MIX" || !heur_val_black1 = "MIX") then
- let dh =
- Game.default_heuristic ~struc:!state.Arena.struc heur_adv_ratio game in
- add_heur dh 0.2 (Game.fluents_heuristic game)
+ Game.default_heuristic ~struc:!state.Arena.struc heur_adv_ratio game
else if (!heur_val_white1 = "FLUENT" || !heur_val_black1 = "FLUENT") then
Game.fluents_heuristic game
else if (!heur_val_white1 <> "" && !heur_val_black1 <> "") then
heur_of_vals !heur_val_white1 !heur_val_black1
else
- Game.default_heuristic ~struc:!state.Arena.struc heur_adv_ratio game in
+ Game.default_heuristic_old ~struc:!state.Arena.struc heur_adv_ratio game in
let heur2 =
if (!heur_val_white2 = "MIX" || !heur_val_black2 = "MIX") then
- let dh =
- Game.default_heuristic ~struc:!state.Arena.struc heur_adv_ratio game in
- add_heur dh 0.2 (Game.fluents_heuristic game)
+ Game.default_heuristic ~struc:!state.Arena.struc heur_adv_ratio game
else if (!heur_val_white2 = "FLUENT" || !heur_val_black2 = "FLUENT") then
Game.fluents_heuristic game
else if (!heur_val_white2 <> "" && !heur_val_black2 <> "") then
heur_of_vals !heur_val_white2 !heur_val_black2
else
- Game.default_heuristic ~struc:!state.Arena.struc heur_adv_ratio game in
+ Game.default_heuristic_old ~struc:!state.Arena.struc heur_adv_ratio game in
if !debug_level > 0 then (print_heur "1" heur1; print_heur "2" heur2);
let play = {Game.game = game; agents=
[| Game.default_maximax !state.Arena.struc ~depth:depth1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|