[Toss-devel-svn] SF.net SVN: toss:[1265] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2010-12-20 02:05:30
|
Revision: 1265
http://toss.svn.sourceforge.net/toss/?rev=1265&view=rev
Author: lukaszkaiser
Date: 2010-12-20 02:05:24 +0000 (Mon, 20 Dec 2010)
Log Message:
-----------
Corrections to play Tic-Tac-Toe on GGP server. (Test broken just this one time.)
Modified Paths:
--------------
trunk/Toss/Formula/Aux.ml
trunk/Toss/Formula/Aux.mli
trunk/Toss/Play/GDL.ml
Modified: trunk/Toss/Formula/Aux.ml
===================================================================
--- trunk/Toss/Formula/Aux.ml 2010-12-20 00:14:59 UTC (rev 1264)
+++ trunk/Toss/Formula/Aux.ml 2010-12-20 02:05:24 UTC (rev 1265)
@@ -398,16 +398,26 @@
with End_of_file -> ());
Buffer.contents buf
+let is_space c =
+ c = '\n' || c = '\r' || c = ' ' || c = '\t'
+
+let strip_spaces s =
+ let (b, e) = (ref 0, ref ((String.length s) - 1)) in
+ while !b < !e && is_space (s.[!b]) do b := !b + 1 done;
+ while !b <= !e && is_space (s.[!e]) do e := !e - 1 done;
+ if !e < !b then "" else String.sub s !b (!e - !b + 1)
+
let rec input_http_message file =
let buf = Buffer.create 256 in
let line = ref "POST / HTTP" in
let msg_len = ref 0 in
- while !line <> "" && !line <> "\r" do
- line := input_line file;
+ while !line <> "" do
+ line := strip_spaces (input_line file);
let line_len = String.length !line in
- if line_len > 16 && String.sub !line 0 15 = "Content-length:" then
+ if line_len > 16 && String.sub !line 0 15 = "Content-length:" then (
msg_len := int_of_string
(String.sub !line 16 (line_len - 16));
+ )
done;
Buffer.add_channel buf file !msg_len;
Buffer.contents buf
Modified: trunk/Toss/Formula/Aux.mli
===================================================================
--- trunk/Toss/Formula/Aux.mli 2010-12-20 00:14:59 UTC (rev 1264)
+++ trunk/Toss/Formula/Aux.mli 2010-12-20 02:05:24 UTC (rev 1265)
@@ -168,7 +168,11 @@
val is_digit : char -> bool
val is_letter : char -> bool
val is_alphanum : char -> bool
+val is_space : char -> bool
+(** Strip spaces from left and right of a string. *)
+val strip_spaces : string -> string
+
(** Printf helper functions. *)
val list_fprint :
(out_channel -> 'a -> unit) -> out_channel -> 'a list -> unit
Modified: trunk/Toss/Play/GDL.ml
===================================================================
--- trunk/Toss/Play/GDL.ml 2010-12-20 00:14:59 UTC (rev 1264)
+++ trunk/Toss/Play/GDL.ml 2010-12-20 02:05:24 UTC (rev 1265)
@@ -59,7 +59,7 @@
state := state_of_file "./examples/Tic-Tac-Toe.toss";
playing_as := player;
game_description := game_descr;
- player_name_terms := [|Const "X"; Const "O"|];
+ player_name_terms := [|Const "XPLAYER"; Const "OPLAYER"|];
let effort, horizon, heur_adv_ratio =
2, 100, 4.0 in
effort, horizon, heur_adv_ratio
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|