[Toss-devel-svn] SF.net SVN: toss:[1580] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2011-09-29 22:34:24
|
Revision: 1580
http://toss.svn.sourceforge.net/toss/?rev=1580&view=rev
Author: lukstafi
Date: 2011-09-29 22:34:18 +0000 (Thu, 29 Sep 2011)
Log Message:
-----------
Reminder to apply environment rules when playing against GDL server.
Modified Paths:
--------------
trunk/Toss/GGP/TranslateGameTest.ml
trunk/Toss/Server/ReqHandler.ml
trunk/Toss/Server/ReqHandler.mli
Modified: trunk/Toss/GGP/TranslateGameTest.ml
===================================================================
--- trunk/Toss/GGP/TranslateGameTest.ml 2011-09-29 22:18:32 UTC (rev 1579)
+++ trunk/Toss/GGP/TranslateGameTest.ml 2011-09-29 22:34:18 UTC (rev 1580)
@@ -94,8 +94,7 @@
(* COPIED FROM ReqHandler. *)
exception Found of int
-(* The player applying the rewrite seems not to be used. *)
-(* players are indexed from 1 in graph (0 is Environment) *)
+(* Players are indexed from 1 in graph (0 is Environment) *)
let apply_rewrite (game,state as gstate) (player, (r_name, mtch)) =
if r_name <> "" then (
let {Arena.rules=rules; graph=graph} = game in
Modified: trunk/Toss/Server/ReqHandler.ml
===================================================================
--- trunk/Toss/Server/ReqHandler.ml 2011-09-29 22:18:32 UTC (rev 1579)
+++ trunk/Toss/Server/ReqHandler.ml 2011-09-29 22:34:18 UTC (rev 1580)
@@ -52,15 +52,31 @@
exception Found of int
-(* The player applying the rewrite seems not to be used. *)
-(* FIXME: adapt to simultaneous moves. *)
-let apply_rewrite state (player, (r_name, mtch)) =
+(* Players are indexed from 1 in graph (0 is Environment) *)
+let apply_rewrite (game,state as gstate) (player, (r_name, mtch)) =
if r_name <> "" then (
- let {Arena.rules=rules; graph=graph} = fst state in
- let mv_loc = select_moving graph.((snd state).Arena.cur_loc) in
+ let {Arena.rules=rules; graph=graph} = game in
+ let struc = state.Arena.struc in
+ let mv_loc = graph.(state.Arena.cur_loc).(player) in
let moves =
- Move.gen_moves Move.cGRID_SIZE rules
- (snd state).Arena.struc mv_loc in
+ Move.gen_moves Move.cGRID_SIZE rules struc mv_loc in
+ (* {{{ log entry *)
+ if !debug_level > 0 then (
+ let prules =
+ List.map (fun (lb,_)->lb.Arena.lb_rule) mv_loc.Arena.moves in
+ Printf.printf
+ "apply_rewrite: r_name=%s; mtch=%s; player=%d; prules=%s; moves= %s\n%!"
+ r_name
+ (ContinuousRule.embedding_str (List.assoc r_name rules) struc mtch)
+ player (String.concat ", " prules)
+ (String.concat "; "
+ (List.map (fun m->
+ let rul = List.assoc m.Arena.rule rules in
+ m.Arena.rule^":"^
+ ContinuousRule.embedding_str rul struc
+ m.Arena.embedding) (Array.to_list moves)))
+ );
+ (* }}} *)
let pos = (
try
for i = 0 to Array.length moves - 1 do
@@ -69,14 +85,18 @@
(fun (e, f) -> f = List.assoc e mov.Arena.embedding) mtch then
raise (Found i)
done;
+ Printf.printf
+ "apply_rewrite: failed for pl. num %d, r_name=%s\n%!"
+ player r_name;
failwith "GDL Play request: action mismatched with play state"
- with Found pos -> pos) in
+ with Found pos ->
+ pos) in
let req = Arena.ApplyRuleInt (r_name, mtch, 0.1, []) in
- let (new_state_noloc, resp) = Arena.handle_request state req in
+ let (new_state_noloc, resp) = Arena.handle_request gstate req in
let new_loc = moves.(pos).Arena.next_loc in
(fst new_state_noloc,
{snd new_state_noloc with Arena.cur_loc = new_loc})
- ) else state
+ ) else gstate
let req_handle (g_heur, game_modified, state, gdl_transl, playclock) = function
@@ -129,6 +149,7 @@
TranslateGame.translate_incoming_move gdl_transl state actions in
let state = List.fold_left apply_rewrite state rewrites in
+ (* FIXME: apply environment's rules here. *)
let state =
if rewrites = [] || TranslateGame.is_turnbased gdl_transl
then state
Modified: trunk/Toss/Server/ReqHandler.mli
===================================================================
--- trunk/Toss/Server/ReqHandler.mli 2011-09-29 22:18:32 UTC (rev 1579)
+++ trunk/Toss/Server/ReqHandler.mli 2011-09-29 22:34:18 UTC (rev 1580)
@@ -16,7 +16,7 @@
val apply_rewrite :
Arena.game * Arena.game_state ->
- (string * (string * DiscreteRule.matching)) ->
+ (int * (string * DiscreteRule.matching)) ->
Arena.game * Arena.game_state
type req_state =
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|