Thread: [Toss-devel-svn] SF.net SVN: toss:[1328] trunk/Toss (Page 4)
Status: Beta
Brought to you by:
lukaszkaiser
From: <luk...@us...> - 2011-02-24 02:15:14
|
Revision: 1328 http://toss.svn.sourceforge.net/toss/?rev=1328&view=rev Author: lukstafi Date: 2011-02-24 02:15:08 +0000 (Thu, 24 Feb 2011) Log Message: ----------- GDL translation: expansion of inconvenient variables (applied to terminal condition, to be applied at two more sites). GDLParser: more consistent lower-casing of keywords. ServerGDLTest: Tic-Tac-Toe definition bug fix. Aux: concat_foldr for backtracking-monad-like computations. Modified Paths: -------------- trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/Formula/AuxTest.ml trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDLParser.mly trunk/Toss/Server/ServerGDLTest.in trunk/Toss/Server/ServerTest.ml Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-02-24 01:47:56 UTC (rev 1327) +++ trunk/Toss/Formula/Aux.ml 2011-02-24 02:15:08 UTC (rev 1328) @@ -72,13 +72,16 @@ let map_reduce mapf redf red0 l = match List.sort (fun x y -> compare (fst x) (fst y)) (List.map mapf l) with - | [] -> [] - | (k0, v0)::tl -> - let k0, vs, l = List.fold_left (fun (k0, vs, l) (kn, vn) -> - if k0 = kn then k0, vn::vs, l else kn, [vn], (k0,vs)::l) - (k0, [v0], []) tl in - List.rev (List.map (fun (k,vs) -> k, List.fold_left redf red0 vs) - ((k0,vs)::l)) + | [] -> [] + | (k0, v0)::tl -> + let k0, vs, l = + List.fold_left (fun (k0, vs, l) (kn, vn) -> + if k0 = kn then k0, vn::vs, l + else kn, [vn], (k0,vs)::l) + (k0, [v0], []) tl in + List.rev ( + List.map (fun (k,vs) -> k, List.fold_left redf red0 vs) + ((k0,vs)::l)) let collect l = match List.sort (fun x y -> compare (fst x) (fst y)) l with @@ -90,6 +93,11 @@ (k0, [v0], []) tl in List.rev ((k0,List.rev vs)::l) +let rec concat_foldr f l init = + match l with + | [] -> init + | a::l -> concat_map (f a) (concat_foldr f l init) + let list_remove v l = List.filter (fun w->v<>w) l Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-02-24 01:47:56 UTC (rev 1327) +++ trunk/Toss/Formula/Aux.mli 2011-02-24 02:15:08 UTC (rev 1328) @@ -53,6 +53,10 @@ [map_reduce (fun x -> x) (fun y x->x::y) []]. *) val collect : ('a * 'b) list -> ('a * 'b list) list +(** Another very useful function from the list monad family: + [concat_foldr f (a::l) init = concat_map (f a) (concat_foldr f l init)] *) +val concat_foldr : ('a -> 'b -> 'b list) -> 'a list -> 'b list -> 'b list + (** Remove all elements equal to the argument, using structural inequality. *) val list_remove : 'a -> 'a list -> 'a list Modified: trunk/Toss/Formula/AuxTest.ml =================================================================== --- trunk/Toss/Formula/AuxTest.ml 2011-02-24 01:47:56 UTC (rev 1327) +++ trunk/Toss/Formula/AuxTest.ml 2011-02-24 02:15:08 UTC (rev 1328) @@ -133,7 +133,7 @@ (Aux.map_try f [`A;`B;`C;`D]); ); - "product, all_tuples_for" >:: + "product, all_tuples_for, concat_foldr" >:: (fun () -> let print_llist l = String.concat "; " (List.map (String.concat ", ") l) in @@ -152,6 +152,14 @@ assert_equal ~printer:print_llist [["a"; "a"; "a"]; ["a"; "a"; "b"]; ["a"; "b"; "a"]; ["a"; "b"; "b"]; ["b"; "a"; "a"]; ["b"; "a"; "b"]; ["b"; "b"; "a"]; ["b"; "b"; "b"]] (Aux.all_tuples_for [();(); ()] ["a";"b"]); + + assert_equal ~printer:print_llist + [["a1"; "b"; "c"; "a1"; "d"]; ["a2"; "b"; "c"; "a1"; "d"]; + ["a1"; "b"; "c"; "a2"; "d"]; ["a2"; "b"; "c"; "a2"; "d"]] + (Aux.concat_foldr (function + | "a" -> + (fun acc -> List.map (fun x->x::acc) ["a1"; "a2"]) + | x -> (fun acc -> [x::acc])) ["a"; "b"; "c"; "a"; "d"] [[]]) ); "list_remove, remove_one" >:: Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-02-24 01:47:56 UTC (rev 1327) +++ trunk/Toss/GGP/GDL.ml 2011-02-24 02:15:08 UTC (rev 1328) @@ -816,7 +816,7 @@ if List.mem_assoc x sb then if List.assoc x sb = term then sb else raise Not_found - else sb1::sb in + else sb1::List.map (fun (x,t)->x, subst_one sb1 t) sb in match_meta sb m_sb terms1 terms2 | _ -> raise Not_found @@ -1043,26 +1043,43 @@ (* 6 *) -(* Need a global access so that the count can be reset between +(* Need a global access so that the support can be reset between different translations. (Generalization uses a local [fresh_count] state.) *) -let freshen_count = ref 0 +let var_support = ref Aux.Strings.empty -(* TODO: do proper elegant renaming... *) let freshen_branch (args, body, neg_body) = - incr freshen_count; + let sb = ref [] in let rec map_vnames = function - | Var x -> Var (x^string_of_int !freshen_count) - | MVar x -> MVar (x^string_of_int !freshen_count) + | Var x -> + if List.mem_assoc x !sb then Var (List.assoc x !sb) + else + let x1 = Aux.not_conflicting_name !var_support x in + var_support := Aux.Strings.add x1 !var_support; + sb := (x,x1)::!sb; + Var x1 + | MVar x -> + if List.mem_assoc x !sb then MVar (List.assoc x !sb) + else + let x1 = Aux.not_conflicting_name !var_support x in + var_support := Aux.Strings.add x1 !var_support; + sb := (x,x1)::!sb; + MVar x1 | Const _ as t -> t | Func (f, args) -> Func (f, List.map map_vnames args) in let map_rel (rel, args) = rel, List.map map_vnames args in let map_neg (vs, atoms) = - Aux.strings_of_list - (List.map (fun x-> x^string_of_int !freshen_count) - (Aux.Strings.elements vs)), + let vs = + List.map (fun x -> + if List.mem_assoc x !sb then List.assoc x !sb + else + let x1 = Aux.not_conflicting_name !var_support x in + var_support := Aux.Strings.add x1 !var_support; + sb := (x,x1)::!sb; x1 + ) (Aux.Strings.elements vs) in + Aux.strings_of_list vs, List.map map_rel atoms in List.map map_vnames args, List.map map_rel body, @@ -1714,8 +1731,75 @@ (* }}} *) res +(* Expand branch variables. If [freshen_unfixed=Right fixed], expand + all variables that don't belong to [fixed]. If + [freshen_unfixed=Left freshen], then expand all variables below + meta-variables of masks. If [freshen] is true, rename other + (i.e. non-expanded) variables while duplicating branches. (When + [freshen] is false, all remaining variables should be fixed.) + + With each branch, also return the instantiation used to derive it??? + + As in the expansion of relation definitions, branches are + duplicated for instantiations of positive literals, and + additionally of heads. For instantiations of atoms in negated + subformulas, the subformulas are duplicated within a branch, with + instantiations kept local to the subformula. Final substitution is + re-applied to catch up with later instantiations. *) +let expand_branch_vars masks playout_terms ~freshen_unfixed brs = + let expand sb arg = + let arg = subst sb arg in + let is_inst_var = + match freshen_unfixed with + | Aux.Left _ -> + let mask, sb, m_sb, blank = term_to_blank masks arg in + let ivars = Aux.concat_map (fun (_,t) -> + Aux.Strings.elements (term_vars t)) m_sb in + (fun v -> List.mem v ivars) + | Aux.Right fixed -> fun v -> not (List.mem v fixed) in + Aux.unique_sorted + (Aux.map_try (fun term -> + let sb1, _ = match_meta [] [] [term] [arg] in + let sb1 = List.sort Pervasives.compare + (List.filter (fun (v,_)->is_inst_var v) sb1) in + extend_sb sb1 sb, subst sb1 arg + ) playout_terms) in + let expand_rel atom (sb, acc) = + match atom with + | "true", [arg] -> + List.map (fun (sb,arg) -> sb, ("true",[arg])::acc) (expand sb arg) + | rel, args -> [sb, (rel, List.map (subst sb) args)::acc] in + let expand_neg sb (vs, neg_conj) = + let neg_conjs = + Aux.concat_foldr expand_rel neg_conj [sb, []] in + List.map (fun (sb, neg_conj) -> + let vs = List.filter (fun v -> not (List.mem_assoc v sb)) + (Aux.Strings.elements vs) in + Aux.strings_of_list vs, neg_conj + ) neg_conjs in + let brs = + Aux.concat_map (function ([head],body,neg_body) -> + Aux.concat_map (fun (sb,head) -> + let bodies = Aux.concat_foldr expand_rel body [sb, []] in + Aux.map_some (fun (sb, body) -> + let head = subst sb head in + let body = List.map (subst_rel sb) body in + let neg_body = + Aux.concat_map (expand_neg sb) neg_body in + if List.exists (function _, [] -> true | _ -> false) + neg_body then None + (* need to pack head into a list for [freshen_branch] *) + else Some ((* sb, *)([head], body, neg_body))) bodies) + (if head = Const "_IGNORE_RHS_" then [[], head] + else expand [] head) + | _ -> assert false) brs in + match freshen_unfixed with + | Aux.Left true -> + List.map (fun ((* sb, *) br) -> (* sb, *) freshen_branch br) brs + | _ -> brs + let translate_game player_term game_descr = - freshen_count := 0; + var_support := Aux.Strings.empty; let player_terms = Array.of_list (Aux.map_some (function Role p -> Some p | _ -> None) game_descr) in @@ -1811,6 +1895,8 @@ done; loc_noops in (* 6 *) + (* TODO: perhaps simplify by using [Aux.concat_foldr], as in + [expand_branch_vars] above. *) let expand_roles rules = Aux.concat_map (fun (head, body, neg_body as br) -> let roles, body = @@ -2652,6 +2738,10 @@ List.map (function | [], body, neg_body -> [Const "_IGNORE_RHS_"], body, neg_body | _ -> assert false) terminal_rules in + (* 7n1 *) + let terminal_brs = + expand_branch_vars masks element_terms + ~freshen_unfixed:(Aux.Left true) terminal_brs in let terminal_uni_vars, terminal_4b, terminal_brs = translate_branches struc masks static_rnames dyn_rels terminal_brs in let terminal_disjs = List.map (fun ((_,_,conjs),_) -> Modified: trunk/Toss/GGP/GDLParser.mly =================================================================== --- trunk/Toss/GGP/GDLParser.mly 2011-02-24 01:47:56 UTC (rev 1327) +++ trunk/Toss/GGP/GDLParser.mly 2011-02-24 02:15:08 UTC (rev 1328) @@ -35,7 +35,9 @@ "GDL: Syntax error in term." } atom: -| r=WORD { Rel (r, []) } +| r=WORD { + if r="TERMINAL" then Rel ("terminal", []) + else Rel (r, []) } | sexp=delimited (OPEN, list (term), CLOSE) { match sexp with | (Const "distinct" | Const "DISTINCT")::args -> @@ -44,6 +46,18 @@ Currently arg | [(Const "does" | Const "DOES"); player; action] -> Does (player, action) + | (Const "role" | Const "ROLE")::player -> + Rel ("role", player) + | (Const "init" | Const "INIT")::state -> + Rel ("init", state) + | (Const "next" | Const "NEXT")::state -> + Rel ("next", state) + | (Const "terminal" | Const "TERMINAL")::no_arg -> + Rel ("terminal", no_arg) + | (Const "legal" | Const "LEGAL")::args -> + Rel ("legal", args) + | (Const "goal" | Const "GOAL")::args -> + Rel ("goal", args) | Const r::args -> Rel (r, args) | _ -> raise (Lexer.Parsing_error "GDL atom: not a constant head") } @@ -59,26 +73,26 @@ game_descr_entry: | OPEN REVIMPL head=atom body=list (literal) CLOSE { match head with - | Rel ("next", [t]) | Rel ("NEXT", [t]) -> Next (t, body) - | Rel ("next", _) | Rel ("NEXT", _) -> + | Rel ("next", [t]) -> Next (t, body) + | Rel ("next", _) -> raise (Lexer.Parsing_error "GDL next: not unary") - | Rel ("init", [arg]) | Rel ("INIT", [arg]) -> Initial (arg, body) - | Rel ("init", _) | Rel ("INIT", _) -> + | Rel ("init", [arg]) -> Initial (arg, body) + | Rel ("init", _) -> raise (Lexer.Parsing_error "GDL init: not unary") - | Rel ("terminal", []) | Rel ("TERMINAL", []) -> Terminal body - | Rel ("terminal", _) | Rel ("TERMINAL", _) -> + | Rel ("terminal", []) -> Terminal body + | Rel ("terminal", _) -> raise (Lexer.Parsing_error "GDL terminal: not nullary") - | Rel ("legal", [t1; t2]) | Rel ("LEGAL", [t1; t2]) -> + | Rel ("legal", [t1; t2]) -> Legal (t1, t2, body) - | Rel ("legal", _) | Rel ("LEGAL", _) -> + | Rel ("legal", _) -> raise (Lexer.Parsing_error "GDL legal: not binary") - | Rel ("goal", [t; Const gv]) | Rel ("GOAL", [t; Const gv]) -> + | Rel ("goal", [t; Const gv]) -> (try let gv = int_of_string gv in Goal (t, gv, body) with Failure _ | Invalid_argument _ -> raise (Lexer.Parsing_error "GDL goal: value not a constant int")) - | Rel ("goal", [t; Var gv]) | Rel ("GOAL", [t; Var gv]) -> + | Rel ("goal", [t; Var gv]) -> (try GoalPattern (t, gv, body) with Failure _ | Invalid_argument _ -> @@ -96,10 +110,10 @@ } | a=atom { match a with - | (Rel ("init", [arg]) | Rel ("INIT", [arg])) -> Initial (arg, []) - | (Rel ("init", _) | Rel ("INIT", _)) -> + | (Rel ("init", [arg])) -> Initial (arg, []) + | (Rel ("init", _)) -> raise (Lexer.Parsing_error "GDL init: not unary") - | (Rel ("role", [arg]) | Rel ("ROLE", [arg])) -> Role arg + | (Rel ("role", [arg])) -> Role arg | (Rel ("role", _) | Rel ("ROLE", _)) -> raise (Lexer.Parsing_error "GDL role: not unary") | Rel (r, args) -> Atomic (r, args) Modified: trunk/Toss/Server/ServerGDLTest.in =================================================================== --- trunk/Toss/Server/ServerGDLTest.in 2011-02-24 01:47:56 UTC (rev 1327) +++ trunk/Toss/Server/ServerGDLTest.in 2011-02-24 02:15:08 UTC (rev 1328) @@ -3,9 +3,9 @@ Sender: GAMEMASTER Receiver: GAMEPLAYER Content-type: text/acl -Content-length: 1661 +Content-length: 1721 -(START MATCH.3316980891 XPLAYER ((ROLE XPLAYER) (ROLE OPLAYER) (INIT (CELL 1 1 B)) (INIT (CELL 1 2 B)) (INIT (CELL 1 3 B)) (INIT (CELL 2 1 B)) (INIT (CELL 2 2 B)) (INIT (CELL 2 3 B)) (INIT (CELL 3 1 B)) (INIT (CELL 3 2 B)) (INIT (CELL 3 3 B)) (INIT (CONTROL XPLAYER)) (<= (NEXT (CELL ?X ?Y ?PLAYER)) (DOES ?PLAYER (MARK ?X ?Y))) (<= (NEXT (CELL ?X ?Y ?MARK)) (TRUE (CELL ?X ?Y ?MARK)) (DOES ?PLAYER (MARK ?M ?N)) (DISTINCTCELL ?X ?Y ?M ?N)) (<= (NEXT (CONTROL XPLAYER)) (TRUE (CONTROL OPLAYER))) (<= (NEXT (CONTROL OPLAYER)) (TRUE (CONTROL XPLAYER))) (<= (ROW ?X ?PLAYER) (TRUE (CELL ?X 1 ?PLAYER)) (TRUE (CELL ?X 2 ?PLAYER)) (TRUE (CELL ?X 3 ?PLAYER))) (<= (COLUMN ?Y ?PLAYER) (TRUE (CELL 1 ?Y ?PLAYER)) (TRUE (CELL 2 ?Y ?PLAYER)) (TRUE (CELL 3 ?Y ?PLAYER))) (<= (DIAGONAL ?PLAYER) (TRUE (CELL 1 1 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 3 ?PLAYER))) (<= (DIAGONAL ?PLAYER) (TRUE (CELL 1 3 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 1 ?PLAYER))) (<= (LINE ?PLAYER) (ROW ?X ?PLAYER)) (<= (LINE ?PLAYER) (COLUMN ?Y ?PLAYER)) (<= (LINE ?PLAYER) (DIAGONAL ?PLAYER)) (<= OPEN (TRUE (CELL ?X ?Y B))) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?X ?M)) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?Y ?N)) (<= (LEGAL ?PLAYER (MARK ?X ?Y)) (TRUE (CELL ?X ?Y B)) (TRUE (CONTROL ?PLAYER))) (<= (LEGAL ?PLAYER NOOP) (NOT (TRUE (CONTROL ?PLAYER)))) (<= (GOAL ?PLAYER 100) (LINE ?PLAYER)) (<= (GOAL ?PLAYER 50) (NOT (LINE XPLAYER)) (NOT (LINE OPLAYER)) (NOT OPEN)) (<= (GOAL ?PLAYER1 0) (LINE ?PLAYER2) (DISTINCT ?PLAYER1 ?PLAYER2)) (<= (GOAL ?PLAYER 0) (NOT (LINE XPLAYER)) (NOT (LINE OPLAYER)) OPEN) (<= TERMINAL (LINE ?PLAYER)) (<= TERMINAL (NOT OPEN))) 30 30) +(START MATCH.3316980891 XPLAYER ((ROLE XPLAYER) (ROLE OPLAYER) (INIT (CELL 1 1 B)) (INIT (CELL 1 2 B)) (INIT (CELL 1 3 B)) (INIT (CELL 2 1 B)) (INIT (CELL 2 2 B)) (INIT (CELL 2 3 B)) (INIT (CELL 3 1 B)) (INIT (CELL 3 2 B)) (INIT (CELL 3 3 B)) (INIT (CONTROL XPLAYER)) (<= (NEXT (CELL ?X ?Y ?PLAYER)) (DOES ?PLAYER (MARK ?X ?Y))) (<= (NEXT (CELL ?X ?Y ?MARK)) (TRUE (CELL ?X ?Y ?MARK)) (DOES ?PLAYER (MARK ?M ?N)) (DISTINCTCELL ?X ?Y ?M ?N)) (<= (NEXT (CONTROL XPLAYER)) (TRUE (CONTROL OPLAYER))) (<= (NEXT (CONTROL OPLAYER)) (TRUE (CONTROL XPLAYER))) (<= (ROW ?X ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL ?X 1 ?PLAYER)) (TRUE (CELL ?X 2 ?PLAYER)) (TRUE (CELL ?X 3 ?PLAYER))) (<= (COLUMN ?Y ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 ?Y ?PLAYER)) (TRUE (CELL 2 ?Y ?PLAYER)) (TRUE (CELL 3 ?Y ?PLAYER))) (<= (DIAGONAL ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 1 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 3 ?PLAYER))) (<= (DIAGONAL ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 3 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 1 ?PLAYER))) (<= (LINE ?PLAYER) (ROW ?X ?PLAYER)) (<= (LINE ?PLAYER) (COLUMN ?Y ?PLAYER)) (<= (LINE ?PLAYER) (DIAGONAL ?PLAYER)) (<= OPEN (TRUE (CELL ?X ?Y B))) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?X ?M)) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?Y ?N)) (<= (LEGAL ?PLAYER (MARK ?X ?Y)) (TRUE (CELL ?X ?Y B)) (TRUE (CONTROL ?PLAYER))) (<= (LEGAL ?PLAYER NOOP) (NOT (TRUE (CONTROL ?PLAYER)))) (<= (GOAL ?PLAYER 100) (LINE ?PLAYER)) (<= (GOAL ?PLAYER 50) (NOT (LINE XPLAYER)) (NOT (LINE OPLAYER)) (NOT OPEN)) (<= (GOAL ?PLAYER1 0) (LINE ?PLAYER2) (DISTINCT ?PLAYER1 ?PLAYER2)) (<= (GOAL ?PLAYER 0) (NOT (LINE XPLAYER)) (NOT (LINE OPLAYER)) OPEN) (<= TERMINAL (LINE ?PLAYER)) (<= TERMINAL (NOT OPEN))) 30 30) POST / HTTP/1.0 Accept: text/delim Modified: trunk/Toss/Server/ServerTest.ml =================================================================== --- trunk/Toss/Server/ServerTest.ml 2011-02-24 01:47:56 UTC (rev 1327) +++ trunk/Toss/Server/ServerTest.ml 2011-02-24 02:15:08 UTC (rev 1328) @@ -47,7 +47,7 @@ "ServerGDLTest.in GDL Tic-Tac-Toe automatic" >:: (fun () -> - todo "Expanding meta-variables is still in GDL.ml's TODO."; + todo "real soon now..."; let old_det_suggest = !Game.deterministic_suggest in Game.deterministic_suggest := true; let old_translation = !GDL.manual_translation in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-02-24 21:59:47
|
Revision: 1330 http://toss.svn.sourceforge.net/toss/?rev=1330&view=rev Author: lukaszkaiser Date: 2011-02-24 21:59:41 +0000 (Thu, 24 Feb 2011) Log Message: ----------- Heuristic.is_constant_sum Modified Paths: -------------- trunk/Toss/Formula/FormulaOps.ml trunk/Toss/Formula/FormulaOps.mli trunk/Toss/Formula/FormulaOpsTest.ml trunk/Toss/Play/Heuristic.ml trunk/Toss/Play/Heuristic.mli trunk/Toss/Play/HeuristicTest.ml Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-02-24 17:08:59 UTC (rev 1329) +++ trunk/Toss/Formula/FormulaOps.ml 2011-02-24 21:59:41 UTC (rev 1330) @@ -562,7 +562,7 @@ (* Recursively simplify a formula *) -let simplify ?(do_pnf=false) phi = +let rec simplify ?(do_pnf=false) ?(do_re=true) phi = let do_simplify phi = let (ids, rev_ids, free_id) = (Hashtbl.create 7, Hashtbl.create 7, ref 1) in let boolean_phi = BoolFormula.bool_formula_of_formula_arg phi (ids, rev_ids, free_id) in @@ -571,7 +571,11 @@ (*print_endline("Simplified to: " ^ str simplified_phi);*) simplified_phi in let rec simplify_subformulas = function - Rel _ | Eq _ | In _ | RealExpr _ as atom -> atom + Rel _ | Eq _ | In _ as atom -> atom + | RealExpr (re, sgn) as rx -> + if do_re then + RealExpr (simplify_re ~do_pnf ~do_formula:true re, sgn) + else rx | Not psi -> do_simplify (Not (simplify_subformulas psi)) | And (flist) -> do_simplify (And (List.rev_map simplify_subformulas flist)) | Or (flist) -> do_simplify (Or (List.rev_map simplify_subformulas flist)) @@ -602,6 +606,42 @@ ) else simplified_prenex_phi +and simplify_re ?(do_pnf=false) ?(do_formula=true) = function + | RVar _ | Const _ | Fun _ as atom -> atom + | Char phi -> + if do_formula then Char (simplify ~do_pnf ~do_re:true phi) else Char phi + | Sum (l, phi, re) -> + let re_simp = simplify_re ~do_pnf ~do_formula re in + if do_formula then + Sum (l, simplify ~do_pnf ~do_re:true phi, re_simp) + else Sum (l, phi, re_simp) + | Plus _ | Times (Const _, _) | Times (_, Const _) as x -> + let rec get_linear = function + | Plus (p, q) -> List.rev_append (get_linear p) (get_linear q) + | Times (Const c, p) | Times (p, Const c) -> + List.map (fun (f, x) -> (c *. f, x)) (get_linear p) + | Const c -> [(c, Const 1.)] + | x -> [(1., x)] in + let one (c, x) = if c = 1. then x else if c = 0. then Const 0. else + if x = Const 1. then Const c else Times (Const c, x) in + let rec collect_linear = function + | [] -> Const 0. + | [x] -> one x + | (c, x) :: ls when c = 0. -> collect_linear ls + | (c, x) :: (d, y) :: ls when x = y -> + collect_linear ((c +. d, x) :: ls) + | x :: y :: ls -> Plus (one x, collect_linear (y :: ls)) in + let l = get_linear x in + let cmp (c, x) (d, y) = + let x = Pervasives.compare x y in + if x <> 0 then x else if c > d then 1 else if d > c then -1 else 0 in + let s = List.map (fun (c, r) -> (c, simplify_re ~do_pnf ~do_formula r)) l in + collect_linear (List.sort cmp s) + | Times (p, q) -> + let simp_p = simplify_re ~do_pnf ~do_formula p in + let simp_q = simplify_re ~do_pnf ~do_formula q in + if simp_p = p && simp_q = q then Times (p, q) else + simplify_re ~do_pnf ~do_formula (Times (simp_p, simp_q)) (* Flatten "and"s and "or"s in a formula -- i.e. associativity. *) let rec flatten_formula phi = Modified: trunk/Toss/Formula/FormulaOps.mli =================================================================== --- trunk/Toss/Formula/FormulaOps.mli 2011-02-24 17:08:59 UTC (rev 1329) +++ trunk/Toss/Formula/FormulaOps.mli 2011-02-24 21:59:41 UTC (rev 1330) @@ -67,8 +67,12 @@ (** {2 Simplification} *) (** Recursively simplify a formula *) -val simplify : ?do_pnf : bool -> formula -> formula +val simplify : ?do_pnf : bool -> ?do_re : bool -> formula -> formula +(** Recursively simplify a real expr *) +val simplify_re : ?do_pnf: bool -> ?do_formula: bool -> real_expr -> real_expr + + val pnf : formula -> formula (** Flatten "and"s and "or"s in a formula -- i.e. associativity. *) Modified: trunk/Toss/Formula/FormulaOpsTest.ml =================================================================== --- trunk/Toss/Formula/FormulaOpsTest.ml 2011-02-24 17:08:59 UTC (rev 1329) +++ trunk/Toss/Formula/FormulaOpsTest.ml 2011-02-24 21:59:41 UTC (rev 1330) @@ -7,12 +7,21 @@ FormulaParser.parse_formula Lexer.lex (Lexing.from_string s) ;; +let real_expr_of_string s = + FormulaParser.parse_real_expr Lexer.lex (Lexing.from_string s) +;; + let formula_eq f1 phi1 f2 phi2 = assert_equal ~printer:(fun x -> Formula.str x) (Formula.flatten (f1 (formula_of_string phi1))) (Formula.flatten (f2 (formula_of_string phi2))) ;; +let real_expr_eq f1 re1 f2 re2 = + assert_equal ~printer:(fun x -> Formula.real_str x) + (f1 (real_expr_of_string re1)) (f2 (real_expr_of_string re2)) +;; + let id x = x ;; let tests = "FormulaOps" >::: [ @@ -222,6 +231,15 @@ and all s (((s in X2) or (s in S)))))"; ); + "simplify_re" >:: + (fun () -> + let simp_eq re1 re2 = real_expr_eq id re2 FormulaOps.simplify_re re1 in + simp_eq ":f(x) - :f(x)" "0"; + simp_eq ":f(x) + 3 * :f(x)" "4 * :f(x)"; + simp_eq " 3 + 4 * 5 - 12" "11"; + simp_eq ":(ex x R(x)) - :(ex x R(x))" "0"; + ); + "prenex" >:: (fun () -> let prenex_eq phi1 phi2 = formula_eq id phi2 FormulaOps.pnf phi1 in Modified: trunk/Toss/Play/Heuristic.ml =================================================================== --- trunk/Toss/Play/Heuristic.ml 2011-02-24 17:08:59 UTC (rev 1329) +++ trunk/Toss/Play/Heuristic.ml 2011-02-24 21:59:41 UTC (rev 1330) @@ -1037,3 +1037,12 @@ let default_heuristic ?struc ?advr g = mix_heur (default_heuristic_old ?struc ?advr g) 0.2 (fluents_heuristic g) + +let is_constant_sum_one heur_arr = + let is_const r1 r2 = + let simp = FormulaOps.simplify_re (Plus (r1, r2)) in + match simp with | Const _ -> true | _ -> false in + Array.length heur_arr = 2 && is_const heur_arr.(0) heur_arr.(1) + +let is_constant_sum harr = + not (Aux.array_existsi (fun _ h -> not (is_constant_sum_one h)) harr) Modified: trunk/Toss/Play/Heuristic.mli =================================================================== --- trunk/Toss/Play/Heuristic.mli 2011-02-24 17:08:59 UTC (rev 1329) +++ trunk/Toss/Play/Heuristic.mli 2011-02-24 21:59:41 UTC (rev 1330) @@ -105,3 +105,6 @@ Arena.game -> Formula.real_expr array array val fluents_heuristic : Arena.game -> Formula.real_expr array array + +val is_constant_sum_one : Formula.real_expr array -> bool +val is_constant_sum : Formula.real_expr array array -> bool Modified: trunk/Toss/Play/HeuristicTest.ml =================================================================== --- trunk/Toss/Play/HeuristicTest.ml 2011-02-24 17:08:59 UTC (rev 1329) +++ trunk/Toss/Play/HeuristicTest.ml 2011-02-24 21:59:41 UTC (rev 1330) @@ -393,6 +393,18 @@ (default_heuristic 3. rules (real_of_str (":("^winPvwxyz^") - :("^winQvwxyz^")"))))); )); + + "is_constant_sum: monotonic gomoku" >:: + (fun () -> backtrace ( + let rules = [ + rule_of_str sigPQ "[a|P:1 {}; Q:1 {}|] -> [|Q:1 {}; P(a)|] emb P, Q"; + rule_of_str sigPQ "[a|P:1 {}; Q:1 {}|] -> [|P:1 {}; Q(a)|] emb P, Q"] in + let h = default_heuristic 2. rules + (real_of_str (":("^winPvwxyz^") - :("^winQvwxyz^")")) in + assert_equal ~printer:(fun x -> string_of_bool x) true + (Heuristic.is_constant_sum_one + [|h; Formula.Times (Formula.Const (-1.), h)|]) + )); ] let a = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-02-25 00:02:44
|
Revision: 1333 http://toss.svn.sourceforge.net/toss/?rev=1333&view=rev Author: lukaszkaiser Date: 2011-02-25 00:02:36 +0000 (Fri, 25 Feb 2011) Log Message: ----------- Small debugging improvements. Modified Paths: -------------- trunk/Toss/Play/Heuristic.ml trunk/Toss/Server/Server.ml Modified: trunk/Toss/Play/Heuristic.ml =================================================================== --- trunk/Toss/Play/Heuristic.ml 2011-02-24 22:57:56 UTC (rev 1332) +++ trunk/Toss/Play/Heuristic.ml 2011-02-25 00:02:36 UTC (rev 1333) @@ -1028,6 +1028,10 @@ let heurs = Array.map (fun f -> Formula.Plus (Formula.Times (Formula.Const (2.), f), Formula.Times (Formula.Const (-1.), sum_all))) sums in + if !debug_level > 0 then ( + let hlist = List.map Formula.real_str (Array.to_list heurs) in + print_endline ("FLHEUR: " ^ (String.concat "; " hlist)) + ); Array.map (fun _ -> heurs) game.Arena.graph Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-02-24 22:57:56 UTC (rev 1332) +++ trunk/Toss/Server/Server.ml 2011-02-25 00:02:36 UTC (rev 1333) @@ -3,6 +3,7 @@ let debug_level = ref 0 let set_debug_level i = debug_level := i; + if i > 5 then Solver.set_debug_level 1; GameTree.set_debug_level 1; Game.set_debug_level i; Heuristic.debug_level := i - 3 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-02-26 12:52:34
|
Revision: 1334 http://toss.svn.sourceforge.net/toss/?rev=1334&view=rev Author: lukstafi Date: 2011-02-26 12:52:28 +0000 (Sat, 26 Feb 2011) Log Message: ----------- GDL translation: better frame/erasure generation (fix). Aux: cleaner fresh names (optional). Modified Paths: -------------- trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDLTest.ml Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-02-25 00:02:36 UTC (rev 1333) +++ trunk/Toss/Formula/Aux.ml 2011-02-26 12:52:28 UTC (rev 1334) @@ -406,6 +406,13 @@ else fold_n f (f accu) (n-1) +(* Character classes. *) +let is_uppercase c = c >= 'A' && c <= 'Z' +let is_lowercase c = c >= 'a' && c <= 'z' +let is_digit c = c >= '0' && c <= '9' +let is_letter c = is_uppercase c || is_lowercase c +let is_alphanum c = is_letter c || is_digit c + (* Return the result of the first index [i] that passes the given test, and [i+1]. *) let rec first_i n gen test = @@ -418,7 +425,13 @@ snd (first_i 1 (fun i->basename^(string_of_int i)^suffix) (fun fname->not (Sys.file_exists fname))) -let not_conflicting_name names s = +let not_conflicting_name ?(truncate=false) names s = + let s = + if truncate then + let i = ref (String.length s - 1) in + while !i > 0 && is_digit s.[!i] do decr i done; + String.sub s 0 (!i + 1) + else s in if not (Strings.mem s names) then s else snd (first_i 0 (fun i -> s^(string_of_int i)) @@ -431,13 +444,6 @@ (fun v -> not (Strings.mem v names)) in i', v::res) (0,[]) n)) -(* Character classes. *) -let is_uppercase c = c >= 'A' && c <= 'Z' -let is_lowercase c = c >= 'a' && c <= 'z' -let is_digit c = c >= '0' && c <= '9' -let is_letter c = is_uppercase c || is_lowercase c -let is_alphanum c = is_letter c || is_digit c - (* Printing. *) let list_fprint e_printf outchan l = Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-02-25 00:02:36 UTC (rev 1333) +++ trunk/Toss/Formula/Aux.mli 2011-02-26 12:52:28 UTC (rev 1334) @@ -217,8 +217,9 @@ (** Generate a fresh filename of the form [base ^ n ^ suffix]. *) val new_filename : string -> string -> string -(** Returns a string proloning [s] and not appearing in [names]. *) -val not_conflicting_name : Strings.t -> string -> string +(** Returns a string proloning [s] and not appearing in [names]. If + [truncate] is true, remove numbers from the end of [s]. *) +val not_conflicting_name : ?truncate:bool -> Strings.t -> string -> string (** Returns [n] strings proloning [s] and not appearing in [names]. *) val not_conflicting_names : Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-02-25 00:02:36 UTC (rev 1333) +++ trunk/Toss/GGP/GDL.ml 2011-02-26 12:52:28 UTC (rev 1334) @@ -258,7 +258,7 @@ discard non-maximal equivalence classes, because negation (7e) is not implemented, and with negation it would still be preferable to have exhaustiveness check so as to not generate spurious - (unapplicable) rules. + (unapplicable) rules. TODO: rethink, compare with (7f2). (7e) Associate negation of equalities specific to the unifiers strictly less general than the equivalence class with it, so that @@ -281,9 +281,6 @@ manner as in (7b) and (7d) for the "legal" term), disjoin bodies in each class (a "multi-body"), then: - implementation TODO: currently, we only use maximal equivalence - classes (see note at 7d) - (7f3) negate the multi-body, push negation inside (using de Morgan laws etc.), split into separate "erasure" branch for each disjunct, place the original "next" atom but with meta-variable @@ -804,7 +801,7 @@ | [], [] -> sb, m_sb | (Const _ (* | Var _ *) as a)::terms1, (Const _ (* | Var _ *) as b)::terms2 - when a=b -> match_meta sb m_sb terms1 terms2 + when a=b -> match_meta sb m_sb terms1 terms2 | Func (f,args1)::terms1, Func (g,args2)::terms2 when f=g -> match_meta sb m_sb (args1 @ terms1) (args2 @ terms2) | term::terms1, MVar x::terms2 -> @@ -817,9 +814,17 @@ if List.mem_assoc x sb then if List.assoc x sb = term then sb else raise Not_found - else sb1::List.map (fun (x,t)->x, subst_one sb1 t) sb in + else sb1::sb in match_meta sb m_sb terms1 terms2 - | _ -> raise Not_found + | _ -> + (* {{{ log entry *) + if !debug_level > 4 then ( + Printf.printf "match_meta: unmatched (%s) against pattern (%s)\n%!" + (String.concat ", " (List.map term_str terms1)) + (String.concat ", " (List.map term_str terms2)) + ); + (* }}} *) + raise Not_found (* 3c1 *) @@ -1055,14 +1060,14 @@ | Var x -> if List.mem_assoc x !sb then Var (List.assoc x !sb) else - let x1 = Aux.not_conflicting_name !var_support x in + let x1 = Aux.not_conflicting_name ~truncate:true !var_support x in var_support := Aux.Strings.add x1 !var_support; sb := (x,x1)::!sb; Var x1 | MVar x -> if List.mem_assoc x !sb then MVar (List.assoc x !sb) else - let x1 = Aux.not_conflicting_name !var_support x in + let x1 = Aux.not_conflicting_name ~truncate:true !var_support x in var_support := Aux.Strings.add x1 !var_support; sb := (x,x1)::!sb; MVar x1 @@ -1076,7 +1081,7 @@ List.map (fun x -> if List.mem_assoc x !sb then List.assoc x !sb else - let x1 = Aux.not_conflicting_name !var_support x in + let x1 = Aux.not_conflicting_name ~truncate:true !var_support x in var_support := Aux.Strings.add x1 !var_support; sb := (x,x1)::!sb; x1 ) (Aux.Strings.elements vs) in @@ -1781,7 +1786,7 @@ let conjs = Aux.unique_sorted (Aux.concat_map FormulaOps.flatten_ands conjs) in (* {{{ log entry *) - if !debug_level > 2 then ( + if !debug_level > 4 then ( Printf.printf "lift_universal: vars %s -- conjs:\n%s\n%!" (String.concat ", " (List.map Formula.var_str (uni_vars :> Formula.var list))) @@ -1802,7 +1807,7 @@ Formula.And (global @ [ Formula.All (used_uni_vars, Formula.And local)]) in (* {{{ log entry *) - if !debug_level > 2 then ( + if !debug_level > 4 then ( Printf.printf "lift_universal: result\n%s\n%!" (Formula.sprint res) ); @@ -2426,25 +2431,45 @@ not (Aux.Strings.mem v fixed_vars)) sb with Not_found -> false in let frames = - Aux.maximal leq3 frame_brs in - let frames = - List.map (fun repr -> - List.filter (fun cl->leq3 cl repr) frame_brs) - frames in + Aux.unique_sorted + (List.map (fun repr -> + List.filter (fun cl->leq3 cl repr) frame_brs) + frame_brs) in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "frames: heads partitioning =\n%s\n%!" + (String.concat "\n" + (List.map (fun l -> + String.concat ", " + (List.map (function [head],_,_->term_str head + | _ -> assert false) l)) frames)) + ); + (* }}} *) (* collect and rename multi-bodies *) let frames = List.map (function | [] -> assert false | [head, body, neg_body] -> head, [body, neg_body] - | (head, body, neg_body)::f_brs -> + | f_brs -> + let repr_head = + match Aux.maximal leq3 f_brs with + | [head, _, _] -> head + | _ -> assert false in let multi_body = List.map (fun (head2, body2, neg_body2) -> - let sb, _ = match_meta [] [] head head2 in + let sb, _ = match_meta [] [] repr_head head2 in subst_rels sb body2, List.map (fun (uni_vs,neg) -> uni_vs, subst_rels sb neg) neg_body2 ) f_brs in - head, (body, neg_body)::multi_body + repr_head, multi_body ) frames in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "frames: heads = %s\n%!" + (String.concat ", " (List.map (function [h],_ ->term_str h + | _ -> assert false) frames)) + ); + (* }}} *) (* 7f3 *) let erasure_brs : exp_def_branch list = Aux.concat_map (function Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-02-25 00:02:36 UTC (rev 1333) +++ trunk/Toss/GGP/GDLTest.ml 2011-02-26 12:52:28 UTC (rev 1334) @@ -113,5 +113,6 @@ DiscreteRule.debug_level := 4; let breakthrough = load_rules "./GGP/examples/breakthrough.gdl" in let connect5 = load_rules "./GGP/examples/connect5.gdl" in + let tictactoe = load_rules "./GGP/examples/tictactoe.gdl" in let gdef = GDL.translate_game (Const "x") connect5 in - ignore gdef; ignore connect5; ignore breakthrough + ignore gdef; ignore connect5; ignore breakthrough; ignore tictactoe This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-02-28 01:18:23
|
Revision: 1335 http://toss.svn.sourceforge.net/toss/?rev=1335&view=rev Author: lukaszkaiser Date: 2011-02-28 01:18:17 +0000 (Mon, 28 Feb 2011) Log Message: ----------- Better cache in Solver, other small corrections. Modified Paths: -------------- trunk/Toss/Formula/FormulaOps.ml trunk/Toss/Formula/FormulaOps.mli trunk/Toss/Play/GameTree.ml trunk/Toss/Play/GameTree.mli trunk/Toss/Play/GameTreeTest.ml trunk/Toss/Solver/Solver.ml trunk/Toss/Solver/Solver.mli trunk/Toss/Solver/Structure.ml Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-02-26 12:52:28 UTC (rev 1334) +++ trunk/Toss/Formula/FormulaOps.ml 2011-02-28 01:18:17 UTC (rev 1335) @@ -121,34 +121,37 @@ (* Map [f] to all literals (i.e. atoms or not(atom)'s) in the given formula. Preserves order of subformulas. *) -let rec map_to_literals f = function +let rec map_to_literals f g = function Rel _ | Eq _ | In _ as x -> f x | Not (Rel _) | Not (Eq _) | Not (In _) as x -> f x - | Not (RealExpr (r, s)) -> Not (RealExpr (map_to_literals_expr f r, s)) - | Not phi -> Not (map_to_literals f phi) - | Or flist -> Or (List.map (map_to_literals f) flist) - | And flist -> And (List.map (map_to_literals f) flist) - | Ex (vs, phi) -> Ex (vs, map_to_literals f phi) - | All (vs, phi) -> All (vs, map_to_literals f phi) - | RealExpr (r, s) -> RealExpr (map_to_literals_expr f r, s) + | Not (RealExpr (r, s)) -> Not (RealExpr (map_to_literals_expr f g r, s)) + | Not phi -> Not (map_to_literals f g phi) + | Or flist -> Or (List.map (map_to_literals f g) flist) + | And flist -> And (List.map (map_to_literals f g) flist) + | Ex (vs, phi) -> Ex (vs, map_to_literals f g phi) + | All (vs, phi) -> All (vs, map_to_literals f g phi) + | RealExpr (r, s) -> RealExpr (map_to_literals_expr f g r, s) -and map_to_literals_expr f = function - | RVar _ | Const _ | Fun _ as x -> x +and map_to_literals_expr f g = function + | RVar _ | Const _ | Fun _ as x -> g x | Times (r1, r2) -> - Times (map_to_literals_expr f r1, map_to_literals_expr f r2) + Times (map_to_literals_expr f g r1, map_to_literals_expr f g r2) | Plus (r1, r2) -> - Plus (map_to_literals_expr f r1, map_to_literals_expr f r2) - | Char (phi) -> Char (map_to_literals f phi) + Plus (map_to_literals_expr f g r1, map_to_literals_expr f g r2) + | Char (phi) -> Char (map_to_literals f g phi) | Sum (vs, phi, r) -> - Sum (vs, map_to_literals f phi, map_to_literals_expr f r) + Sum (vs, map_to_literals f g phi, map_to_literals_expr f g r) (* Map [f] to all atoms in the given formula. *) +let map_to_atoms_full f g phi = + map_to_literals (function Not (x) -> Not (f x) | x -> f x) g phi + let map_to_atoms f phi = - map_to_literals (function Not (x) -> Not (f x) | x -> f x) phi + map_to_literals (function Not (x) -> Not (f x) | x -> f x) (fun x -> x) phi let map_to_atoms_expr f r = - map_to_literals_expr (function Not (x) -> Not (f x) | x -> f x) r + map_to_literals_expr (function Not (x) -> Not (f x) | x -> f x) (fun x -> x) r (* Map [f] to all variables occurring in the formula. Preserves order of subformulas. *) Modified: trunk/Toss/Formula/FormulaOps.mli =================================================================== --- trunk/Toss/Formula/FormulaOps.mli 2011-02-26 12:52:28 UTC (rev 1334) +++ trunk/Toss/Formula/FormulaOps.mli 2011-02-28 01:18:17 UTC (rev 1335) @@ -21,10 +21,14 @@ (** Map [f] to all literals (i.e. atoms or not(atom)'s) in the given formula. Preserves order of subformulas. *) -val map_to_literals : (formula -> formula) -> formula -> formula -val map_to_literals_expr : (formula -> formula) -> real_expr -> real_expr +val map_to_literals : (formula -> formula) -> (real_expr -> real_expr) -> + formula -> formula +val map_to_literals_expr : (formula -> formula) -> (real_expr -> real_expr) -> + real_expr -> real_expr (** Map [f] to all atoms in the given formula. *) +val map_to_atoms_full : (formula -> formula) -> (real_expr -> real_expr) -> + formula -> formula val map_to_atoms : (formula -> formula) -> formula -> formula val map_to_atoms_expr : (formula -> formula) -> real_expr -> real_expr Modified: trunk/Toss/Play/GameTree.ml =================================================================== --- trunk/Toss/Play/GameTree.ml 2011-02-26 12:52:28 UTC (rev 1334) +++ trunk/Toss/Play/GameTree.ml 2011-02-28 01:18:17 UTC (rev 1335) @@ -6,8 +6,8 @@ (* Abstract game tree, just stores state and move information. *) type ('a, 'b) abstract_game_tree = | Terminal of Arena.game_state * int * 'b (* terminal state with player *) - | Leaf of Arena.game_state * int * Solver.cachetbl * 'a - (* leaf with state, player, cache and info *) + | Leaf of Arena.game_state * int * 'a + (* leaf with state, player, and info *) | Node of Arena.game_state * int * 'a * (Move.move * ('a, 'b) abstract_game_tree) array (* node with state, player, moves and info *) @@ -24,7 +24,7 @@ match tree with | Terminal (state, player, info) -> s "Terminal. " state player (str_info_terminal info) - | Leaf (state, player, _, info) -> s "Leaf. " state player (str_info info) + | Leaf (state, player, info) -> s "Leaf. " state player (str_info info) | Node (state, player, info, children) -> let next_str (_, t) = str_abstract ~depth:(depth+1) str_info str_info_terminal t in @@ -40,37 +40,36 @@ (* Player in the given node. *) let player = function | Terminal (_, player, _) -> player - | Leaf (_, player, _, _) -> player + | Leaf (_, player, _) -> player | Node (_, player, _, _) -> player (* State in the given node. *) let state = function | Terminal (state, _, _) -> state - | Leaf (state, _, _, _) -> state + | Leaf (state, _, _) -> state | Node (state, _, _, _) -> state (* Abstract game tree initialization. *) let init_abstract game state info_leaf = let player = game.Arena.graph.(state.Arena.cur_loc).Arena.player in - let info, cache = info_leaf game state player in - Leaf (state, player, cache, info) + let info = info_leaf game state player in + Leaf (state, player, info) (* Abstract game tree unfolding function, calls argument functions for work. *) let rec unfold_abstract ?(depth=0) game ~info_terminal ~info_leaf ~info_node ~choice = function | Terminal _ -> raise Not_found - | Leaf (state, player, cache, info) -> - Solver.set_cache (state.Arena.struc, cache); + | Leaf (state, player, info) -> let moves = Move.list_moves game state in if moves = [||] then Terminal (state, player, info_terminal depth game state player info) else let leaf_of_move leaf_s = let l_pl = game.Arena.graph.(leaf_s.Arena.cur_loc).Arena.player in - let l_info, cache = info_leaf (depth+1) game leaf_s l_pl in - Leaf (leaf_s, l_pl, cache, l_info) in + let l_info = info_leaf (depth+1) game leaf_s l_pl in + Leaf (leaf_s, l_pl, l_info) in let children = Array.map (fun (m, s) -> (m, leaf_of_move s)) moves in Node (state, player,info_node depth game state player children,children) | Node (state, player, info, children) -> @@ -113,13 +112,13 @@ (* Get the payoffs / heuristics array of a game tree node. *) let node_values = function | Terminal (_, _, i) -> Array.map (fun p -> !cPAYOFF_AS_HEUR *. p) i.payoffs - | Leaf (_, _, _, i) -> i.heurs + | Leaf (_, _, i) -> i.heurs | Node (_, _, i, _) -> i.heurs (* Get the stored information of a game tree node. *) let node_info = function | Terminal (_, _, i) -> i.info_t - | Leaf (_, _, _, i) -> i.info + | Leaf (_, _, i) -> i.info | Node (_, _, i, _) -> i.info @@ -130,7 +129,7 @@ let res = { heurs = Array.map calc heurs.(state.Arena.cur_loc); info = f depth game state } in - (res, snd (Solver.get_cache ())) + res let init game state f h = init_abstract game state (info_leaf_f f h 0) @@ -167,7 +166,7 @@ (* Choose one of the maximizing moves (at random) given a game tree. *) let choose_move game = function | Terminal _ -> raise Not_found - | Leaf (state, _, _, _) -> + | Leaf (state, _, _) -> Aux.random_elem (Array.to_list (Move.list_moves game state)) | Node (_, p, info, succ) -> let mval = info.heurs.(p) in Modified: trunk/Toss/Play/GameTree.mli =================================================================== --- trunk/Toss/Play/GameTree.mli 2011-02-26 12:52:28 UTC (rev 1334) +++ trunk/Toss/Play/GameTree.mli 2011-02-28 01:18:17 UTC (rev 1335) @@ -5,8 +5,8 @@ (** Abstract game tree, just stores state and move information. *) type ('a, 'b) abstract_game_tree = | Terminal of Arena.game_state * int * 'b (** terminal state with player *) - | Leaf of Arena.game_state * int * Solver.cachetbl * 'a - (** leaf with state, player, moves and info *) + | Leaf of Arena.game_state * int * 'a + (** leaf with state, player, and info *) | Node of Arena.game_state * int * 'a * (Move.move * ('a, 'b) abstract_game_tree) array (** node with state, player, moves *) @@ -27,14 +27,13 @@ (** Abstract initialization function. *) val init_abstract : Arena.game -> Arena.game_state -> - (Arena.game -> Arena.game_state -> int -> 'a * Solver.cachetbl) -> + (Arena.game -> Arena.game_state -> int -> 'a) -> ('a, 'b) abstract_game_tree (** Abstract game tree unfolding function, calls argument functions for work. *) val unfold_abstract : ?depth:int -> Arena.game -> info_terminal : (int -> Arena.game -> Arena.game_state -> int -> 'a -> 'b) -> - info_leaf : (int -> Arena.game -> Arena.game_state -> int -> - 'a * Solver.cachetbl) -> + info_leaf : (int -> Arena.game -> Arena.game_state -> int -> 'a) -> info_node : (int -> Arena.game -> Arena.game_state -> int -> (Move.move * ('a, 'b) abstract_game_tree) array -> 'a) -> choice : (int -> Arena.game -> Arena.game_state -> int -> 'a -> Modified: trunk/Toss/Play/GameTreeTest.ml =================================================================== --- trunk/Toss/Play/GameTreeTest.ml 2011-02-26 12:52:28 UTC (rev 1334) +++ trunk/Toss/Play/GameTreeTest.ml 2011-02-28 01:18:17 UTC (rev 1335) @@ -17,13 +17,13 @@ "abstract tree init, to string" >:: (fun () -> let s = {Arena.struc=Structure.empty_structure(); cur_loc=0; time=0.} in - let t = Leaf (s, 1, Hashtbl.create 1, 5) in + let t = Leaf (s, 1, 5) in assert_equal ~printer:(fun x -> x) "\n|| Leaf. Player 1 loc 0 time 0.0.\n|| [ | | ]\n|| 5" (GameTree.str_abstract ~depth:2 string_of_int string_of_int t); let (g, s) = state_of_file "./examples/Tic-Tac-Toe.toss" in - let t = GameTree.init_abstract g s (fun _ _ _ -> 5, Hashtbl.create 1) in + let t = GameTree.init_abstract g s (fun _ _ _ -> 5) in assert_equal ~printer:(fun x -> x) ("\nLeaf. Player 0 loc 0 time 0.0.\n[ | P:1 {}; Q:1 {} | ] \"\n" ^ "\t \n\t. . . \n" ^ @@ -35,9 +35,9 @@ "abstract unfold, size" >:: (fun () -> let (g, s) = state_of_file "./examples/Tic-Tac-Toe.toss" in - let t = GameTree.init_abstract g s (fun _ _ _ -> 5, Hashtbl.create 1) in + let t = GameTree.init_abstract g s (fun _ _ _ -> 5) in let i_t = (fun _ _ _ _ _ -> 0) in - let i_l = (fun _ _ _ _ -> 1, Hashtbl.create 1) in + let i_l = (fun _ _ _ _ -> 1) in let (i_n, ch) = (fun _ _ _ _ _ -> 2), (fun _ _ _ _ _ _ -> 0) in let u = GameTree.unfold_abstract g i_t i_l i_n ch t in (* print_endline (GameTree.str_abstract string_of_int string_of_int u);*) Modified: trunk/Toss/Solver/Solver.ml =================================================================== --- trunk/Toss/Solver/Solver.ml 2011-02-26 12:52:28 UTC (rev 1334) +++ trunk/Toss/Solver/Solver.ml 2011-02-28 01:18:17 UTC (rev 1335) @@ -10,7 +10,8 @@ (* CACHE *) -type cachetbl = (Formula.formula, Assignments.assignment_set) Hashtbl.t +type cachetbl = + (Formula.formula, Assignments.assignment_set * string list option) Hashtbl.t let cache_struc = ref (empty_structure ()) let cache_results = ref (Hashtbl.create 15) @@ -232,20 +233,55 @@ let eval_counter = ref 0 +let diffrels_struc s1 s2 = + if Structure.equal { s1 with relations = StringMap.empty; } + { s2 with relations = StringMap.empty; } then + let is_eq_in2 rel tp = + try + Structure.Tuples.equal (Structure.StringMap.find rel s2.relations) tp + with Not_found -> false in + let diffrels = ref [] in + let appdiff r tp = if not (is_eq_in2 r tp) then diffrels := r::!diffrels in + Structure.StringMap.iter appdiff s1.relations; + if !debug_level > 1 then + print_endline ("SOME DIFF: " ^ (String.concat ", " !diffrels)); + Some (!diffrels) + else None + +let phi_rels phi = + let rels = ref [] in + let app_rel = function Rel (s, _) as r -> rels := s :: !rels; r | x -> x in + let app_re = function Fun _ -> raise Not_found | x -> x in + try + let _ = FormulaOps.map_to_atoms_full app_rel app_re phi in + let rs = Aux.unique_sorted !rels in + if !debug_level > 1 then + print_endline ("F: " ^ (Formula.str phi) ^" "^ (String.concat ", " rs)); + Some rs + with Not_found -> None + (* Eval with very basic caching. *) let eval_m struc phi = - if phi = And [] then Any else - if !cache_struc != struc then ( - let els = Set (Elems.cardinal struc.elements, struc.elements) in - let asg = eval struc (ref els) Any phi in - incr eval_counter; - cache_struc := struc; - Hashtbl.clear !cache_results; - Hashtbl.add !cache_results phi asg; - asg - ) else + if phi = And [] then Any else ( + if not (Structure.equal !cache_struc struc) then ( + match diffrels_struc struc !cache_struc with + | None -> + cache_struc := struc; + Hashtbl.clear !cache_results; + | Some rs -> + cache_struc := struc; + let is_bad (_, prs_opt) = + match prs_opt with + | None -> true + | Some prs -> List.exists (fun r -> List.mem r rs) prs in + let ok = ref [] in + Hashtbl.iter (fun p r -> if is_bad r then () else ok := (p, r)::!ok) + !cache_results; + Hashtbl.clear !cache_results; + List.iter (fun (p, r) -> Hashtbl.add !cache_results p r) !ok + ); try - let res = Hashtbl.find !cache_results phi in + let (res, _) = Hashtbl.find !cache_results phi in if !debug_level > 1 then ( print_endline ("found in cache: " ^ (Formula.str phi)); ); @@ -255,8 +291,9 @@ let els = Set (Elems.cardinal struc.elements, struc.elements) in let asg = eval struc (ref els) Any phi in incr eval_counter; - Hashtbl.add !cache_results phi asg; + Hashtbl.add !cache_results phi (asg, phi_rels phi); asg + ) (* Helper function, assignment of tuple. *) let asg_of_tuple struc vars tuple = Modified: trunk/Toss/Solver/Solver.mli =================================================================== --- trunk/Toss/Solver/Solver.mli 2011-02-26 12:52:28 UTC (rev 1334) +++ trunk/Toss/Solver/Solver.mli 2011-02-28 01:18:17 UTC (rev 1335) @@ -8,7 +8,8 @@ (** {2 Evaluation} *) -type cachetbl = (Formula.formula, Assignments.assignment_set) Hashtbl.t +type cachetbl = + (Formula.formula, Assignments.assignment_set * string list option) Hashtbl.t val eval_counter : int ref val get_cache : unit -> Structure.structure * cachetbl Modified: trunk/Toss/Solver/Structure.ml =================================================================== --- trunk/Toss/Solver/Structure.ml 2011-02-26 12:52:28 UTC (rev 1334) +++ trunk/Toss/Solver/Structure.ml 2011-02-28 01:18:17 UTC (rev 1335) @@ -41,9 +41,9 @@ let compare s1 s2 = if s1 == s2 then 0 else - let c = Elems.compare s1.elements s2.elements in + let c = StringMap.compare Tuples.compare s1.relations s2.relations in if c <> 0 then c else - let d = StringMap.compare Tuples.compare s1.relations s2.relations in + let d = Elems.compare s1.elements s2.elements in if d <> 0 then d else StringMap.compare (IntMap.compare Pervasives.compare) s1.functions s2.functions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-02-28 22:04:26
|
Revision: 1337 http://toss.svn.sourceforge.net/toss/?rev=1337&view=rev Author: lukstafi Date: 2011-02-28 22:04:19 +0000 (Mon, 28 Feb 2011) Log Message: ----------- GDL trasnlation: affine shift of payoffs; handle GDL relation <distinct> (somewhat ignoring it); action translation bug fixes. Aux: optional nicer fresh names; update_assoc bug fix. DiscreteRule: translation from precond (for GDL) bug fix; more logging. Game: settable default effort; random move bug fix. Modified Paths: -------------- trunk/Toss/Arena/DiscreteRule.ml trunk/Toss/Arena/DiscreteRuleTest.ml trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/AuxTest.ml trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDLTest.ml trunk/Toss/Play/Game.ml trunk/Toss/Play/Game.mli trunk/Toss/Server/ServerGDLTest.in trunk/Toss/Server/ServerGDLTest.out trunk/Toss/Server/ServerTest.ml Added Paths: ----------- trunk/Toss/Server/ServerGDLTest.in2 trunk/Toss/Server/ServerGDLTest.out2 Modified: trunk/Toss/Arena/DiscreteRule.ml =================================================================== --- trunk/Toss/Arena/DiscreteRule.ml 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Arena/DiscreteRule.ml 2011-02-28 22:04:19 UTC (rev 1337) @@ -459,11 +459,11 @@ let ldmap = List.map find_fst_name matching in match rlmap with | None -> - (* [ldmap = rmmap] *) + (* [ldmap = rmmap] *) rewrite_nonstruct model ldmap rule_obj.rhs_pos_tuples - rule_obj.rhs_neg_tuples rule_obj.rhs_elem_names + rule_obj.rhs_neg_tuples rule_obj.rhs_elem_names | Some rlmap -> - rewrite_emb model ldmap rlmap rule_obj + rewrite_emb model ldmap rlmap rule_obj (** {2 Building a rule.} *) @@ -530,7 +530,7 @@ (or "keep") the tuple if R is present on the RHS - when both _opt_R and R are present over a single tuple, or when - _opt_R is only present on the RHS, is an error (or unspecified) + _opt_R is only present on the RHS, it is an error (or unspecified) Another set of special relations is used to compactly specify which optional relations should be considered as present. The special @@ -563,7 +563,15 @@ if List.mem_assoc rel defined_rels then let args, _, rphi = List.assoc rel defined_rels in List.map fst (List.filter (fun (rel, ar) -> - Solver.M.check_formula (Structure.free_for_rel rel ar) rphi + let selector = Structure.free_for_rel rel ar in + let res = Solver.M.check_formula selector rphi in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "compile_rule.expand_def_rels: %s on %s = %b\n%!" + rel (Structure.str selector) res + ); + (* }}} *) + res ) signat) else [rel] in let expand_defrel_tups (drel, tups) = @@ -575,6 +583,13 @@ let selector = Structure.free_for_rel brel ar in let asgn = Solver.M.evaluate selector rphi in + (* {{{ log entry *) + if !debug_level > 3 && asgn<>AssignmentSet.Empty then ( + Printf.printf "compile_rule.expand_defrel_tups: %s {%s} over\ + %s = %s\n%!" drel (Solver.M.formula_str rphi) (Structure.str selector) + (AssignmentSet.str asgn) + ); + (* }}} *) let btup = Array.init ar (fun i->i+1) in (* [selector] has only [btup] with its elements *) let selvars = @@ -929,7 +944,7 @@ lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = emb_rels; - rule_s = []; + rule_s = List.map (fun (_,i) ->i,i) struc_elems; pre = precond; } Modified: trunk/Toss/Arena/DiscreteRuleTest.ml =================================================================== --- trunk/Toss/Arena/DiscreteRuleTest.ml 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Arena/DiscreteRuleTest.ml 2011-02-28 22:04:19 UTC (rev 1337) @@ -705,6 +705,6 @@ let a () = DiscreteRule.debug_level := 7 let a () = - match (test_filter ["DiscreteRule:4:rewrite: compile_rule integers"] tests) with + match (test_filter ["DiscreteRule:13:compile_rule: defined relations"] tests) with | Some tests -> ignore (run_test_tt ~verbose:true tests) | None -> () Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Formula/Aux.ml 2011-02-28 22:04:19 UTC (rev 1337) @@ -144,9 +144,9 @@ else aux (pair :: acc) l in aux [] l -let rec update_assoc k v0 f l = +let update_assoc k v0 f l = let rec aux acc = function - | [] -> [k, f v0] + | [] -> List.rev_append acc [k, f v0] | (a, b as pair) :: l -> if compare a k = 0 then List.rev_append acc ((k, f b)::l) else aux (pair :: acc) l in Modified: trunk/Toss/Formula/AuxTest.ml =================================================================== --- trunk/Toss/Formula/AuxTest.ml 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Formula/AuxTest.ml 2011-02-28 22:04:19 UTC (rev 1337) @@ -112,9 +112,16 @@ (fun () -> Aux.pop_assq g ["B","f";"G", "T0"; "C","B"; "F","Ts"]); + assert_equal ~msg:"update_assoc: two-level path" + [(7, [('b', ["ha"])])] + (Aux.update_assoc 7 [] (Aux.update_assoc 'b' [] (Aux.cons "ha")) []); + assert_equal ~msg:"update_assoc: two-level trie" - [(7, [('b', ["ha"])])] - (Aux.update_assoc 7 [] (Aux.update_assoc 'b' [] (Aux.cons "ha")) []) + [(1, [("a", [4; 4]); ("b", [4])]); (2, [("b", [4])])] + (List.fold_left (fun acc (path,t) -> + Aux.update_assoc t [] + (Aux.update_assoc path [] (Aux.cons 4)) acc + ) [] ["a",1; "b",2; "b",1; "a",1]) ); "unsome, map_try" >:: Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/GGP/GDL.ml 2011-02-28 22:04:19 UTC (rev 1337) @@ -350,6 +350,9 @@ (4b) relations is a necessary "heuristic". Whether to extend it to constant subterms (see above) is not clear. + (7i0) Heuristic (reason for unsoundness): for "distinct", only + check whether its arguments are syntactically equal. + (7i1) Remove branches that are unsatisfiable by their static relations (4a), (4b) and (positive) (4c) alone. @@ -429,12 +432,20 @@ variables (both static and dynamic) using (6); fail if a goal value cannot be determined. - (8a) The payoff formula is the sum of "goal" value times the - characterisic function of the corresponding "goal" bodies. We do - not translate the body if the value is zero (we drop the zero goal - branches from the definition). For each goal value we collect - bodies to form a disjunction. + (8a) Filter-out goal branches that are contradictory with the + terminal condition (using resolution on the GDL + side). Implementation TODO. + (8b) For each goal value we collect bodies to form a disjunction. + + (8c) The payoff formula is the sum of "goal" value times the + characterisic function of the corresponding "goal" bodies. To + simplify the result, we find the longest formula, and center the + payoff around it: for the goal value V_i if i-th formula phi_i and + phi_K being the longest formula, we translate the payoff into "K + + (V_1 - V_K) :(phi_1) + ... (V_n - V_K) :(phi_n)" thus removing + phi_K from translation. + (9) To translate an incoming action, we: (9a) find the "lead legal" term to which the "does move" ground @@ -488,6 +499,10 @@ (** Expand static relations that do not have ground facts and have arity above the threshold. *) let expand_arity_above = ref 0 +(** Generate all tuples for equivalences, to faciliate further + transformations of formulas in the game definition (outside of + translation). *) +let equivalences_all_tuples = ref false type term = | Const of string @@ -796,18 +811,20 @@ (* 3d *) (* Match the first argument as term against the second argument as pattern. Allow nonlinear (object) variables. *) -let rec match_meta sb m_sb terms1 terms2 = +let rec match_meta ?(ignore_meta=false) sb m_sb terms1 terms2 = match terms1, terms2 with | [], [] -> sb, m_sb | (Const _ (* | Var _ *) as a)::terms1, (Const _ (* | Var _ *) as b)::terms2 - when a=b -> match_meta sb m_sb terms1 terms2 + when a=b -> match_meta ~ignore_meta sb m_sb terms1 terms2 | Func (f,args1)::terms1, Func (g,args2)::terms2 when f=g -> - match_meta sb m_sb (args1 @ terms1) (args2 @ terms2) + match_meta ~ignore_meta sb m_sb (args1 @ terms1) (args2 @ terms2) | term::terms1, MVar x::terms2 -> (* we don't substitute because metavariables are linear *) - match_meta sb ((x, term)::m_sb) terms1 terms2 - | MVar _::_, _ -> raise Not_found + match_meta ~ignore_meta sb ((x, term)::m_sb) terms1 terms2 + | MVar _::terms1, _::terms2 -> + if ignore_meta then match_meta ~ignore_meta sb m_sb terms1 terms2 + else raise Not_found | term::terms1, Var x::terms2 -> let sb1 = x, term in let sb = @@ -815,7 +832,7 @@ if List.assoc x sb = term then sb else raise Not_found else sb1::sb in - match_meta sb m_sb terms1 terms2 + match_meta ~ignore_meta sb m_sb terms1 terms2 | _ -> (* {{{ log entry *) if !debug_level > 4 then ( @@ -872,17 +889,27 @@ | Func (f, args) -> Func (f, List.map (subst sb) args) -let unify_rels (rel1, args1) (rel2, args2) = - if rel1 = rel2 then unify [] args1 args2 - else raise Not_found +let extend_sb sb1 sb = Aux.map_prepend sb1 (fun (x,t)->x, subst sb1 t) sb +let rec unify_all sb = function + | [] | [_] -> sb + | t1::t2::tl -> + let t1 = subst sb t1 in + let t2 = subst sb t2 in + let sb = unify sb [t1] [t2] in + unify_all sb ((subst sb t2)::tl) + + let unifies term1 term2 = try ignore (unify [] [term1] [term2]); true with Not_found -> false +let unify_rels (rel1, args1) (rel2, args2) = + if rel1 = rel2 then unify [] args1 args2 + else raise Not_found + let subst_rel sb (rel, args) = rel, List.map (subst sb) args let subst_rels sb body = List.map (subst_rel sb) body -let extend_sb sb1 sb = Aux.map_prepend sb1 (fun (x,t)->x, subst sb1 t) sb let compose_sb sb1 sb2 = let vars1, terms1 = List.split sb1 in @@ -1359,7 +1386,7 @@ let find_cycle cands = (* {{{ log entry *) - if !debug_level > -1 then ( + if !debug_level > 0 then ( Printf.printf "GDL.find_cycle: %s\n%!" (String.concat ", " ( List.map (function Some c -> term_str c | None -> "None") cands)) ); @@ -1509,7 +1536,6 @@ List.map (fun (sb, br) -> sb, freshen_branch br) brs | _ -> brs - let translate_branches struc masks playout_terms static_rnames dyn_rels (brs : exp_def_branch list) = (* 7i *) @@ -1603,9 +1629,18 @@ let vars = Aux.unique_sorted (List.map (fun t -> snd (toss_var masks t)) terms) in constrained_vars := vars @ !constrained_vars; - (* (4b) are equivalences, so we just build a "star" *) - let tups = match vars with [] -> [] - | v::vs -> List.map (fun w -> [|v; w|]) vs in + let tups = + if !equivalences_all_tuples + then + (* generating more relations to faciliate "contraction" of + co-occurring relations in GameSimpl, which will also clean + the redundant atoms *) + Aux.concat_map (fun v -> Aux.map_some (fun w -> + if v=w then None else Some [|v; w|]) vars) vars + else + (* (4b) are equivalences, so we just build a "star" *) + match vars with [] -> [] + | v::vs -> List.map (fun w -> [|v; w|]) vs in List.map (fun tup -> Formula.Rel (rname, tup)) tups ) terms ) path_subterms in @@ -1654,11 +1689,17 @@ else if rel = "_DOES_PLACEHOLDER_" then [] else if List.mem rel static_rnames then - (* 7i-4a *) + (* 7i-4a *) List.map (fun c -> Formula.Not c) (conjs_4a rel args) - else - (* dynamic relations have been expanded *) - assert false + else if rel = "distinct" then + (* 7i0 *) + if Aux.not_unique args then [Formula.Or []] + else [] + else ( + (* dynamic relations have been expanded *) + Printf.printf + "translate_game: (7i) unexpected dynamic %s\n%!" rel; + assert false) | _ -> []) neg_body in let all_conjs = phi @ conjs @ neg_conjs in let phi = Formula.And all_conjs in @@ -1729,6 +1770,10 @@ ) m_sb else if List.mem rel static_rnames || rel = "_DOES_PLACEHOLDER_" then [] + else if rel = "distinct" then + (* 7i0 *) + if Aux.not_unique args then [Formula.Or []] + else [] else ( Printf.printf "\nunexpected_dynamic: %s\n%!" rel; (* dynamic relations have been expanded *) @@ -1768,9 +1813,15 @@ (* 7i-4a *) Some (Formula.And ( List.map (fun c -> Formula.Not c) (conjs_4a rel args))) - else + else if rel = "distinct" then + (* 7i0 *) + if Aux.not_unique args then Some (Formula.Or []) + else None + else ( (* dynamic relations have been expanded *) - assert false + Printf.printf + "translate_game: (7k) unexpected dynamic %s\n%!" rel; + assert false) ) neg_conjs in match disjs with | [] -> None @@ -1832,10 +1883,6 @@ let static_rules, dynamic_rules, static_base, init_state, (agg_actions, agg_states) = aggregate_playout player_terms 30 rules in - (* (8) -- drop zero goal branches, "first round" *) - let dynamic_rules = List.filter - (function ("goal", [_; Const "0"]), _, _ -> false | _ -> true) - dynamic_rules in let element_terms : term list = List.fold_left (fun acc st -> Aux.unique_sorted (st @ acc)) [] agg_states in @@ -2480,8 +2527,6 @@ Printf.printf "Blanking-out of %s by %s\n%!" (term_str next_arg) (term_str mask) ); - (* }}} *) - (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "Frame multibody:\n%s\n%!" ( String.concat "\n" (List.map ( @@ -2828,12 +2873,14 @@ List.map (fun (player, goal_brs) -> player, Aux.collect goal_brs) (Aux.collect goal_brs) in let payoffs = List.map (fun (player, goals) -> - let payoff = List.fold_left (fun sum (score, brs) -> + let payoff = List.map (fun (score, brs) -> let score = match score with | Const pay -> (try float_of_string pay with _ -> assert false) | _ -> assert false in + (* 8a: TODO *) + (* 8b *) (* FIXME: should we expand before, with [~freshen_unfixed:(Aux.Left true)]? *) let goal_uni_vars, goal_4b, brs = @@ -2847,10 +2894,34 @@ let disj = lift_universal goal_uni_vars (disj_4b @ conjs) in Formula.Ex (FormulaOps.free_vars disj, disj) ) brs in - let guard = Formula.Or goal_disjs in - Formula.Plus (sum, Formula.Times ( - Formula.Const score, Formula.Char guard)) - ) (Formula.Const 0.) goals in + score, Formula.Or goal_disjs + ) goals in + (* 8c *) + let sized = + List.map (fun (score,phi) -> FormulaOps.size phi, score) payoff in + let cmp (s1,v1) (s2,v2) = + if s2-s1 = 0 then Pervasives.compare v1 v2 else s2-s1 in + let base_score = + match List.sort cmp sized with [] -> 0. + | (_, score)::_ -> score in + let payoff = match payoff with + | [score, guard] -> + Formula.Times ( + Formula.Const score, Formula.Char guard) + | scores -> + List.fold_left (fun sum (score, guard) -> + if score = base_score then ( + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "translate_game: (8) dropping score %f guard:\n%s\n\n%!" + score (Formula.sprint guard) + ); + (* }}} *) + sum) + else Formula.Plus (sum, Formula.Times ( + Formula.Const (score -. base_score), Formula.Char guard))) + (Formula.Const base_score) scores in player, payoff ) player_goals in @@ -2912,14 +2983,27 @@ let fixvar_elemvars = List.fold_left (fun acc (evar,elem) -> let mask, sb, m_sb, blank = term_to_blank masks elem in - List.fold_left (fun acc (path,t) -> - match t with - | Var v -> - Aux.update_assoc v [] - (Aux.update_assoc mask [] - (Aux.update_assoc path [] (Aux.cons evar))) acc - | _ -> acc - ) acc sb + let res = + List.fold_left (fun acc (path,t) -> + match t with + | Var v -> + Aux.update_assoc v [] + (Aux.update_assoc mask [] + (Aux.update_assoc path [] (Aux.cons evar))) acc + | _ -> acc + ) acc sb in + (* {{{ log entry *) + if !debug_level > 4 then ( + Printf.printf "fixvars: elem=%s; sb=%s\n%!" + (term_str elem) + (String.concat "; " + (List.map (fun (v,ts)-> v^": "^ + String.concat ", " + (List.map (fun (t,_)->term_str t) ts) + ) res)) + ); + (* }}} *) + res ) [] var_elems in tossrule_data := Aux.StrMap.add rname { @@ -3049,12 +3133,28 @@ match tossrules with | [lead, tossrules] -> lead, tossrules | _ -> assert false in + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "GDL.translate_incoming_move: action=%s; lead=%s\n%!" + (term_str player_action) (term_str lead) + ); + (* }}} *) (* 9c *) let fixed_inst, _ = match_meta [] [] [player_action] [lead] in + let struc = (snd state).Arena.struc in let candidates = Aux.map_some ( fun (rname, precond, add, struc_elems, fixvar_elemvars) -> (* 9d *) + (* {{{ log entry *) + if !debug_level > 4 then ( + Printf.printf "fixvar_elemvars: %s\n%!" + (String.concat "; " + (List.map (fun (v,ts)->v^": "^ + String.concat ", " (List.map (fun (t,_)->term_str t) ts)) + fixvar_elemvars)) + ); + (* }}} *) let anchors = Aux.concat_map (fun (v,t) -> let elemvars = List.assoc v fixvar_elemvars in Aux.concat_map (fun (mask, pevs) -> @@ -3067,30 +3167,52 @@ pevs) elemvars ) fixed_inst in let precond = Formula.And (anchors @ [precond]) in + (* {{{ log entry *) + if !debug_level > 4 then ( + Printf.printf "GDL.translate_incoming_move: trying precond=\n%s\n...%!" + (Formula.sprint precond) + ); + (* }}} *) let rule = DiscreteRule.translate_from_precond ~precond ~add ~embed:gdl.fluents ~struc_elems in + let lhs_struc = rule.DiscreteRule.lhs_struc in let rule = DiscreteRule.compile_rule - (Structure.rel_signature (snd state).Arena.struc) [] rule in + (Structure.rel_signature struc) [] rule in let asgns = - DiscreteRule.find_matchings (snd state).Arena.struc rule in + DiscreteRule.find_matchings struc rule in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "found %s\n%!" (AssignmentSet.str asgns) + ); + (* }}} *) (* faster *) (* let emb = DiscreteRule.choose_match (snd state).Arena.struc rule asgns in *) (* but we should check whether there's no ambiguity... *) match - DiscreteRule.enumerate_matchings (snd state).Arena.struc rule asgns + DiscreteRule.enumerate_matchings struc rule asgns with | [] -> None - | [emb] -> Some (rname, emb) + | [emb] -> Some (rname, emb, lhs_struc) | _ -> failwith ("GDL.translate_incoming_move: match ambiguity for rule "^rname) ) tossrules in match candidates with - | [rname, emb] -> rname, emb + | [rname, emb, lhs_struc] -> + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "GDL.translate_incoming_move: rname=%s; emb=%s\n...%!" + rname + (String.concat ", " (List.map (fun (v,e) -> + Structure.elem_str lhs_struc v ^ ": " ^ + Structure.elem_str struc e) emb)) + ); + (* }}} *) + rname, emb | _ -> failwith ("GDL.translate_incoming_move: ambiguity among rules "^ - String.concat ", " (List.map fst candidates)) + String.concat ", " (List.map Aux.fst3 candidates)) (* @@ -3116,6 +3238,20 @@ (* let location = (fst state).Arena.graph.(loc) in *) let tossrule = Aux.StrMap.find rname gdl.tossrule_data in let rule = List.assoc rname (fst state).Arena.rules in + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "GDL.translate_outgoing_move: rname=%s; emb={%s}\n%!" + rname (String.concat ", "(List.map (fun (v, e)-> + let vname = + DiscreteRule.elemvar_of_elem + rule.ContinuousRule.compiled.DiscreteRule.lhs_elem_inv_names v in + let ename = Structure.elem_str (snd state).Arena.struc e in + if ename = "control__blank_" then + Structure.print (snd state).Arena.struc; + vname ^ ": " ^ ename + ) emb)) + ); + (* }}} *) (* 10d *) let emb = List.map (fun (v, e) -> let vterm = @@ -3123,14 +3259,27 @@ rule.ContinuousRule.compiled.DiscreteRule.lhs_elem_inv_names v in Aux.StrMap.find vterm tossrule.elemvars, Aux.IntMap.find e gdl.t_elements) emb in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "outgoing-emb={%s}\n%!" + (String.concat ", "(List.map (fun (vt, et)-> + term_str vt ^ ": " ^ term_str et) emb)) + ); + (* }}} *) let sb = try List.fold_left (fun sb (v_term, e_term) -> - fst (match_meta sb [] [e_term] [v_term])) [] emb + fst (match_meta ~ignore_meta:true sb [] [e_term] [v_term])) [] emb with Not_found -> failwith ("GDL.translate_outgoing_move: inconsistent match for rule " ^rname) in - term_str (subst sb tossrule.lead_legal) + let res = term_str (subst sb tossrule.lead_legal) in + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "GDL.translate_outgoing_move: result = %s\n%!" res + ); + (* }}} *) + res let our_turn gdl state = let loc = (snd state).Arena.cur_loc in Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/GGP/GDLTest.ml 2011-02-28 22:04:19 UTC (rev 1337) @@ -114,5 +114,5 @@ let breakthrough = load_rules "./GGP/examples/breakthrough.gdl" in let connect5 = load_rules "./GGP/examples/connect5.gdl" in let tictactoe = load_rules "./GGP/examples/tictactoe.gdl" in - let gdef = GDL.translate_game (Const "x") connect5 in + let gdef = GDL.translate_game (Const "white") breakthrough in ignore gdef; ignore connect5; ignore breakthrough; ignore tictactoe Modified: trunk/Toss/Play/Game.ml =================================================================== --- trunk/Toss/Play/Game.ml 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Play/Game.ml 2011-02-28 22:04:19 UTC (rev 1337) @@ -3,7 +3,7 @@ open Printf (* Default effort overshoots to let timeout handle stopping. *) -let default_effort = 2 (* 10 *) +let default_effort = ref 10 let debug_level = ref 0 let set_debug_level i = (debug_level := i) @@ -530,7 +530,9 @@ to follow the best move (or both). Also return the accrued computation as updated "memory" for the current state. - Use [Random_move] for other agents if their "effort" is set to zero. *) + Uses [Random_move] for other agents if their "effort" is set to + zero. Do not use [Random_move] or [effort=0] when the table of + moves is used for more than extracting the move selected! *) and toss ~grid_size ?(just_payoffs=false) ({game={Arena.rules=rules; graph=graph; num_players=num_players; defined_rels=defined_rels}; @@ -579,9 +581,10 @@ loc.Arena.payoffs_pp in Aux.Right payoff | Some state -> - (* FIXME: [pos] refers to unfiltered array! *) + (* [pos] refers to unfiltered array! use only to extract + | the move from the returned array *) Aux.Left - (!pos, moves, memory, + (!pos mod mlen, moves, memory, {game_state = state; memory = update_memory ~num_players state !pos memory})) @@ -1156,9 +1159,11 @@ evgame_of_heuristic heuristics heuristics_pp game in Maximax_evgame (heur_evgame, false, depth, pruning) -let initialize_default state ?loc ?(effort=default_effort) +let initialize_default state ?loc ?effort ~search_method ?horizon ?advr ?(payoffs_already_tnf=false) ?heuristic () = + let effort = match effort with + | None -> !default_effort | Some e -> e in let {Arena.rules=rules; graph=graph; num_players=num_players} = fst state in let struc = (snd state).Arena.struc in (* {{{ log entry *) @@ -1229,8 +1234,9 @@ (* {{{ log entry *) if !debug_level > 1 then - printf "suggest: pos %d\n%!" bpos; - + printf "suggest: pos %d out of %d -- %s\n%!" bpos + (Array.length moves) + (Move.move_gs_str (play.game, play_state.game_state) moves.(bpos)); (* }}} *) Some (moves.(bpos), {play_state with memory=memory}) | Aux.Right payoffs -> None) Modified: trunk/Toss/Play/Game.mli =================================================================== --- trunk/Toss/Play/Game.mli 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Play/Game.mli 2011-02-28 22:04:19 UTC (rev 1337) @@ -1,5 +1,8 @@ (** Game-related definitions. The UCTS algorithm. *) +(** Default effort used in {!Game.initialize_default} when not + otherwise specified. *) +val default_effort : int ref (** A global "hurry up!" switch triggered by the timer alarm. *) val get_timeout : unit -> bool Modified: trunk/Toss/Server/ServerGDLTest.in =================================================================== --- trunk/Toss/Server/ServerGDLTest.in 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Server/ServerGDLTest.in 2011-02-28 22:04:19 UTC (rev 1337) @@ -3,9 +3,9 @@ Sender: GAMEMASTER Receiver: GAMEPLAYER Content-type: text/acl -Content-length: 1721 +Content-length: 1652 -(START MATCH.3316980891 XPLAYER ((ROLE XPLAYER) (ROLE OPLAYER) (INIT (CELL 1 1 B)) (INIT (CELL 1 2 B)) (INIT (CELL 1 3 B)) (INIT (CELL 2 1 B)) (INIT (CELL 2 2 B)) (INIT (CELL 2 3 B)) (INIT (CELL 3 1 B)) (INIT (CELL 3 2 B)) (INIT (CELL 3 3 B)) (INIT (CONTROL XPLAYER)) (<= (NEXT (CELL ?X ?Y ?PLAYER)) (DOES ?PLAYER (MARK ?X ?Y))) (<= (NEXT (CELL ?X ?Y ?MARK)) (TRUE (CELL ?X ?Y ?MARK)) (DOES ?PLAYER (MARK ?M ?N)) (DISTINCTCELL ?X ?Y ?M ?N)) (<= (NEXT (CONTROL XPLAYER)) (TRUE (CONTROL OPLAYER))) (<= (NEXT (CONTROL OPLAYER)) (TRUE (CONTROL XPLAYER))) (<= (ROW ?X ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL ?X 1 ?PLAYER)) (TRUE (CELL ?X 2 ?PLAYER)) (TRUE (CELL ?X 3 ?PLAYER))) (<= (COLUMN ?Y ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 ?Y ?PLAYER)) (TRUE (CELL 2 ?Y ?PLAYER)) (TRUE (CELL 3 ?Y ?PLAYER))) (<= (DIAGONAL ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 1 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 3 ?PLAYER))) (<= (DIAGONAL ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 3 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 1 ?PLAYER))) (<= (LINE ?PLAYER) (ROW ?X ?PLAYER)) (<= (LINE ?PLAYER) (COLUMN ?Y ?PLAYER)) (<= (LINE ?PLAYER) (DIAGONAL ?PLAYER)) (<= OPEN (TRUE (CELL ?X ?Y B))) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?X ?M)) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?Y ?N)) (<= (LEGAL ?PLAYER (MARK ?X ?Y)) (TRUE (CELL ?X ?Y B)) (TRUE (CONTROL ?PLAYER))) (<= (LEGAL ?PLAYER NOOP) (NOT (TRUE (CONTROL ?PLAYER)))) (<= (GOAL ?PLAYER 100) (LINE ?PLAYER)) (<= (GOAL ?PLAYER 50) (NOT (LINE XPLAYER)) (NOT (LINE OPLAYER)) (NOT OPEN)) (<= (GOAL ?PLAYER1 0) (LINE ?PLAYER2) (DISTINCT ?PLAYER1 ?PLAYER2)) (<= (GOAL ?PLAYER 0) (NOT (LINE XPLAYER)) (NOT (LINE OPLAYER)) OPEN) (<= TERMINAL (LINE ?PLAYER)) (<= TERMINAL (NOT OPEN))) 30 30) +(START MATCH.3316980891 OPLAYER ((ROLE XPLAYER) (ROLE OPLAYER) (INIT (CELL 1 1 B)) (INIT (CELL 1 2 B)) (INIT (CELL 1 3 B)) (INIT (CELL 2 1 B)) (INIT (CELL 2 2 B)) (INIT (CELL 2 3 B)) (INIT (CELL 3 1 B)) (INIT (CELL 3 2 B)) (INIT (CELL 3 3 B)) (INIT (CONTROL XPLAYER)) (<= (NEXT (CELL ?X ?Y ?PLAYER)) (DOES ?PLAYER (MARK ?X ?Y))) (<= (NEXT (CELL ?X ?Y ?MARK)) (TRUE (CELL ?X ?Y ?MARK)) (DOES ?PLAYER (MARK ?M ?N)) (DISTINCTCELL ?X ?Y ?M ?N)) (<= (NEXT (CONTROL XPLAYER)) (TRUE (CONTROL OPLAYER))) (<= (NEXT (CONTROL OPLAYER)) (TRUE (CONTROL XPLAYER))) (<= (ROW ?X ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL ?X 1 ?PLAYER)) (TRUE (CELL ?X 2 ?PLAYER)) (TRUE (CELL ?X 3 ?PLAYER))) (<= (COLUMN ?Y ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 ?Y ?PLAYER)) (TRUE (CELL 2 ?Y ?PLAYER)) (TRUE (CELL 3 ?Y ?PLAYER))) (<= (DIAGONAL ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 1 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 3 ?PLAYER))) (<= (DIAGONAL ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 3 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 1 ?PLAYER))) (<= (LINE ?PLAYER) (ROW ?X ?PLAYER)) (<= (LINE ?PLAYER) (COLUMN ?Y ?PLAYER)) (<= (LINE ?PLAYER) (DIAGONAL ?PLAYER)) (<= OPEN (TRUE (CELL ?X ?Y B))) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?X ?M)) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?Y ?N)) (<= (LEGAL ?PLAYER (MARK ?X ?Y)) (TRUE (CELL ?X ?Y B)) (TRUE (CONTROL ?PLAYER))) (<= (LEGAL ?PLAYER NOOP) (NOT (TRUE (CONTROL ?PLAYER)))) (<= (GOAL ?PLAYER 100) (LINE ?PLAYER)) (<= (GOAL ?PLAYER 50) (NOT (LINE XPLAYER)) (NOT (LINE OPLAYER)) (NOT OPEN)) (<= (GOAL ?PLAYER1 0) (LINE ?PLAYER2) (DISTINCT ?PLAYER1 ?PLAYER2)) (<= TERMINAL (LINE ?PLAYER)) (<= TERMINAL (NOT OPEN))) 30 30) POST / HTTP/1.0 Accept: text/delim @@ -23,7 +23,7 @@ Content-type: text/acl Content-length: 41 -(PLAY MATCH.3316980891 ((MARK 2 2) NOOP)) +(PLAY MATCH.3316980891 ((MARK 1 2) NOOP)) POST / HTTP/1.0 Accept: text/delim @@ -32,7 +32,7 @@ Content-type: text/acl Content-length: 41 -(PLAY MATCH.3316980891 (NOOP (MARK 3 1))) +(PLAY MATCH.3316980891 (NOOP (MARK 2 2))) POST / HTTP/1.0 Accept: text/delim @@ -41,7 +41,7 @@ Content-type: text/acl Content-length: 41 -(PLAY MATCH.3316980891 ((MARK 1 1) NOOP)) +(PLAY MATCH.3316980891 ((MARK 3 2) NOOP)) POST / HTTP/1.0 Accept: text/delim @@ -50,7 +50,7 @@ Content-type: text/acl Content-length: 41 -(PLAY MATCH.3316980891 (NOOP (MARK 3 2))) +(PLAY MATCH.3316980891 (NOOP (MARK 1 1))) POST / HTTP/1.0 Accept: text/delim @@ -59,4 +59,13 @@ Content-type: text/acl Content-length: 41 -(STOP MATCH.3316980891 ((MARK 3 3) NOOP)) +(PLAY MATCH.3316980891 ((MARK 3 1) NOOP)) + +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 41 + +(STOP MATCH.3316980891 (NOOP (MARK 3 3))) Added: trunk/Toss/Server/ServerGDLTest.in2 =================================================================== --- trunk/Toss/Server/ServerGDLTest.in2 (rev 0) +++ trunk/Toss/Server/ServerGDLTest.in2 2011-02-28 22:04:19 UTC (rev 1337) @@ -0,0 +1,71 @@ +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 1652 + +(START MATCH.3316980891 OPLAYER ((ROLE XPLAYER) (ROLE OPLAYER) (INIT (CELL 1 1 B)) (INIT (CELL 1 2 B)) (INIT (CELL 1 3 B)) (INIT (CELL 2 1 B)) (INIT (CELL 2 2 B)) (INIT (CELL 2 3 B)) (INIT (CELL 3 1 B)) (INIT (CELL 3 2 B)) (INIT (CELL 3 3 B)) (INIT (CONTROL XPLAYER)) (<= (NEXT (CELL ?X ?Y ?PLAYER)) (DOES ?PLAYER (MARK ?X ?Y))) (<= (NEXT (CELL ?X ?Y ?MARK)) (TRUE (CELL ?X ?Y ?MARK)) (DOES ?PLAYER (MARK ?M ?N)) (DISTINCTCELL ?X ?Y ?M ?N)) (<= (NEXT (CONTROL XPLAYER)) (TRUE (CONTROL OPLAYER))) (<= (NEXT (CONTROL OPLAYER)) (TRUE (CONTROL XPLAYER))) (<= (ROW ?X ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL ?X 1 ?PLAYER)) (TRUE (CELL ?X 2 ?PLAYER)) (TRUE (CELL ?X 3 ?PLAYER))) (<= (COLUMN ?Y ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 ?Y ?PLAYER)) (TRUE (CELL 2 ?Y ?PLAYER)) (TRUE (CELL 3 ?Y ?PLAYER))) (<= (DIAGONAL ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 1 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 3 ?PLAYER))) (<= (DIAGONAL ?PLAYER) (ROLE ?PLAYER) (TRUE (CELL 1 3 ?PLAYER)) (TRUE (CELL 2 2 ?PLAYER)) (TRUE (CELL 3 1 ?PLAYER))) (<= (LINE ?PLAYER) (ROW ?X ?PLAYER)) (<= (LINE ?PLAYER) (COLUMN ?Y ?PLAYER)) (<= (LINE ?PLAYER) (DIAGONAL ?PLAYER)) (<= OPEN (TRUE (CELL ?X ?Y B))) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?X ?M)) (<= (DISTINCTCELL ?X ?Y ?M ?N) (DISTINCT ?Y ?N)) (<= (LEGAL ?PLAYER (MARK ?X ?Y)) (TRUE (CELL ?X ?Y B)) (TRUE (CONTROL ?PLAYER))) (<= (LEGAL ?PLAYER NOOP) (NOT (TRUE (CONTROL ?PLAYER)))) (<= (GOAL ?PLAYER 100) (LINE ?PLAYER)) (<= (GOAL ?PLAYER 50) (NOT (LINE XPLAYER)) (NOT (LINE OPLAYER)) (NOT OPEN)) (<= (GOAL ?PLAYER1 0) (LINE ?PLAYER2) (DISTINCT ?PLAYER1 ?PLAYER2)) (<= TERMINAL (LINE ?PLAYER)) (<= TERMINAL (NOT OPEN))) 30 30) + +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 27 + +(PLAY MATCH.3316980891 NIL) + +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 41 + +(PLAY MATCH.3316980891 ((MARK 1 2) NOOP)) + +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 41 + +(PLAY MATCH.3316980891 (NOOP (MARK 1 1))) + +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 41 + +(PLAY MATCH.3316980891 ((MARK 3 2) NOOP)) + +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 41 + +(PLAY MATCH.3316980891 (NOOP (MARK 2 2))) + +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 41 + +(PLAY MATCH.3316980891 ((MARK 3 1) NOOP)) + +POST / HTTP/1.0 +Accept: text/delim +Sender: GAMEMASTER +Receiver: GAMEPLAYER +Content-type: text/acl +Content-length: 41 + +(STOP MATCH.3316980891 (NOOP (MARK 3 3))) Modified: trunk/Toss/Server/ServerGDLTest.out =================================================================== --- trunk/Toss/Server/ServerGDLTest.out 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Server/ServerGDLTest.out 2011-02-28 22:04:19 UTC (rev 1337) @@ -5,6 +5,11 @@ READY HTTP/1.0 200 OK Content-type: text/acl +Content-length: 4 + +NOOP +HTTP/1.0 200 OK +Content-type: text/acl Content-length: 10 (MARK 2 2) Added: trunk/Toss/Server/ServerGDLTest.out2 =================================================================== --- trunk/Toss/Server/ServerGDLTest.out2 (rev 0) +++ trunk/Toss/Server/ServerGDLTest.out2 2011-02-28 22:04:19 UTC (rev 1337) @@ -0,0 +1,41 @@ +HTTP/1.0 200 OK +Content-type: text/acl +Content-length: 5 + +READY +HTTP/1.0 200 OK +Content-type: text/acl +Content-length: 4 + +NOOP +HTTP/1.0 200 OK +Content-type: text/acl +Content-length: 10 + +(MARK 1 1) +HTTP/1.0 200 OK +Content-type: text/acl +Content-length: 4 + +NOOP +HTTP/1.0 200 OK +Content-type: text/acl +Content-length: 10 + +(MARK 2 2) +HTTP/1.0 200 OK +Content-type: text/acl +Content-length: 4 + +NOOP +HTTP/1.0 200 OK +Content-type: text/acl +Content-length: 10 + +(MARK 3 3) +HTTP/1.0 200 OK +Content-type: text/acl +Content-length: 4 + +DONE +ERR processing completed -- EOF Modified: trunk/Toss/Server/ServerTest.ml =================================================================== --- trunk/Toss/Server/ServerTest.ml 2011-02-28 19:19:18 UTC (rev 1336) +++ trunk/Toss/Server/ServerTest.ml 2011-02-28 22:04:19 UTC (rev 1337) @@ -52,11 +52,11 @@ Game.deterministic_suggest := true; let old_translation = !GDL.manual_translation in GDL.manual_translation := false; - let in_ch = open_in "./Server/ServerGDLTest.in" in + let in_ch = open_in "./Server/ServerGDLTest.in2" in let out_ch = open_out "./Server/ServerGDLTest.temp" in - GDL.debug_level := 4; - Server.set_debug_level 6; Game.deterministic_suggest := true; + let old_effort = !Game.default_effort in + Game.default_effort := 2; (try while true do Server.req_handle in_ch out_ch done with End_of_file -> ()); @@ -65,11 +65,12 @@ let result = Aux.input_file (open_in "./Server/ServerGDLTest.temp") in let target = - Aux.input_file (open_in "./Server/ServerGDLTest.out") in + Aux.input_file (open_in "./Server/ServerGDLTest.out2") in Sys.remove "./Server/ServerGDLTest.temp"; assert_equal ~printer:(fun x->x) (strip_spaces target) (strip_spaces result); - GDL.manual_translation := old_translation + GDL.manual_translation := old_translation; + Game.default_effort := old_effort ); ] @@ -79,6 +80,11 @@ Aux.run_test_if_target "ServerTest" tests let a () = + GDL.debug_level := 4; + (* Server.set_debug_level 6 *) + Game.set_debug_level 2 + +let a () = match test_filter ["server:2:ServerGDLTest.in GDL Tic-Tac-Toe automatic"] tests This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-01 02:15:14
|
Revision: 1338 http://toss.svn.sourceforge.net/toss/?rev=1338&view=rev Author: lukaszkaiser Date: 2011-03-01 02:15:08 +0000 (Tue, 01 Mar 2011) Log Message: ----------- Correcting FormulaOps.tnf_fv bug found during GDL translation, real_expr cache in Solver. Modified Paths: -------------- trunk/Toss/Formula/FormulaOps.ml trunk/Toss/Formula/FormulaOps.mli trunk/Toss/Formula/FormulaOpsTest.ml trunk/Toss/Server/ServerTest.ml trunk/Toss/Solver/Solver.ml Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-02-28 22:04:19 UTC (rev 1337) +++ trunk/Toss/Formula/FormulaOps.ml 2011-03-01 02:15:08 UTC (rev 1338) @@ -147,6 +147,9 @@ let map_to_atoms_full f g phi = map_to_literals (function Not (x) -> Not (f x) | x -> f x) g phi +let map_to_atoms_full_re f g re = + map_to_literals_expr (function Not (x) -> Not (f x) | x -> f x) g re + let map_to_atoms f phi = map_to_literals (function Not (x) -> Not (f x) | x -> f x) (fun x -> x) phi @@ -919,27 +922,30 @@ | [] -> [] | [f] -> [order_by_fv_phi acc_fv f] | l -> - let cross x = List.exists (fun v -> List.mem v acc_fv) (free_vars x) in + let cross x = + let fv = free_vars x in + fv = [] || List.exists (fun v -> List.mem v acc_fv) fv in let (cf, o) = List.partition cross l in - if cf = [] then + if cf = [] then ( let new_fv = free_vars (List.hd l) in order_by_fv new_fv l - else + ) else ( let new_fv = acc_fv @ (free_vars_fo (And cf)) in (List.map (order_by_fv_phi acc_fv) cf) @ (order_by_fv new_fv o) + ) and order_by_fv_phi acc_fv = function | And fl -> let is_pred = function Rel (_, [|_|]) -> true | _ -> false in let (p, np) = List.partition is_pred fl in let res = And (order_by_fv acc_fv (p @ np)) in - if !debug_level > 0 then print_endline ("fvordered and: " ^ (str res)); + if !debug_level > 1 then print_endline ("fvordered and: " ^ (str res)); res | Or fl -> let is_pred = function Rel (_, [|_|]) -> true | _ -> false in let (p, np) = List.partition is_pred fl in let res = Or (order_by_fv acc_fv (p @ np)) in - if !debug_level > 0 then print_endline ("fvordered or: " ^ (str res)); + if !debug_level > 1 then print_endline ("fvordered or: " ^ (str res)); res | Ex (vs, phi) -> Ex (vs, order_by_fv_phi acc_fv phi) | All (vs, phi) -> All (vs, order_by_fv_phi acc_fv phi) Modified: trunk/Toss/Formula/FormulaOps.mli =================================================================== --- trunk/Toss/Formula/FormulaOps.mli 2011-02-28 22:04:19 UTC (rev 1337) +++ trunk/Toss/Formula/FormulaOps.mli 2011-03-01 02:15:08 UTC (rev 1338) @@ -29,6 +29,8 @@ (** Map [f] to all atoms in the given formula. *) val map_to_atoms_full : (formula -> formula) -> (real_expr -> real_expr) -> formula -> formula +val map_to_atoms_full_re : (formula -> formula) -> (real_expr -> real_expr) -> + real_expr -> real_expr val map_to_atoms : (formula -> formula) -> formula -> formula val map_to_atoms_expr : (formula -> formula) -> real_expr -> real_expr Modified: trunk/Toss/Formula/FormulaOpsTest.ml =================================================================== --- trunk/Toss/Formula/FormulaOpsTest.ml 2011-02-28 22:04:19 UTC (rev 1337) +++ trunk/Toss/Formula/FormulaOpsTest.ml 2011-03-01 02:15:08 UTC (rev 1338) @@ -114,6 +114,20 @@ ((not P(x) and not Q(x)) <-> RT(p, r)) )"; ); + "tnf fv" >:: + (fun () -> + let tnffv_eq phi1 phi2 = formula_eq id phi2 FormulaOps.tnf_fv phi1 in + tnffv_eq "P(x) and (P(x) or Q(x))" "P(x)"; + tnffv_eq ("ex x_3_3, x_2_2, x_1_1 (" ^ + "(R_1_Y_MV1(x_1_1) and R_2_Y_MV1(x_2_2) and R_3_Y_MV1(x_3_3) " ^ + "and R_X_1_MV1(x_1_1) and R_X_2_MV1(x_2_2) and R_X_3_MV1(x_3_3) " ^ + "and R_X_Y_XP(x_1_1) and R_X_Y_XP(x_2_2) and R_X_Y_XP(x_3_3)))") + ("ex x_1_1 ((R_1_Y_MV1(x_1_1) and R_X_1_MV1(x_1_1) and " ^ + "R_X_Y_XP(x_1_1))) and ex x_2_2 ((R_2_Y_MV1(x_2_2) and " ^ + "R_X_2_MV1(x_2_2) and R_X_Y_XP(x_2_2))) and ex x_3_3 (" ^ + "(R_3_Y_MV1(x_3_3) and R_X_3_MV1(x_3_3) and R_X_Y_XP(x_3_3)))") + ); + "subst free and all" >:: (fun () -> let subst phi = FormulaOps.subst_vars [("x", "a"); ("y", "b")] phi in Modified: trunk/Toss/Server/ServerTest.ml =================================================================== --- trunk/Toss/Server/ServerTest.ml 2011-02-28 22:04:19 UTC (rev 1337) +++ trunk/Toss/Server/ServerTest.ml 2011-03-01 02:15:08 UTC (rev 1338) @@ -47,7 +47,8 @@ "ServerGDLTest.in GDL Tic-Tac-Toe automatic" >:: (fun () -> - todo "real soon now..."; + (* todo "real soon now..."; *) + (* Solver.set_debug_level 2; *) let old_det_suggest = !Game.deterministic_suggest in Game.deterministic_suggest := true; let old_translation = !GDL.manual_translation in Modified: trunk/Toss/Solver/Solver.ml =================================================================== --- trunk/Toss/Solver/Solver.ml 2011-02-28 22:04:19 UTC (rev 1337) +++ trunk/Toss/Solver/Solver.ml 2011-03-01 02:15:08 UTC (rev 1338) @@ -15,6 +15,7 @@ let cache_struc = ref (empty_structure ()) let cache_results = ref (Hashtbl.create 15) +let re_cache_results = ref (Hashtbl.create 15) let get_cache () = (!cache_struc, Hashtbl.copy !cache_results) let set_cache (struc, res) = cache_struc := struc; cache_results := res @@ -47,8 +48,8 @@ if !debug_level > 0 then print_endline ("Found " ^ (str phi)); (Hashtbl.find solver.formulas_eval res, res) with Not_found -> + if !debug_level > 0 then print_endline ("Entered " ^ (str phi)); let psi = FormulaOps.tnf_fv phi in - if !debug_level > 0 then print_endline ("Entered " ^ (str phi)); if !debug_level > 0 then print_endline ("Registering " ^ (str psi)); let id = Hashtbl.length solver.formulas_eval + 1 in Hashtbl.add solver.reg_formulas phi id; @@ -263,26 +264,50 @@ Some rs with Not_found -> None +let re_rels re = + let rels = ref [] in + let app_rel = function Rel (s, _) as r -> rels := s :: !rels; r | x -> x in + let app_re = function Fun _ -> raise Not_found | x -> x in + try + let _ = FormulaOps.map_to_atoms_full_re app_rel app_re re in + let rs = Aux.unique_sorted !rels in + if !debug_level > 1 then + print_endline ("FR: " ^ (Formula.real_str re) ^ " " ^ + (String.concat ", " rs)); + Some rs + with Not_found -> None + + +let update_cache struc = + if not (Structure.equal !cache_struc struc) then + match diffrels_struc struc !cache_struc with + | None -> + cache_struc := struc; + Hashtbl.clear !cache_results; + Hashtbl.clear !re_cache_results; + | Some rs -> + cache_struc := struc; + let is_bad (_, prs_opt) = + match prs_opt with + | None -> true + | Some prs -> List.exists (fun r -> List.mem r rs) prs in + let ok = ref [] in + Hashtbl.iter (fun p r -> if is_bad r then () else ok := (p, r)::!ok) + !cache_results; + Hashtbl.clear !cache_results; + List.iter (fun (p, r) -> Hashtbl.add !cache_results p r) !ok; + let ok_re = ref [] in + Hashtbl.iter + (fun p r -> if is_bad r then () else ok_re := (p, r)::!ok_re) + !re_cache_results; + Hashtbl.clear !re_cache_results; + List.iter (fun (p, r) -> Hashtbl.add !re_cache_results p r) !ok_re + + (* Eval with very basic caching. *) let eval_m struc phi = if phi = And [] then Any else ( - if not (Structure.equal !cache_struc struc) then ( - match diffrels_struc struc !cache_struc with - | None -> - cache_struc := struc; - Hashtbl.clear !cache_results; - | Some rs -> - cache_struc := struc; - let is_bad (_, prs_opt) = - match prs_opt with - | None -> true - | Some prs -> List.exists (fun r -> List.mem r rs) prs in - let ok = ref [] in - Hashtbl.iter (fun p r -> if is_bad r then () else ok := (p, r)::!ok) - !cache_results; - Hashtbl.clear !cache_results; - List.iter (fun (p, r) -> Hashtbl.add !cache_results p r) !ok - ); + update_cache struc; try let (res, _) = Hashtbl.find !cache_results phi in if !debug_level > 1 then ( @@ -396,7 +421,27 @@ AssignmentSet.str ev_assgn) in get_rval (join asg (evaluate_real "#" expr struc)) +let rec get_real_val_cache solver struc = function + | Const c -> c + | Plus (e1, e2) -> + (get_real_val_cache solver struc e1) +. (get_real_val_cache solver struc e2) + | Times (e1, e2) -> + (get_real_val_cache solver struc e1) *. (get_real_val_cache solver struc e2) + | re -> + update_cache struc; + try + let (res, _) = Hashtbl.find !re_cache_results re in + if !debug_level > 1 then ( + print_endline ("found in re cache: " ^ (Formula.real_str re)); + ); + res + with Not_found -> + if !debug_level > 0 then print_endline ("Get real val " ^ (real_str re)); + let re_val = get_real_val solver Any re struc in + Hashtbl.add !re_cache_results re (re_val, re_rels re); + re_val + (* Evaluate i-th formula on j-th structure. *) let evaluate solver ~formula struc = let phi = Hashtbl.find solver.formulas_eval formula in @@ -441,7 +486,7 @@ let check_formula struc formula = check solver ~formula struc - let get_real_val = get_real_val solver Any + let get_real_val re struc = get_real_val_cache solver struc re let formula_str phi = let phi = Hashtbl.find solver.formulas_check phi in Formula.str phi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-02 01:21:00
|
Revision: 1339 http://toss.svn.sourceforge.net/toss/?rev=1339&view=rev Author: lukaszkaiser Date: 2011-03-02 01:20:52 +0000 (Wed, 02 Mar 2011) Log Message: ----------- Simplify solver interface and adapt to it. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/Arena/ContinuousRule.ml trunk/Toss/Arena/ContinuousRule.mli trunk/Toss/Arena/DiscreteRule.ml trunk/Toss/Arena/DiscreteRule.mli trunk/Toss/Arena/DiscreteRuleTest.ml trunk/Toss/GGP/GDL.ml trunk/Toss/Play/Game.ml trunk/Toss/Play/GameTest.ml trunk/Toss/Play/GameTree.ml trunk/Toss/Play/Heuristic.ml trunk/Toss/Server/Server.ml trunk/Toss/Solver/Class.ml trunk/Toss/Solver/Class.mli trunk/Toss/Solver/ClassTest.ml trunk/Toss/Solver/PresbTest.ml trunk/Toss/Solver/Solver.ml trunk/Toss/Solver/Solver.mli trunk/Toss/Solver/SolverTest.ml Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Arena/Arena.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -22,7 +22,6 @@ id : int ; player : int ; payoffs : Formula.real_expr array ; - payoffs_pp : Solver.M.registered_real_expr array ; moves : (label * int) list ; } @@ -33,8 +32,7 @@ num_players : int; player_names : (string * int) list ; data : (string * string) list ; - defined_rels : (string * (string list * Formula.formula * - Solver.M.registered_formula)) list ; + defined_rels : (string * (string list * Formula.formula)) list ; } (* State of the game and additional information. *) @@ -47,12 +45,8 @@ let empty_state = let emp_struc = Structure.empty_structure () in let zero = Formula.Const 0.0 in - {rules=[]; - graph=Array.make 1 - { id = 0; player = 0; payoffs = [|zero|]; - payoffs_pp = - [|Solver.M.register_real_expr zero|]; - moves = [] }; + {rules = []; + graph = Array.make 1 { id = 0; player = 0; payoffs = [|zero|]; moves = [] }; player_names = ["1", 0] ; data = [] ; defined_rels = [] ; @@ -76,8 +70,7 @@ (* Add a defined relation to a structure. *) let add_def_rel_single struc (r_name, vars, def_phi) = - let def_asg = Solver.M.evaluate struc - (Solver.M.register_formula def_phi) in + let def_asg = Solver.M.evaluate struc def_phi in match def_asg with | AssignmentSet.Empty -> Structure.add_rel_name r_name (List.length vars) struc @@ -148,11 +141,7 @@ let zero = Formula.Const 0.0 in let payoffs = array_of_players zero player_names payoffs in - let payoffs_pp = - Array.map Solver.M.register_real_expr payoffs in - { id = id; player = player; - payoffs = payoffs; payoffs_pp = payoffs_pp; - moves = moves } + { id = id; player = player; payoffs = payoffs; moves = moves } open Printf @@ -168,8 +157,8 @@ (fst state).rules, Array.to_list (fst state).graph, List.map fst (List.sort (fun (_,x) (_,y) -> x-y) (fst state).player_names), - List.map (fun (rel, (args, body, _)) ->rel, args, body) - (fst state).defined_rels, + List.map (fun (rel, (args, body)) -> rel, args, body) + (fst state).defined_rels, (snd state).struc, (snd state).time, (snd state).cur_loc, (fst state).data in (* {{{ log entry *) @@ -219,10 +208,6 @@ let defined_rels = old_defined_rels @ List.rev defined_rels in let def_rels_pure = List.map (fun (rel, args, body) -> (rel, (args, body))) defined_rels in - let defined_rels = - List.map (fun (rel, args, body) -> - rel, (args, body, Solver.M.register_formula body)) - defined_rels in let player_names = Array.to_list (Array.mapi (fun i pname->pname, i) (Array.of_list players)) in @@ -247,21 +232,13 @@ if old_locs = [] then old_locs else let zero = Formula.Const 0.0 in - let pp_zero = Solver.M.register_real_expr zero in let add_payoffs loc = let more = num_players - Array.length loc.payoffs in - {loc with - payoffs = - Array.append loc.payoffs (Array.make more zero); - payoffs_pp = - Array.append loc.payoffs_pp (Array.make more pp_zero); - } in + {loc with payoffs = Array.append loc.payoffs (Array.make more zero);} in List.map add_payoffs old_locs in let add_def_rel loc = let ps = Array.map (FormulaOps.subst_rels_expr def_rels_pure) loc.payoffs in - let reg_ps = - Array.map Solver.M.register_real_expr ps in - { loc with payoffs = ps; payoffs_pp = reg_ps } in + { loc with payoffs = ps; } in (* {{{ log entry *) if !debug_level > 2 then ( printf "process_definition: parsing locations (registering payoffs)...%!"; @@ -291,7 +268,7 @@ num_players = num_players; player_names = player_names; data = data; - defined_rels = defined_rels + defined_rels = List.map (fun (a, b, c) -> (a, (b, c))) defined_rels; } in game, { struc = state; time = time; @@ -350,7 +327,7 @@ cur_loc = cur_loc; }) = Format.fprintf ppf "@[<v>"; - List.iter (fun (drel, (args, body, _)) -> + List.iter (fun (drel, (args, body)) -> if !equational_def_style then Format.fprintf ppf "@[<1>REL@ %s@,(@[<1>%a@])@ =@ @[<1>%a@]" drel (Aux.fprint_sep_list "," Format.pp_print_string) args @@ -391,12 +368,8 @@ let add_new_player (state_game, state) pname = let player = state_game.num_players in let zero = Formula.Const 0.0 in - let pp_zero = Solver.M.register_real_expr zero in let add_payoff loc = - {loc with - payoffs = Array.append loc.payoffs [|zero|]; - payoffs_pp = Array.append loc.payoffs_pp [|pp_zero|]; - } in + {loc with payoffs = Array.append loc.payoffs [|zero|]; } in let game = {state_game with num_players = state_game.num_players + 1; graph = Array.map add_payoff state_game.graph; @@ -490,9 +463,7 @@ try let r = (List.assoc rn state_game.rules) in let signat = Structure.rel_signature state.struc in - let defs = List.map - (fun (drel, (args, body, _)) -> drel,(args,body)) - state_game.defined_rels in + let defs = state_game.defined_rels in let (new_r, msg) = ContinuousRule.apply_to_side true f signat defs r in let new_rules = Aux.replace_assoc rn new_r state_game.rules in @@ -505,9 +476,7 @@ try let r = (List.assoc rn state_game.rules) in let signat = Structure.rel_signature state.struc in - let defs = List.map - (fun (drel, (args, body, _)) -> drel,(args,body)) - state_game.defined_rels in + let defs = state_game.defined_rels in let (new_r, msg) = ContinuousRule.apply_to_side false f signat defs r in let new_rules = Aux.replace_assoc rn new_r state_game.rules in @@ -649,7 +618,7 @@ let l = Array.length state_game.graph in if i < 0 || i > l then (* make new location and set there *) let a = Array.make 1 - { id = l; player=0; payoffs=[| |]; payoffs_pp=[| |]; moves=[] } in + { id = l; player=0; payoffs=[| |]; moves=[] } in (({state_game with graph=Array.append state_game.graph a}, {state with cur_loc = l }), "NEW LOC ADDED AND CUR LOC SET TO " ^ (string_of_int l)) @@ -698,7 +667,7 @@ | GetCurPayoffs -> let payoffs = Array.to_list (Array.mapi (fun i v->string_of_int i,v) - state_game.graph.(state.cur_loc).payoffs_pp) in + state_game.graph.(state.cur_loc).payoffs) in let ev (p,e) = p^": "^(string_of_float (Solver.M.get_real_val e struc)) in ((state_game, state), @@ -723,9 +692,7 @@ | SetRule (r_name, r) -> ( try let signat = Structure.rel_signature state.struc in - let defs = List.map - (fun (drel, (args, body, _)) -> drel,(args,body)) - state_game.defined_rels in + let defs = state_game.defined_rels in let new_rules = Aux.replace_assoc r_name (r signat defs r_name) state_game.rules in @@ -770,9 +737,7 @@ let d = r.ContinuousRule.discrete in let (dyn, upd)=(r.ContinuousRule.dynamics, r.ContinuousRule.update) in let signat = Structure.rel_signature state.struc in - let defs = List.map - (fun (drel, (args, body, _)) -> drel,(args,body)) - state_game.defined_rels in + let defs = state_game.defined_rels in let nr = (* TODO: rename lhs_* relations to be consistent with ln *) ContinuousRule.make_rule signat defs d dyn upd ~pre ~inv ~post () in (nr, "RULE COND SET") in @@ -794,9 +759,7 @@ and inv = r.ContinuousRule.inv and post = r.ContinuousRule.post in let signat = Structure.rel_signature state.struc in - let defs = List.map - (fun (drel, (args, body, _)) -> drel,(args,body)) - state_game.defined_rels in + let defs = state_game.defined_rels in let nr = ContinuousRule.make_rule signat defs d dyn upd ~pre ~inv ~post () in (nr, "RULE EMB SET") in @@ -821,9 +784,7 @@ and inv = r.ContinuousRule.inv and post = r.ContinuousRule.post in let signat = Structure.rel_signature state.struc in - let defs = List.map - (fun (drel, (args, body, _)) -> drel,(args,body)) - state_game.defined_rels in + let defs = state_game.defined_rels in let nr = ContinuousRule.make_rule signat defs d dyn upd ~pre ~inv ~post () in (nr, "RULE ASSOC SET") in Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Arena/Arena.mli 2011-03-02 01:20:52 UTC (rev 1339) @@ -17,7 +17,6 @@ id : int ; player : int ; payoffs : Formula.real_expr array ; - payoffs_pp : Solver.M.registered_real_expr array ; moves : (label * int) list ; } @@ -29,8 +28,7 @@ num_players : int; player_names : (string * int) list ; data : (string * string) list ; - defined_rels : (string * (string list * Formula.formula * - Solver.M.registered_formula)) list ; + defined_rels : (string * (string list * Formula.formula)) list ; } (** State of the game. *) Modified: trunk/Toss/Arena/ContinuousRule.ml =================================================================== --- trunk/Toss/Arena/ContinuousRule.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Arena/ContinuousRule.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -17,11 +17,7 @@ update : ((string * string) * Term.term) list; (* Update equations calT *) (* Note that, for efficiency, the precondition is part of DiscreteRule. *) inv : Formula.formula; (* Invariant for the evolution *) - inv_pp : Solver.M.registered_formula; - (* Optimized invariant *) post : Formula.formula; (* Postcondition for application *) - post_pp : Solver.M.registered_formula; -(* Optimized postcondition *) } (* Create a continuous rule given a discrete rule and other params. *) @@ -32,19 +28,15 @@ let cinv = FormulaOps.subst_rels defs inv in let cpost = FormulaOps.subst_rels defs post in let discrete = { discr with DiscreteRule.pre = cpre } in - let defrels = List.map (fun (rel,(args,body)) -> - rel, (args, body, Solver.M.register_formula body)) defs in (* we use [discrete] instead of [discr] because parser does not insert precondition into discr! *) - let obj = DiscreteRule.compile_rule signat defrels discrete in + let obj = DiscreteRule.compile_rule signat defs discrete in { discrete = discrete; compiled = obj ; dynamics = dynamics ; update = update ; inv = cinv ; - inv_pp = Solver.M.register_formula cinv; post = cpost ; - post_pp = Solver.M.register_formula cpost; } @@ -114,7 +106,7 @@ let all_vals = ref [] in let end_time = !time +. t -. (0.01 *. !time_step) in (*TODO: 1% is decimals!*) if !debug_level > 1 then print_endline ("et: " ^ (string_of_float end_time)); - let is_inv s = Solver.M.check_formula s r.inv_pp in + let is_inv s = Solver.M.check s r.inv in let lhs_to_model ((f, a), _) = (* dynamics refer to elements by LHS matches *) let e = Structure.find_elem r.discrete.DiscreteRule.lhs_struc a in @@ -176,7 +168,7 @@ let is_ok m = let (res_struc, _, _) = rewrite_single_nocheck struc cur_time m r 1. [] in - Solver.M.check_formula res_struc r.post_pp in + Solver.M.check res_struc r.post in if r.post = Formula.And [] then matches struc r else List.filter is_ok (matches struc r) @@ -186,7 +178,7 @@ let (res_struc, _, _ as res_struc_n_shifts) = rewrite_single_nocheck struc cur_time m r t params in if r.post = Formula.And [] || - Solver.M.check_formula res_struc r.post_pp + Solver.M.check res_struc r.post then Some res_struc_n_shifts else None Modified: trunk/Toss/Arena/ContinuousRule.mli =================================================================== --- trunk/Toss/Arena/ContinuousRule.mli 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Arena/ContinuousRule.mli 2011-03-02 01:20:52 UTC (rev 1339) @@ -15,10 +15,8 @@ update : ((string * string) * Term.term) list; (** Update equations calT *) (** Note that, for efficiency, the precondition is part of DiscreteRule. *) inv : Formula.formula; (** Invariant for the evolution *) - inv_pp : Solver.M.registered_formula; (** Optimized invariant *) post : Formula.formula; (** Postcondition for application *) - post_pp : Solver.M.registered_formula; (** Optimized postcondition *) } Modified: trunk/Toss/Arena/DiscreteRule.ml =================================================================== --- trunk/Toss/Arena/DiscreteRule.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Arena/DiscreteRule.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -36,7 +36,6 @@ lhs_elem_inv_names : elem_inv_names; lhs_elem_vars : string list; lhs_form : Formula.formula; - lhs_form_pp : Solver.M.registered_formula; (* gets instantiated in the model *) (* the precondition [pre] is compiled as part of [lhs_form] *) rhs_elem_names : elem_names; @@ -173,7 +172,7 @@ (* Find all embeddings of a rule. Does not guarantee that rewriting will succeed for all of them. *) let find_matchings model rule_obj = - Solver.M.evaluate model rule_obj.lhs_form_pp + Solver.M.evaluate model rule_obj.lhs_form (* Convert assignment to an embedding of the LHS structure. *) let assignment_to_embedding rule_obj asgn = @@ -561,10 +560,10 @@ not (List.mem_assoc rel defined_rels)) signat in let expand_def_rels rel = if List.mem_assoc rel defined_rels then - let args, _, rphi = List.assoc rel defined_rels in + let args, rphi = List.assoc rel defined_rels in List.map fst (List.filter (fun (rel, ar) -> let selector = Structure.free_for_rel rel ar in - let res = Solver.M.check_formula selector rphi in + let res = Solver.M.check selector rphi in (* {{{ log entry *) if !debug_level > 3 then ( Printf.printf "compile_rule.expand_def_rels: %s on %s = %b\n%!" @@ -577,7 +576,7 @@ let expand_defrel_tups (drel, tups) = if List.mem_assoc drel defined_rels then - let args, _, rphi = List.assoc drel defined_rels in + let args, rphi = List.assoc drel defined_rels in let arg_tup = Array.of_list args in map_some (fun (brel, ar) -> let selector = Structure.free_for_rel brel ar in @@ -586,7 +585,7 @@ (* {{{ log entry *) if !debug_level > 3 && asgn<>AssignmentSet.Empty then ( Printf.printf "compile_rule.expand_defrel_tups: %s {%s} over\ - %s = %s\n%!" drel (Solver.M.formula_str rphi) (Structure.str selector) + %s = %s\n%!" drel (Formula.str rphi) (Structure.str selector) (AssignmentSet.str asgn) ); (* }}} *) @@ -766,8 +765,6 @@ ] in (* Substitute defined relations, expanding their special variants. *) - let defs = List.map (fun (rel, (args, body, _)) -> rel,(args,body)) - defined_rels in let transform_new_rel = function | Rel (rn, tup) when List.mem rn base_emb_rels -> Rel ("_new_"^rn, tup) @@ -779,12 +776,12 @@ let defined_new_rels = List.map (fun (drel, (args,body)) -> "_new_"^drel, (args, FormulaOps.map_to_atoms transform_new_rel body)) - defs in + defined_rels in let defined_del_rels = List.map (fun (drel, (args,body)) -> "_del_"^drel, (args, FormulaOps.map_to_atoms transform_del_rel body)) - defs in - let defs = defs @ defined_new_rels @ defined_del_rels in + defined_rels in + let defs = defined_rels @ defined_new_rels @ defined_del_rels in let emb = FormulaOps.subst_rels defs emb in (* RHS *) @@ -854,10 +851,6 @@ Printf.printf "compile_rule: embedding formula = %s\n%!" (Formula.sprint emb) ); - (* }}} *) - let lhs_form_pp = - Solver.M.register_formula emb in -(* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "compile_rule: done.\n%!"; ); @@ -867,7 +860,6 @@ lhs_elem_inv_names = lhs_elem_inv_names; lhs_elem_vars = lhs_elem_vars; lhs_form = emb; - lhs_form_pp = lhs_form_pp; rhs_elem_names = rule_src.rhs_struc.Structure.names; rhs_elem_vars = rhs_elem_vars; rhs_pos_tuples = rhs_pos_tuples; @@ -995,7 +987,7 @@ List.map (fun tup->Not (Rel (r,Array.map (fun v->`FO v) tup))) tups) obj.rhs_neg_tuples in - Solver.M.formula_str obj.lhs_form_pp ^ "-> " ^ + Formula.str obj.lhs_form ^ "-> " ^ Formula.str (And (plits @ nlits)) Modified: trunk/Toss/Arena/DiscreteRule.mli =================================================================== --- trunk/Toss/Arena/DiscreteRule.mli 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Arena/DiscreteRule.mli 2011-03-02 01:20:52 UTC (rev 1339) @@ -31,7 +31,6 @@ lhs_elem_inv_names : elem_inv_names; lhs_elem_vars : string list; lhs_form : Formula.formula; - lhs_form_pp : Solver.M.registered_formula; (* gets instantiated in the model *) (* the precondition [pre] is compiled as part of [lhs_form] *) rhs_elem_names : elem_names; @@ -106,8 +105,7 @@ in the RHS, it is still not removed by a rewrite. *) val compile_rule : (string * int) list -> - (string * - (string list * Formula.formula * Solver.M.registered_formula)) + (string * (string list * Formula.formula)) list -> rule -> rule_obj (** Relations that can explicitly change state by rewriting (i.e. not Modified: trunk/Toss/Arena/DiscreteRuleTest.ml =================================================================== --- trunk/Toss/Arena/DiscreteRuleTest.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Arena/DiscreteRuleTest.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -583,8 +583,6 @@ let rhs_struc = struc_of_str "[ b | _opt_D (b) | ]" in let signat = ["O", 1; "P", 1; "Q", 1] in let defrels = ["D", (["a"], formula_of_str "P(a) or Q(a)")] in - let defrels = List.map (fun (rel,(args,body)) -> - rel, (args, body, Solver.M.register_formula body)) defrels in let rule_obj = compile_rule signat defrels {lhs_struc = lhs_struc; rhs_struc = rhs_struc; @@ -599,8 +597,6 @@ let rhs_struc = struc_of_str "[ b | _opt_D (b) | ]" in let signat = ["O", 1; "P", 1; "Q", 1] in let defrels = ["D", (["a"], formula_of_str "P(a) or Q(a)")] in - let defrels = List.map (fun (rel,(args,body)) -> - rel, (args, body, Solver.M.register_formula body)) defrels in let rule_obj = compile_rule signat defrels {lhs_struc = lhs_struc; rhs_struc = rhs_struc; @@ -615,8 +611,6 @@ let rhs_struc = struc_of_str "[ b | _opt_D (b); O(b) | ]" in let signat = ["O", 1; "P", 1; "Q", 1] in let defrels = ["D", (["a"], formula_of_str "P(a) or Q(a)")] in - let defrels = List.map (fun (rel,(args,body)) -> - rel, (args, body, Solver.M.register_formula body)) defrels in let rule_obj = compile_rule signat defrels {lhs_struc = lhs_struc; rhs_struc = rhs_struc; @@ -631,8 +625,6 @@ let rhs_struc = struc_of_str "[ b | O(b) | ]" in let signat = ["O", 1; "P", 1; "Q", 1] in let defrels = ["D", (["a"], formula_of_str "P(a) or Q(a)")] in - let defrels = List.map (fun (rel,(args,body)) -> - rel, (args, body, Solver.M.register_formula body)) defrels in let rule_obj = compile_rule signat defrels {lhs_struc = lhs_struc; rhs_struc = rhs_struc; @@ -652,8 +644,6 @@ let rhs_struc = struc_of_str "[ b | _opt_O (b) | ]" in let signat = ["O", 1; "P", 1; "Q", 1] in let defrels = ["D", (["a"], formula_of_str "P(a) or Q(a)")] in - let defrels = List.map (fun (rel,(args,body)) -> - rel, (args, body, Solver.M.register_formula body)) defrels in let rule_obj = compile_rule signat defrels {lhs_struc = lhs_struc; rhs_struc = rhs_struc; @@ -668,8 +658,6 @@ let rhs_struc = struc_of_str "[ b | P (b) | ]" in let signat = ["O", 1; "P", 1; "Q", 1] in let defrels = ["D", (["a"], formula_of_str "P(a) or Q(a)")] in - let defrels = List.map (fun (rel,(args,body)) -> - rel, (args, body, Solver.M.register_formula body)) defrels in let rule_obj = compile_rule signat defrels {lhs_struc = lhs_struc; rhs_struc = rhs_struc; @@ -684,8 +672,6 @@ let rhs_struc = struc_of_str "[ b | O(b) | ]" in let signat = ["O", 1; "P", 1; "Q", 1] in let defrels = ["D", (["a"], formula_of_str "P(a) or Q(a)")] in - let defrels = List.map (fun (rel,(args,body)) -> - rel, (args, body, Solver.M.register_formula body)) defrels in let rule_obj = compile_rule signat defrels {lhs_struc = lhs_struc; rhs_struc = rhs_struc; Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/GGP/GDL.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -1707,15 +1707,14 @@ let optim_conjs = List.filter (fun c-> List.for_all (fun v->List.mem v lvars) (FormulaOps.free_vars c)) (conjs_4b @ all_conjs) in - let rphi = Solver.M.register_formula - (Formula.And optim_conjs) in + let rphi = Formula.And optim_conjs in (* {{{ log entry *) if !debug_level > 4 then ( Printf.printf "evaluating: %s\n%!" (Formula.str phi) ); (* }}} *) - if Solver.M.check_formula struc rphi + if Solver.M.check struc rphi then ( (* {{{ log entry *) if !debug_level > 4 then ( @@ -2783,8 +2782,7 @@ static_phis, phis)) cases in let cases = Aux.map_some ( fun (var_elems,struc_elems,rhs_pos,static_phis,phis) -> - let phi = Formula.And static_phis in - let rphi = Solver.M.register_formula phi in + let rphi = Formula.And static_phis in (* {{{ log entry *) if !debug_level > 4 then ( (* do not print, because it generates too many @@ -2793,16 +2791,16 @@ (* let assgn = Solver.M.evaluate struc rphi in let avars = List.map Formula.var_str - (FormulaOps.free_vars phi) in + (FormulaOps.free_vars rphi) in let atups = AssignmentSet.tuples struc.Structure.elements avars assgn in *) Printf.printf "evaluating: %s\n%!" - (Formula.str phi) + (Formula.str rphi) (* (List.length atups) *) ); (* }}} *) - let res = Solver.M.check_formula struc rphi in + let res = Solver.M.check struc rphi in (* {{{ log entry *) if !debug_level > 4 && res then ( Printf.printf "holds\n%!" @@ -2955,14 +2953,6 @@ let payoffs = Aux.array_from_assoc (List.map (fun (player, payoff) -> find_player player, payoff) payoffs) in - let payoffs_pp = - Array.map (fun pay -> - (* {{{ log entry *) - if !debug_level > 2 then ( - Printf.printf "Registering payoff %s...\n%!" (Formula.real_str pay) - ); - (* }}} *) - Solver.M.register_real_expr pay) payoffs in let tossrule_data = ref Aux.StrMap.empty in let fluents = Aux.concat_map snd dyn_rels in (* {{{ log entry *) @@ -3047,7 +3037,6 @@ Arena.id = loc; player = find_player loc_players.(loc); payoffs = payoffs; - payoffs_pp = payoffs_pp; moves = labels} in rules, location ) loc_toss_rules in Modified: trunk/Toss/Play/Game.ml =================================================================== --- trunk/Toss/Play/Game.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Play/Game.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -503,7 +503,7 @@ let subloc = evgame.ev_game.Arena.graph.(evgame.ev_location) in if subloc.Arena.moves = [] then (* optimization *) Array.map (fun expr -> - Solver.M.get_real_val expr model) subloc.Arena.payoffs_pp + Solver.M.get_real_val expr model) subloc.Arena.payoffs else let state = {game_state={Arena.cur_loc=evgame.ev_location; struc=model; time=time}; @@ -548,7 +548,7 @@ let payoff = Array.map (fun expr -> Solver.M.get_real_val expr state.Arena.struc) - loc.Arena.payoffs_pp in + loc.Arena.payoffs in Aux.Right payoff else let agent = agents.(loc.Arena.player) in @@ -578,7 +578,7 @@ let payoff = Array.map (fun expr -> Solver.M.get_real_val expr state.Arena.struc) - loc.Arena.payoffs_pp in + loc.Arena.payoffs in Aux.Right payoff | Some state -> (* [pos] refers to unfiltered array! use only to extract @@ -645,7 +645,7 @@ Array.map (fun expr -> 100000. *. Solver.M.get_real_val expr model) - location.Arena.payoffs_pp (* see [let payoff] above *) + location.Arena.payoffs (* see [let payoff] above *) (* * play_evgame grid_size model time subgames.(loc) * *) @@ -671,7 +671,7 @@ Array.map (fun expr -> 100000. *. Solver.M.get_real_val expr model) - location.Arena.payoffs_pp + location.Arena.payoffs (* * play_evgame grid_size model time subgames.(loc) * *) @@ -747,7 +747,7 @@ let payoff = Array.map (fun expr -> Solver.M.get_real_val expr state.Arena.struc) - loc.Arena.payoffs_pp in + loc.Arena.payoffs in Aux.Right payoff else let cur_depth = ref 0 in @@ -894,7 +894,7 @@ let payoff = Array.map (fun expr -> Solver.M.get_real_val expr state.Arena.struc) - loc.Arena.payoffs_pp in + loc.Arena.payoffs in Aux.Right payoff else let descriptions = @@ -1039,7 +1039,7 @@ let payoff = Array.map (fun expr -> Solver.M.get_real_val expr state.Arena.struc) - location.Arena.payoffs_pp in + location.Arena.payoffs in let upscore = score_payoff payoff in upscore, Terminal (state, upscore, heuristic, payoff) @@ -1050,7 +1050,7 @@ let payoff = Array.map (fun expr -> Solver.M.get_real_val expr state.Arena.struc) - location.Arena.payoffs_pp in + location.Arena.payoffs in let upscore = score_payoff payoff in upscore, Terminal (state, upscore, heuristic, payoff) else @@ -1102,7 +1102,7 @@ node_subtrees=subtrees; node_bestheur=bestheur; }) -let evgame_of_heuristic heuristics heuristics_pp game = +let evgame_of_heuristic heuristics game = let evgame gloc = {ev_game = {Arena.rules = []; @@ -1112,7 +1112,7 @@ graph = [| {Arena.id=0; player=gloc.Arena.player; payoffs=heuristics.(gloc.Arena.id); - payoffs_pp=heuristics_pp.(gloc.Arena.id); moves=[]} |]; + moves=[]} |]; num_players = game.Arena.num_players}; ev_agents = [| |]; ev_delta = 0.0; ev_location = 0; ev_horizon = Some 0; ev_memory = [| |]} in @@ -1130,10 +1130,8 @@ let heuristics = match heuristic with Some h -> h | None -> default_heuristic ~struc ?advr game in - let heuristics_pp = - Array.map (Array.map Solver.M.register_real_expr) heuristics in let heur_evgame = - evgame_of_heuristic heuristics heuristics_pp game in + evgame_of_heuristic heuristics game in let playout_agents = if not (random_playout || heur_effect = Heuristic_only) then Array.map (fun _ -> @@ -1153,10 +1151,8 @@ let heuristics = match heuristic with Some h -> h | None -> default_heuristic ~struc ?advr game in - let heuristics_pp = - Array.map (Array.map Solver.M.register_real_expr) heuristics in let heur_evgame = - evgame_of_heuristic heuristics heuristics_pp game in + evgame_of_heuristic heuristics game in Maximax_evgame (heur_evgame, false, depth, pruning) let initialize_default state ?loc ?effort Modified: trunk/Toss/Play/GameTest.ml =================================================================== --- trunk/Toss/Play/GameTest.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Play/GameTest.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -346,7 +346,7 @@ (Aux.Right [| -1.0; 1.0 |]) move_opt; let payoffs = Array.to_list (Array.mapi (fun i v->string_of_int i,v) - (fst state).Arena.graph.((snd state).Arena.cur_loc).Arena.payoffs_pp) + (fst state).Arena.graph.((snd state).Arena.cur_loc).Arena.payoffs) in let ev (p,e) = p^": "^(string_of_float @@ -384,7 +384,7 @@ let payoffs = Array.to_list (Array.mapi (fun i v->string_of_int i,v) - (fst state).Arena.graph.((snd state).Arena.cur_loc).Arena.payoffs_pp) + (fst state).Arena.graph.((snd state).Arena.cur_loc).Arena.payoffs) in let ev (p,e) = p^": "^(string_of_float Modified: trunk/Toss/Play/GameTree.ml =================================================================== --- trunk/Toss/Play/GameTree.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Play/GameTree.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -124,8 +124,7 @@ (* Game tree initialization. *) let info_leaf_f f heurs depth game state player = - let calc re = - Solver.M.get_real_val (Solver.M.register_real_expr re) state.Arena.struc in + let calc re = Solver.M.get_real_val re state.Arena.struc in let res = { heurs = Array.map calc heurs.(state.Arena.cur_loc); info = f depth game state } in @@ -139,7 +138,7 @@ let info_terminal_f f depth game state player leaf_info = let calc re = Solver.M.get_real_val re state.Arena.struc in let payoffs = - Array.map calc game.Arena.graph.(state.Arena.cur_loc).Arena.payoffs_pp in + Array.map calc game.Arena.graph.(state.Arena.cur_loc).Arena.payoffs in { payoffs = payoffs; heurs_t = leaf_info.heurs ; info_t = f depth game state } let info_node_f f depth game state player children = @@ -198,7 +197,10 @@ (* Maximax unfolding upto depth. *) let rec unfold_maximax_upto count game heur t = - if count = 0 || Game.get_timeout () then t else + if count = 0 || Game.get_timeout () then ( + if !debug_level > 1 && Game.get_timeout () then print_endline "Timeout"; + t + ) else try let u = unfold_maximax game heur t in if !debug_level > 0 then Printf.printf "%d,%!" (size u); Modified: trunk/Toss/Play/Heuristic.ml =================================================================== --- trunk/Toss/Play/Heuristic.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Play/Heuristic.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -348,7 +348,6 @@ let expanded_descr max_alt_descr elems rels struc all_vars xvars xsubsts = - let solver = Solver.new_solver () in let alt_descr = ref 0 in let max_arity = find_max (-) (List.map (fun (_,tups) -> @@ -485,10 +484,7 @@ flush stdout) in let new_substs = map_some (fun atom -> (* g *) - let assgns = - Solver.evaluate_partial_aset solver - ~formula:(Solver.register_formula solver atom) - struc path_assgns in + let assgns = Solver.M.evaluate_partial struc path_assgns atom in let _ = if !debug_level > 3 then (printf "yxvars=%s\n" (String.concat ", "(List.map var_str yxvars)); flush stdout) in let substs = AssignmentSet.fo_assgn_to_list elems yxvars assgns in @@ -600,8 +596,7 @@ List.map Formula.to_fo (FormulaOps.free_vars phi) in if vars = [] then Or [] else - let aset = Solver.M.evaluate struc - (Solver.M.register_formula phi) in + let aset = Solver.M.evaluate struc phi in let substs = AssignmentSet.fo_assgn_to_list elems vars aset in (* sort substitutions; TODO: optimizable *) @@ -651,8 +646,7 @@ (* }}} *) let substs = AssignmentSet.fo_assgn_to_list elems vars - (Solver.M.evaluate struc - (Solver.M.register_formula phi)) in + (Solver.M.evaluate struc phi) in (* sort substitutions; TODO: optimizable *) let substs = trunc_to_vars vars substs in let all_vars = add_strings (List.map var_str vars) all_vars in Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Server/Server.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -30,7 +30,10 @@ let g_heur = ref None let no_gtree = ref true +let exp_p1_timeout = ref 9000 +let exp_p2_timeout = ref 9000 + (* -------------------- GENERAL SERVER AND REQUEST HANDLER ------------------ *) exception Host_not_found @@ -485,25 +488,29 @@ let pl =game.Arena.graph.(!cur_state.Arena.cur_loc).Arena.player in let depth = if pl = 0 then depth1 else if pl = 1 then depth2 else failwith "only 2-player games supported in experiments for now" in + let timeo = if pl = 0 then !exp_p1_timeout else !exp_p2_timeout in if depth < 12 then ( + ignore (Unix.alarm timeo); match Game.suggest ~effort:depth play (init_pl !cur_state) with - | None -> Game.set_debug_level 0; failwith "no suggestion" + | None -> + Game.cancel_timeout (); + failwith "no suggestion" | Some (mv, _) -> - Game.set_debug_level 0; + Game.cancel_timeout (); let (_, new_state) = Move.make_move mv (game, !cur_state) in cur_state := new_state; ) else ( let heur = if pl = 0 then heur1 else heur2 in - GameTree.set_debug_level 1; + ignore (Unix.alarm timeo); let (_, s) = GameTree.maximax_unfold_choose depth game !cur_state heur in - GameTree.set_debug_level 0; + Game.cancel_timeout(); cur_state := s ); print_endline ("State: " ^ (Structure.str !cur_state.Arena.struc)); print_endline ("Evals: " ^ (string_of_int !Solver.eval_counter)); Solver.eval_counter := 0; done; - let payoffs = game.Arena.graph.(!cur_state.Arena.cur_loc).Arena.payoffs_pp in + let payoffs = game.Arena.graph.(!cur_state.Arena.cur_loc).Arena.payoffs in Array.map (fun p -> Solver.M.get_real_val p (!cur_state).Arena.struc) payoffs ;; @@ -577,6 +584,8 @@ "white (=first) player heuristic for use by the second player in tests"); ("-heur-black-2", Arg.String (fun s -> heur_val_black2 := s), "black (=second) player heuristic for use by the second player in tests"); + ("-eto1", Arg.Int (fun i -> exp_p1_timeout := i), "p1 timeout for exper"); + ("-eto2", Arg.Int (fun i -> exp_p2_timeout := i), "p1 timeout for exper"); ("-gtree", Arg.Unit (fun () -> no_gtree := false), "use GameTree module"); ("-experiment", Arg.Tuple [Arg.Int (fun i -> experiment := true; e_len := i); Modified: trunk/Toss/Solver/Class.ml =================================================================== --- trunk/Toss/Solver/Class.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Solver/Class.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -64,10 +64,8 @@ - each exists X (phi) by exists "A:c:X" "B:d:X" (phi), x in X-> x in X1 or X2 - dually the forall quantifiers - each resulting atom, say R(A:c:x, B:d:y), as given in WITH reldefs. *) -let split solver phi = function - Struct s -> - let phi_i = Solver.register_formula solver phi in - if Solver.check solver phi_i s then And [] else Or [] +let split phi = function + | Struct s -> if Solver.M.check s phi then And [] else Or [] | Sum (ids_l, rels_l) -> let prefixes s = List.map (fun (i, _) -> s ^ ":" ^ i) ids_l in let replace_in s = function @@ -199,27 +197,25 @@ (* Split formula and perform first simplification steps. *) -let split_simplify solver ?(get_ids=false) phi = function - Struct s -> - let phi_i = Solver.register_formula solver phi in - if Solver.check solver phi_i s then And [] else Or [] +let split_simplify ?(get_ids=false) phi = function + | Struct s -> if Solver.M.check s phi then And [] else Or [] | Sum (ids_l, rels_r) as cdef -> - let split_phi = split solver phi cdef in + let split_phi = split phi cdef in let (summand_ids, _) = List.split ids_l in flatten_sort (map_to_atoms (simplify_atom summand_ids) split_phi) (* Compute a decomposition of a formula on a given class definition. *) -let decompose solver ?(get_ids=false) phi_in = function +let decompose ?(get_ids=false) phi_in = function Struct s as cdef -> if !debug_level > 0 then print_endline ("Deciding " ^ (Formula.str phi_in) ^ " on struct"); - [[("", split solver phi_in cdef)]] + [[("", split phi_in cdef)]] | Sum (ids_l, rels_r) as cdef -> let phi = class_tnf (simplify phi_in) in if !debug_level > 0 then print_endline ("Decomposing " ^ (Formula.str phi) ^ " on " ^ (struct_sum_str cdef)); let phi_fv = free_vars phi in - let split_phi = split solver (Ex (phi_fv, phi)) cdef in + let split_phi = split (Ex (phi_fv, phi)) cdef in let (summand_ids, _) = List.split ids_l in let simp_split_phi = map_to_atoms (simplify_atom summand_ids) split_phi in match List.rev_map simplify (to_dnf (class_tnf (simplify (simp_split_phi)))) with @@ -256,7 +252,7 @@ List.sort (fun x y -> (lsize x) - (lsize y)) x (* Model-checking function. *) -let rec check_raw solver mem cid cls in_psi = +let rec check_raw mem cid cls in_psi = let rec check_r = function And [f] | Or [f] -> check_r f | Or (flist) -> List.exists check_r flist @@ -268,7 +264,7 @@ if !debug_level > 1 then print_endline (" CHECK EX: " ^ (Formula.str (Ex ([v], phi)))); if is_fo v then ( - let res = fo_game solver mem [] cid cls v phi in + let res = fo_game mem [] cid cls v phi in if !debug_level > 1 then print_endline (" CHECK EX: " ^ (Formula.str (Ex ([v], phi))) ^ " is " ^ (if res then "true" else "false") ^ @@ -276,7 +272,7 @@ res ) else if is_mso v then ( - let res = wmso_game solver mem [] cid cls (var_str v) phi in + let res = wmso_game mem [] cid cls (var_str v) phi in if !debug_level > 1 then print_endline (" CHECK EX: " ^ (Formula.str (Ex ([v], phi))) ^ " is " ^ (if res then "true" else "false") ^ @@ -294,54 +290,54 @@ ": " ^ (Formula.str psi)); res -and fo_game sv mem hist cid cls v phi_in = +and fo_game mem hist cid cls v phi_in = let (fmem, _) = mem in - let phi = unsentence sv mem cid cls (class_tnf (simplify phi_in)) in + let phi = unsentence mem cid cls (class_tnf (simplify phi_in)) in try List.assoc (cid, phi) !fmem with Not_found -> if phi = Or [] || List.mem (phi, cid) hist then false else ( if !debug_level > 0 then print_endline (" FO game: " ^ (Formula.str phi)); let play_on (ci, psi) = (* If v still there, play game, else qr--, check *) if List.mem v (free_vars psi) then - fo_game sv mem ((phi, cid) :: hist) ci cls v psi - else check_raw sv mem ci cls psi in + fo_game mem ((phi, cid) :: hist) ci cls v psi + else check_raw mem ci cls psi in if cid = "" then if phi = And [] then true else if phi = Or [] then false else failwith "empty class id but non-trivial formula (fo)" else let struc_eq = List.hd (List.assoc cid cls) in (* Only SINGLE structures*) - let decomp = decompose sv phi struc_eq in + let decomp = decompose phi struc_eq in let res = List.exists (List.for_all play_on) (g_sort cls decomp) in fmem := ((cid, phi), res) :: !fmem; res ) -and wmso_game sv mem hist cid cls v_str phi_in = +and wmso_game mem hist cid cls v_str phi_in = let (_, wmem) = mem in - let phi = unsentence sv mem cid cls (class_tnf (simplify phi_in)) in + let phi = unsentence mem cid cls (class_tnf (simplify phi_in)) in try List.assoc (cid, phi) !wmem with Not_found -> if phi = Or [] || List.mem (phi, cid) hist then false else ( if !debug_level > 0 then print_endline (" WMSO game: "^ (Formula.str phi)); - if check_raw sv mem cid cls (assign_emptyset v_str phi) then true else + if check_raw mem cid cls (assign_emptyset v_str phi) then true else if cid = "" then if phi = And [] then true else if phi = Or [] then false else failwith "empty class id but non-trivial formula (wmso)" else - let play_on (ci,psi)= wmso_game sv mem ((phi, cid) :: hist) ci cls v_str psi in + let play_on (ci,psi)= wmso_game mem ((phi, cid) :: hist) ci cls v_str psi in let struc_eq = List.hd (List.assoc cid cls) in (*Only SINGLE structs*) - let decomp = decompose sv phi struc_eq in + let decomp = decompose phi struc_eq in let res = List.exists (List.for_all play_on) (g_sort cls decomp) in wmem := ((cid, phi), res) :: !wmem; res ) -and unsentence sv mem cid cls = function - Or [f] -> unsentence sv mem cid cls f +and unsentence mem cid cls = function + Or [f] -> unsentence mem cid cls f | And fl -> let (sentences, other) = List.partition (fun f -> free_vars f = []) fl in - if List.for_all (check_raw sv mem cid cls) sentences then + if List.for_all (check_raw mem cid cls) sentences then And other else Or [] | f -> f -let check solver cid cls in_psi = - check_raw solver (ref [], ref []) cid cls in_psi +let check cid cls in_psi = + check_raw (ref [], ref []) cid cls in_psi Modified: trunk/Toss/Solver/Class.mli =================================================================== --- trunk/Toss/Solver/Class.mli 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Solver/Class.mli 2011-03-02 01:20:52 UTC (rev 1339) @@ -37,11 +37,11 @@ - each exists X (phi) by exists "A:c:X" "B:d:X" (phi), x in X-> x in X1 or X2 - dually the forall quantifiers - each resulting atom, say R(A:c:x, B:d:y), as given in WITH reldefs. *) -val split : Solver.solver -> Formula.formula -> struct_sum -> Formula.formula +val split : Formula.formula -> struct_sum -> Formula.formula (** Split the formula as above and simplify by replacing trivially true or false atoms such as L(x:R) ... *) -val split_simplify : Solver.solver -> ?get_ids : bool -> +val split_simplify : ?get_ids : bool -> Formula.formula -> struct_sum -> Formula.formula @@ -49,12 +49,11 @@ (** Compute a decomposition of a formula on a given class definition. *) -val decompose : Solver.solver -> ?get_ids : bool -> +val decompose : ?get_ids : bool -> Formula.formula -> struct_sum -> (string * Formula.formula) list list (** {2 WMSO model checking on inductive structures} *) -val check : Solver.solver -> string -> structure_class -> - Formula.formula -> bool +val check : string -> structure_class -> Formula.formula -> bool Modified: trunk/Toss/Solver/ClassTest.ml =================================================================== --- trunk/Toss/Solver/ClassTest.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Solver/ClassTest.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -94,13 +94,13 @@ let test_split phi_s cs = let f = formula_of_string phi_s in - let split_f s = Class.split (Solver.new_solver ()) f s in + let split_f s = Class.split f s in test_sum ("Split of " ^ phi_s) split_f Formula.str cs ;; let test_split_simplify phi_s cs = let f = formula_of_string phi_s in - let split_f s = Class.split_simplify (Solver.new_solver ()) f s in + let split_f s = Class.split_simplify f s in test_sum ("Simplified Split of " ^ phi_s) split_f Formula.str cs ;; @@ -131,7 +131,7 @@ let test_decompose ids phi_s cs = let f = formula_of_string phi_s in - let decompose_f s = Class.decompose ~get_ids:ids (Solver.new_solver ()) f s in + let decompose_f s = Class.decompose ~get_ids:ids f s in let decomp_lit_str (cid, phi) = "some " ^ cid ^ " |= " ^ (Formula.str phi) in let decomp_tuple_str cj = "(" ^ String.concat " and " (List.map decomp_lit_str cj) ^ ")" in @@ -184,7 +184,7 @@ let test_check phi_s id cs = let (f, c) = (formula_of_string phi_s, class_of_string cs) in print_endline ("Checking " ^ (Formula.str f) ^ " on " ^ id); - print_endline (string_of_bool (Class.check (Solver.new_solver()) id c f)); + print_endline (string_of_bool (Class.check id c f)); print_endline ""; ;; Modified: trunk/Toss/Solver/PresbTest.ml =================================================================== --- trunk/Toss/Solver/PresbTest.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Solver/PresbTest.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -81,7 +81,7 @@ let test_check phi_s id cs = let (f, c) = (formula_of_string phi_s, class_of_string cs) in print_endline ("Checking " ^ (Formula.str f) ^ " on " ^ id); - print_endline (string_of_bool (Class.check (Solver.new_solver()) id c f)); + print_endline (string_of_bool (Class.check id c f)); print_endline ""; ;; Modified: trunk/Toss/Solver/Solver.ml =================================================================== --- trunk/Toss/Solver/Solver.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Solver/Solver.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -57,7 +57,7 @@ Hashtbl.add solver.formulas_check id (check_form psi); (psi, id) -let register_formula solver phi = +let register_formula_s solver phi = try let res = Hashtbl.find solver.reg_formulas phi in if !debug_level > 0 then print_endline ("DirectFound " ^ (str phi)); @@ -223,7 +223,16 @@ FO (v, List.rev asg_list) in process_vars [] (List.sort Formula.compare_vars (fo_vars_real p)) +let eval_counter = ref 0 +(* Evaluate with assignment, no cache. *) +let evaluate_partial_aset solver ~formula struc fo_aset = + let elems = + ref (Set (Elems.cardinal struc.elements, struc.elements)) in + let phi = Hashtbl.find solver.formulas_eval formula in + incr eval_counter; + eval struc elems fo_aset phi + (* Helper: find assoc and remove. *) let rec assoc_del (x : Formula.formula) = function | [] -> raise Not_found @@ -232,8 +241,6 @@ let (b, nl) = assoc_del x l in (b, pair :: nl) -let eval_counter = ref 0 - let diffrels_struc s1 s2 = if Structure.equal { s1 with relations = StringMap.empty; } { s2 with relations = StringMap.empty; } then @@ -441,7 +448,6 @@ Hashtbl.add !re_cache_results re (re_val, re_rels re); re_val - (* Evaluate i-th formula on j-th structure. *) let evaluate solver ~formula struc = let phi = Hashtbl.find solver.formulas_eval formula in @@ -458,37 +464,23 @@ if !debug_level > 1 then print_endline ("Check " ^ (str phi)) else (); check_formula phi -let evaluate_partial_aset solver ~formula struc fo_aset = (* not memoized *) - let elems = - ref (Set (Elems.cardinal struc.elements, struc.elements)) in - let phi = Hashtbl.find solver.formulas_eval formula in - incr eval_counter; - eval struc elems fo_aset phi (* Interface to {!SolverIntf}. *) module M = struct - type registered_formula = int - type registered_real_expr = Formula.real_expr let solver = new_solver () - let register_formula phi = - register_formula solver phi - let register_real_expr expr = expr (* TODO? *) - let evaluate struc formula = evaluate solver ~formula struc - let evaluate_partial struc intpr formula = (* not memoized *) - let make_fo_asg asg (v, e) = FO (v, [(e, asg)]) in - let fo_aset = List.fold_left make_fo_asg Any intpr in - let elems = - ref (Set (Elems.cardinal struc.elements, struc.elements)) in - let phi = Hashtbl.find solver.formulas_eval formula in - incr eval_counter; - eval struc elems fo_aset phi + let evaluate struc phi = + evaluate solver ~formula:(register_formula_s solver phi) struc + let evaluate_real = evaluate_real + let evaluate_partial struc intpr phi = + evaluate_partial_aset solver ~formula:(register_formula_s solver phi) + struc intpr - let check_formula struc formula = - check solver ~formula struc + let check struc phi = + check solver ~formula:(register_formula_s solver phi) struc let get_real_val re struc = get_real_val_cache solver struc re let formula_str phi = - let phi = Hashtbl.find solver.formulas_check phi in + (* let phi = Hashtbl.find solver.formulas_check phi in *) Formula.str phi let real_str expr = Formula.real_str expr Modified: trunk/Toss/Solver/Solver.mli =================================================================== --- trunk/Toss/Solver/Solver.mli 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Solver/Solver.mli 2011-03-02 01:20:52 UTC (rev 1339) @@ -1,68 +1,40 @@ (** Solver for checking if formulas hold on structures. *) -type solver +(** {1 Interface} *) -val new_solver : unit -> solver -val register_formula : solver -> Formula.formula -> int -val get_formula : solver -> int -> Formula.formula -(** {2 Evaluation} *) +(** Interface to the solver. *) +module M : sig + (** Check the formula on the structure. *) + val check : Structure.structure -> Formula.formula -> bool -type cachetbl = - (Formula.formula, Assignments.assignment_set * string list option) Hashtbl.t + (** Evaluate the formula on the structure. *) + val evaluate : Structure.structure -> + Formula.formula -> AssignmentSet.assignment_set -val eval_counter : int ref -val get_cache : unit -> Structure.structure * cachetbl -val set_cache : Structure.structure * cachetbl -> unit + (** Evaluate the formula on the structure and join with given assignment. *) + val evaluate_partial : Structure.structure -> AssignmentSet.assignment_set -> + Formula.formula -> AssignmentSet.assignment_set -(** Evaluate i-th formula on j-th structure. *) -val evaluate : solver -> formula:int -> Structure.structure -> - Assignments.assignment_set + (** Evaluate real expressions. Result is represented as assignments with + real-valued polynomials using variable [rvar] to represent [expr]. + We assume that [rvar] does not occur in [expr]. *) + val evaluate_real : string -> Formula.real_expr -> Structure.structure -> + Assignments.assignment_set -(** Check if i-th formula holds on j-th structure. *) -val check : solver -> formula:int -> Structure.structure -> bool + (** Get the value of a real expression without free variables. *) + val get_real_val : Formula.real_expr -> Structure.structure -> float +end -(** Evaluate real expressions. Result is represented as assignments with - real-valued polynomials using variable [rvar] to represent [expr]. - We assume that [rvar] does not occur in [expr]. *) -val evaluate_real : string -> Formula.real_expr -> Structure.structure -> - Assignments.assignment_set -(** Fast function to get a value of a real expression without free variables. *) -val get_real_val : solver -> Assignments.assignment_set -> - Formula.real_expr -> Structure.structure -> float - -(** Evaluate a formula and intersect its assignments with the given set. *) -val evaluate_partial_aset : - solver -> formula:int -> Structure.structure -> - AssignmentSet.assignment_set -> - AssignmentSet.assignment_set - - (** {2 Debugging} *) - (** Debugging information. At level 0 nothing is printed out. *) val set_debug_level : int -> unit -(** Interface to {!SolverIntf}. *) -module M : sig - type registered_formula - type registered_real_expr - val register_formula : - Formula.formula -> registered_formula - val register_real_expr : - Formula.real_expr -> registered_real_expr - val evaluate : Structure.structure -> - registered_formula -> AssignmentSet.assignment_set - val evaluate_partial : - Structure.structure -> (Formula.fo_var * int) list -> - registered_formula -> AssignmentSet.assignment_set - val check_formula : Structure.structure -> - registered_formula -> bool - val get_real_val : registered_real_expr -> Structure.structure -> float - val formula_str : registered_formula -> string - val real_str : registered_real_expr -> string -end +(** Counter of internal formula evaluations for profiling. *) +val eval_counter : int ref + + Modified: trunk/Toss/Solver/SolverTest.ml =================================================================== --- trunk/Toss/Solver/SolverTest.ml 2011-03-01 02:15:08 UTC (rev 1338) +++ trunk/Toss/Solver/SolverTest.ml 2011-03-02 01:20:52 UTC (rev 1339) @@ -1,4 +1,4 @@ -open Solver ;; +open Solver.M ;; open OUnit ;; Solver.set_debug_level 0 ;; @@ -22,9 +22,8 @@ let res = ref "" in backtrace ( let (struc, phi) = (struc_of_string struc_s, formula_of_string phi_s) in - let solver = new_solver () in - let f = register_formula solver phi in - res := AssignmentSet.str (evaluate solver f struc); + (* let solver = new_solver () in *) + res := AssignmentSet.str (evaluate struc phi); ); assert_equal ~printer:(fun x -> x) aset_s !res ;; @@ -38,7 +37,7 @@ let real_val_eq struc_s expr_s x = let (struc, expr) = (struc_of_string struc_s, real_expr_of_string expr_s) in assert_equal ~printer:(fun x -> string_of_float x) - x (get_real_val (new_solver ()) AssignmentSet.Any expr struc) + x (get_real_val expr struc) ;; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-03 21:40:07
|
Revision: 1342 http://toss.svn.sourceforge.net/toss/?rev=1342&view=rev Author: lukstafi Date: 2011-03-03 21:40:00 +0000 (Thu, 03 Mar 2011) Log Message: ----------- GDL translation: progress on negation handling. Aux: tiny helper for below-diagonal pairs of elements. Various test fixes. Modified Paths: -------------- trunk/Toss/Arena/DiscreteRule.ml trunk/Toss/Arena/DiscreteRuleTest.ml trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/GDLTest.ml trunk/Toss/Play/GameTest.ml trunk/Toss/Server/Server.ml trunk/Toss/Server/ServerGDLTest.in2 trunk/Toss/Server/ServerGDLTest.out2 trunk/Toss/Server/ServerTest.ml Modified: trunk/Toss/Arena/DiscreteRule.ml =================================================================== --- trunk/Toss/Arena/DiscreteRule.ml 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Arena/DiscreteRule.ml 2011-03-03 21:40:00 UTC (rev 1342) @@ -754,15 +754,17 @@ let varify_lhs tup = Array.map (fun e -> `FO (lhs_name_of e)) tup in (* summing up: the LHS structure embedding plus the precondition *) - let emb = And [ - And (Aux.concat_map (fun (rel, tups) -> - List.map (fun tup -> Rel (rel, varify_lhs tup)) tups) lhs_pos_tups); - And (Aux.concat_map (fun (rel, tups) -> - List.map (fun tup -> Not (Rel (rel, varify_lhs tup))) tups) lhs_neg_tups); - And (List.map (function [x;y] -> Not (Eq (`FO x, `FO y)) - | _ -> assert false) lhs_alldif_tups); - precond - ] in + let emb = And ( + Aux.concat_map (fun (rel, tups) -> + List.map (fun tup -> Rel (rel, varify_lhs tup)) tups) + lhs_pos_tups @ + Aux.concat_map (fun (rel, tups) -> + List.map (fun tup -> Not (Rel (rel, varify_lhs tup))) tups) + lhs_neg_tups @ + List.map (function [x;y] -> Not (Eq (`FO x, `FO y)) + | _ -> assert false) lhs_alldif_tups @ + FormulaOps.flatten_ands precond + ) in (* Substitute defined relations, expanding their special variants. *) let transform_new_rel = function Modified: trunk/Toss/Arena/DiscreteRuleTest.ml =================================================================== --- trunk/Toss/Arena/DiscreteRuleTest.ml 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Arena/DiscreteRuleTest.ml 2011-03-03 21:40:00 UTC (rev 1342) @@ -665,7 +665,7 @@ pre = Formula.And []; rule_s = [1,1]} in assert_one_of ~msg:"del defrel" - ["(O(b) and (not P(b)) and (not Q(b)) and (_del_P(b) or _del_Q(b)))-> (P(b) and (not O(b)))";"((_del_Q(b) or _del_P(b)) and O(b) and (not P(b)) and (not Q(b)))-> (P(b) and (not O(b)))";"((_del_P(b) and O(b) and (not P(b)) and (not Q(b))) or (_del_Q(b) and O(b) and (not P(b)) and (not Q(b))))-> (P(b) and (not O(b)))"] + ["(O(b) and (not P(b)) and (not Q(b)) and (_del_P(b) or _del_Q(b)))-> (P(b) and (not O(b)))";"((_del_Q(b) or _del_P(b)) and O(b) and (not P(b)) and (not Q(b)))-> (P(b) and (not O(b)))";"((_del_P(b) and O(b) and (not P(b)) and (not Q(b))) or (_del_Q(b) and O(b) and (not P(b)) and (not Q(b))))-> (P(b) and (not O(b)))";"((_del_P(b) or _del_Q(b)) and O(b) and (not P(b)) and (not Q(b)))-> (P(b) and (not O(b)))"] (rule_obj_str rule_obj); let lhs_struc = struc_of_str "[ e | _opt_D (e); _diffthan_P(e) | ]" in Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Formula/Aux.ml 2011-03-03 21:40:00 UTC (rev 1342) @@ -178,6 +178,12 @@ concat_map (fun el -> List.map (fun tup -> el::tup) prod) set) l [[]] +let rec pairs l = + match l with + | [] -> [] + | hd::tl -> + List.rev_append (List.map (fun e-> hd, e) tl) (pairs tl) + let all_tuples_for args elems = List.fold_left (fun tups _ -> concat_map (fun e -> (List.map (fun tup -> e::tup) tups)) Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Formula/Aux.mli 2011-03-03 21:40:00 UTC (rev 1342) @@ -113,6 +113,10 @@ (** Cartesian product of lists. Not tail recursive. *) val product : 'a list list -> 'a list list +(** A list of all pairs of elements that preserve the order of + elements from the list. *) +val pairs : 'a list -> ('a * 'a) list + (** An [n]th cartesian power of the second list, where [n] is the length of the first list. Tail recursive. *) val all_tuples_for : 'a list -> 'b list -> 'b list list Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/GGP/GDL.ml 2011-03-03 21:40:00 UTC (rev 1342) @@ -189,11 +189,39 @@ [not (r, args) <=> not exist vars1 (args = params1 /\ body1) /\ ... /\ not exist vars_n (args = params_n /\ body_n)] - Currently we do not allow defined dynamic relations with negative - occurrences to have negative literals (or atoms of defined - relations with negative part) in any of [body_i]. (The limitation - can be lifted but it would further complicate the implementation.) - We therefore allow conjunctions of atoms to be negated (not only + (6b1) If the relation has negative subformulas in any of [body_i], + we first negate the definition and then expand the negation as in + the positive case. + + (6b1a) Eliminate [args = params_i] by substituting-out variables + from [params_i] whenever possible. + + Note: the [args] need to be instatiated for the particular + solution that is extended (the solution substitution applied). + + (6b1b) We group the positive atoms of body_i together and split + the quantifier if each negative subformula and the positive part + have disjoint [vars_i] variables; if not, the translation fails; + currently, if a negative subformula has free variables in vars_i, + the translation also fails. + + (6b1c) So we have two levels of specification-affecting TODOs; + working around variables shared between negated subformulas or the + positive part -- forbidding pushing quantification inside -- will + require major rethinking of implementation; if the quantification + can be pushed inside but doesn't disappear around a negated + subformula, we will need to extend the universal quantifier + handling from only negated to both negated and positive + subformulas, which shouldn't be problematic. + + (6b1d) Now push the negation inside the conjunction so that all + double negations cancel out (the positive conjuncts are under a + single, now negated, quantifier -- see (6b2) about negated + conjunctions of atoms). Next we pull the disjunctions out + (reducing to DNF-like form), and continue as in the positive case + (6a). + + (6b2) We allow conjunctions of atoms to be negated (not only literals) in a branch. We expand [not (r, args)] (in general, [not (and (...(r args)...))]) into the conjunction of negations, with no branch duplication (in general, duplicating the negated @@ -633,6 +661,12 @@ (* Type shortcuts (mostly for documentation). *) type gdl_atom = string * term list type gdl_rule = gdl_atom * gdl_atom list * gdl_atom list +(* Definition with collected relation branches and negation-local + variables found. *) +type lit_def_branch = + term list * gdl_atom list * (Aux.Strings.t * gdl_atom) list +type lit_def = + string * lit_def_branch list (* Definition with expanded definitions: expansion of a negated relation brings negated (possibly locally existentially quantified) conjunctions. *) @@ -699,13 +733,14 @@ head, pos_body, neg_body) bodies | Atomic (rel, args) -> [(rel, args), [], []] -let add_neg_body_vars global_vars neg_body = +let add_neg_body_vars global_vars neg_body + : (Aux.Strings.t * gdl_atom) list = List.map (fun (_, args as a)-> let local_vs = Aux.Strings.diff (terms_vars args) global_vars in - local_vs, [a]) neg_body + local_vs, a) neg_body -let defs_of_rules rules - : (string * exp_def_branch list) list = +let lit_defs_of_rules rules + : (string * lit_def_branch list) list = Aux.map_reduce (fun ((drel, params), body, neg_body) -> let global_vs = @@ -714,27 +749,36 @@ add_neg_body_vars global_vs neg_body)) (fun x y->y::x) [] rules -(* Only use [rules_of_defs] when sure that no multi-premise negative - literal has been expanded. *) -let rules_of_defs (defs : exp_def list) = +let rules_of_lit_defs (defs : lit_def list) = Aux.concat_map (fun (rel, branches) -> List.map (fun (args, body, neg_body) -> let neg_body = - List.map (function _,[a]->a | _ -> assert false) neg_body in + List.map snd neg_body in (rel, args), body, neg_body) branches) defs +let exp_brs_of_lit_brs brs = + List.map (fun (args, body, neg_body) -> + let neg_body = + List.map (fun (vs,a) -> vs,[a]) neg_body in + args, body, neg_body) brs + +let exp_defs_of_lit_defs defs : exp_def list = + List.map (fun (rel, branches) -> + rel, exp_brs_of_lit_brs branches) defs + + (* Stratify either w.r.t. the dependency graph ([~def:true]) or its subgraph the negation graph ([~def:false]). *) -let rec stratify ?(def=false) strata (defs : exp_def list) = +let rec stratify ?(def=false) strata (defs : lit_def list) = match List.partition (fun (_, branches) -> List.for_all (fun (_, body, neg_body) -> - let neg_bodies = List.concat (List.map snd neg_body) in + let neg_body = List.map snd neg_body in List.for_all (fun (rel1,_) -> rel1 = "distinct" || rel1 = "true" || rel1 = "does" || not (List.mem_assoc rel1 defs)) - (if def then body @ neg_bodies - else neg_bodies)) branches) defs + (if def then body @ neg_body + else neg_body)) branches) defs with | [], [] -> (* {{{ log entry *) @@ -935,6 +979,13 @@ let facts_str facts = String.concat " " (List.map fact_str facts) +let neg_lfacts_str negs = + String.concat " " + (List.map (fun (vs,d) -> + let vs = Aux.Strings.elements vs in + let q = if vs = [] then "" + else "forall "^String.concat ", " vs in + q ^ "(not "^fact_str d^")") negs) let neg_facts_str negs = String.concat " " (List.map (fun (vs,d) -> @@ -947,9 +998,15 @@ "("^ fact_str (rel, args) ^ " <= " ^ facts_str body ^ " " ^ neg_facts_str neg_body ^ ")" -let def_str (rel, branches) = +let lit_def_str (rel, branches) = String.concat "\n" (List.map (fun (args, body, neg_body) -> "("^ fact_str (rel, args) ^ " <= " ^ facts_str body ^ + " " ^ neg_lfacts_str neg_body ^ ")" + ) branches) + +let exp_def_str (rel, branches) = + String.concat "\n" (List.map (fun (args, body, neg_body) -> + "("^ fact_str (rel, args) ^ " <= " ^ facts_str body ^ " " ^ neg_facts_str neg_body ^ ")" ) branches) (* @@ -1059,19 +1116,17 @@ instantiate (inst_stratum [] [] base stratum) strata in instantiate base - (List.map rules_of_defs (stratify [] (defs_of_rules rules))) + (List.map rules_of_lit_defs (stratify [] (lit_defs_of_rules rules))) let game_description = ref [] let player_terms = ref [| |] let state_of_file s = - Printf.printf "GDL: Loading file %s...\n%!" s; let f = open_in s in let res = ArenaParser.parse_game_state Lexer.lex (Lexing.from_channel f) in - Printf.printf "GDL: File %s loaded.\n%!" s; res (* 6 *) @@ -1121,12 +1176,61 @@ let freshen_def_branches = List.map freshen_branch +(* [args] are the actual, instatiated, arguments. *) +let negate_def uni_vs args neg_def = + (* 6b1a *) + let global_vars = terms_vars args in + let aux_br (params, body, neg_body) = + let sb = unify [] params args in + let body = subst_rels sb body in + let neg_body = List.map (fun (vs, conjs) -> + vs, subst_rels sb conjs) neg_body in + let subforms = (Aux.Strings.empty, body) :: neg_body in + (* components of [vars_i] by conjuncts *) + let sub_fvars = List.map (fun (_, subphi) -> + Aux.Strings.diff (rels_vars subphi) global_vars) subforms in + let subvars = List.map2 (fun fvs (qvs,_) -> + Aux.Strings.diff fvs qvs) sub_fvars subforms in + (* 6b1b *) + if List.exists (fun (vs1, vs2) -> + not (Aux.Strings.is_empty (Aux.Strings.inter vs1 vs2))) + (Aux.pairs subvars) + then failwith + ("GDL.negate_def: variables shared between negated subformulas" ^ + " -- long term TODO (params: "^terms_str params^")"); + (if List.exists (fun (fvs, (qvs,_)) -> + (* [fvs - qvs] must be a subset of the "vars_i" quantified vars *) + not (Aux.Strings.is_empty (Aux.Strings.diff fvs qvs))) + (List.tl (List.combine sub_fvars subforms)) + then + let (fvs,(qvs,_)) = List.find (fun (fvs, (qvs,_)) -> + not (Aux.Strings.is_empty (Aux.Strings.diff fvs qvs))) + (List.tl (List.combine sub_fvars subforms)) in + failwith + ("GDL.negate_def: universal quantification escapes negation" ^ + " -- doable TODO (params: "^terms_str params^") (vars: "^ + String.concat ", " (Aux.Strings.elements + (Aux.Strings.diff fvs qvs))^")")); + Aux.Right (List.hd sub_fvars, body) :: + List.map (fun (_,conjs) -> Aux.Left conjs) neg_body in + (* 6b1c *) + (* We drop branches whose heads don't match. *) + let cnf = Aux.map_try aux_br neg_def in + let dnf = Aux.product cnf in + List.map (fun conjs -> + let pos, neg = Aux.partition_choice conjs in + (* since (6b1b), no local universal quantification *) + let pos = List.concat pos in + pos, neg + ) dnf + + (* assumption: [defs] bodies are already clean of defined relations *) let subst_def_branch (defs : exp_def list) - (head, body, neg_body as br : exp_def_branch) : exp_def_branch list = + (head, body, neg_body as br : lit_def_branch) : exp_def_branch list = (* {{{ log entry *) if !debug_level > 4 then ( - Printf.printf "Expanding branch %s\n%!" (def_str ("BRANCH", [br])); + Printf.printf "Expanding branch %s\n%!" (lit_def_str ("BRANCH", [br])); ); (* }}} *) (* 6a *) @@ -1137,7 +1241,7 @@ (* {{{ log entry *) if !debug_level > 4 then ( Printf.printf "Expanding positive %s by %s\n%!" rel - (def_str (rel, def)) + (exp_def_str (rel, def)) ); (* }}} *) Aux.concat_map (fun (pos_sol, neg_sol, sb) -> @@ -1158,48 +1262,91 @@ subst_rel sb atom::pos_sol, neg_sol, sb) sols)) ([[],[],[]]) body in (* 6b *) + let neg_body_flat, neg_body_rec = + Aux.partition_map (fun (uni_vs, (neg_rel, neg_args) as neg_lit) -> + (let try def = + freshen_def_branches (List.assoc neg_rel defs) in + if not (List.exists (fun (_,_,negb) -> negb<>[]) def) + then Aux.Left (neg_lit, Some def) + else ( + (* {{{ log entry *) + + if !debug_level > 3 then ( + let _,_,def_neg_body = + List.find (fun (_,_,negb) -> negb <> []) def in + Printf.printf + "expand: found recursive negative %s(%s): neg_body= not %s\n%!" + neg_rel (terms_str neg_args) + (String.concat " and not " + (List.map facts_str (List.map snd def_neg_body))) + ); + + (* }}} *) + Aux.Right (neg_lit, def)) + with Not_found -> Aux.Left (neg_lit, None)) + ) neg_body in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "Expanding (%s) negative part: flat %s; rec %s\n%!" + (terms_str head) + (String.concat ", "(List.map (fun ((_,(nr,_)),_) -> nr) neg_body_flat)) + (String.concat ", "(List.map (fun ((_,(nr,_)),_) -> nr) neg_body_rec)) + ); + (* }}} *) + (* 6b1 *) let sols = - (* no branch duplication, but each negation has its own substitution *) + List.fold_left (fun sols ((uni_vs, (rel, args)), neg_def) -> + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "Expanding rec-negative %s by %s\n%!" rel + (exp_def_str (rel, neg_def)) + ); + (* }}} *) + (* we don't keep the substitution from the negated match *) + Aux.concat_map (fun (pos_sol, neg_sol, sb) -> + let args = List.map (subst sb) args in + let branches = negate_def uni_vs args neg_def in + List.map (fun (dbody, dneg_body) -> + dbody @ pos_sol, dneg_body @ neg_sol, sb) branches + ) sols) + sols neg_body_rec in + + (* 6b2 *) + let sols = List.map (fun (pos_sol, neg_sol, sb) -> let more_neg_sol = - Aux.concat_map (fun (uni_vs, neg_conjs) -> - (* negated subformulas are duplicated instead *) - List.fold_left (fun neg_sol (rel, args as atom) -> - (let try def = - freshen_def_branches (List.assoc rel defs) in - Aux.concat_map (fun (uni_vs, neg_acc, sb) -> - let args = List.map (subst sb) args in - Aux.map_try (fun (dparams, dbody, dneg_body) -> - if dneg_body <> [] then - failwith - ("GDL.subst_def_branch: negation in negatively used" ^ - " defined rels not supported yet, relation "^rel); - (let sb1 = unify [] dparams args in - let param_vars = terms_vars dparams in - let body_vars = rels_vars dbody in - let dbody = subst_rels sb1 dbody in - let local_vs = - Aux.Strings.inter (Aux.Strings.diff body_vars param_vars) - (rels_vars dbody) in - let neg_acc = subst_rels sb1 neg_acc in - Aux.Strings.union uni_vs local_vs, - dbody @ neg_acc, - extend_sb sb1 sb) - ) def) neg_sol - with Not_found -> (* rel not in defs *) - List.map (fun (uni_vs, neg_acc, sb) -> - uni_vs, subst_rel sb atom::neg_acc, sb) neg_sol) - ) [uni_vs, [], sb] neg_conjs - ) neg_body in - let more_neg_sol = - List.map (fun (uni_vs, neg_conjs,_) -> uni_vs, neg_conjs) - more_neg_sol in + Aux.concat_map (fun ((uni_vs, (rel, args as atom)), def_opt) -> + (* negated subformulas are duplicated instead of branches *) + match def_opt with + | Some def -> + let args = List.map (subst sb) args in + Aux.map_try (fun (dparams, dbody, _) -> + (let sb1 = unify [] dparams args in + let param_vars = terms_vars dparams in + let body_vars = rels_vars dbody in + let dbody = subst_rels sb1 dbody in + let local_vs = + Aux.Strings.diff body_vars + (Aux.Strings.diff param_vars uni_vs) in + local_vs, dbody) + ) def + | None -> (* rel not in defs *) + [uni_vs, [atom]] + ) neg_body_flat in List.rev pos_sol, List.rev_append neg_sol more_neg_sol, sb ) sols in - Aux.map_some (fun (pos_sol, neg_sol, sb) -> - if List.exists (function _,[] -> true | _ -> false) neg_sol - then None - else Some (List.map (subst sb) head, pos_sol, neg_sol)) sols + let res = + Aux.map_some (fun (pos_sol, neg_sol, sb) -> + if List.exists (function _,[] -> true | _ -> false) neg_sol + then None + else Some (List.map (subst sb) head, pos_sol, neg_sol)) sols in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "Expansion: res =\n%s\nExpansion done.\n%!" + (String.concat "\n"(List.map (branch_str "exp-unkn") res)) + ); + (* }}} *) + res (* Stratify and expand all relations in the given set. *) let expand_def_rules ?(more_defs=[]) rules = @@ -1218,14 +1365,16 @@ (* {{{ log entry *) if !debug_level > 3 then ( Printf.printf "expand_def_rules: step result = %s\nexpand_def_rules: end step\n%!" - (String.concat "\n" (List.map def_str step)) + (String.concat "\n" (List.map exp_def_str step)) ); (* }}} *) loop (base @ step) strata in - match stratify ~def:true [] (defs_of_rules rules) with + match stratify ~def:true [] (lit_defs_of_rules rules) with | [] -> [] - | [no_defined_rels] when more_defs=[] -> no_defined_rels - | def_base::def_strata when more_defs=[] -> loop def_base def_strata + | [no_defined_rels] when more_defs=[] -> + exp_defs_of_lit_defs no_defined_rels + | def_base::def_strata when more_defs=[] -> + loop (exp_defs_of_lit_defs def_base) def_strata | def_strata -> loop more_defs def_strata @@ -1262,6 +1411,11 @@ (List.rev_append more_neg_body neg_body))) with Not_found -> None +let subst_legal_rules def_brs brs = + Aux.concat_map (fun br -> + List.map snd + (Aux.map_some (fun def -> subst_legal_rule def br) def_brs)) brs + (* 1 *) (* Collect the aggregate playout, but also the actions available in @@ -1994,27 +2148,21 @@ | _ -> false) static_rules ) static_rules in (* {{{ log entry *) - if !debug_level > 0 then ( Printf.printf "translate_game: expanded static rules: %s\n%!" (String.concat ", " (List.map (fun ((r,_),_,_)->r) exp_static_rules)); ); - (* }}} *) let static_exp_defs = expand_def_rules exp_static_rules in - let static_rules = - if static_exp_defs = [] then static_rules - else rules_of_defs - (List.map (fun (rel,branches) -> - rel, Aux.concat_map (subst_def_branch static_exp_defs) branches) - (defs_of_rules static_rules)) in + let static_rules = Aux.unique_sorted + (List.map Aux.fst3 static_rules) in let exp_defs = expand_def_rules ~more_defs:static_exp_defs dynamic_rules in (* {{{ log entry *) if !debug_level > 0 then ( Printf.printf "translate_game: All expanded dynamic rules:\n%s\n%!" - (String.concat "\n" (List.map def_str exp_defs)) + (String.concat "\n" (List.map exp_def_str exp_defs)) ); (* }}} *) (* 3 *) @@ -2023,15 +2171,13 @@ let terminal_rules = List.assoc "terminal" exp_defs in let goal_rules = List.assoc "goal" exp_defs in (* 3b *) - let exp_next = - Aux.concat_map (subst_def_branch ["does", legal_rules]) next_rules in + let exp_next = subst_legal_rules legal_rules next_rules in + (* {{{ log entry *) - if !debug_level > 0 then ( Printf.printf "translate_game: \"next\" rules with \"does\"<-\"legal\":\n%s\n%!" - (def_str ("next", exp_next)) + (exp_def_str ("next", exp_next)) ); - (* }}} *) (* 3c *) let masks = List.map (function @@ -2119,9 +2265,8 @@ | mask, (sb,_)::_ -> List.map (fun (v,_)->mask, v) sb) elements in (* 4a *) let static_rels = - Aux.unique_sorted - (List.map (fun ((rname,args),_,_) -> - rname, List.map (fun _ -> ()) args) static_rules) in + List.map (fun (rname,args) -> + rname, List.map (fun _ -> ()) args) static_rules in let static_rels = List.map (fun (rel,args) -> rel, List.length args, @@ -2517,7 +2662,9 @@ ); (* }}} *) (* 7f3 *) - let erasure_brs : exp_def_branch list = Aux.concat_map + (* TODO: minimize the number of branches by keeping + negations over conjunctions like in (6b1) *) + let erasure_brs : lit_def_branch list = Aux.concat_map (function | [next_arg] as next_args,multi_body -> let mask, _, _, blank_arg = term_to_blank masks next_arg in @@ -2596,8 +2743,7 @@ List.mem pos neg_conjs) lead_neg_body ) body) && not (List.exists (fun (_,neg) -> - List.for_all - (fun neg->List.mem neg lead_body) neg + List.mem neg lead_body ) neg_body) then Some ([head], body, neg_body) else None @@ -2612,7 +2758,8 @@ (* TODO: (7f5) we ignore the possibility that "lead" is instantiated by some of erasure substitutions, since we already ignore non-maximal "legal" classes *) - lead_head, fixed_brs @ expanded_brs @ erasure_brs + lead_head, fixed_brs @ expanded_brs @ + exp_brs_of_lit_brs erasure_brs ) rules_brs in (* let rules_inds = Array.of_list rules_brs in *) rules_brs @@ -2625,12 +2772,12 @@ List.iter (fun (lead, brs) -> Printf.printf "Rule-precursor: player %s move %s\n%s\n%!" (term_str loc_players.(loc)) (term_str lead) - (def_str ("action", brs)) + (exp_def_str ("action", brs)) ) rules_brs; ) loc_next_classes; ); (* }}} *) - let static_rnames = List.map (fun ((srel,_),_,_) -> srel) static_rules in + let static_rnames = List.map fst static_rules in (* 7h *) let loc_toss_rules = Array.mapi (fun loc rules_brs -> @@ -2890,7 +3037,8 @@ List.filter (fun a -> List.exists (fun v->List.mem v disj_vars) (FormulaOps.free_vars a)) goal_4b in let disj = lift_universal goal_uni_vars (disj_4b @ conjs) in - Formula.Ex (FormulaOps.free_vars disj, disj) + let disj_vs = FormulaOps.free_vars disj in + if disj_vs = [] then disj else Formula.Ex (disj_vs, disj) ) brs in score, Formula.Or goal_disjs ) goals in Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/GGP/GDL.mli 2011-03-03 21:40:00 UTC (rev 1342) @@ -85,7 +85,7 @@ gdl_translation * (Arena.game * Arena.game_state) (* DEBUG intermediate *) -val defs_of_rules : gdl_rule list -> exp_def list +(* val exp_defs_of_rules : gdl_rule list -> exp_def list *) val expand_def_rules : ?more_defs:exp_def list -> gdl_rule list -> exp_def list @@ -109,4 +109,4 @@ val term_str : term -> string val fact_str : string * term list -> string val facts_str : (string * term list) list -> string -val def_str : exp_def -> string +val exp_def_str : exp_def -> string Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/GGP/GDLTest.ml 2011-03-03 21:40:00 UTC (rev 1342) @@ -73,7 +73,7 @@ ((alpha ?X) <= (rho ?X) (not (and (gamma ?X) (rho ?X)))) ((zeta ?X) <= (rho ?X) (not (and (gamma ?X))))" (String.concat "\n" - (List.map GDL.def_str res)); + (List.map GDL.exp_def_str res)); ); "connect5" >:: @@ -114,5 +114,5 @@ let breakthrough = load_rules "./GGP/examples/breakthrough.gdl" in let connect5 = load_rules "./GGP/examples/connect5.gdl" in let tictactoe = load_rules "./GGP/examples/tictactoe.gdl" in - let gdef = GDL.translate_game (Const "white") breakthrough in + let gdef = GDL.translate_game (Const "x") connect5 in ignore gdef; ignore connect5; ignore breakthrough; ignore tictactoe Modified: trunk/Toss/Play/GameTest.ml =================================================================== --- trunk/Toss/Play/GameTest.ml 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Play/GameTest.ml 2011-03-03 21:40:00 UTC (rev 1342) @@ -31,12 +31,10 @@ (Lexing.from_string s) let state_of_file s = - Printf.printf "Loading file %s...\n%!" s; let f = open_in s in let res = ArenaParser.parse_game_state Lexer.lex (Lexing.from_channel f) in - Printf.printf "File %s loaded.\n%!" s; res module StrMap = Structure.StringMap Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Server/Server.ml 2011-03-03 21:40:00 UTC (rev 1342) @@ -441,12 +441,10 @@ let set_state_from_file fn = - Printf.printf "Loading file %s...\n%!" fn; let f = open_in fn in let s = ArenaParser.parse_game_state Lexer.lex (Lexing.from_channel f) in - Printf.printf "File %s loaded.\n%!" fn; game_modified := true; - state := s; + state := s ;; let heur_val_white1 = ref "";; Modified: trunk/Toss/Server/ServerGDLTest.in2 =================================================================== --- trunk/Toss/Server/ServerGDLTest.in2 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Server/ServerGDLTest.in2 2011-03-03 21:40:00 UTC (rev 1342) @@ -32,7 +32,7 @@ Content-type: text/acl Content-length: 41 -(PLAY MATCH.3316980891 (NOOP (MARK 1 1))) +(PLAY MATCH.3316980891 (NOOP (MARK 2 2))) POST / HTTP/1.0 Accept: text/delim @@ -41,7 +41,7 @@ Content-type: text/acl Content-length: 41 -(PLAY MATCH.3316980891 ((MARK 3 2) NOOP)) +(PLAY MATCH.3316980891 ((MARK 1 3) NOOP)) POST / HTTP/1.0 Accept: text/delim @@ -50,7 +50,7 @@ Content-type: text/acl Content-length: 41 -(PLAY MATCH.3316980891 (NOOP (MARK 2 2))) +(PLAY MATCH.3316980891 (NOOP (MARK 1 1))) POST / HTTP/1.0 Accept: text/delim @@ -59,7 +59,7 @@ Content-type: text/acl Content-length: 41 -(PLAY MATCH.3316980891 ((MARK 3 1) NOOP)) +(PLAY MATCH.3316980891 ((MARK 2 3) NOOP)) POST / HTTP/1.0 Accept: text/delim Modified: trunk/Toss/Server/ServerGDLTest.out2 =================================================================== --- trunk/Toss/Server/ServerGDLTest.out2 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Server/ServerGDLTest.out2 2011-03-03 21:40:00 UTC (rev 1342) @@ -12,7 +12,7 @@ Content-type: text/acl Content-length: 10 -(MARK 1 1) +(MARK 2 2) HTTP/1.0 200 OK Content-type: text/acl Content-length: 4 @@ -22,7 +22,7 @@ Content-type: text/acl Content-length: 10 -(MARK 2 2) +(MARK 1 1) HTTP/1.0 200 OK Content-type: text/acl Content-length: 4 Modified: trunk/Toss/Server/ServerTest.ml =================================================================== --- trunk/Toss/Server/ServerTest.ml 2011-03-03 18:28:09 UTC (rev 1341) +++ trunk/Toss/Server/ServerTest.ml 2011-03-03 21:40:00 UTC (rev 1342) @@ -57,7 +57,7 @@ let out_ch = open_out "./Server/ServerGDLTest.temp" in Game.deterministic_suggest := true; let old_effort = !Game.default_effort in - Game.default_effort := 2; + Game.default_effort := 6; (try while true do Server.req_handle in_ch out_ch done with End_of_file -> ()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-05 23:01:27
|
Revision: 1344 http://toss.svn.sourceforge.net/toss/?rev=1344&view=rev Author: lukaszkaiser Date: 2011-03-05 23:01:19 +0000 (Sat, 05 Mar 2011) Log Message: ----------- Separate small (fast) and big (slower) tests. Modified Paths: -------------- trunk/Toss/Makefile trunk/Toss/Play/GameTest.ml trunk/Toss/Play/HeuristicTest.ml Added Paths: ----------- trunk/Toss/TossFullTest.ml Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2011-03-03 23:47:31 UTC (rev 1343) +++ trunk/Toss/Makefile 2011-03-05 23:01:19 UTC (rev 1344) @@ -136,6 +136,7 @@ # All OUnit tests, aggregate TossTest: +TossFullTest: # ------ CLEAN ------ Modified: trunk/Toss/Play/GameTest.ml =================================================================== --- trunk/Toss/Play/GameTest.ml 2011-03-03 23:47:31 UTC (rev 1343) +++ trunk/Toss/Play/GameTest.ml 2011-03-05 23:01:19 UTC (rev 1344) @@ -259,54 +259,6 @@ (move_opt <> None) ); - "play: chess suggest first move" >:: - (fun () -> - skip_if true "loading takes long, worked last time"; - let horizon, advr, state = - Lazy.force chess_game in - let move_opt = (let p,ps = Game.initialize_default state - ~advr ?horizon - ~loc:0 ~effort:1 - ~search_method:"alpha_beta_ord" () in - Game.suggest p ps) in - assert_bool "Game is not over yet -- some move expected." - (move_opt <> None); - ); - - "play: checkers suggest first move depth 4" >:: - (fun () -> - let horizon, advr, state = - Lazy.force checkers_game in - let move_opt = (let p,ps = Game.initialize_default state - ~advr ?horizon - ~loc:0 ~effort:4 - ~search_method:"alpha_beta_ord" () in - Game.suggest p ps) in - assert_bool "Game is not over yet -- some move expected." - (move_opt <> None); - ); - - "play: chess begin random play" >:: - (fun () -> - skip_if true "loading takes long, worked last time"; - let _, advr, state = - Lazy.force chess_game in - let (game, struc) = (fst state, (snd state).Arena.struc) in - let play = - {Game.game = game; agents= - [|Game.Random_move; Game.Random_move|]; - delta = 2.0} in (* FIXME: give/calc delta *) - let init_state = Game.initial_state play struc in - (* let endstate,payoff = *) - ignore (Game.play ~grid_size:Move.cGRID_SIZE - ~set_timer:360 ~horizon:30 play init_state) (* in *) - (* nothing to assert -- just check halting without exceptions *) - (* - Printf.printf "Chess random play horizon=30 ended in:\n%s\n%!" - (Structure.sprint endstate) - *) - ); - "breakthrough payoff" >:: (fun () -> let horizon, advr, state = @@ -356,55 +308,6 @@ ); - "chess draw" >:: - (fun () -> - skip_if true "loading takes long, worked last time"; - let horizon, advr, state = - update_game chess_game -"[a1, b1, c1, d1, e1, f1, g1, h1, a2, b2, c2, d2, e2, f2, g2, h2, a3, b3, c3, d3, e3, f3, g3, h3, a4, b4, c4, d4, e4, f4, g4, h4, a5, b5, c5, d5, e5, f5, g5, h5, a6, b6, c6, d6, e6, f6, g6, h6, a7, b7, c7, d7, e7, f7, g7, h7, a8, b8, c8, d8, e8, f8, g8, h8 | D1 {(a1, b2); (b1, c2); (c1, d2); (d1, e2); (e1, f2); (f1, g2); (g1, h2); (a2, b3); (b2, a1); (b2, c3); (c2, b1); (c2, d3); (d2, c1); (d2, e3); (e2, d1); (e2, f3); (f2, e1); (f2, g3); (g2, f1); (g2, h3); (h2, g1); (a3, b4); (b3, a2); (b3, c4); (c3, b2); (c3, d4); (d3, c2); (d3, e4); (e3, d2); (e3, f4); (f3, e2); (f3, g4); (g3, f2); (g3, h4); (h3, g2); (a4, b5); (b4, a3); (b4, c5); (c4, b3); (c4, d5); (d4, c3); (d4, e5); (e4, d3); (e4, f5); (f4, e3); (f4, g5); (g4, f3); (g4, h5); (h4, g3); (a5, b6); (b5, a4); (b5, c6); (c5, b4); (c5, d6); (d5, c4); (d5, e6); (e5, d4); (e5, f6); (f5, e4); (f5, g6); (g5, f4); (g5, h6); (h5, g4); (a6, b7); (b6, a5); (b6, c7); (c6, b5); (c6, d7); (d6, c5); (d6, e7); (e6, d5); (e6, f7); (f6, e5); (f6, g7); (g6, f5); (g6, h7); (h6, g5); (a7, b8); (b7, a6); (b7, c8); (c7, b6); (c7, d8); (d7, c6); (d7, e8); (e7, d6); (e7, f8); (f7, e6); (f7, g8); (g7, f6); (g7, h8); (h7, g6); (b8, a7); (c8, b7); (d8, c7); (e8, d7); (f8, e7); (g8, f7); (h8, g7)}; D2 {(b1, a2); (c1, b2); (d1, c2); (e1, d2); (f1, e2); (g1, f2); (h1, g2); (a2, b1); (b2, c1); (b2, a3); (c2, d1); (c2, b3); (d2, e1); (d2, c3); (e2, f1); (e2, d3); (f2, g1); (f2, e3); (g2, h1); (g2, f3); (h2, g3); (a3, b2); (b3, c2); (b3, a4); (c3, d2); (c3, b4); (d3, e2); (d3, c4); (e3, f2); (e3, d4); (f3, g2); (f3, e4); (g3, h2); (g3, f4); (h3, g4); (a4, b3); (b4, c3); (b4, a5); (c4, d3); (c4, b5); (d4, e3); (d4, c5); (e4, f3); (e4, d5); (f4, g3); (f4, e5); (g4, h3); (g4, f5); (h4, g5); (a5, b4); (b5, c4); (b5, a6); (c5, d4); (c5, b6); (d5, e4); (d5, c6); (e5, f4); (e5, d6); (f5, g4); (f5, e6); (g5, h4); (g5, f6); (h5, g6); (a6, b5); (b6, c5); (b6, a7); (c6, d5); (c6, b7); (d6, e5); (d6, c7); (e6, f5); (e6, d7); (f6, g5); (f6, e7); (g6, h5); (g6, f7); (h6, g7); (a7, b6); (b7, c6); (b7, a8); (c7, d6); (c7, b8); (d7, e6); (d7, c8); (e7, f6); (e7, d8); (f7, g6); (f7, e8); (g7, h6); (g7, f8); (h7, g8); (a8, b7); (b8, c7); (c8, d7); (d8, e7); (e8, f7); (f8, g7); (g8, h7)}; bB:1 {}; wB:1 {}; wN:1 {}; wP:1 {}; wQ:1 {}; wR:1 {} | ] \" - ... ... ... ... - ... ... +bN ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... bP. ...-bNwK. - ... ... ... ... - ...bP ... ... ... - ... ... ... ... - bR. ... ...bQ ... - ... ... ... ... - ... ...bK ... ...bP - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... -\"" 0 in - - let payoffs = Array.to_list - (Array.mapi (fun i v->string_of_int i,v) - (fst state).Arena.graph.((snd state).Arena.cur_loc).Arena.payoffs) - in - let ev (p,e) = - p^": "^(string_of_float - (Solver.M.get_real_val e (snd state).Arena.struc)) in - let answ = - String.concat ", " (List.sort compare (List.map ev payoffs)) in - assert_equal ~msg:"draw (white no move): direct" ~printer:(fun x->x) - "0: 0., 1: 0." answ; - - let move_opt = (let p,ps = Game.initialize_default state - ~advr ?horizon - ~loc:0 ~effort:1 - ~search_method:"alpha_beta_ord" () in - Game.toss ~grid_size:Move.cGRID_SIZE p ps) in - assert_equal ~msg:"draw (white no move): suggest" ~printer:(function - | Aux.Left (bpos, moves, _, _) -> - "game not over: "^ move_gs_str (snd state) moves.(bpos) - | Aux.Right poffs -> - Printf.sprintf "{W: %F; B: %F}" poffs.(0) poffs.(1)) - (Aux.Right [| 0.0; 0.0 |]) move_opt; -); - "matching: breakthrough suggest start" >:: (fun () -> let horizon, advr, state = @@ -460,6 +363,107 @@ ] +let misc_tests_big = "misc_big" >::: [ + + "play: chess suggest first move" >:: + (fun () -> + skip_if true "loading takes long, worked last time"; + let horizon, advr, state = + Lazy.force chess_game in + let move_opt = (let p,ps = Game.initialize_default state + ~advr ?horizon + ~loc:0 ~effort:1 + ~search_method:"alpha_beta_ord" () in + Game.suggest p ps) in + assert_bool "Game is not over yet -- some move expected." + (move_opt <> None); + ); + + "play: checkers suggest first move depth 4" >:: + (fun () -> + let horizon, advr, state = + Lazy.force checkers_game in + let move_opt = (let p,ps = Game.initialize_default state + ~advr ?horizon + ~loc:0 ~effort:4 + ~search_method:"alpha_beta_ord" () in + Game.suggest p ps) in + assert_bool "Game is not over yet -- some move expected." + (move_opt <> None); + ); + + "play: chess begin random play" >:: + (fun () -> + skip_if true "loading takes long, worked last time"; + let _, advr, state = + Lazy.force chess_game in + let (game, struc) = (fst state, (snd state).Arena.struc) in + let play = + {Game.game = game; agents= + [|Game.Random_move; Game.Random_move|]; + delta = 2.0} in (* FIXME: give/calc delta *) + let init_state = Game.initial_state play struc in + (* let endstate,payoff = *) + ignore (Game.play ~grid_size:Move.cGRID_SIZE + ~set_timer:360 ~horizon:30 play init_state) (* in *) + (* nothing to assert -- just check halting without exceptions *) + (* + Printf.printf "Chess random play horizon=30 ended in:\n%s\n%!" + (Structure.sprint endstate) + *) + ); + + "chess draw" >:: + (fun () -> + skip_if true "loading takes long, worked last time"; + let horizon, advr, state = + update_game chess_game +"[a1, b1, c1, d1, e1, f1, g1, h1, a2, b2, c2, d2, e2, f2, g2, h2, a3, b3, c3, d3, e3, f3, g3, h3, a4, b4, c4, d4, e4, f4, g4, h4, a5, b5, c5, d5, e5, f5, g5, h5, a6, b6, c6, d6, e6, f6, g6, h6, a7, b7, c7, d7, e7, f7, g7, h7, a8, b8, c8, d8, e8, f8, g8, h8 | D1 {(a1, b2); (b1, c2); (c1, d2); (d1, e2); (e1, f2); (f1, g2); (g1, h2); (a2, b3); (b2, a1); (b2, c3); (c2, b1); (c2, d3); (d2, c1); (d2, e3); (e2, d1); (e2, f3); (f2, e1); (f2, g3); (g2, f1); (g2, h3); (h2, g1); (a3, b4); (b3, a2); (b3, c4); (c3, b2); (c3, d4); (d3, c2); (d3, e4); (e3, d2); (e3, f4); (f3, e2); (f3, g4); (g3, f2); (g3, h4); (h3, g2); (a4, b5); (b4, a3); (b4, c5); (c4, b3); (c4, d5); (d4, c3); (d4, e5); (e4, d3); (e4, f5); (f4, e3); (f4, g5); (g4, f3); (g4, h5); (h4, g3); (a5, b6); (b5, a4); (b5, c6); (c5, b4); (c5, d6); (d5, c4); (d5, e6); (e5, d4); (e5, f6); (f5, e4); (f5, g6); (g5, f4); (g5, h6); (h5, g4); (a6, b7); (b6, a5); (b6, c7); (c6, b5); (c6, d7); (d6, c5); (d6, e7); (e6, d5); (e6, f7); (f6, e5); (f6, g7); (g6, f5); (g6, h7); (h6, g5); (a7, b8); (b7, a6); (b7, c8); (c7, b6); (c7, d8); (d7, c6); (d7, e8); (e7, d6); (e7, f8); (f7, e6); (f7, g8); (g7, f6); (g7, h8); (h7, g6); (b8, a7); (c8, b7); (d8, c7); (e8, d7); (f8, e7); (g8, f7); (h8, g7)}; D2 {(b1, a2); (c1, b2); (d1, c2); (e1, d2); (f1, e2); (g1, f2); (h1, g2); (a2, b1); (b2, c1); (b2, a3); (c2, d1); (c2, b3); (d2, e1); (d2, c3); (e2, f1); (e2, d3); (f2, g1); (f2, e3); (g2, h1); (g2, f3); (h2, g3); (a3, b2); (b3, c2); (b3, a4); (c3, d2); (c3, b4); (d3, e2); (d3, c4); (e3, f2); (e3, d4); (f3, g2); (f3, e4); (g3, h2); (g3, f4); (h3, g4); (a4, b3); (b4, c3); (b4, a5); (c4, d3); (c4, b5); (d4, e3); (d4, c5); (e4, f3); (e4, d5); (f4, g3); (f4, e5); (g4, h3); (g4, f5); (h4, g5); (a5, b4); (b5, c4); (b5, a6); (c5, d4); (c5, b6); (d5, e4); (d5, c6); (e5, f4); (e5, d6); (f5, g4); (f5, e6); (g5, h4); (g5, f6); (h5, g6); (a6, b5); (b6, c5); (b6, a7); (c6, d5); (c6, b7); (d6, e5); (d6, c7); (e6, f5); (e6, d7); (f6, g5); (f6, e7); (g6, h5); (g6, f7); (h6, g7); (a7, b6); (b7, c6); (b7, a8); (c7, d6); (c7, b8); (d7, e6); (d7, c8); (e7, f6); (e7, d8); (f7, g6); (f7, e8); (g7, h6); (g7, f8); (h7, g8); (a8, b7); (b8, c7); (c8, d7); (d8, e7); (e8, f7); (f8, g7); (g8, h7)}; bB:1 {}; wB:1 {}; wN:1 {}; wP:1 {}; wQ:1 {}; wR:1 {} | ] \" + ... ... ... ... + ... ... +bN ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... bP. ...-bNwK. + ... ... ... ... + ...bP ... ... ... + ... ... ... ... + bR. ... ...bQ ... + ... ... ... ... + ... ...bK ... ...bP + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... +\"" 0 in + + let payoffs = Array.to_list + (Array.mapi (fun i v->string_of_int i,v) + (fst state).Arena.graph.((snd state).Arena.cur_loc).Arena.payoffs) + in + let ev (p,e) = + p^": "^(string_of_float + (Solver.M.get_real_val e (snd state).Arena.struc)) in + let answ = + String.concat ", " (List.sort compare (List.map ev payoffs)) in + assert_equal ~msg:"draw (white no move): direct" ~printer:(fun x->x) + "0: 0., 1: 0." answ; + + let move_opt = (let p,ps = Game.initialize_default state + ~advr ?horizon + ~loc:0 ~effort:1 + ~search_method:"alpha_beta_ord" () in + Game.toss ~grid_size:Move.cGRID_SIZE p ps) in + assert_equal ~msg:"draw (white no move): suggest" ~printer:(function + | Aux.Left (bpos, moves, _, _) -> + "game not over: "^ move_gs_str (snd state) moves.(bpos) + | Aux.Right poffs -> + Printf.sprintf "{W: %F; B: %F}" poffs.(0) poffs.(1)) + (Aux.Right [| 0.0; 0.0 |]) move_opt; +); + +] + let search_tests algo comment randomize effort_easy time_easy effort_medium time_medium effort_hard time_hard = let easy_case = compute_try algo randomize effort_easy time_easy @@ -898,6 +902,10 @@ let tests = "Game" >::: [ misc_tests; search_tests "alpha_beta_ord" "effort 2 3 4" false 2 120 3 240 4 360; +] + +let bigtests = "GameBig" >::: [ + misc_tests_big; search_tests "alpha_beta_ord" "time 8 16 32" false 10 8 10 16 10 32; ] @@ -945,9 +953,10 @@ ); ] -let a = - Aux.run_test_if_target "GameTest" tests +let a = Aux.run_test_if_target "GameTest" tests +let a = Aux.run_test_if_target "GameTest" bigtests + let a () = run_test_tt ~verbose:true experiments let a () = Modified: trunk/Toss/Play/HeuristicTest.ml =================================================================== --- trunk/Toss/Play/HeuristicTest.ml 2011-03-03 23:47:31 UTC (rev 1343) +++ trunk/Toss/Play/HeuristicTest.ml 2011-03-05 23:01:19 UTC (rev 1344) @@ -133,113 +133,6 @@ state (formula_of_str "ex y (C(x, y) and F(y))"))); ); - "expanded_description: fenced breakthrough 2 vars" >:: - (fun () -> - let state = - struc_of_string -"[ | | ] \" - - F F F F F F F F - ... ... ... ... - B B..B B..B B..B B.. - ... ... ... ... - B..B B..B B..B B..B - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - W W..W W..W W..W W.. - ... ... ... ... - W..W W..W W..W W..W - - F F F F F F F F -\"" in - assert_equal ~printer:(fun x->x) - "ex y7, y6, y5, y4, y3, y2, y1, y0 ((C(y7, y6) and C(y6, y5) and C(y5, y4) and C(y4, y3) and C(y3, y2) and C(y2, y1) and C(y1, y0) and C(y0, x) and C(x, y)))" - (Formula.str (Heuristic.expanded_description 5 - (Aux.strings_of_list ["B"; "W"]) - state (formula_of_str "C(x, y) and F(y)"))); - ); -(* - "suggest_expansion: tic-tac-toe" >:: - (fun () -> - let state = struc_of_string -"[ | P:1 { }; Q:1 { } | ] \" - - . . . - - . . . - - . . . -\"" in - (* A single substructure usually has exponentially many - different descriptions. *) - assert_bool "Should suggest not expanding tic-tac-toe." - (not (Heuristic.suggest_expansion - (formula_of_str winQxyz) state)); - ); - - "suggest_expansion: breakthrough" >:: - (fun () -> - let state = - struc_of_string -"[ | | ] \" - ... ... ... ... - B B..B B..B B..B B.. - ... ... ... ... - B..B B..B B..B B..B - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - W W..W W..W W..W W.. - ... ... ... ... - W..W W..W W..W W..W -\"" in - (* A single substructure usually has exponentially many - different descriptions. *) - assert_bool "Should suggest expanding breakthrough." - (Heuristic.suggest_expansion - (formula_of_str "ex x (W(x) and not ex y C(x, y))") state); - ); - - "suggest_expansion: gomoku8x8" >:: - (fun () -> - let state = - struc_of_string -"[ | P:1 { }; Q:1 { } | ] \" - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... -\"" in - assert_bool "Should suggest not expanding gomoku." - (not (Heuristic.suggest_expansion - (formula_of_str winQvwxyz) state)); - ); -*) "expanded_form: fenced breakthrough" >:: (fun () -> let state = @@ -407,9 +300,123 @@ )); ] + +let bigtests = "HeuristicBig" >::: [ + "expanded_description: fenced breakthrough 2 vars" >:: + (fun () -> + let state = + struc_of_string +"[ | | ] \" + + F F F F F F F F + ... ... ... ... + B B..B B..B B..B B.. + ... ... ... ... + B..B B..B B..B B..B + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + W W..W W..W W..W W.. + ... ... ... ... + W..W W..W W..W W..W + + F F F F F F F F +\"" in + assert_equal ~printer:(fun x->x) + "ex y7, y6, y5, y4, y3, y2, y1, y0 ((C(y7, y6) and C(y6, y5) and C(y5, y4) and C(y4, y3) and C(y3, y2) and C(y2, y1) and C(y1, y0) and C(y0, x) and C(x, y)))" + (Formula.str (Heuristic.expanded_description 5 + (Aux.strings_of_list ["B"; "W"]) + state (formula_of_str "C(x, y) and F(y)"))); + ); +(* + "suggest_expansion: tic-tac-toe" >:: + (fun () -> + let state = struc_of_string +"[ | P:1 { }; Q:1 { } | ] \" + + . . . + + . . . + + . . . +\"" in + (* A single substructure usually has exponentially many + different descriptions. *) + assert_bool "Should suggest not expanding tic-tac-toe." + (not (Heuristic.suggest_expansion + (formula_of_str winQxyz) state)); + ); + + "suggest_expansion: breakthrough" >:: + (fun () -> + let state = + struc_of_string +"[ | | ] \" + ... ... ... ... + B B..B B..B B..B B.. + ... ... ... ... + B..B B..B B..B B..B + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + W W..W W..W W..W W.. + ... ... ... ... + W..W W..W W..W W..W +\"" in + (* A single substructure usually has exponentially many + different descriptions. *) + assert_bool "Should suggest expanding breakthrough." + (Heuristic.suggest_expansion + (formula_of_str "ex x (W(x) and not ex y C(x, y))") state); + ); + + "suggest_expansion: gomoku8x8" >:: + (fun () -> + let state = + struc_of_string +"[ | P:1 { }; Q:1 { } | ] \" + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... +\"" in + assert_bool "Should suggest not expanding gomoku." + (not (Heuristic.suggest_expansion + (formula_of_str winQvwxyz) state)); + ); +*) +] + + let a = Aux.run_test_if_target "HeuristicTest" tests +let a = + Aux.run_test_if_target "HeuristicTest" bigtests let a () = match test_filter ["Heuristic:9:of_payoff: monotonic gomoku"] Added: trunk/Toss/TossFullTest.ml =================================================================== --- trunk/Toss/TossFullTest.ml (rev 0) +++ trunk/Toss/TossFullTest.ml 2011-03-05 23:01:19 UTC (rev 1344) @@ -0,0 +1,31 @@ +open OUnit + +let formula_tests = TossTest.formula_tests + +let solver_tests = TossTest.solver_tests + +let arena_tests = TossTest.arena_tests + +let play_tests = TossTest.play_tests + +let play_tests_big = "Play" >::: [ + HeuristicTest.bigtests; + GameTest.bigtests; +] + +let ggp_tests = TossTest.ggp_tests + +let server_tests = TossTest.server_tests + +let tests = "Toss" >::: [ + formula_tests; + solver_tests; + arena_tests; + play_tests; + play_tests_big; + ggp_tests; + server_tests; +] + +let a = + Aux.run_test_if_target "TossFullTest" tests This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-07 23:33:24
|
Revision: 1347 http://toss.svn.sourceforge.net/toss/?rev=1347&view=rev Author: lukaszkaiser Date: 2011-03-07 23:33:14 +0000 (Mon, 07 Mar 2011) Log Message: ----------- Debugging GameTree, using timeout in Client. Modified Paths: -------------- trunk/Toss/Client/SystemDisplay.py trunk/Toss/Client/Wrapper.py trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/Play/GameTree.ml trunk/Toss/Play/GameTreeTest.ml trunk/Toss/Server/Server.ml trunk/Toss/TossFullTest.ml Modified: trunk/Toss/Client/SystemDisplay.py =================================================================== --- trunk/Toss/Client/SystemDisplay.py 2011-03-07 12:43:57 UTC (rev 1346) +++ trunk/Toss/Client/SystemDisplay.py 2011-03-07 23:33:14 UTC (rev 1347) @@ -43,10 +43,10 @@ suggest_bt = self.toolbar.addAction (QIcon(":/pics/move.svg"),"Hint") QObject.connect(suggest_bt, SIGNAL("triggered ()"), self.suggest) - self.__sg_iters = 2 - dp = self.system.get_data("depth") - if dp != "none": self.__sg_iters = int(dp) - self.sg_iters_bt = self.toolbar.addAction ("Depth: " + + self.__sg_iters = 5 + #dp = self.system.get_data("depth") + #if dp != "none": self.__sg_iters = int(dp) + self.sg_iters_bt = self.toolbar.addAction ("Timeout: " + str(self.__sg_iters)) QObject.connect(self.sg_iters_bt, SIGNAL("triggered ()"), self.set_sg_iters) @@ -153,11 +153,11 @@ self.run_iters_bt.setText ("Length: " + str(ri)) def set_sg_iters (self): - (si, ok) = QInputDialog.getInt (self, "Game Tree Depth to Analyze", - "Set depth of suggestions: ", - self.__sg_iters, 1, 10, 1) + (si, ok) = QInputDialog.getInt (self, "Hint Timeout", + "Set hint timeout (seconds): ", + self.__sg_iters, 2, 1000, 1) self.__sg_iters = si - self.sg_iters_bt.setText ("Depth: " + str(si)) + self.sg_iters_bt.setText ("Timeout: " + str(si)) def set_adv_ratio (self): (ar, ok) = QInputDialog.getInt (self, "Advancement Agresiveness Ratio", Modified: trunk/Toss/Client/Wrapper.py =================================================================== --- trunk/Toss/Client/Wrapper.py 2011-03-07 12:43:57 UTC (rev 1346) +++ trunk/Toss/Client/Wrapper.py 2011-03-07 23:33:14 UTC (rev 1347) @@ -403,7 +403,7 @@ # "EVAL LOC MOVES advancement_ratio location TIMEOUT time_in_sec iters_or_depth_limit method optional_playout_horizon" # syntax variant 2: # "EVAL LOC MOVES [{0: heuristic_player_0_loc_0; 1: heuristic_player_1_loc_0}; {0: heuristic_player_0_loc_1; 1: heuristic_player_1_loc_1}] advancement_ratio location TIMEOUT time_in_sec iters_or_depth_limit method optional_playout_horizon" - m = self.msg ("EVAL LOC MOVES " + str(adv_ratio) + ".0 " + str(loc) +" TIMEOUT 1200 "+ str(no_iters) + " alpha_beta_ord") + m = self.msg ("EVAL LOC MOVES " + str(adv_ratio) + ".0 " + str(loc) +" TIMEOUT "+ str(no_iters) + " 50500 alpha_beta_ord") self.set_time (ts, t) msg = [s.strip() for s in m.split(';')] emb = dict() Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-03-07 12:43:57 UTC (rev 1346) +++ trunk/Toss/Formula/Aux.ml 2011-03-07 23:33:14 UTC (rev 1347) @@ -336,6 +336,20 @@ done; !r +let array_find_all_max cmp a = + let n = Array.length a in + if n=0 then [] + else + let best = ref (Array.unsafe_get a (n-1)) in + let beste = ref [!best] in + for i = n-2 downto 0 do + let e = Array.unsafe_get a i in + let res = cmp e !best in + if res > 0 then (best := e; beste := [e]) + else if res = 0 then beste := e :: !beste + done; + !beste + let array_argfind_all_max cmp a = let n = Array.length a in if n=0 then [] Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-03-07 12:43:57 UTC (rev 1346) +++ trunk/Toss/Formula/Aux.mli 2011-03-07 23:33:14 UTC (rev 1347) @@ -192,6 +192,8 @@ arrays are of different lengths. *) val array_for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool +(** Find all maximal elements in an array. *) +val array_find_all_max : ('a -> 'a -> int) -> 'a array -> 'a list (** Find indices of all maximal elements in an array. *) val array_argfind_all_max : ('a -> 'a -> int) -> 'a array -> int list Modified: trunk/Toss/Play/GameTree.ml =================================================================== --- trunk/Toss/Play/GameTree.ml 2011-03-07 12:43:57 UTC (rev 1346) +++ trunk/Toss/Play/GameTree.ml 2011-03-07 23:33:14 UTC (rev 1347) @@ -137,7 +137,7 @@ let (heurs, is_calc) = if ab && issome !last_vals && issome !stop_vals && ((Aux.unsome !last_vals).(pl) > (Aux.unsome !stop_vals).(pl)) then - (Aux.unsome !stop_vals, false) + (Aux.unsome !last_vals, false) else ( let resh = Array.map calc heurs.(state.Arena.cur_loc) in if not (issome !last_vals) then last_vals := Some (resh) else @@ -202,9 +202,19 @@ | Leaf (state, _, _) -> Aux.random_elem (Array.to_list (Move.list_moves game state)) | Node (_, p, info, succ) -> + let cmp (_, c1) (_, c2) = + let nval child = (node_values child).(p) in + let (e1, e2) = (node_is_exact c1, node_is_exact c2) in + if e1 && not e2 then 1 else if e2 && not e1 then -1 else + if nval c1 > nval c2 then 1 else if nval c2> nval c1 then -1 else 0 in + let maxs_exact = Aux.array_find_all_max cmp succ in let mval = info.heurs.(p) in + let maxs = if maxs_exact <> [] then maxs_exact else + Aux.array_find_all (fun (_,c) -> (node_values c).(p) = mval) succ in let nonleaf = function Leaf _ -> false | _ -> true in - let maxs= Aux.array_find_all (fun (_,c) -> (node_values c).(p)=mval) succ in + let move_s (m, n) = Move.move_gs_str_short (state n) m in + if !debug_level > 0 then print_endline + ("\nBest Moves: " ^ (String.concat ", " (List.map move_s maxs))); if List.exists (fun x -> nonleaf (snd x)) maxs then let (m, t) = Aux.random_elem maxs in (m, state t) else ( (* Do *not* take a shallow leaf if possible. *) Modified: trunk/Toss/Play/GameTreeTest.ml =================================================================== --- trunk/Toss/Play/GameTreeTest.ml 2011-03-07 12:43:57 UTC (rev 1346) +++ trunk/Toss/Play/GameTreeTest.ml 2011-03-07 23:33:14 UTC (rev 1347) @@ -91,10 +91,28 @@ (* print_endline (GameTree.str string_of_int u1); *) assert_equal ~printer:(fun x -> string_of_int x) 250 (GameTree.size u1); ); + + "maximax suggest move: Tic-Tac-Toe defense" >:: + (fun () -> + let struc = "MODEL [ | P:1 {}; Q:1 {} | ] \" + + . . . + + . P . + + . P Q +\"" in + let (g, s) = state_of_file "./examples/Tic-Tac-Toe.toss" ~struc ~loc:1 in + (* GameTree.set_debug_level 1; *) + let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr:4. g in + let (m, ns) = GameTree.maximax_unfold_choose 9 g s h in + assert_equal ~printer:(fun x -> x) "Circle{1:b3}" + (Move.move_gs_str_short s m); + ); ] let bigtests = "GameTreeBig" >::: [ - "maximax suggest move: Gomoku" >:: + "maximax suggest move: Gomoku defense" >:: (fun () -> let struc = "MODEL [ | P:1 {}; Q:1 {} | ] \" ... ... ... ... @@ -116,11 +134,9 @@ \" with DiagA (x, y) = ex u (R(x, u) and C(u, y)); DiagB (x, y) = ex u (R(x, u) and C(y, u))" in let (g, s) = state_of_file "./examples/Gomoku.toss" ~struc ~loc:1 in - ignore (Unix.alarm 20); - GameTree.set_debug_level 1; + (* GameTree.set_debug_level 1; *) let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr:4. g in - let (m, ns) = GameTree.maximax_unfold_choose 200 g s h in - Game.cancel_timeout (); + let (m, ns) = GameTree.maximax_unfold_choose 160 g s h in assert_equal ~printer:(fun x -> x) "Circle{1:d8}" (Move.move_gs_str_short s m); ); Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-03-07 12:43:57 UTC (rev 1346) +++ trunk/Toss/Server/Server.ml 2011-03-07 23:33:14 UTC (rev 1347) @@ -4,7 +4,7 @@ let set_debug_level i = debug_level := i; if i > 5 then Solver.set_debug_level 1; - GameTree.set_debug_level 1; + if i > 0 then GameTree.set_debug_level 1; Game.set_debug_level i; Heuristic.debug_level := i - 3 @@ -193,13 +193,26 @@ play := Some p; play_state := Some ps; p, ps in ignore (Unix.alarm timer); - let res = Game.suggest ~effort p ps in - Game.cancel_timeout (); - match res with - | Some (move, new_state) -> - play_state := Some new_state; - Move.move_gs_str !state move - | None -> "None" + if !no_gtree then + let res = Game.suggest ~effort p ps in + Game.cancel_timeout (); + match res with + | Some (move, new_state) -> + play_state := Some new_state; + Move.move_gs_str !state move + | None -> "None" + else + let heur = match !game_modified, !g_heur with + | false, Some h -> h + | true, _ | _, None -> + g_heur := Some (Heuristic.default_heuristic + ~struc:(snd !state).Arena.struc + ~advr:4. (fst !state)); + Aux.unsome !g_heur in + let (move, _) = GameTree.maximax_unfold_choose effort + (fst !state) (snd !state) heur in + Game.cancel_timeout (); + Move.move_gs_str !state move ) | Aux.Left (Arena.ApplyRule (r_name, mtch, t, p) as req) -> ( Modified: trunk/Toss/TossFullTest.ml =================================================================== --- trunk/Toss/TossFullTest.ml 2011-03-07 12:43:57 UTC (rev 1346) +++ trunk/Toss/TossFullTest.ml 2011-03-07 23:33:14 UTC (rev 1347) @@ -10,6 +10,7 @@ let play_tests_big = "Play" >::: [ HeuristicTest.bigtests; + GameTreeTest.bigtests; GameTest.bigtests; ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-08 11:15:27
|
Revision: 1348 http://toss.svn.sourceforge.net/toss/?rev=1348&view=rev Author: lukaszkaiser Date: 2011-03-08 11:15:20 +0000 (Tue, 08 Mar 2011) Log Message: ----------- Separate GameTree into GameTree and Play, debug alpha-beta variable depth problems. Modified Paths: -------------- trunk/Toss/Play/GameTree.ml trunk/Toss/Play/GameTree.mli trunk/Toss/Play/GameTreeTest.ml trunk/Toss/Play/Makefile trunk/Toss/Server/Server.ml trunk/Toss/TossFullTest.ml trunk/Toss/TossTest.ml Added Paths: ----------- trunk/Toss/Play/Play.ml trunk/Toss/Play/Play.mli trunk/Toss/Play/PlayTest.ml Modified: trunk/Toss/Play/GameTree.ml =================================================================== --- trunk/Toss/Play/GameTree.ml 2011-03-07 23:33:14 UTC (rev 1347) +++ trunk/Toss/Play/GameTree.ml 2011-03-08 11:15:20 UTC (rev 1348) @@ -170,8 +170,11 @@ min minv (move_val p children.(i))) (move_val p child) mids in let heurs = Array.mapi (fun p _ -> pval p) (node_values (snd child)) in let is_exact_child c = node_is_exact (snd children.(c)) in + let non_leaf c = match snd children.(c) with Leaf _ -> false | _ -> true in + let exact_nonleaf c = is_exact_child c && non_leaf c in { heurs= heurs; - heurs_are_exact = List.for_all is_exact_child mids; + heurs_are_exact = + List.exists non_leaf mids || List.for_all is_exact_child mids; info = f depth player heurs children } let choice_f g_heurs choice depth game state player info children_orig = @@ -228,58 +231,3 @@ let mxs = List.filter (fun (_,c) -> (node_values c).(p)=mx) nonleaves in let (m, t) = Aux.random_elem mxs in (m, state t) ) - -(* ------------ MAXIMAX BY DEPTH ------------- *) - -let maxdepth_node dp player heurs children = - let depths = Array.map (fun child -> (node_info (snd child))) children in - (Array.fold_left (fun m d -> max m d) 0 depths) + 1 - -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 (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 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); - if ab then ( - let cmp_dpt c1 c2 = (snd (mval c1)) - (snd (mval c2)) in - let maxdps = Aux.array_argfind_all_max cmp_dpt children in - let maxd = snd (mval children.(List.hd maxdps)) in - if snd (mval children.(res)) = maxd - 1 then ( - let maxa = ref (node_values (snd children.(List.hd maxdps))) in - let big c = fst (mval children.(c)) > !maxa.(player) in - let upd c = maxa := node_values (snd children.(c)) in - List.iter (fun c -> if big c then upd c) maxdps; - stop_vals := Some !maxa - ) else stop_vals := None - ); - res - - -(* Maximax by depth unfolding function. Throws Not_found if ready. *) -let unfold_maximax ?(ab=false) game heur = - unfold ~ab:ab game heur ~info_leaf:(fun _ _ _ -> 0) - ~info_node:(maxdepth_node) ~choice:(maximax_depth_choice ab) - -(* Maximax unfolding upto depth. *) -let rec unfold_maximax_upto ?(ab=false) count game heur t = - if count = 0 || Game.get_timeout () then ( - if !debug_level > 1 && Game.get_timeout () then print_endline "Timeout"; - t - ) else - try - let u = unfold_maximax ~ab:ab game heur t in - if !debug_level > 0 then Printf.printf "%d,%!" (size u); - unfold_maximax_upto ~ab:ab (count-1) game heur u - with Not_found -> t - -(* Maximax unfold upto depth and choose move. *) -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; - let t = init game state (fun _ _ _ -> 0) heur in - let u = unfold_maximax_upto ~ab count game heur t in - if !debug_level > 1 then print_endline (str string_of_int u); - choose_move game u Modified: trunk/Toss/Play/GameTree.mli =================================================================== --- trunk/Toss/Play/GameTree.mli 2011-03-07 23:33:14 UTC (rev 1347) +++ trunk/Toss/Play/GameTree.mli 2011-03-08 11:15:20 UTC (rev 1348) @@ -91,18 +91,3 @@ int -> 'a node_info -> (Move.move * 'a game_tree) array -> int) -> 'a game_tree -> 'a game_tree - -(** ------------ MAXIMAX BY DEPTH ------------- *) - -(** Maximax by depth unfolding function. Throws Not_found if ready. *) -val unfold_maximax : ?ab:bool -> Arena.game -> - Formula.real_expr array array -> int game_tree -> int game_tree - - -(** Maximax unfolding upto depth. *) -val unfold_maximax_upto : ?ab:bool -> int -> Arena.game -> - Formula.real_expr array array -> int game_tree -> int game_tree - -(** Maximax unfold upto depth and choose move. *) -val maximax_unfold_choose : int -> Arena.game -> Arena.game_state -> - Formula.real_expr array array -> Move.move * Arena.game_state Modified: trunk/Toss/Play/GameTreeTest.ml =================================================================== --- trunk/Toss/Play/GameTreeTest.ml 2011-03-07 23:33:14 UTC (rev 1347) +++ trunk/Toss/Play/GameTreeTest.ml 2011-03-08 11:15:20 UTC (rev 1348) @@ -67,82 +67,7 @@ assert_equal ~printer:(fun x -> string_of_int x) (GameTree.player u) g.Arena.graph.((GameTree.state u).Arena.cur_loc).Arena.player; ); - - "maximax unfold once, node_info" >:: - (fun () -> - let (g, s) = state_of_file "./examples/Tic-Tac-Toe.toss" in - let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr:4. g in - let t = GameTree.init g s (fun _ _ _ -> 0) h in - let u = GameTree.unfold_maximax g h t in - (* print_endline (GameTree.str string_of_int u); *) - assert_equal ~printer:(fun x -> string_of_int x) 1 (GameTree.node_info u); - ); - - "maximax unfold upto depth, size" >:: - (fun () -> - let (g, s) = state_of_file "./examples/Tic-Tac-Toe.toss" in - let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr:4. g in - let t = GameTree.init g s (fun _ _ _ -> 0) h in - let u = GameTree.unfold_maximax_upto 50 g h t in - (* print_endline (GameTree.str string_of_int u); *) - assert_equal ~printer:(fun x -> string_of_int x) 250 (GameTree.size u); - - let u1 = GameTree.unfold_maximax_upto ~ab:true 50 g h t in - (* print_endline (GameTree.str string_of_int u1); *) - assert_equal ~printer:(fun x -> string_of_int x) 250 (GameTree.size u1); - ); - - "maximax suggest move: Tic-Tac-Toe defense" >:: - (fun () -> - let struc = "MODEL [ | P:1 {}; Q:1 {} | ] \" - - . . . - - . P . - - . P Q -\"" in - let (g, s) = state_of_file "./examples/Tic-Tac-Toe.toss" ~struc ~loc:1 in - (* GameTree.set_debug_level 1; *) - let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr:4. g in - let (m, ns) = GameTree.maximax_unfold_choose 9 g s h in - assert_equal ~printer:(fun x -> x) "Circle{1:b3}" - (Move.move_gs_str_short s m); - ); ] -let bigtests = "GameTreeBig" >::: [ - "maximax suggest move: Gomoku defense" >:: - (fun () -> - let struc = "MODEL [ | P:1 {}; Q:1 {} | ] \" - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ...P ... ... - ... ... ... ... - ... P.. ... ... - ... ... ... ... - ... Q..P P..P ... - ... ... ... ... - Q ... P..Q ... ... - ... ... ... ... - ... Q..Q ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... -\" with DiagA (x, y) = ex u (R(x, u) and C(u, y)); - DiagB (x, y) = ex u (R(x, u) and C(y, u))" in - let (g, s) = state_of_file "./examples/Gomoku.toss" ~struc ~loc:1 in - (* GameTree.set_debug_level 1; *) - let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr:4. g in - let (m, ns) = GameTree.maximax_unfold_choose 160 g s h in - assert_equal ~printer:(fun x -> x) "Circle{1:d8}" - (Move.move_gs_str_short s m); - ); -] - let exec = Aux.run_test_if_target "GameTreeTest" tests - -let execbig = Aux.run_test_if_target "GameTreeTest" bigtests Modified: trunk/Toss/Play/Makefile =================================================================== --- trunk/Toss/Play/Makefile 2011-03-07 23:33:14 UTC (rev 1347) +++ trunk/Toss/Play/Makefile 2011-03-08 11:15:20 UTC (rev 1348) @@ -12,16 +12,19 @@ HeuristicTest: MoveTest: GameTreeTest: +PlayTest: GameTest: HeuristicTestProfile: MoveTestProfile: GameTreeTestProfile: +PlayTestProfile: GameTestProfile: HeuristicTestDebug: MoveTestDebug: GameTreeTestDebug: +PlayTestDebug: GameTestDebug: tests: Added: trunk/Toss/Play/Play.ml =================================================================== --- trunk/Toss/Play/Play.ml (rev 0) +++ trunk/Toss/Play/Play.ml 2011-03-08 11:15:20 UTC (rev 1348) @@ -0,0 +1,62 @@ +(* Module with different play strategies. *) + +open GameTree + +let debug_level = ref 0 +let set_debug_level i = debug_level := i + + +(* ------------ MAXIMAX BY DEPTH ------------- *) + +let maxdepth_node dp player heurs children = + let depths = Array.map (fun child -> (node_info (snd child))) children in + (Array.fold_left (fun m d -> max m d) 0 depths) + 1 + +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 (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 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); + if ab then ( + let cmp_dpt c1 c2 = (snd (mval c1)) - (snd (mval c2)) in + let maxdps = Aux.array_argfind_all_max cmp_dpt children in + let maxd = snd (mval children.(List.hd maxdps)) in + if snd (mval children.(res)) = maxd - 1 then ( + let maxa = ref (node_values (snd children.(List.hd maxdps))) in + let big c = fst (mval children.(c)) > !maxa.(player) in + let upd c = maxa := node_values (snd children.(c)) in + List.iter (fun c -> if big c then upd c) maxdps; + stop_vals := Some !maxa + ) else stop_vals := None + ); + res + + +(* Maximax by depth unfolding function. Throws Not_found if ready. *) +let unfold_maximax ?(ab=false) game heur = + unfold ~ab:ab game heur ~info_leaf:(fun _ _ _ -> 0) + ~info_node:(maxdepth_node) ~choice:(maximax_depth_choice ab) + +(* Maximax unfolding upto depth. *) +let rec unfold_maximax_upto ?(ab=false) count game heur t = + if count = 0 || Game.get_timeout () then ( + if !debug_level > 1 && Game.get_timeout () then print_endline "Timeout"; + t + ) else + try + let u = unfold_maximax ~ab:ab game heur t in + if !debug_level > 0 then Printf.printf "%d,%!" (size u); + unfold_maximax_upto ~ab:ab (count-1) game heur u + with Not_found -> t + +(* Maximax unfold upto depth and choose move. *) +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; + let t = init game state (fun _ _ _ -> 0) heur in + let u = unfold_maximax_upto ~ab count game heur t in + if !debug_level > 1 then print_endline (str string_of_int u); + choose_move game u Added: trunk/Toss/Play/Play.mli =================================================================== --- trunk/Toss/Play/Play.mli (rev 0) +++ trunk/Toss/Play/Play.mli 2011-03-08 11:15:20 UTC (rev 1348) @@ -0,0 +1,20 @@ +(** Different play strategies. *) + +val set_debug_level : int -> unit + + +(** ------------ MAXIMAX BY DEPTH ------------- *) + +(** Maximax by depth unfolding function. Throws Not_found if ready. *) +val unfold_maximax : ?ab:bool -> Arena.game -> Formula.real_expr array array -> + int GameTree.game_tree -> int GameTree.game_tree + + +(** Maximax unfolding upto depth. *) +val unfold_maximax_upto : ?ab:bool -> int -> Arena.game -> + Formula.real_expr array array -> + int GameTree.game_tree -> int GameTree.game_tree + +(** Maximax unfold upto depth and choose move. *) +val maximax_unfold_choose : int -> Arena.game -> Arena.game_state -> + Formula.real_expr array array -> Move.move * Arena.game_state Added: trunk/Toss/Play/PlayTest.ml =================================================================== --- trunk/Toss/Play/PlayTest.ml (rev 0) +++ trunk/Toss/Play/PlayTest.ml 2011-03-08 11:15:20 UTC (rev 1348) @@ -0,0 +1,158 @@ +open OUnit + +open Play + +let debug_level = ref 0 + +let raw_state_of_file s = + if !debug_level > 0 then Printf.printf "Loading file %s...\n%!" s; + let f = open_in s in + let res = + ArenaParser.parse_game_state Lexer.lex + (Lexing.from_channel f) in + if !debug_level > 0 then Printf.printf "File %s loaded.\n%!" s; + res + +let struc_of_str s = + match ArenaParser.parse_game_defs Lexer.lex (Lexing.from_string s) with + | Arena.StateStruc struc -> struc + | _ -> failwith "GameTreeTest:struc_of_str: not a structure" + +let state_of_file ?(struc="") ?(time=0.) ?(loc=0) fname = + let (g, s) = raw_state_of_file fname in + let structure = if struc = "" then s.Arena.struc else struc_of_str struc in + (g, { Arena.struc = structure; time = time; cur_loc = loc }) + + +let test_maximax ?(debug=0) ?(advr=4.) ?(struc="") ?(time=0.) ?(loc=0) + ~iters gname move_s = + let (g, s) = state_of_file ("./examples/"^gname^".toss") ~struc ~time ~loc in + GameTree.set_debug_level debug; + Play.set_debug_level debug; + let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr g in + let (m, ns) = Play.maximax_unfold_choose iters g s h in + assert_equal ~printer:(fun x -> x) move_s (Move.move_gs_str_short s m) + + +let tests = "Play" >::: [ + "maximax unfold once, node_info" >:: + (fun () -> + let (g, s) = state_of_file "./examples/Tic-Tac-Toe.toss" in + let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr:4. g in + let t = GameTree.init g s (fun _ _ _ -> 0) h in + let u = Play.unfold_maximax g h t in + (* print_endline (GameTree.str string_of_int u); *) + assert_equal ~printer:(fun x -> string_of_int x) 1 (GameTree.node_info u); + ); + + "maximax unfold upto depth, size" >:: + (fun () -> + let (g, s) = state_of_file "./examples/Tic-Tac-Toe.toss" in + let h = Heuristic.default_heuristic ~struc:s.Arena.struc ~advr:4. g in + let t = GameTree.init g s (fun _ _ _ -> 0) h in + let u = Play.unfold_maximax_upto 50 g h t in + (* print_endline (GameTree.str string_of_int u); *) + assert_equal ~printer:(fun x -> string_of_int x) 250 (GameTree.size u); + + let u1 = Play.unfold_maximax_upto ~ab:true 50 g h t in + (* print_endline (GameTree.str string_of_int u1); *) + assert_equal ~printer:(fun x -> string_of_int x) 250 (GameTree.size u1); + ); + + "maximax suggest move: Tic-Tac-Toe defense" >:: + (fun () -> + let struc = "MODEL [ | P:1 {}; Q:1 {} | ] \" + + . . . + + . P . + + . P Q +\"" in + test_maximax "Tic-Tac-Toe" ~struc ~loc:1 ~iters:9 "Circle{1:b3}"; + ); +] + + +let gomoku_tests_big = "Gomoku" >::: [ + "maximax suggest defense 1" >:: + (fun () -> + let struc = "MODEL [ | P:1 {}; Q:1 {} | ] \" + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ...P ... ... + ... ... ... ... + ... P.. ... ... + ... ... ... ... + ... Q..P P..P ... + ... ... ... ... + Q ... P..Q ... ... + ... ... ... ... + ... Q..Q ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... +\" with DiagA (x, y) = ex u (R(x, u) and C(u, y)); + DiagB (x, y) = ex u (R(x, u) and C(y, u))" in + test_maximax "Gomoku" ~debug:0 ~struc ~loc:1 ~iters:160 "Circle{1:d8}"; + ); + + "maximax suggest defense 2" >:: + (fun () -> + let struc = "MODEL [ | P:1 {}; Q:1 {} | ] \" + ... ... ... ... + P.. ... ... ... + ... ... ... ... + ...P ...Q ...P ... + ... ... ... ... + Q..P Q..Q Q..P Q.. + ... ... ... ... + P.. P..Q Q..Q Q..P + ... ... ... ... + P..Q P..P Q.. ... + ... ... ... ... + ...Q P..Q Q.. P..P + ... ... ... ... + P ... P..Q ... P.. + ... ... ... ... + ... ... ... ... +\" with DiagA (x, y) = ex u (R(x, u) and C(u, y)); + DiagB (x, y) = ex u (R(x, u) and C(y, u))" in + test_maximax "Gomoku" ~debug:0 ~struc ~loc:1 ~iters:180 "Circle{1:e1}"; + ); + + "maximax suggest defense 3" >:: + (fun () -> + let struc = "MODEL [ | P:1 {}; Q:1 {} | ] \" + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ...P ... ... + ... ... ... ... + ... Q..Q ... ... + ... ... ... ... + ... P..P Q..P ... + ... ... ... ... + ... P..Q ... ... + ... ... ... ... + ... ...Q P.. ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... +\" with DiagA (x, y) = ex u (R(x, u) and C(u, y)); + DiagB (x, y) = ex u (R(x, u) and C(y, u))" in + test_maximax "Gomoku" ~debug:0 ~struc ~loc:1 ~iters:210 "Circle{1:b6}"; + ); +] + +let bigtests = "PlayBig" >::: [ + gomoku_tests_big; +] + + +let exec = Aux.run_test_if_target "PlayTest" tests + +let execbig = Aux.run_test_if_target "PlayTest" bigtests Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-03-07 23:33:14 UTC (rev 1347) +++ trunk/Toss/Server/Server.ml 2011-03-08 11:15:20 UTC (rev 1348) @@ -209,7 +209,7 @@ ~struc:(snd !state).Arena.struc ~advr:4. (fst !state)); Aux.unsome !g_heur in - let (move, _) = GameTree.maximax_unfold_choose effort + let (move, _) = Play.maximax_unfold_choose effort (fst !state) (snd !state) heur in Game.cancel_timeout (); Move.move_gs_str !state move @@ -414,7 +414,7 @@ let heur = match !g_heur with | Some h -> h | None -> failwith "no heuristic for gametree!" in - let (move, _) = GameTree.maximax_unfold_choose 5500 + let (move, _) = Play.maximax_unfold_choose 5500 (fst !state) (snd !state) heur in Game.cancel_timeout (); GDL.translate_move !gdl_transl !state @@ -513,7 +513,7 @@ ) else ( let heur = if pl = 0 then heur1 else heur2 in ignore (Unix.alarm timeo); - let (_, s) = GameTree.maximax_unfold_choose depth game !cur_state heur in + let (_, s) = Play.maximax_unfold_choose depth game !cur_state heur in Game.cancel_timeout(); cur_state := s ); Modified: trunk/Toss/TossFullTest.ml =================================================================== --- trunk/Toss/TossFullTest.ml 2011-03-07 23:33:14 UTC (rev 1347) +++ trunk/Toss/TossFullTest.ml 2011-03-08 11:15:20 UTC (rev 1348) @@ -10,7 +10,7 @@ let play_tests_big = "Play" >::: [ HeuristicTest.bigtests; - GameTreeTest.bigtests; + PlayTest.bigtests; GameTest.bigtests; ] Modified: trunk/Toss/TossTest.ml =================================================================== --- trunk/Toss/TossTest.ml 2011-03-07 23:33:14 UTC (rev 1347) +++ trunk/Toss/TossTest.ml 2011-03-08 11:15:20 UTC (rev 1348) @@ -24,6 +24,7 @@ HeuristicTest.tests; MoveTest.tests; GameTreeTest.tests; + PlayTest.tests; GameTest.tests; ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-10 18:14:31
|
Revision: 1349 http://toss.svn.sourceforge.net/toss/?rev=1349&view=rev Author: lukaszkaiser Date: 2011-03-10 18:14:24 +0000 (Thu, 10 Mar 2011) Log Message: ----------- WebClient corrections, adding Connect4 and Pawn-Whopping. Modified Paths: -------------- trunk/Toss/GGP/GDL.ml trunk/Toss/Play/Play.ml trunk/Toss/Play/Play.mli trunk/Toss/Server/Server.ml trunk/Toss/WebClient/Connect.js trunk/Toss/WebClient/Handler.py trunk/Toss/WebClient/Login.js trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/MakeDB.py trunk/Toss/WebClient/Style.css trunk/Toss/WebClient/Wrapper.py trunk/Toss/WebClient/index.html trunk/Toss/examples/Chess.toss Added Paths: ----------- trunk/Toss/examples/Pawn-Whopping.toss trunk/Toss/examples/Pawn-Whopping.tossstyle Removed Paths: ------------- trunk/Toss/examples/PawnWhopping.toss trunk/Toss/examples/PawnWhopping.tossstyle Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/GGP/GDL.ml 2011-03-10 18:14:24 UTC (rev 1349) @@ -3578,7 +3578,7 @@ let initialize_game_pawn_whopping player game_descr startcl = let state = - state_of_file (!top_exec_path ^ "/examples/PawnWhopping.toss") in + state_of_file (!top_exec_path ^ "/examples/Pawn-Whopping.toss") in game_description := game_descr; let pterms = [|Const "X"; Const "O"|] in let noops = [|Some (Const "NOOP"); Some (Const "NOOP")|] in Modified: trunk/Toss/Play/Play.ml =================================================================== --- trunk/Toss/Play/Play.ml 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/Play/Play.ml 2011-03-10 18:14:24 UTC (rev 1349) @@ -5,7 +5,12 @@ let debug_level = ref 0 let set_debug_level i = debug_level := i +let timeout = ref 0. +let set_timeout t = timeout := Unix.time() +. t +let cancel_timeout () = timeout := 0. +let timed_out () = !timeout > 1. && Unix.time() > !timeout + (* ------------ MAXIMAX BY DEPTH ------------- *) let maxdepth_node dp player heurs children = @@ -42,8 +47,9 @@ (* Maximax unfolding upto depth. *) let rec unfold_maximax_upto ?(ab=false) count game heur t = - if count = 0 || Game.get_timeout () then ( - if !debug_level > 1 && Game.get_timeout () then print_endline "Timeout"; + if count = 0 || Game.get_timeout () || timed_out () then ( + if !debug_level > 1 && (Game.get_timeout() || timed_out()) then + print_endline "Timeout"; t ) else try Modified: trunk/Toss/Play/Play.mli =================================================================== --- trunk/Toss/Play/Play.mli 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/Play/Play.mli 2011-03-10 18:14:24 UTC (rev 1349) @@ -2,7 +2,10 @@ val set_debug_level : int -> unit +val set_timeout : float -> unit +val cancel_timeout : unit -> unit + (** ------------ MAXIMAX BY DEPTH ------------- *) (** Maximax by depth unfolding function. Throws Not_found if ready. *) Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/Server/Server.ml 2011-03-10 18:14:24 UTC (rev 1349) @@ -4,7 +4,7 @@ let set_debug_level i = debug_level := i; if i > 5 then Solver.set_debug_level 1; - if i > 0 then GameTree.set_debug_level 1; + if i > 0 then (GameTree.set_debug_level 1; Play.set_debug_level 1); Game.set_debug_level i; Heuristic.debug_level := i - 3 @@ -173,29 +173,29 @@ (loc, timer, effort, how, horizon, heuristic, advr)) -> ( Random.self_init (); - (* TODO: should be in idle time, not now *) - Gc.full_major (); - let heuristic = - match heuristic with None -> None - | Some heur -> - Some (Array.map ( - Arena.array_of_players (Formula.Const 0.0) - (fst !state).Arena.player_names) heur) in - let p, ps = - match !game_modified, !play, !play_state with - | false, Some play, Some play_state -> - play, play_state - | _ -> - let p, ps = Game.initialize_default - !state ~loc ~effort ~search_method:how - ?horizon ?heuristic ?advr () in - game_modified := false; - play := Some p; play_state := Some ps; - p, ps in ignore (Unix.alarm timer); + Play.set_timeout (float(timer)); if !no_gtree then + let heuristic = + match heuristic with None -> None + | Some heur -> + Some (Array.map ( + Arena.array_of_players (Formula.Const 0.0) + (fst !state).Arena.player_names) heur) in + let p, ps = + match !game_modified, !play, !play_state with + | false, Some play, Some play_state -> + play, play_state + | _ -> + let p, ps = Game.initialize_default + !state ~loc ~effort ~search_method:how + ?horizon ?heuristic ?advr () in + game_modified := false; + play := Some p; play_state := Some ps; + p, ps in let res = Game.suggest ~effort p ps in Game.cancel_timeout (); + Play.cancel_timeout (); match res with | Some (move, new_state) -> play_state := Some new_state; @@ -212,6 +212,7 @@ let (move, _) = Play.maximax_unfold_choose effort (fst !state) (snd !state) heur in Game.cancel_timeout (); + Play.cancel_timeout (); Move.move_gs_str !state move ) Modified: trunk/Toss/WebClient/Connect.js =================================================================== --- trunk/Toss/WebClient/Connect.js 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/WebClient/Connect.js 2011-03-10 18:14:24 UTC (rev 1349) @@ -26,8 +26,8 @@ var RELS_STR = "" var MOVES_STR = "" var PAYOFF_STR = "" +var PLAYER_STR = "" - // Helper function: sign of a number. function sign (x) { if (x > 0.01) { return (1); } @@ -38,7 +38,7 @@ function set_info (info) { var res_arr = []; res_arr = info.split("$"); - if (res_arr.length != 4) { return (false); } + if (res_arr.length != 5) { return (false); } DIM_STR = res_arr[0]; ELEM_STR = res_arr[1]; RELS_STR = res_arr[2]; @@ -49,6 +49,7 @@ MOVES_STR = ""; PAYOFF_STR = res_arr[3]; }; + PLAYER_STR = res_arr[4]; var dim = strip('(', ')', DIM_STR).split(','); MODEL_MAXX = parseFloat(strip(' ', ' ', dim[0])); MODEL_MINX = parseFloat(strip(' ', ' ', dim[1])); Modified: trunk/Toss/WebClient/Handler.py =================================================================== --- trunk/Toss/WebClient/Handler.py 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/WebClient/Handler.py 2011-03-10 18:14:24 UTC (rev 1349) @@ -106,18 +106,19 @@ fid = int(f[0]) return (fid + 1) -def new_play (db, client, game, p1, p2, move): +def new_play (db, client, game, p1, p2): res = get_all_from_db (db, "games", "game='" + game + "'") (_, toss) = res[0] client.open_from_str (toss) info = get_game_info (client) model = client.get_model () loc = client.get_cur_loc () + move_pl = int(client.get_loc_player (loc)) - 1 get_global_lock (db) pid = get_free_id (db) - db_cur_insert (db, game, p1, p2, pid, move, model, loc, info, "") + db_cur_insert (db, game, p1, p2, pid, move_pl, model, loc, info, "") release_global_lock (db) - return (str(pid) + "$" + info) + return (str(pid) + "$" + info + "$" + str(move_pl)) def game_select_s (g, p1, p2, pid, m): return("game='" + g + "' and player1='" + p1 + "' and player2='" + p2 + @@ -126,8 +127,8 @@ def open_db (db, game, p1, p2, pid, move): select_s = game_select_s (game, p1, p2, pid, move) res = get_all_from_db (db, "cur_states", select_s) - (_, _, _, _, _, _, _, info, _) = res[0] - return (info) + (_, _, _, _, move, _, _, info, _) = res[0] + return (info + "$" + str(move)) def db_escape (s): return (s.replace("'", "''")) @@ -141,16 +142,16 @@ client.open_from_str (game_toss + "\n MODEL " + old_toss) client.set_cur_loc (old_loc) (move1, move2, move3) = move_tup - client.make_move (move1, move2, move3) + new_pl = int(client.make_move (move1, move2, move3)) - 1 new_toss = db_escape (client.get_model ()) new_info = get_game_info (client) new_info_db = db_escape (new_info) db.execute ("update cur_states set toss='" + new_toss + "' where " + sel_s) db.execute ("update cur_states set info='"+ new_info_db +"' where "+ sel_s) db.execute ("update cur_states set loc='"+ str(move3) +"' where "+ sel_s) - db.execute ("update cur_states set move=" + str(int(m)+1) +" where "+ sel_s) + db.execute ("update cur_states set move=" + str(new_pl) +" where "+ sel_s) db_old_insert (db, g, p1, p2, pid, m, old_toss, old_loc, old_info, old_svg) - return (new_info) + return (new_info + "$" + str(new_pl)) def upd_svg (db, g, p1, p2, pid, m, svg_s): select_s = game_select_s (g, p1, p2, pid, m) @@ -253,17 +254,17 @@ (_, game_toss) = game_res[0] client.open_from_str (game_toss + "\n MODEL " + toss) client.set_cur_loc (loc) - depth = client.get_data ("depth") - if depth == "none": depth = 2 - adv_ratio = client.get_data ("adv_ratio") - if adv_ratio == "none": adv_ratio = 2 - return (client.suggest (int(depth) + offset, adv_ratio)) + #depth = client.get_data ("depth") + #if depth == "none": depth = 2 + #adv_ratio = client.get_data ("adv_ratio") + #if adv_ratio == "none": adv_ratio = 2 + return (client.suggest (offset)) def suggest (db, client, g, p1, p2, pid, m): - return (suggest_offset (0, db, client, g, p1, p2, pid, m)) + return (suggest_offset (5, db, client, g, p1, p2, pid, m)) def suggestx (db, client, g, p1, p2, pid, m): - return (suggest_offset (1, db, client, g, p1, p2, pid, m)) + return (suggest_offset (10, db, client, g, p1, p2, pid, m)) def handler(req): req.content_type = "text/plain" Modified: trunk/Toss/WebClient/Login.js =================================================================== --- trunk/Toss/WebClient/Login.js 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/WebClient/Login.js 2011-03-10 18:14:24 UTC (rev 1349) @@ -25,9 +25,11 @@ list_plays_string ("Breakthrough", udata[2]); list_plays_string ("Checkers", udata[3]); list_plays_string ("Chess", udata[4]); - list_plays_string ("Entanglement", udata[5]); - list_plays_string ("Gomoku", udata[6]); - list_plays_string ("Tic-Tac-Toe", udata[7]); + list_plays_string ("Connect4", udata[5]); + list_plays_string ("Entanglement", udata[6]); + list_plays_string ("Gomoku", udata[7]); + list_plays_string ("Pawn-Whopping", udata[8]); + list_plays_string ("Tic-Tac-Toe", udata[9]); get_opponents (); } Modified: trunk/Toss/WebClient/Main.js =================================================================== --- trunk/Toss/WebClient/Main.js 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/WebClient/Main.js 2011-03-10 18:14:24 UTC (rev 1349) @@ -216,7 +216,7 @@ // Apply current move. function make_move () { if (CUR_MOVE == "") return; - var m = PLAYS[CUR_PLAY_I][3] % 2; + var m = PLAYS[CUR_PLAY_I][3]; if (PLAYS[CUR_PLAY_I][m] != UNAME && PLAYS[CUR_PLAY_I][m] != "computer") { alert ("It is your Opponent's turn"); return; @@ -227,17 +227,17 @@ CUR_MOVE = ""; CUR_ELEMS = []; ELEM_COUNTERS = {}; + PLAYS[CUR_PLAY_I][3] = PLAYER_STR; document.getElementById("cur-player").innerHTML = - disp_name(PLAYS[CUR_PLAY_I][(m + 1) % 2]); + disp_name(PLAYS[CUR_PLAY_I][PLAYER_STR]); document.getElementById("working").style.display = "none"; full_redraw (); - PLAYS[CUR_PLAY_I][3] = parseInt(PLAYS[CUR_PLAY_I][3]) + 1; async_srv ("UPD_SVG", play_py_id(CUR_PLAY_I) + ", " + svg_string()); var old_li = document.getElementById ("plays-list-" + GAME_NAME + "-elem-" + CUR_PLAY_I); var li = new_play_item (GAME_NAME, CUR_PLAY_I); old_li.parentNode.replaceChild (li, old_li); - if (PLAYS[CUR_PLAY_I][(m + 1) % 2] == "computer") { + if (PLAYS[CUR_PLAY_I][PLAYER_STR] == "computer") { var m = suggest_move_better (); if (m != "") { make_move (); } } @@ -281,7 +281,9 @@ for (var i = 0; i < FRIENDS.length; i++) { var oi = opponent_item (FRIENDS[i], i+1); if (i > MAX_OPNT_LEN - 2) { oi.style.display = "none"; } - o.appendChild (oi); + if (GAME_NAME != 'Chess' || FRIENDS[i] != 'computer') { + o.appendChild (oi); + } } document.getElementById("opponents").style.display = "block"; } @@ -343,7 +345,7 @@ document.getElementById("plays-list-" + GAME_NAME).style.display = "block"; document.getElementById("working").style.display = "block"; info_nbr = srv ("NEW_PLAY", "c, '" + GAME_NAME + "', '" + UNAME + - "', '" + opp_uid + "', 0"); + "', '" + opp_uid + "'"); document.getElementById("working").style.display = "none"; info_idx = info_nbr.indexOf('$'); FREE_PLAY_NO = parseInt(info_nbr.substring(0, info_idx)); Modified: trunk/Toss/WebClient/MakeDB.py =================================================================== --- trunk/Toss/WebClient/MakeDB.py 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/WebClient/MakeDB.py 2011-03-10 18:14:24 UTC (rev 1349) @@ -11,8 +11,8 @@ GAMES_PATH = "../examples" -GAMES = ["Breakthrough", "Checkers", "Chess", "Entanglement", - "Gomoku", "Tic-Tac-Toe"] +GAMES = ["Breakthrough", "Checkers", "Chess", "Connect4", "Entanglement", + "Gomoku", "Pawn-Whopping", "Tic-Tac-Toe"] def create_db (db_file, games_path, games): Modified: trunk/Toss/WebClient/Style.css =================================================================== --- trunk/Toss/WebClient/Style.css 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/WebClient/Style.css 2011-03-10 18:14:24 UTC (rev 1349) @@ -638,13 +638,15 @@ stroke-width: 3px; } -.Game-Chess .model-elem-0, .Game-Checkers .model-elem-0 { +.Game-Chess .model-elem-0, .Game-Checkers .model-elem-0, + .Game-Pawn-Whopping .model-elem-0 { fill: #d18b47; stroke: #260314; stroke-width: 3px; } -.Game-Chess .model-elem-1, .Game-Checkers .model-elem-1 { +.Game-Chess .model-elem-1, .Game-Checkers .model-elem-1, + .Game-Pawn-Whopping .model-elem-1 { fill: #ffe4aa; /* #ffce9e; */ stroke: #260314; stroke-width: 3px; Modified: trunk/Toss/WebClient/Wrapper.py =================================================================== --- trunk/Toss/WebClient/Wrapper.py 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/WebClient/Wrapper.py 2011-03-10 18:14:24 UTC (rev 1349) @@ -193,10 +193,15 @@ moves.append ((m, r, endp)) return ("; ".join([str(m) for m in moves])) + def get_loc_player (self, i): + """Get player for the i-th location.""" + m = self.msg ("GET LOC PLAYER " + (str (i))) + return (m) + def make_move (self, m, r, endp): self.apply_rule (r, m, 1.0, []) self.set_cur_loc (endp) - return ("move ok") + return (self.get_loc_player(endp)) def get_data (self, did): m = self.msg ("GET DATA " + did) @@ -213,12 +218,11 @@ t = [s.strip() for s in m.split('/')] return ((float(t[0]), float(t[1]))) - def suggest (self, depth, adv_ratio): + def suggest (self, timeout): loc = self.get_cur_loc () (ts, t) = self.get_time () - m = self.msg ("EVAL LOC MOVES " + str(adv_ratio) + ".0 " + - str(loc) +" TIMEOUT 1200 "+ str(depth) + - " alpha_beta_ord") + m = self.msg ("EVAL LOC MOVES 4.0 " + str(loc) + + " TIMEOUT "+ str(timeout) + " 55500 alpha_beta_ord") self.set_time (ts, t) msg = [s.strip() for s in m.split(';')] if len(msg) < 2: return ("") Modified: trunk/Toss/WebClient/index.html =================================================================== --- trunk/Toss/WebClient/index.html 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/WebClient/index.html 2011-03-10 18:14:24 UTC (rev 1349) @@ -130,6 +130,14 @@ <li style="display: none;"/> </ul> <p class="game-par"> + <button onclick="new_play('Connect4')" + class="boldobt">Connect4</button> + (<a href="http://en.wikipedia.org/wiki/Connect4">info</a>) + </p> + <ul class="plays-list" id="plays-list-Connect4"> + <li style="display: none;"/> + </ul> + <p class="game-par"> <button onclick="new_play('Entanglement')" class="boldobt">Entanglement</button> (<a href="http://en.wikipedia.org/wiki/Entanglement_(graph_measure)" @@ -147,6 +155,14 @@ <li style="display: none;"/> </ul> <p class="game-par"> + <button onclick="new_play('Pawn-Whopping')" + class="boldobt">Pawn-Whopping</button> + (<a href="http://en.wikipedia.org/wiki/Pawn-Whopping">info</a>) + </p> + <ul class="plays-list" id="plays-list-Pawn-Whopping"> + <li style="display: none;"/> + </ul> + <p class="game-par"> <button onclick="new_play('Tic-Tac-Toe')" class="boldobt">Tic-Tac-Toe</button> (<a href="http://en.wikipedia.org/wiki/Tic-tac-toe">info</a>) Modified: trunk/Toss/examples/Chess.toss =================================================================== --- trunk/Toss/examples/Chess.toss 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/examples/Chess.toss 2011-03-10 18:14:24 UTC (rev 1349) @@ -94,33 +94,14 @@ bP " emb w, b pre IsSeventh(a3) post not CheckB() -RULE WhitePawnRight: +RULE WhitePawnBeat: + [ a, b | wP { a }; b { b } | - ] + -> + [ a, b | wP { b } | - ] + emb w, b pre ex z (C(a, z) and (R(z, b) or R(b, z))) post not CheckW() +RULE WhitePawnBeatRDbl: [ | | ] " ... - ?..b - ... - wP ?.. -" -> [ | | ] " - ... - ?..wP - ... - . ?.. -" emb w, b post not CheckW() -RULE WhitePawnLeft: - [ | | ] " - ... - b..? - ... - ? wP. -" -> [ | | ] " - ... - wP.? - ... - ? ... -" emb w, b post not CheckW() -RULE WhitePawnRightDbl: - [ | | ] " - ... ?..-bP ... ? ... @@ -134,7 +115,7 @@ ... .... " emb w, b post not CheckW() -RULE WhitePawnLeftDbl: +RULE WhitePawnBeatLDbl: [ | | ] " ... -bP? @@ -150,33 +131,14 @@ ... .... " emb w, b post not CheckW() -RULE BlackPawnRight: +RULE BlackPawnBeat: + [ a, b | bP { a }; w { b } | - ] + -> + [ a, b | bP { b } | - ] + emb w, b pre ex z (C(z, a) and (R(z, b) or R(b, z))) post not CheckB() +RULE BlackPawnBeatRDbl: [ | | ] " ... - bP.? - ... - ? w.. -" -> [ | | ] " - ... - ...? - ... - ? bP. -" emb w, b post not CheckB() -RULE BlackPawnLeft: - [ | | ] " - ... - ?..bP - ... - w ?.. -" -> [ | | ] " - ... - ?... - ... - bP ?.. -" emb w, b post not CheckB() -RULE BlackPawnRightDbl: - [ | | ] " - ... bP.wP ... ? ... @@ -190,7 +152,7 @@ ... ?... " emb w, b post not CheckB() -RULE BlackPawnLeftDbl: +RULE BlackPawnBeatLDbl: [ | | ] " ... wP.bP @@ -341,10 +303,9 @@ MOVES [WhitePawnMove -> 1]; [WhitePawnMoveDbl -> 1]; - [WhitePawnLeft -> 1]; - [WhitePawnLeftDbl -> 1]; - [WhitePawnRight -> 1]; - [WhitePawnRightDbl -> 1]; + [WhitePawnBeat -> 1]; + [WhitePawnBeatLDbl -> 1]; + [WhitePawnBeatRDbl -> 1]; [WhitePawnPromote -> 1]; [WhiteKnight -> 1]; [WhiteBishop -> 1]; @@ -365,10 +326,9 @@ MOVES [BlackPawnMove -> 0]; [BlackPawnMoveDbl -> 0]; - [BlackPawnLeft -> 0]; - [BlackPawnLeftDbl -> 0]; - [BlackPawnRight -> 0]; - [BlackPawnRightDbl -> 0]; + [BlackPawnBeat -> 0]; + [BlackPawnBeatLDbl -> 0]; + [BlackPawnBeatRDbl -> 0]; [BlackPawnPromote -> 0]; [BlackKnight -> 0]; [BlackBishop -> 0]; @@ -389,10 +349,9 @@ MOVES [WhitePawnMove -> 3]; [WhitePawnMoveDbl -> 3]; - [WhitePawnLeft -> 3]; - [WhitePawnLeftDbl -> 3]; - [WhitePawnRight -> 3]; - [WhitePawnRightDbl -> 3]; + [WhitePawnBeat -> 3]; + [WhitePawnBeatLDbl -> 3]; + [WhitePawnBeatRDbl -> 3]; [WhitePawnPromote -> 3]; [WhiteKnight -> 3]; [WhiteBishop -> 3]; @@ -412,10 +371,9 @@ MOVES [BlackPawnMove -> 2]; [BlackPawnMoveDbl -> 2]; - [BlackPawnLeft -> 2]; - [BlackPawnLeftDbl -> 2]; - [BlackPawnRight -> 2]; - [BlackPawnRightDbl -> 2]; + [BlackPawnBeat -> 2]; + [BlackPawnBeatLDbl -> 2]; + [BlackPawnBeatRDbl -> 2]; [BlackPawnPromote -> 2]; [BlackKnight -> 2]; [BlackBishop -> 2]; @@ -436,10 +394,9 @@ MOVES [WhitePawnMove -> 5]; [WhitePawnMoveDbl -> 5]; - [WhitePawnLeft -> 5]; - [WhitePawnLeftDbl -> 5]; - [WhitePawnRight -> 5]; - [WhitePawnRightDbl -> 5]; + [WhitePawnBeat -> 5]; + [WhitePawnBeatLDbl -> 5]; + [WhitePawnBeatRDbl -> 5]; [WhitePawnPromote -> 5]; [WhiteKnight -> 5]; [WhiteBishop -> 5]; @@ -459,10 +416,9 @@ MOVES [BlackPawnMove -> 4]; [BlackPawnMoveDbl -> 4]; - [BlackPawnLeft -> 4]; - [BlackPawnLeftDbl -> 4]; - [BlackPawnRight -> 4]; - [BlackPawnRightDbl -> 4]; + [BlackPawnBeat -> 4]; + [BlackPawnBeatLDbl -> 4]; + [BlackPawnBeatRDbl -> 4]; [BlackPawnPromote -> 4]; [BlackKnight -> 4]; [BlackBishop -> 4]; @@ -483,10 +439,9 @@ MOVES [WhitePawnMove -> 7]; [WhitePawnMoveDbl -> 7]; - [WhitePawnLeft -> 7]; - [WhitePawnLeftDbl -> 7]; - [WhitePawnRight -> 7]; - [WhitePawnRightDbl -> 7]; + [WhitePawnBeat -> 7]; + [WhitePawnBeatLDbl -> 7]; + [WhitePawnBeatRDbl -> 7]; [WhitePawnPromote -> 7]; [WhiteKnight -> 7]; [WhiteBishop -> 7]; @@ -505,10 +460,9 @@ MOVES [BlackPawnMove -> 6]; [BlackPawnMoveDbl -> 6]; - [BlackPawnLeft -> 6]; - [BlackPawnLeftDbl -> 6]; - [BlackPawnRight -> 6]; - [BlackPawnRightDbl -> 6]; + [BlackPawnBeat -> 6]; + [BlackPawnBeatLDbl -> 6]; + [BlackPawnBeatRDbl -> 6]; [BlackPawnPromote -> 6]; [BlackKnight -> 6]; [BlackBishop -> 6]; @@ -529,10 +483,9 @@ MOVES [WhitePawnMove -> 9]; [WhitePawnMoveDbl -> 9]; - [WhitePawnLeft -> 9]; - [WhitePawnLeftDbl -> 9]; - [WhitePawnRight -> 9]; - [WhitePawnRightDbl -> 9]; + [WhitePawnBeat -> 9]; + [WhitePawnBeatLDbl -> 9]; + [WhitePawnBeatRDbl -> 9]; [WhitePawnPromote -> 9]; [WhiteKnight -> 9]; [WhiteBishop -> 9]; @@ -553,10 +506,9 @@ MOVES [BlackPawnMove -> 8]; [BlackPawnMoveDbl -> 8]; - [BlackPawnLeft -> 8]; - [BlackPawnLeftDbl -> 8]; - [BlackPawnRight -> 8]; - [BlackPawnRightDbl -> 8]; + [BlackPawnBeat -> 8]; + [BlackPawnBeatLDbl -> 8]; + [BlackPawnBeatRDbl -> 8]; [BlackPawnPromote -> 8]; [BlackKnight -> 8]; [BlackBishop -> 8]; @@ -576,10 +528,9 @@ MOVES [WhitePawnMove -> 11]; [WhitePawnMoveDbl -> 11]; - [WhitePawnLeft -> 11]; - [WhitePawnLeftDbl -> 11]; - [WhitePawnRight -> 11]; - [WhitePawnRightDbl -> 11]; + [WhitePawnBeat -> 11]; + [WhitePawnBeatLDbl -> 11]; + [WhitePawnBeatRDbl -> 11]; [WhitePawnPromote -> 11]; [WhiteKnight -> 11]; [WhiteBishop -> 11]; @@ -599,10 +550,9 @@ MOVES [BlackPawnMove -> 10]; [BlackPawnMoveDbl -> 10]; - [BlackPawnLeft -> 10]; - [BlackPawnLeftDbl -> 10]; - [BlackPawnRight -> 10]; - [BlackPawnRightDbl -> 10]; + [BlackPawnBeat -> 10]; + [BlackPawnBeatLDbl -> 10]; + [BlackPawnBeatRDbl -> 10]; [BlackPawnPromote -> 10]; [BlackKnight -> 10]; [BlackBishop -> 10]; @@ -622,10 +572,9 @@ MOVES [WhitePawnMove -> 13]; [WhitePawnMoveDbl -> 13]; - [WhitePawnLeft -> 13]; - [WhitePawnLeftDbl -> 13]; - [WhitePawnRight -> 13]; - [WhitePawnRightDbl -> 13]; + [WhitePawnBeat -> 13]; + [WhitePawnBeatLDbl -> 13]; + [WhitePawnBeatRDbl -> 13]; [WhitePawnPromote -> 13]; [WhiteKnight -> 13]; [WhiteBishop -> 13]; @@ -645,10 +594,9 @@ MOVES [BlackPawnMove -> 12]; [BlackPawnMoveDbl -> 12]; - [BlackPawnLeft -> 12]; - [BlackPawnLeftDbl -> 12]; - [BlackPawnRight -> 12]; - [BlackPawnRightDbl -> 12]; + [BlackPawnBeat -> 12]; + [BlackPawnBeatLDbl -> 12]; + [BlackPawnBeatRDbl -> 12]; [BlackPawnPromote -> 12]; [BlackKnight -> 12]; [BlackBishop -> 12]; @@ -668,10 +616,9 @@ MOVES [WhitePawnMove -> 15]; [WhitePawnMoveDbl -> 15]; - [WhitePawnLeft -> 15]; - [WhitePawnLeftDbl -> 15]; - [WhitePawnRight -> 15]; - [WhitePawnRightDbl -> 15]; + [WhitePawnBeat -> 15]; + [WhitePawnBeatLDbl -> 15]; + [WhitePawnBeatRDbl -> 15]; [WhitePawnPromote -> 15]; [WhiteKnight -> 15]; [WhiteBishop -> 15]; @@ -690,10 +637,9 @@ MOVES [BlackPawnMove -> 14]; [BlackPawnMoveDbl -> 14]; - [BlackPawnLeft -> 14]; - [BlackPawnLeftDbl -> 14]; - [BlackPawnRight -> 14]; - [BlackPawnRightDbl -> 14]; + [BlackPawnBeat -> 14]; + [BlackPawnBeatLDbl -> 14]; + [BlackPawnBeatRDbl -> 14]; [BlackPawnPromote -> 14]; [BlackKnight -> 14]; [BlackBishop -> 14]; @@ -713,10 +659,9 @@ MOVES [WhitePawnMove -> 17]; [WhitePawnMoveDbl -> 17]; - [WhitePawnLeft -> 17]; - [WhitePawnLeftDbl -> 17]; - [WhitePawnRight -> 17]; - [WhitePawnRightDbl -> 17]; + [WhitePawnBeat -> 17]; + [WhitePawnBeatLDbl -> 17]; + [WhitePawnBeatRDbl -> 17]; [WhitePawnPromote -> 17]; [WhiteKnight -> 17]; [WhiteBishop -> 17]; @@ -737,10 +682,9 @@ MOVES [BlackPawnMove -> 16]; [BlackPawnMoveDbl -> 16]; - [BlackPawnLeft -> 16]; - [BlackPawnLeftDbl -> 16]; - [BlackPawnRight -> 16]; - [BlackPawnRightDbl -> 16]; + [BlackPawnBeat -> 16]; + [BlackPawnBeatLDbl -> 16]; + [BlackPawnBeatRDbl -> 16]; [BlackPawnPromote -> 16]; [BlackKnight -> 16]; [BlackBishop -> 16]; @@ -760,10 +704,9 @@ MOVES [WhitePawnMove -> 19]; [WhitePawnMoveDbl -> 19]; - [WhitePawnLeft -> 19]; - [WhitePawnLeftDbl -> 19]; - [WhitePawnRight -> 19]; - [WhitePawnRightDbl -> 19]; + [WhitePawnBeat -> 19]; + [WhitePawnBeatLDbl -> 19]; + [WhitePawnBeatRDbl -> 19]; [WhitePawnPromote -> 19]; [WhiteKnight -> 19]; [WhiteBishop -> 19]; @@ -783,10 +726,9 @@ MOVES [BlackPawnMove -> 18]; [BlackPawnMoveDbl -> 18]; - [BlackPawnLeft -> 18]; - [BlackPawnLeftDbl -> 18]; - [BlackPawnRight -> 18]; - [BlackPawnRightDbl -> 18]; + [BlackPawnBeat -> 18]; + [BlackPawnBeatLDbl -> 18]; + [BlackPawnBeatRDbl -> 18]; [BlackPawnPromote -> 18]; [BlackKnight -> 18]; [BlackBishop -> 18]; @@ -806,10 +748,9 @@ MOVES [WhitePawnMove -> 21]; [WhitePawnMoveDbl -> 21]; - [WhitePawnLeft -> 21]; - [WhitePawnLeftDbl -> 21]; - [WhitePawnRight -> 21]; - [WhitePawnRightDbl -> 21]; + [WhitePawnBeat -> 21]; + [WhitePawnBeatLDbl -> 21]; + [WhitePawnBeatRDbl -> 21]; [WhitePawnPromote -> 21]; [WhiteKnight -> 21]; [WhiteBishop -> 21]; @@ -829,10 +770,9 @@ MOVES [BlackPawnMove -> 20]; [BlackPawnMoveDbl -> 20]; - [BlackPawnLeft -> 20]; - [BlackPawnLeftDbl -> 20]; - [BlackPawnRight -> 20]; - [BlackPawnRightDbl -> 20]; + [BlackPawnBeat -> 20]; + [BlackPawnBeatLDbl -> 20]; + [BlackPawnBeatRDbl -> 20]; [BlackPawnPromote -> 20]; [BlackKnight -> 20]; [BlackBishop -> 20]; @@ -852,10 +792,9 @@ MOVES [WhitePawnMove -> 23]; [WhitePawnMoveDbl -> 23]; - [WhitePawnLeft -> 23]; - [WhitePawnLeftDbl -> 23]; - [WhitePawnRight -> 23]; - [WhitePawnRightDbl -> 23]; + [WhitePawnBeat -> 23]; + [WhitePawnBeatLDbl -> 23]; + [WhitePawnBeatRDbl -> 23]; [WhitePawnPromote -> 23]; [WhiteKnight -> 23]; [WhiteBishop -> 23]; @@ -874,10 +813,9 @@ MOVES [BlackPawnMove -> 22]; [BlackPawnMoveDbl -> 22]; - [BlackPawnLeft -> 22]; - [BlackPawnLeftDbl -> 22]; - [BlackPawnRight -> 22]; - [BlackPawnRightDbl -> 22]; + [BlackPawnBeat -> 22]; + [BlackPawnBeatLDbl -> 22]; + [BlackPawnBeatRDbl -> 22]; [BlackPawnPromote -> 22]; [BlackKnight -> 22]; [BlackBishop -> 22]; @@ -897,10 +835,9 @@ MOVES [WhitePawnMove -> 25]; [WhitePawnMoveDbl -> 25]; - [WhitePawnLeft -> 25]; - [WhitePawnLeftDbl -> 25]; - [WhitePawnRight -> 25]; - [WhitePawnRightDbl -> 25]; + [WhitePawnBeat -> 25]; + [WhitePawnBeatLDbl -> 25]; + [WhitePawnBeatRDbl -> 25]; [WhitePawnPromote -> 25]; [WhiteKnight -> 25]; [WhiteBishop -> 25]; @@ -921,10 +858,9 @@ MOVES [BlackPawnMove -> 24]; [BlackPawnMoveDbl -> 24]; - [BlackPawnLeft -> 24]; - [BlackPawnLeftDbl -> 24]; - [BlackPawnRight -> 24]; - [BlackPawnRightDbl -> 24]; + [BlackPawnBeat -> 24]; + [BlackPawnBeatLDbl -> 24]; + [BlackPawnBeatRDbl -> 24]; [BlackPawnPromote -> 24]; [BlackKnight -> 24]; [BlackBishop -> 24]; @@ -943,10 +879,9 @@ MOVES [WhitePawnMove -> 27]; [WhitePawnMoveDbl -> 27]; - [WhitePawnLeft -> 27]; - [WhitePawnLeftDbl -> 27]; - [WhitePawnRight -> 27]; - [WhitePawnRightDbl -> 27]; + [WhitePawnBeat -> 27]; + [WhitePawnBeatLDbl -> 27]; + [WhitePawnBeatRDbl -> 27]; [WhitePawnPromote -> 27]; [WhiteKnight -> 27]; [WhiteBishop -> 27]; @@ -966,10 +901,9 @@ MOVES [BlackPawnMove -> 26]; [BlackPawnMoveDbl -> 26]; - [BlackPawnLeft -> 26]; - [BlackPawnLeftDbl -> 26]; - [BlackPawnRight -> 26]; - [BlackPawnRightDbl -> 26]; + [BlackPawnBeat -> 26]; + [BlackPawnBeatLDbl -> 26]; + [BlackPawnBeatRDbl -> 26]; [BlackPawnPromote -> 26]; [BlackKnight -> 26]; [BlackBishop -> 26]; @@ -988,10 +922,9 @@ MOVES [WhitePawnMove -> 29]; [WhitePawnMoveDbl -> 29]; - [WhitePawnLeft -> 29]; - [WhitePawnLeftDbl -> 29]; - [WhitePawnRight -> 29]; - [WhitePawnRightDbl -> 29]; + [WhitePawnBeat -> 29]; + [WhitePawnBeatLDbl -> 29]; + [WhitePawnBeatRDbl -> 29]; [WhitePawnPromote -> 29]; [WhiteKnight -> 29]; [WhiteBishop -> 29]; @@ -1011,10 +944,9 @@ MOVES [BlackPawnMove -> 28]; [BlackPawnMoveDbl -> 28]; - [BlackPawnLeft -> 28]; - [BlackPawnLeftDbl -> 28]; - [BlackPawnRight -> 28]; - [BlackPawnRightDbl -> 28]; + [BlackPawnBeat -> 28]; + [BlackPawnBeatLDbl -> 28]; + [BlackPawnBeatRDbl -> 28]; [BlackPawnPromote -> 28]; [BlackKnight -> 28]; [BlackBishop -> 28]; @@ -1033,10 +965,9 @@ MOVES [WhitePawnMove -> 31]; [WhitePawnMoveDbl -> 31]; - [WhitePawnLeft -> 31]; - [WhitePawnLeftDbl -> 31]; - [WhitePawnRight -> 31]; - [WhitePawnRightDbl -> 31]; + [WhitePawnBeat -> 31]; + [WhitePawnBeatLDbl -> 31]; + [WhitePawnBeatRDbl -> 31]; [WhitePawnPromote -> 31]; [WhiteKnight -> 31]; [WhiteBishop -> 31]; @@ -1055,10 +986,9 @@ MOVES [BlackPawnMove -> 30]; [BlackPawnMoveDbl -> 30]; - [BlackPawnLeft -> 30]; - [BlackPawnLeftDbl -> 30]; - [BlackPawnRight -> 30]; - [BlackPawnRightDbl -> 30]; + [BlackPawnBeat -> 30]; + [BlackPawnBeatLDbl -> 30]; + [BlackPawnBeatRDbl -> 30]; [BlackPawnPromote -> 30]; [BlackKnight -> 30]; [BlackBishop -> 30]; Copied: trunk/Toss/examples/Pawn-Whopping.toss (from rev 1348, trunk/Toss/examples/PawnWhopping.toss) =================================================================== --- trunk/Toss/examples/Pawn-Whopping.toss (rev 0) +++ trunk/Toss/examples/Pawn-Whopping.toss 2011-03-10 18:14:24 UTC (rev 1349) @@ -0,0 +1,170 @@ +PLAYERS 1, 2 +DATA depth: 4, adv_ratio: 2 +REL DiagW (x, y) = ex z (C(x, z) and (R(y, z) or R(z, y))) +REL DiagB (x, y) = ex z (C(z, x) and (R(y, z) or R(z, y))) +REL IsFirst(x) = not ex z C(z, x) +REL IsSecond(x) = ex y (C(y, x) and IsFirst(y)) +REL IsEight(x) = not ex z C(x, z) +REL IsSeventh(x) = ex y (C(x, y) and IsEight(y)) +REL WhiteEnds() = (ex x (wP(x) and not ex y C(x, y))) or (not ex z bP(z)) +REL BlackEnds() = (ex x (bP(x) and not ex y C(y, x))) or (not ex z wP(z)) +RULE WhiteDiag: + [ a, b | wP { a }; bP { b } | - ] -> [ a, b | wP { b } | - ] emb wP, bP + pre DiagW(a, b) and not BlackEnds() +RULE WhiteStraight: + [ | bP:1 {}; R:2 {} | ] " + + . + + wP +" -> [ | bP:1 {}; R:2 {} | ] " + + wP + + . +" emb wP, bP pre not BlackEnds() +RULE WhiteStraightTwo: + [ | bP:1 {}; R:2 {} | ] " + + . + + . + + wP +" -> [ | bP:1 {}; R:2 {} | ] " + + wP + + . + + . +" emb wP, bP pre IsSecond(a1) and not BlackEnds() +RULE WhitePawnRightDbl: + [ | | ] " + ... + ?..-bP + ... + ? ... + ... + wP.bP +" -> [ | | ] " + ... + ?... + ... + ? wP. + ... + .... +" emb wP, bP pre not BlackEnds() +RULE WhitePawnLeftDbl: + [ | | ] " + ... + -bP? + ... + . ?.. + ... + bP.wP +" -> [ | | ] " + ... + ...? + ... + wP ?.. + ... + .... +" emb wP, bP pre not BlackEnds() +RULE BlackDiag: + [ a, b | bP { a }; wP { b } | - ] -> [ a, b | bP { b } | - ] emb wP, bP + pre DiagB(a, b) and not WhiteEnds() +RULE BlackStraight: + [ | R:2 {}; wP:1 {} | ] " + + bP + + . +" -> [ | R:2 {}; wP:1 {} | ] " + + . + + bP +" emb wP, bP pre not WhiteEnds() +RULE BlackStraightTwo: + [ | R:2 {}; wP:1 {} | ] " + + bP + + . + + . +" -> [ | R:2 {}; wP:1 {} | ] " + + . + + . + + bP +" emb wP, bP pre IsSeventh(a3) and not WhiteEnds() +RULE BlackPawnRightDbl: + [ | | ] " + ... + bP.wP + ... + ? ... + ... + ?..-wP +" -> [ | | ] " + ... + .... + ... + ? bP. + ... + ?... +" emb wP, bP pre not WhiteEnds() +RULE BlackPawnLeftDbl: + [ | | ] " + ... + wP.bP + ... + . ?.. + ... + -wP? +" -> [ | | ] " + ... + .... + ... + bP ?.. + ... + ...? +" emb wP, bP pre not WhiteEnds() +LOC 0 { + PLAYER 1 + PAYOFF { + 1: :(WhiteEnds()) - :(BlackEnds()); + 2: :(BlackEnds()) - :(WhiteEnds()) + } + MOVES [WhiteDiag -> 1]; [WhiteStraight -> 1]; [WhiteStraightTwo -> 1] +} +LOC 1 { + PLAYER 2 + PAYOFF { + 1: :(WhiteEnds()) - :(BlackEnds()); + 2: :(BlackEnds()) - :(WhiteEnds()) + } + MOVES [BlackDiag -> 0]; [BlackStraight -> 0]; [BlackStraightTwo -> 0] +} +MODEL [ | | ] " + ... ... ... ... + ... ... ... ... + ... ... ... ... + bP.bP bP.bP bP.bP bP.bP + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + wP wP.wP wP.wP wP.wP wP. + ... ... ... ... + ... ... ... ... +" Copied: trunk/Toss/examples/Pawn-Whopping.tossstyle (from rev 1348, trunk/Toss/examples/PawnWhopping.tossstyle) =================================================================== --- trunk/Toss/examples/Pawn-Whopping.tossstyle (rev 0) +++ trunk/Toss/examples/Pawn-Whopping.tossstyle 2011-03-10 18:14:24 UTC (rev 1349) @@ -0,0 +1,6 @@ +nocolor ; +elOPACITY: 20 ; +relOPACITY: 150 ; +arrLENscale: 0.0 ; +wP: ~/pawn_white.svg; +bP: ~/pawn_black.svg; Deleted: trunk/Toss/examples/PawnWhopping.toss =================================================================== --- trunk/Toss/examples/PawnWhopping.toss 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/examples/PawnWhopping.toss 2011-03-10 18:14:24 UTC (rev 1349) @@ -1,170 +0,0 @@ -PLAYERS 1, 2 -DATA depth: 4, adv_ratio: 2 -REL DiagW (x, y) = ex z (C(x, z) and (R(y, z) or R(z, y))) -REL DiagB (x, y) = ex z (C(z, x) and (R(y, z) or R(z, y))) -REL IsFirst(x) = not ex z C(z, x) -REL IsSecond(x) = ex y (C(y, x) and IsFirst(y)) -REL IsEight(x) = not ex z C(x, z) -REL IsSeventh(x) = ex y (C(x, y) and IsEight(y)) -REL WhiteEnds() = (ex x (W(x) and not ex y C(x, y))) or (not ex z B(z)) -REL BlackEnds() = (ex x (B(x) and not ex y C(y, x))) or (not ex z W(z)) -RULE WhiteDiag: - [ a, b | W { a }; B { b } | - ] -> [ a, b | W { b } | - ] emb W, B - pre DiagW(a, b) and not BlackEnds() -RULE WhiteStraight: - [ | B:1 {}; R:2 {} | ] " - - . - - W -" -> [ | B:1 {}; R:2 {} | ] " - - W - - . -" emb W, B pre not BlackEnds() -RULE WhiteStraightTwo: - [ | B:1 {}; R:2 {} | ] " - - . - - . - - W -" -> [ | B:1 {}; R:2 {} | ] " - - W - - . - - . -" emb W, B pre IsSecond(a1) and not BlackEnds() -RULE WhitePawnRightDbl: - [ | | ] " - ... - ?..-B - ... - ? ... - ... - W..B -" -> [ | | ] " - ... - ?... - ... - ? W.. - ... - .... -" emb W, B pre not BlackEnds() -RULE WhitePawnLeftDbl: - [ | | ] " - ... - -B.? - ... - . ?.. - ... - B..W -" -> [ | | ] " - ... - ...? - ... - W ?.. - ... - .... -" emb W, B pre not BlackEnds() -RULE BlackDiag: - [ a, b | B { a }; W { b } | - ] -> [ a, b | B { b } | - ] emb W, B - pre DiagB(a, b) and not WhiteEnds() -RULE BlackStraight: - [ | R:2 {}; W:1 {} | ] " - - B - - . -" -> [ | R:2 {}; W:1 {} | ] " - - . - - B -" emb W, B pre not WhiteEnds() -RULE BlackStraightTwo: - [ | R:2 {}; W:1 {} | ] " - - B - - . - - . -" -> [ | R:2 {}; W:1 {} | ] " - - . - - . - - B -" emb W, B pre IsSeventh(a3) and not WhiteEnds() -RULE BlackPawnRightDbl: - [ | | ] " - ... - B..W - ... - ? ... - ... - ?..-W -" -> [ | | ] " - ... - .... - ... - ? B.. - ... - ?... -" emb W, B pre not WhiteEnds() -RULE BlackPawnLeftDbl: - [ | | ] " - ... - W..B - ... - . ?.. - ... - -W.? -" -> [ | | ] " - ... - .... - ... - B ?.. - ... - ...? -" emb W, B pre not WhiteEnds() -LOC 0 { - PLAYER 1 - PAYOFF { - 1: :(WhiteEnds()) - :(BlackEnds()); - 2: :(BlackEnds()) - :(WhiteEnds()) - } - MOVES [WhiteDiag -> 1]; [WhiteStraight -> 1]; [WhiteStraightTwo -> 1] -} -LOC 1 { - PLAYER 2 - PAYOFF { - 1: :(WhiteEnds()) - :(BlackEnds()); - 2: :(BlackEnds()) - :(WhiteEnds()) - } - MOVES [BlackDiag -> 0]; [BlackStraight -> 0]; [BlackStraightTwo -> 0] -} -MODEL [ | | ] " - ... ... ... ... - ... ... ... ... - ... ... ... ... - B..B B..B B..B B..B - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - ... ... ... ... - W W..W W..W W..W W.. - ... ... ... ... - ... ... ... ... -" Deleted: trunk/Toss/examples/PawnWhopping.tossstyle =================================================================== --- trunk/Toss/examples/PawnWhopping.tossstyle 2011-03-08 11:15:20 UTC (rev 1348) +++ trunk/Toss/examples/PawnWhopping.tossstyle 2011-03-10 18:14:24 UTC (rev 1349) @@ -1,6 +0,0 @@ -nocolor ; -elOPACITY: 20 ; -relOPACITY: 150 ; -arrLENscale: 0.0 ; -W: ~/pawn_white.svg; -B: ~/pawn_black.svg; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-12 04:23:34
|
Revision: 1353 http://toss.svn.sourceforge.net/toss/?rev=1353&view=rev Author: lukaszkaiser Date: 2011-03-12 04:23:27 +0000 (Sat, 12 Mar 2011) Log Message: ----------- Ideas page, some first www corrections. Modified Paths: -------------- trunk/Toss/www/.cvsignore trunk/Toss/www/contact.xml trunk/Toss/www/navigation.xml Added Paths: ----------- trunk/Toss/www/ideas.xml Removed Paths: ------------- trunk/Toss/WebClient/pics/Checkers.html Property Changed: ---------------- trunk/Toss/www/ trunk/Toss/www/Publications/ Deleted: trunk/Toss/WebClient/pics/Checkers.html =================================================================== --- trunk/Toss/WebClient/pics/Checkers.html 2011-03-11 18:41:40 UTC (rev 1352) +++ trunk/Toss/WebClient/pics/Checkers.html 2011-03-12 04:23:27 UTC (rev 1353) @@ -1,16 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xml:lang="en" lang="en"> -<head> - <meta http-equiv="Content-Type" content="text/xhtml+xml; charset=UTF-8" /> - <title>tPlay</title> - <meta name="Description" - content="Play the best strategic games online with a nice interface." /> - <meta http-equiv="X-UA-Compatible" content="chrome=1" /> - <link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" /> - <link href="fontstyle.css" media="screen" rel="stylesheet" type="text/css" /> - <link rel="stylesheet" type="text/css" href="Style.css" media="screen" title="Default"/> -</head> -<body> -<svg id="svg" class="Game-Checkers" viewBox="0 0 580 580"><rect class="model-elem-0" x="4.285714285714285" y="504.2857142857143" width="71.42857142857143" height="71.42857142857143" id="elem_a1" ></rect><rect class="model-elem-1" x="75.71428571428572" y="504.2857142857143" width="71.42857142857143" height="71.42857142857143" id="elem_b1" ></rect><rect class="model-elem-0" x="147.14285714285714" y="504.2857142857143" width="71.42857142857143" height="71.42857142857143" id="elem_c1" ></rect><rect class="model-elem-1" x="218.57142857142856" y="504.2857142857143" width="71.42857142857143" height="71.42857142857143" id="elem_d1" ></rect><rect class="model-elem-0" x="290" y="504.2857142857143" width="71.42857142857143" height="71.42857142857143" id="elem_e1" ></rect><rect class="model-elem-1" x="361.42857142857144" y="504.2857142857143" width="71.42857142857143" height="71.42857142857143" id="elem_f1" ></rect><rect class="model-elem-0" x="432.85714285714283" y="504.2857142857143" width="71.42857142857143" height="71.42857142857143" id="elem_g1" ></rect><rect class="model-elem-1" x="504.2857142857143" y="504.2857142857143" width="71.42857142857143" height="71.42857142857143" id="elem_h1" ></rect><rect class="model-elem-1" x="4.285714285714285" y="432.85714285714283" width="71.42857142857143" height="71.42857142857143" id="elem_a2" ></rect><rect class="model-elem-0" x="75.71428571428572" y="432.85714285714283" width="71.42857142857143" height="71.42857142857143" id="elem_b2" ></rect><rect class="model-elem-1" x="147.14285714285714" y="432.85714285714283" width="71.42857142857143" height="71.42857142857143" id="elem_c2" ></rect><rect class="model-elem-0" x="218.57142857142856" y="432.85714285714283" width="71.42857142857143" height="71.42857142857143" id="elem_d2" ></rect><rect class="model-elem-1" x="290" y="432.85714285714283" width="71.42857142857143" height="71.42857142857143" id="elem_e2" ></rect><rect class="model-elem-0" x="361.42857142857144" y="432.85714285714283" width="71.42857142857143" height="71.42857142857143" id="elem_f2" ></rect><rect class="model-elem-1" x="432.85714285714283" y="432.85714285714283" width="71.42857142857143" height="71.42857142857143" id="elem_g2" ></rect><rect class="model-elem-0" x="504.2857142857143" y="432.85714285714283" width="71.42857142857143" height="71.42857142857143" id="elem_h2" ></rect><rect class="model-elem-0" x="4.285714285714285" y="361.42857142857144" width="71.42857142857143" height="71.42857142857143" id="elem_a3" ></rect><rect class="model-elem-1" x="75.71428571428572" y="361.42857142857144" width="71.42857142857143" height="71.42857142857143" id="elem_b3" ></rect><rect class="model-elem-0" x="147.14285714285714" y="361.42857142857144" width="71.42857142857143" height="71.42857142857143" id="elem_c3" ></rect><rect class="model-elem-1" x="218.57142857142856" y="361.42857142857144" width="71.42857142857143" height="71.42857142857143" id="elem_d3" ></rect><rect class="model-elem-0" x="290" y="361.42857142857144" width="71.42857142857143" height="71.42857142857143" id="elem_e3" ></rect><rect class="model-elem-1" x="361.42857142857144" y="361.42857142857144" width="71.42857142857143" height="71.42857142857143" id="elem_f3" ></rect><rect class="model-elem-0" x="432.85714285714283" y="361.42857142857144" width="71.42857142857143" height="71.42857142857143" id="elem_g3" ></rect><rect class="model-elem-1" x="504.2857142857143" y="361.42857142857144" width="71.42857142857143" height="71.42857142857143" id="elem_h3" ></rect><rect class="model-elem-1" x="4.285714285714285" y="290" width="71.42857142857143" height="71.42857142857143" id="elem_a4" ></rect><rect class="model-elem-0" x="75.71428571428572" y="290" width="71.42857142857143" height="71.42857142857143" id="elem_b4" ></rect><rect class="model-elem-1" x="147.14285714285714" y="290" width="71.42857142857143" height="71.42857142857143" id="elem_c4" ></rect><rect class="model-elem-0" x="218.57142857142856" y="290" width="71.42857142857143" height="71.42857142857143" id="elem_d4" ></rect><rect class="model-elem-1" x="290" y="290" width="71.42857142857143" height="71.42857142857143" id="elem_e4" ></rect><rect class="model-elem-0" x="361.42857142857144" y="290" width="71.42857142857143" height="71.42857142857143" id="elem_f4" ></rect><rect class="model-elem-1" x="432.85714285714283" y="290" width="71.42857142857143" height="71.42857142857143" id="elem_g4" ></rect><rect class="model-elem-0" x="504.2857142857143" y="290" width="71.42857142857143" height="71.42857142857143" id="elem_h4" ></rect><rect class="model-elem-0" x="4.285714285714285" y="218.57142857142856" width="71.42857142857143" height="71.42857142857143" id="elem_a5" ></rect><rect class="model-elem-1" x="75.71428571428572" y="218.57142857142856" width="71.42857142857143" height="71.42857142857143" id="elem_b5" ></rect><rect class="model-elem-0" x="147.14285714285714" y="218.57142857142856" width="71.42857142857143" height="71.42857142857143" id="elem_c5" ></rect><rect class="model-elem-1" x="218.57142857142856" y="218.57142857142856" width="71.42857142857143" height="71.42857142857143" id="elem_d5" ></rect><rect class="model-elem-0" x="290" y="218.57142857142856" width="71.42857142857143" height="71.42857142857143" id="elem_e5" ></rect><rect class="model-elem-1" x="361.42857142857144" y="218.57142857142856" width="71.42857142857143" height="71.42857142857143" id="elem_f5" ></rect><rect class="model-elem-0" x="432.85714285714283" y="218.57142857142856" width="71.42857142857143" height="71.42857142857143" id="elem_g5" ></rect><rect class="model-elem-1" x="504.2857142857143" y="218.57142857142856" width="71.42857142857143" height="71.42857142857143" id="elem_h5" ></rect><rect class="model-elem-1" x="4.285714285714285" y="147.14285714285714" width="71.42857142857143" height="71.42857142857143" id="elem_a6" ></rect><rect class="model-elem-0" x="75.71428571428572" y="147.14285714285714" width="71.42857142857143" height="71.42857142857143" id="elem_b6" ></rect><rect class="model-elem-1" x="147.14285714285714" y="147.14285714285714" width="71.42857142857143" height="71.42857142857143" id="elem_c6" ></rect><rect class="model-elem-0" x="218.57142857142856" y="147.14285714285714" width="71.42857142857143" height="71.42857142857143" id="elem_d6" ></rect><rect class="model-elem-1" x="290" y="147.14285714285714" width="71.42857142857143" height="71.42857142857143" id="elem_e6" ></rect><rect class="model-elem-0" x="361.42857142857144" y="147.14285714285714" width="71.42857142857143" height="71.42857142857143" id="elem_f6" ></rect><rect class="model-elem-1" x="432.85714285714283" y="147.14285714285714" width="71.42857142857143" height="71.42857142857143" id="elem_g6" ></rect><rect class="model-elem-0" x="504.2857142857143" y="147.14285714285714" width="71.42857142857143" height="71.42857142857143" id="elem_h6" ></rect><rect class="model-elem-0" x="4.285714285714285" y="75.71428571428572" width="71.42857142857143" height="71.42857142857143" id="elem_a7" ></rect><rect class="model-elem-1" x="75.71428571428572" y="75.71428571428572" width="71.42857142857143" height="71.42857142857143" id="elem_b7" ></rect><rect class="model-elem-0" x="147.14285714285714" y="75.71428571428572" width="71.42857142857143" height="71.42857142857143" id="elem_c7" ></rect><rect class="model-elem-1" x="218.57142857142856" y="75.71428571428572" width="71.42857142857143" height="71.42857142857143" id="elem_d7" ></rect><rect class="model-elem-0" x="290" y="75.71428571428572" width="71.42857142857143" height="71.42857142857143" id="elem_e7" ></rect><rect class="model-elem-1" x="361.42857142857144" y="75.71428571428572" width="71.42857142857143" height="71.42857142857143" id="elem_f7" ></rect><rect class="model-elem-0" x="432.85714285714283" y="75.71428571428572" width="71.42857142857143" height="71.42857142857143" id="elem_g7" ></rect><rect class="model-elem-1" x="504.2857142857143" y="75.71428571428572" width="71.42857142857143" height="71.42857142857143" id="elem_h7" ></rect><rect class="model-elem-1" x="4.285714285714285" y="4.285714285714285" width="71.42857142857143" height="71.42857142857143" id="elem_a8" ></rect><rect class="model-elem-0" x="75.71428571428572" y="4.285714285714285" width="71.42857142857143" height="71.42857142857143" id="elem_b8" ></rect><rect class="model-elem-1" x="147.14285714285714" y="4.285714285714285" width="71.42857142857143" height="71.42857142857143" id="elem_c8" ></rect><rect class="model-elem-0" x="218.57142857142856" y="4.285714285714285" width="71.42857142857143" height="71.42857142857143" id="elem_d8" ></rect><rect class="model-elem-1" x="290" y="4.285714285714285" width="71.42857142857143" height="71.42857142857143" id="elem_e8" ></rect><rect class="model-elem-0" x="361.42857142857144" y="4.285714285714285" width="71.42857142857143" height="71.42857142857143" id="elem_f8" ></rect><rect class="model-elem-1" x="432.85714285714283" y="4.285714285714285" width="71.42857142857143" height="71.42857142857143" id="elem_g8" ></rect><rect class="model-elem-0" x="504.2857142857143" y="4.285714285714285" width="71.42857142857143" height="71.42857142857143" id="elem_h8" ></rect><circle class="model-pred-W" cx="40" cy="540" r="23.714285714285715" id="pred_a1_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="182.85714285714286" cy="540" r="23.714285714285715" id="pred_c1_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="325.7142857142857" cy="540" r="23.714285714285715" id="pred_e1_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="468.57142857142856" cy="540" r="23.714285714285715" id="pred_g1_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="111.42857142857143" cy="468.57142857142856" r="23.714285714285715" id="pred_b2_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="254.28571428571428" cy="468.57142857142856" r="23.714285714285715" id="pred_d2_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="397.14285714285717" cy="468.57142857142856" r="23.714285714285715" id="pred_f2_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="540" cy="468.57142857142856" r="23.714285714285715" id="pred_h2_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="40" cy="397.14285714285717" r="23.714285714285715" id="pred_a3_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="182.85714285714286" cy="397.14285714285717" r="23.714285714285715" id="pred_c3_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="325.7142857142857" cy="397.14285714285717" r="23.714285714285715" id="pred_e3_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-W" cx="468.57142857142856" cy="397.14285714285717" r="23.714285714285715" id="pred_g3_W" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="111.42857142857143" cy="182.85714285714286" r="23.714285714285715" id="pred_b6_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="254.28571428571428" cy="182.85714285714286" r="23.714285714285715" id="pred_d6_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="397.14285714285717" cy="182.85714285714286" r="23.714285714285715" id="pred_f6_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="540" cy="182.85714285714286" r="23.714285714285715" id="pred_h6_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="40" cy="111.42857142857143" r="23.714285714285715" id="pred_a7_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="182.85714285714286" cy="111.42857142857143" r="23.714285714285715" id="pred_c7_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="325.7142857142857" cy="111.42857142857143" r="23.714285714285715" id="pred_e7_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="468.57142857142856" cy="111.42857142857143" r="23.714285714285715" id="pred_g7_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="111.42857142857143" cy="40" r="23.714285714285715" id="pred_b8_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="254.28571428571428" cy="40" r="23.714285714285715" id="pred_d8_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="397.14285714285717" cy="40" r="23.714285714285715" id="pred_f8_B" stroke-width="5.571428571428571" ></circle><circle class="model-pred-B" cx="540" cy="40" r="23.714285714285715" id="pred_h8_B" stroke-width="5.571428571428571" ></circle></svg> -</body> -</html> Property changes on: trunk/Toss/www ___________________________________________________________________ Modified: svn:ignore - # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html reference.pdf *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html *.html.de *.html.en *.texml *.xml.de *.xml.en reference.xml reference.pdf *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ Modified: trunk/Toss/www/.cvsignore =================================================================== --- trunk/Toss/www/.cvsignore 2011-03-11 18:41:40 UTC (rev 1352) +++ trunk/Toss/www/.cvsignore 2011-03-12 04:23:27 UTC (rev 1353) @@ -3,6 +3,12 @@ # svn propset svn:ignore -F .cvsignore . *.html +*.html.de +*.html.en +*.texml +*.xml.de +*.xml.en +reference.xml reference.pdf *.ps *.dvi Property changes on: trunk/Toss/www/Publications ___________________________________________________________________ Added: svn:ignore + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.xml.de *.xml.en *.html *.html.de *.html.en all.texml all.xml *~ Modified: trunk/Toss/www/contact.xml =================================================================== --- trunk/Toss/www/contact.xml 2011-03-11 18:41:40 UTC (rev 1352) +++ trunk/Toss/www/contact.xml 2011-03-12 04:23:27 UTC (rev 1353) @@ -36,19 +36,19 @@ Gridlock is a collection of open-source board games. It is nice to play but is does not allow you to change the game in any easy way.</par> - <par><a href="http://www.zillions-of-games.com/">Zillions of Games</a><br/> + <par><br/><a href="http://www.zillions-of-games.com/">Zillions of Games</a><br/> Zillions of Games is a language for defining games together with a simulator and a large library of games. It is very nice but unluckily not open source.</par> - <par><a href="http://www.kurnik.pl/">Kurnik</a><br/> + <par><br/><a href="http://www.kurnik.pl/">Kurnik</a><br/> Kurnik is a polish site on which you can play various games.</par> - <par><a href="http://abstractstrategy.com/main.html">Abstract Strategy + <par><br/><a href="http://abstractstrategy.com/main.html">Abstract Strategy Games</a><br/> Abstract Strategy Games site allows you to learn and play such games.</par> - <par><a href="http://www.yourturnmyturn.com/">Your Turn My Turn</a><br/> + <par><br/><a href="http://www.yourturnmyturn.com/">Your Turn My Turn</a><br/> On Your-Turn-My-Turn you can play various board games online.</par> </section> @@ -59,17 +59,17 @@ Project. It can be used for simulation of systems with continuous dynamics.</par> - <par><a href="http://www.iseesystems.com/softwares/Education/StellaSoftware.aspx">STELLA</a><br/> + <par><br/><a href="http://www.iseesystems.com/softwares/Education/StellaSoftware.aspx">STELLA</a><br/> STELLA is a commercial simulator allowing both continuous and discrete dynamics.</par> - <par><a href="http://ptolemy.eecs.berkeley.edu/">Ptolemy</a><br/> + <par><br/><a href="http://ptolemy.eecs.berkeley.edu/">Ptolemy</a><br/> The Ptolemy project studies modelling, simulation, and design of concurrent, real-time, embedded systems. This advanced project allows to use various models of computation that govern the interactions between components.</par> - <par><a href="http://www.microsoft.com/esp/about_esp/overview.htm" + <par><br/><a href="http://www.microsoft.com/esp/about_esp/overview.htm" >Microsoft ESP</a><br/>ESP is a visual simulation platform that applies game-based technology to some more complex problems.</par> </section> @@ -79,20 +79,20 @@ <a href="http://www.algosyn.rwth-aachen.de/">AlgoSyn</a> research group. Many people contributed, here we name just a few. Current leaders:</par> <itemize> - <item>Łukasz Kaiser (<mailto address="ka...@li..."/>)</item> + <item>Łukasz Kaiser (<mailto address="luk...@gm..."/>)</item> <item>Tobias Ganzow</item> <item>Łukasz Stafiniak</item> + <item>Michał Wójcik</item> </itemize> - <par>Friends who helped us a lot with dicussion and code at some point.</par> + <par>Friends who helped us a lot with dicussion and code.</par> <itemize> <item>Dietmar Berwanger</item> <item>Matko Botincan</item> <item>Diana Fischer</item> - <item>Michał Wójcik</item> </itemize> - <par>Yet another group of people worked on the oldest version of Toss - (around 2004).</par> + <par>Yet another group of people, who worked on the oldest version of Toss + (around 2004), was lead by:</par> <itemize> <item>Alexander Kharitonov</item> <item>Peter Cholewinski</item> Added: trunk/Toss/www/ideas.xml =================================================================== --- trunk/Toss/www/ideas.xml (rev 0) +++ trunk/Toss/www/ideas.xml 2011-03-12 04:23:27 UTC (rev 1353) @@ -0,0 +1,240 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE lecture SYSTEM "xsl/xhtml1-lat1.ent"> + +<?xml-stylesheet type="text/xsl" href="xsl/main.xsl" charset="UTF-8"?> + +<personal> + <title lang="en">GSoC Ideas</title> + <title lang="de">GSoC Ideen</title> + <history> + <link id="ideas" href="/ideas.html">GSoC Ideas</link> + </history> + + <section title="Google Summer of Code 2011"> + <par>Toss is applying to participate in <em>Google Summer of Code</em> + in 2011. This page contains a few ideas for students who wish to work + on Toss this summer. But, most importantly, we welcome new ideas from + students who wish to participate! We are very positive about suggestions + and we think that best proposals (and code) come from students who are + simply passionate about realizing their own ideas!<br/></par> + </section> + + <section title="Your Project Proposal"> + <par>If you decide to present your own idea, here are a few questions + we would like to ask you. You can see a similar pattern in the ideas + presented below – please, use it!</par> + <itemize> + <item>Provide a concise and precise description of your idea.</item> + <item>What is the goal, what do you want to create at the end?</item> + <item>There must be something usable by mid-term. What will it be?</item> + <item>Make a list of smaller pieces you wish to construct and sketch + their dependencies.</item> + <item>Which pieces can you skip if it turns out to be necessary?</item> + <item>How will your code enrich Toss and help people create and play + games?</item> + </itemize> + </section> + + <section title="Contact"> + <par>If you have an idea, or just want to talk, contact us! + We will respond to all of the emails below, but <em>toss-devel</em> + is the place we prefer.</par> + <itemize> + <item>Toss Mailing List: + <mailto address="tos...@li..."/></item> + <item>Łukasz Kaiser (GSoC admin): + <mailto address="luk...@gm..."/></item> + <item>Łukasz Stafiniak (GSoC backup admin): + <mailto address="luk...@gm..."/></item> + <item>Michał Wójcik: + <mailto address="mic...@gm..."/></item> + </itemize> + </section> + + <section title="Idea: Go and Arimaa"> + <par><em>Description and Goals.</em> The ancient game + of <a href="http://en.wikipedia.org/wiki/Go_(game)">Go</a> and the modern + <a href="http://en.wikipedia.org/wiki/Arimaa">Arimaa</a> are known to be + hard for computer AI algorithms. The goal of this project is to define + these games in Toss, compare how current Toss algorithms fare on these + two hard games, and possibly extend the algorithms to play well! + <br/><br/></par> + <par><em>Deliverables.</em> + By mid-term both games will be defined in Toss, ready for non-automatic + play. By the end, both the current minimax with alpha-beta playout + method and the Monte-Carlo with UTC method will be compared on these + games with different generated and hand-crafted heuristics. + <br/><br/></par> + <par><em>Modules (in planned construction order).</em> + <enumerate> + <item>Arimaa definition in Toss (easy)</item> + <item>Go definition in Toss without Ko (medium)</item> + <item>Toss extension to handle repeated positions (medium)</item> + <item>Go definition with Ko (easy after 3)</item> + <item>Adapting Heuristics, Minimax, UCT to play somehow (medium)</item> + <item>Optimizing the algorithms to play well (unknown)</item> + </enumerate> + <br/></par> + <par><em>Needed Skills and Difficulty.</em> + Good OCaml programming skills are required, and some general knowledge + of game playing algorithms will be necessary. Between easy and medium, + but can become very interesting and challenging in the last phase! + <br/><br/></par> + <par><em>Possible Mentors (in order of preference):</em> + Łukasz Stafiniak, Łukasz Kaiser, + Michał Wójcik, Tobias Ganzow + </par> + </section> + + + <section title="Idea: Pac-Man in Toss"> + <par><em>Description and Goals.</em> + While there is support for continuous dynamics and some concurrency + in current Toss code and GUI, these are not fully developed, tested, + and not supported in the web interface. The good old + <a href="http://en.wikipedia.org/wiki/Pac-Man">Pac-Man</a> is an ideal + test candidate for these features. + <br/><br/></par> + <par><em>Deliverables.</em> + By mid-term it will be possible to play Pac-Man in Toss in command + line mode and in the GUI. By the end, it will be supported in the web + interface as well. + <br/><br/></par> + <par><em>Modules (in planned construction order).</em> + <enumerate> + <item>Allow multiple players in one location in Toss (easy)</item> + <item>Test, debug and implement missing timing features (easy)</item> + <item>Relate Toss-internal time with real time (medium)</item> + <item>Pac-Man in command line and GUI (easy after 1, 2)</item> + <item>Make Toss web interface fully asynchronous (medium)</item> + <item>Pac-Man in the web interface (easy after 5)</item> + </enumerate> + <br/></par> + <par><em>Needed Skills and Difficulty.</em> + This idea is straight-forward and does not contain any hard bits. + But it requires the student to know both OCaml and AJAX with JavaScript, + and to be able to use and debug them in parallel. + <br/><br/></par> + <par><em>Possible Mentors (in order of preference):</em> + Łukasz Kaiser, Tobias Ganzow, Łukasz Stafiniak + </par> + </section> + + + <section title="Idea: Game Design made Comfortable"> + <par><em>Description and Goals.</em> + If you are passionate for interfaces, you see clearly that there + is work for you in Toss. The stand-alone GUI, made in python and Qt4, + differs significantly from the web interface. And more complex games + are written in a text editor anyway, in a syntax which could also see + some improvements. The goal is to make one interface to take the best + of these all and make it the preferred choice for Toss. + <br/><br/></par> + <par><em>Deliverables.</em> + The web interface will be extended to allow textual definitions of + new games by mid-term, including a possibility to test the game + before publishing it to friends or to everyone. Before the end, + basic functions of the GUI such as separate editing of rules and + changing relations, elements and positions will work online. + <br/><br/></par> + <par><em>Modules (in planned construction order).</em> + <enumerate> + <item>Make game list dynamic in the web interface</item> + <item>Allow users to add new games by uploading .toss files</item> + <item>Separate tab or page for game editing, simple text form</item> + <item>Handling of errors and basic sanity checks for new games</item> + <item>Extend game editing tab, separate rules, definitions</item> + <item>Tab for model editing, allow to view defined relations</item> + <item>Define a new game with the created interface, is it usable?</item> + </enumerate> + <br/></par> + <par><em>Needed Skills and Difficulty.</em> + OCaml skills are not required for this project, as it concerns mostly + web programming and interface design. But being easy from technical + point of view does not make it really easy – a good feeling for + interface design is necessary, and a lot of testing to make it right. + <br/><br/></par> + <par><em>Possible Mentors (in order of preference):</em> + Dietmar Berwanger, Michał Wójcik, Tobias Ganzow + </par> + </section> + + + <section title="Idea: Fast Optimizing Solver"> + <par><em>Description and Goals.</em> + The solver in Toss is no slouch, but it could be better. + Formulas should be compiled to a more optimized form, + possibly using relation size statistics. Structures should + be optimized for memory footprint and these together for + cache coherency – maybe with some parts rewritten in C. + Dynamics calculations should be moved nearer to the structure. + <br/><br/></par> + <par><em>Deliverables.</em> + By mid-term, the compilation of formulas for the solver will be optimized + and cleaned-up, with a separate module not using the current TNF. By the + end, the structure module will be optimized and dynamics calculations + moved there from the current Term module. + <br/><br/></par> + <par><em>Modules (in planned construction order).</em> + <enumerate> + <item>Written detailed design of new compilation module</item> + <item>New formula compilation functions and unit tests</item> + <item>Testing full Toss with the new module, quantify gains</item> + <item>Detailed design of new structure module with dynamics</item> + <item>Implementation of the new module, possibly in C</item> + <item>Interfacing the new module and testing it</item> + <item>Testing and optimizing performance of both modules</item> + </enumerate> + <br/></par> + <par><em>Needed Skills and Difficulty.</em> + This project is technical and requires very good understanding + of OCaml, the interface between OCaml and C, and the various factors + which can influence performance. Some knowledge of databases and + their optimization techniques can be helpful. + <br/><br/></par> + <par><em>Possible Mentors (in order of preference):</em> + Tobias Ganzow, Łukasz Kaiser, Łukasz Stafiniak + </par> + </section> + + <section title="Idea: GGP Competition and Cooperation"> + <par><em>Description and Goals.</em> + General Game Playing, GGP, is a name for the task of playing a game + given as input. Recently, Toss gained a module to translate games + defined in GDL, the Game Description Language used in GGP Competitions, + to the Toss format. This allows to compete against GGP players, and we + even won quite a few games already! But the GGP translation is not + complete and some games are translated to very inefficient variants, + on which it is almost impossible to play well. The idea is to improve + this, but also to cooperate with the GGP guys, especially with the + <a href="http://code.google.com/p/ggp-galaxy/">GGP Galaxy Project</a>, + to make General Game Playing truly accessible for everyone! + <br/><br/></par> + <par><em>Deliverables.</em> + Toss GGP translation module will be improved by mid-term to handle + standard Toss games well enough so that the manual translation code + can be removed. By the end, the majority of games in GDL will translate + well and will be made usable from the web interface. + <br/><br/></par> + <par><em>Modules (in planned construction order).</em> + <enumerate> + <item>Enrich Toss formulas with fixed-points (medium, needed)</item> + <item>Generalize GGP translation using fixed-points (medium)</item> + <item>Improve readability of translated games, test, debug</item> + <item>Add some position detection or layouting to the translation</item> + <item>Adapt web interface to be usable with translated games</item> + </enumerate> + <br/></par> + <par><em>Needed Skills and Difficulty.</em> + The GDL translation is not that hard in principle, but turns out to be + quite tricky in practice. Good knowlede of OCaml is necessary, and some + previous knowledge of GGP/GDL or Prolog would be good. But passsion + for GGP is the best recommendation for this project! + <br/><br/></par> + <par><em>Possible Mentors (in order of preference):</em> + Łukasz Stafiniak, Łukasz Kaiser, maybe someone from GGP Galaxy + </par> + </section> + + +</personal> Modified: trunk/Toss/www/navigation.xml =================================================================== --- trunk/Toss/www/navigation.xml 2011-03-11 18:41:40 UTC (rev 1352) +++ trunk/Toss/www/navigation.xml 2011-03-12 04:23:27 UTC (rev 1353) @@ -4,6 +4,7 @@ <navigation> <menu lang="en"> <item href="/" id="Home">Home</item> + <item href="/ideas.html" id="ideas">GSoC Ideas</item> <item href="http://tplay.org">Play Online</item> <item href="http://sourceforge.net/project/showfiles.php?group_id=115606" >Download Toss</item> @@ -23,6 +24,7 @@ <menu lang="de"> <item href="/" id="Home">Home</item> + <item href="/ideas.html" id="ideas">GSoC Ideen</item> <item href="http://tplay.org">Online Spielen</item> <item href="http://sourceforge.net/project/showfiles.php?group_id=115606" >Toss Runterladen</item> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-12 17:52:00
|
Revision: 1354 http://toss.svn.sourceforge.net/toss/?rev=1354&view=rev Author: lukaszkaiser Date: 2011-03-12 17:51:51 +0000 (Sat, 12 Mar 2011) Log Message: ----------- Website corrections, debug ocamldoc. Modified Paths: -------------- trunk/Toss/Arena/Term.mli trunk/Toss/Formula/Formula.mli trunk/Toss/Makefile trunk/Toss/Play/GameTree.mli trunk/Toss/Play/Play.mli trunk/Toss/Toss.odocl trunk/Toss/www/.cvsignore trunk/Toss/www/Makefile trunk/Toss/www/contact.xml trunk/Toss/www/create.xml trunk/Toss/www/docs.xml trunk/Toss/www/gui_interface.xml trunk/Toss/www/ideas.xml trunk/Toss/www/index.xml trunk/Toss/www/navigation.xml trunk/Toss/www/play.xml trunk/Toss/www/xsl/include/common.xsl Added Paths: ----------- trunk/Toss/www/reference/ trunk/Toss/www/reference/.cvsignore trunk/Toss/www/reference/Makefile trunk/Toss/www/reference/reference.bib trunk/Toss/www/reference/reference.tex Removed Paths: ------------- trunk/Toss/www/reference.bib trunk/Toss/www/reference.tex Property Changed: ---------------- trunk/Toss/www/ Modified: trunk/Toss/Arena/Term.mli =================================================================== --- trunk/Toss/Arena/Term.mli 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/Arena/Term.mli 2011-03-12 17:51:51 UTC (rev 1354) @@ -76,7 +76,7 @@ eq_sys -> eq_sys -(** {2 Runge-Kutta Method for Term Equations *) +(** {2 Runge-Kutta Method for Term Equations} *) (** Perform a Runge-Kutta (RK4) step for [vars] with [vals_init] and right-hand Modified: trunk/Toss/Formula/Formula.mli =================================================================== --- trunk/Toss/Formula/Formula.mli 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/Formula/Formula.mli 2011-03-12 17:51:51 UTC (rev 1354) @@ -52,6 +52,8 @@ | Or of formula list | Ex of var list * formula | All of var list * formula + +(** Real-valued terms allow counting, characteristic functions and arithmetic. *) and real_expr = RVar of string | Const of float @@ -61,6 +63,7 @@ | Char of formula | Sum of fo_var list * formula * real_expr + val pow : real_expr -> int -> real_expr val size : ?acc : int -> formula -> int Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/Makefile 2011-03-12 17:51:51 UTC (rev 1354) @@ -46,10 +46,12 @@ OCB_CFLAG=-cflags -I,+oUnit,-g OCB_LIB=-libs str,nums,unix,oUnit OCB_PP=-pp "camlp4o ../caml_extensions/pa_let_try.cmo ../caml_extensions/pa_backtrace.cmo" -OCAMLBUILD=ocamlbuild -j 8 -menhir ../menhir_conf $(OCB_PP) \ +OCAMLBUILD=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf $(OCB_PP) \ $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) -OCAMLBUILDBT=ocamlbuild -j 8 menhir ../menhir_conf $(OCB_PP) \ +OCAMLBUILDBT=ocamlbuild -log build.log -j 8 menhir ../menhir_conf $(OCB_PP) \ $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAGBT) +OCAMLBUILDNOPP=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf \ + $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) FormulaINC=Formula/Sat SolverINC=Formula,Formula/Sat,Solver/RealQuantElim @@ -76,7 +78,8 @@ doc: Formula/Sat/minisat/SatSolver.o Formula/Sat/minisat/MiniSATWrap.o \ caml_extensions/pa_let_try.cmo caml_extensions/pa_backtrace.cmo - $(OCAMLBUILD) -Is $(.INC) Toss.docdir/index.html + $(OCAMLBUILDNOPP) -Is +oUnit,$(.INC) Toss.docdir/index.html + make -C www code_doc_link # ---------- TESTS -------- Modified: trunk/Toss/Play/GameTree.mli =================================================================== --- trunk/Toss/Play/GameTree.mli 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/Play/GameTree.mli 2011-03-12 17:51:51 UTC (rev 1354) @@ -2,6 +2,8 @@ val set_debug_level : int -> unit +(** {2 Abstract Game Trees} *) + (** Abstract game tree, just stores state and move information. *) type ('a, 'b) abstract_game_tree = | Terminal of Arena.game_state * int * 'b (** terminal state with player *) @@ -42,7 +44,7 @@ -(** -------------- TREES WITH PAYOFF AND HEURISTIC DATA --------------- *) +(** {2 Trees with Payoff and Heuristic Data} *) (** How to exchange payoffs for heuristics. *) val cPAYOFF_AS_HEUR : float ref Modified: trunk/Toss/Play/Play.mli =================================================================== --- trunk/Toss/Play/Play.mli 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/Play/Play.mli 2011-03-12 17:51:51 UTC (rev 1354) @@ -6,7 +6,7 @@ val cancel_timeout : unit -> unit -(** ------------ MAXIMAX BY DEPTH ------------- *) +(** {2 Maximax by depth} *) (** Maximax by depth unfolding function. Throws Not_found if ready. *) val unfold_maximax : ?ab:bool -> Arena.game -> Formula.real_expr array array -> Modified: trunk/Toss/Toss.odocl =================================================================== --- trunk/Toss/Toss.odocl 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/Toss.odocl 2011-03-12 17:51:51 UTC (rev 1354) @@ -1,16 +1,27 @@ Formula/Formula +Formula/FormulaParser Formula/BoolFormula Formula/FFTNF Formula/FormulaOps Solver/Structure +Solver/StructureParser Solver/AssignmentSet Solver/Assignments -Solver/FFSolver Solver/Solver Solver/Class +Solver/ClassParser Arena/Term +Arena/TermParser Arena/DiscreteRule +Arena/DiscreteRuleParser Arena/ContinuousRule +Arena/ContinuousRuleParser Arena/Arena +Arena/ArenaParser Play/Heuristic +Play/Move +Play/GameTree +Play/Play Play/Game +GGP/GDL +GGP/GDLParser \ No newline at end of file Property changes on: trunk/Toss/www ___________________________________________________________________ Modified: svn:ignore - # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html *.html.de *.html.en *.texml *.xml.de *.xml.en reference.xml reference.pdf *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html *.html.de *.html.en *.texml *.xml.de *.xml.en reference.xml code_doc *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ Modified: trunk/Toss/www/.cvsignore =================================================================== --- trunk/Toss/www/.cvsignore 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/.cvsignore 2011-03-12 17:51:51 UTC (rev 1354) @@ -9,7 +9,7 @@ *.xml.de *.xml.en reference.xml -reference.pdf +code_doc *.ps *.dvi *.aux Modified: trunk/Toss/www/Makefile =================================================================== --- trunk/Toss/www/Makefile 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/Makefile 2011-03-12 17:51:51 UTC (rev 1354) @@ -1,3 +1,8 @@ TOPDIR = . include $(TOPDIR)/default.mak + +code_doc_link: + ln -fs ../Toss.docdir code_doc + cp code_doc/index.html code_doc/index.html.en + cp code_doc/index.html code_doc/index.html.de Modified: trunk/Toss/www/contact.xml =================================================================== --- trunk/Toss/www/contact.xml 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/contact.xml 2011-03-12 17:51:51 UTC (rev 1354) @@ -15,7 +15,7 @@ <section title="Email"> <par>Toss is an open source project hosted by <a href="http://sourceforge.net">SourceForge</a> - and distributed under the BSD licence.</par> + and distributed under the BSD licence.<br/></par> <par>Contact us by writing to: <mailto address="tos...@li..."/> </par> Modified: trunk/Toss/www/create.xml =================================================================== --- trunk/Toss/www/create.xml 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/create.xml 2011-03-12 17:51:51 UTC (rev 1354) @@ -10,22 +10,53 @@ <link id="create" href="/create.html">Create</link> </history> - <section title="Create New Games" lang="en"> - <par>The <a href="http://vimeo.com/10110495">Toss Tutorial</a> below + <section title="Two Ways to Create a New Game"> + <par>When you are done playing the games already defined in Toss, it's + time to start the real fun – create your own game! + There are two ways to create a game in Toss.</par> + <itemize> + <item>You can use the GUI to edit and create games</item> + <item>You can edit the .toss files directly</item> + </itemize> + If you plan to make small changes or an easy experiment, the GUI might + be the better option. For larger or completely new games, it is more + convenient to edit the files in your favourite text editor. + </section> + + <section title="Creating Games in Toss GUI"> + <par>To start the Toss GUI do the following.</par> + <itemize> + <item><em>Download</em> Toss from the + <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> + Sourceforge Download Page</a>.</item> + <item><em>Run Toss</em> by clicking <em>Toss.py</em>. + You can start by opening a file from the <em>examples</em> + directory.</item> + </itemize> + <par>When you have the GUI running, we recommend that you watch the + <a href="http://vimeo.com/10110495">Toss Tutorial</a> below, which shows all the steps needed to define a simple game in Toss and explains - several other features. Alternatively, you can just take a look at our - <a href="interface.php">Interface</a> page and play with the examples. - </par> - <toss-video/> + several other features. Alternatively, you can take a look at our + <a href="gui_interface.html">GUI interface</a> description page + and play with the examples.<br/></par> + <par><br/><toss-video/></par> </section> - <section title="Neue Spiele Erzeugen" lang="de"> - <par>The <a href="http://vimeo.com/10110495">Toss Tutorial</a> below - shows all the steps needed to define a simple game in Toss and explains - several other features. Alternatively, you can just take a look at our - <a href="interface.php">Interface</a> page and play with the examples. + <section title="Creating Games in Text Editor" lang="en"> + <par>For larger games, we find it easier to edit them in text + form than from the GUI. To understand the meaning of the fields + in the text file, you should probably first be acquainted with + Toss (e.g. go through the tutorial above) and at least skim through + the <a href="reference/reference.pdf">referece.pdf</a> file, look + at our <a href="docs.html">documentation</a>. After this, you can + simply edit the .toss file, maybe starting with one of these. </par> - <toss-video/> + <itemize> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss?revision=1349">Chess</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss?revision=1349">Tic-Tac-Toe</a></item> + </itemize> </section> + </personal> Modified: trunk/Toss/www/docs.xml =================================================================== --- trunk/Toss/www/docs.xml 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/docs.xml 2011-03-12 17:51:51 UTC (rev 1354) @@ -10,24 +10,48 @@ <link id="docs" href="/docs.html">Documentation</link> </history> - <section title="Background"> + <section title="Using Toss"> + <par>If you want to learn how to use Toss to create games, + go to the <a href="create.html">Create Games</a> page + or just watch the video tutorial below to get started.<br/></par> + <par><br/><toss-video/></par> + </section> + + <section title="Reference"> + <par>The Toss Design and Specification reference is an evolving document + in which we try to describe the high-level mathematical model of Toss + and the main ideas used in the implementation. The document is best + viewed as <a href="reference/reference.pdf">reference.pdf</a> but + a <a href="reference/">html version</a> is available as well + for fast fact-checking.</par> + </section> + + <section title="Code Documentation"> + We generate <a href="code_doc/">documentation from code comments</a> using + <a href="http://caml.inria.fr/pub/docs/manual-ocaml/manual029.html"> + ocamldoc</a>. It gives the most up-to date information on our code, + modules and their interfaces. + </section> + + <section title="Scientific Background"> <par>To learn more about the mathematical background and - the design of Toss, use the following links.</par> + the design of Toss, go to the <a href="Publications/">Papers + and Talks</a> page or use the following links.</par> <itemize> -<item><em>Compact description</em> of the mathematical model behind Toss and -our game playing algorithm can be found in the paper -<a href="http://logic.rwth-aachen.de/~kaiser/playing_structure_rewriting_games.pdf">Playing Structure Rewriting Games</a>.</item> - -<item><em>Design and specification</em> of Toss are described in - the <a href="reference.pdf">reference.pdf</a> document.</item> - -<item> <em>Complexity</em> of a syntactic fragment of Toss was analyzed in - the paper <a href="http://logic.rwth-aachen.de/~kaiser/graph_games_short.pdf"> - Synthesis for Structure Rewriting Systems</a>.</item> -<item><em>Presentation</em> on the mathematics behind Toss was given at - <em>IIT Kanpur</em> and can be - <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> - watched</a> online.</item> + <item><em>Compact description</em> of the mathematical model behind + Toss and our game playing algorithm can be found in the paper + <a href="pub/playing_structure_rewriting_games.pdf">Playing + Structure Rewriting Games</a>. + </item> + <item> <em>Complexity</em> of a syntactic fragment of Toss was + analyzed in the paper <a href="pub/graph_games_short.pdf"> + Synthesis for Structure Rewriting Systems</a>. + </item> + <item><em>Presentation</em> on the mathematics behind Toss was given at + <em>IIT Kanpur</em> and can be + <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> + watched</a> online. + </item> </itemize> </section> Modified: trunk/Toss/www/gui_interface.xml =================================================================== --- trunk/Toss/www/gui_interface.xml 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/gui_interface.xml 2011-03-12 17:51:51 UTC (rev 1354) @@ -11,19 +11,8 @@ <link id="examples" href="/examples.html">Examples</link> </history> - <section title="Running the Toss GUI"> - <itemize> - <item><em>Download</em> Toss from the - <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> - Sourceforge Download Page</a>.</item> - <item><em>Run Toss</em> by clicking <em>Toss.py</em>. - You can start by opening a file from the <em>examples</em> - directory.</item> - <item><em>Screenshots</em> of a few example games are - given on the <a href="/examples.html">Examples</a> page.</item> - </itemize> - </section> + <section title="Changing Elements"> <itemize> <item> Modified: trunk/Toss/www/ideas.xml =================================================================== --- trunk/Toss/www/ideas.xml 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/ideas.xml 2011-03-12 17:51:51 UTC (rev 1354) @@ -71,14 +71,14 @@ <item>Go definition in Toss without Ko (medium)</item> <item>Toss extension to handle repeated positions (medium)</item> <item>Go definition with Ko (easy after 3)</item> - <item>Adapting Heuristics, Minimax, UCT to play somehow (medium)</item> + <item>Adapting Minimax and UCT to play somehow (medium)</item> <item>Optimizing the algorithms to play well (unknown)</item> </enumerate> <br/></par> <par><em>Needed Skills and Difficulty.</em> Good OCaml programming skills are required, and some general knowledge - of game playing algorithms will be necessary. Between easy and medium, - but can become very interesting and challenging in the last phase! + of game playing algorithms will be necessary. This is a medium difficulty + project, but it can become very interesting in the last phase! <br/><br/></par> <par><em>Possible Mentors (in order of preference):</em> Łukasz Stafiniak, Łukasz Kaiser, @@ -155,7 +155,7 @@ interface design is necessary, and a lot of testing to make it right. <br/><br/></par> <par><em>Possible Mentors (in order of preference):</em> - Dietmar Berwanger, Michał Wójcik, Tobias Ganzow + Dietmar Berwanger, Michał Wójcik, Diana Fischer </par> </section> @@ -189,8 +189,8 @@ <par><em>Needed Skills and Difficulty.</em> This project is technical and requires very good understanding of OCaml, the interface between OCaml and C, and the various factors - which can influence performance. Some knowledge of databases and - their optimization techniques can be helpful. + which can influence performance. Some knowledge of either databases and + their optimization techniques or constraint solving will be helpful. <br/><br/></par> <par><em>Possible Mentors (in order of preference):</em> Tobias Ganzow, Łukasz Kaiser, Łukasz Stafiniak @@ -226,10 +226,11 @@ </enumerate> <br/></par> <par><em>Needed Skills and Difficulty.</em> - The GDL translation is not that hard in principle, but turns out to be - quite tricky in practice. Good knowlede of OCaml is necessary, and some - previous knowledge of GGP/GDL or Prolog would be good. But passsion - for GGP is the best recommendation for this project! + Due to different design choices behind the GDL and Toss formalisms, + the translation is a complex task and it requires acquaintance with + concepts from logic programming. Good knowledge of OCaml is necessary of + course, but some previous knowledge of GGP/GDL or Prolog would be helpful. + Still, passion for GGP is the best recommendation for this project! <br/><br/></par> <par><em>Possible Mentors (in order of preference):</em> Łukasz Stafiniak, Łukasz Kaiser, maybe someone from GGP Galaxy Modified: trunk/Toss/www/index.xml =================================================================== --- trunk/Toss/www/index.xml 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/index.xml 2011-03-12 17:51:51 UTC (rev 1354) @@ -43,8 +43,8 @@ shows all the steps needed to define a simple game in Toss and explains several other features. Alternatively, you can just take a look at our <a href="interface.php">Interface</a> page and play with the examples. - </par> - <toss-video/> + <br/></par> + <par><br/><toss-video/></par> </section> <section title="Neue Spiele Erzeugen" lang="de"> @@ -52,8 +52,8 @@ shows all the steps needed to define a simple game in Toss and explains several other features. Alternatively, you can just take a look at our <a href="interface.php">Interface</a> page and play with the examples. - </par> - <toss-video/> + <br/></par> + <par><br/><toss-video/></par> </section> <section title="Features"> @@ -74,7 +74,7 @@ <item><em>Solver</em> in Toss is optimized: it does quantifier elimination and formula decomposition (with <a href="http://minisat.se/">MiniSat</a>).</item> <item><em>Move hints</em> are given in all games using our general - game playing algorithm based on UCT.</item> + game playing algorithm based on UCT or Maximax.</item> </itemize> </section> Modified: trunk/Toss/www/navigation.xml =================================================================== --- trunk/Toss/www/navigation.xml 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/navigation.xml 2011-03-12 17:51:51 UTC (rev 1354) @@ -15,7 +15,9 @@ </menu> <item href="/play.html" id="play">Watch Toss Play</item> <menu title="Documentation" href="/docs.html" id="docs"> - <item href="/background.html" id="background">Background</item> + <item href="/reference/reference.pdf" id="refpdf">Reference (pdf)</item> + <item href="/reference/" id="refhtml">Reference (html)</item> + <item href="/code_doc/" id="code">Code Documentation</item> </menu> <item href="/Publications/" id="Publications">Papers and Talks</item> <item href="/contact.html" id="contact">Contact and Links</item> Modified: trunk/Toss/www/play.xml =================================================================== --- trunk/Toss/www/play.xml 2011-03-12 04:23:27 UTC (rev 1353) +++ trunk/Toss/www/play.xml 2011-03-12 17:51:51 UTC (rev 1354) @@ -10,8 +10,157 @@ <link id="play" href="/play.html">Toss Play</link> </history> - <section title="Watch Toss Play"> - <par>Here you can watch Toss play. Beware of Heuristics!</par> + <section title="General Game Playing"> + <a href="http://en.wikipedia.org/wiki/General_Game_Playing">General + Game Playing</a>, GGP in short, is a name for the task of playing + a previously unknown game. GGP is currently a popular field of AI, + with people at <a href="http://games.stanford.edu/">Stanford</a> + and in <a href="http://www.general-game-playing.de/">Germany</a> + doing great work. Players which accept games in the GDL format can + play on the <a href="http://euklid.inf.tu-dresden.de:8180/ggpserver/"> + Dresden GGP Server</a> and Toss recently started competing there as well. + Games in GDL format are not directly suited for online presentation, but + the <a href="http://code.google.com/p/ggp-galaxy/">GGP Galaxy Project</a> + has recently started to work on bringing them online – something + we already have for games in the Toss format. Below we show a few of + the games played by Toss against Fluxplayer on the Dresden Server. </section> + + <section title="Breakthrough Games"> + <itemize> + <item><ggp-game match_id="breakthrough.1297045579170" + name="Breakthrough 1"/></item> + <item><ggp-game match_id="breakthrough.1297045589259" + name="Breakthrough 2"/></item> + <item><ggp-game match_id="breakthrough.1297173861071" + name="Breakthrough 3"/></item> + <item><ggp-game match_id="breakthrough.1297173869694" + name="Breakthrough 4"/></item> + <item><ggp-game match_id="breakthrough.1297173874334" + name="Breakthrough 5"/></item> + <item><ggp-game match_id="breakthrough.1297173876674" + name="Breakthrough 6"/></item> + <item><ggp-game match_id="breakthrough.1297173880713" + name="Breakthrough 7"/></item> + <item><ggp-game match_id="breakthrough.1297173884736" + name="Breakthrough 8"/></item> + <item><ggp-game match_id="breakthrough.1297173889956" + name="Breakthrough 9"/></item> + <item><ggp-game match_id="breakthrough.1297173895209" + name="Breakthrough 10"/></item> + <item><ggp-game match_id="breakthrough.1297190115986" + name="Breakthrough 11"/></item> + <item><ggp-game match_id="breakthrough.1297190121191" + name="Breakthrough 12"/></item> + <item><ggp-game match_id="breakthrough.1297190129741" + name="Breakthrough 13"/></item> + <item><ggp-game match_id="breakthrough.1297190137203" + name="Breakthrough 14"/></item> + <item><ggp-game match_id="breakthrough.1297190149280" + name="Breakthrough 15"/></item> + <item><ggp-game match_id="breakthrough.1297190159057" + name="Breakthrough 16"/></item> + <item><ggp-game match_id="breakthrough.1297190171807" + name="Breakthrough 17"/></item> + <item><ggp-game match_id="breakthrough.1297190182797" + name="Breakthrough 18"/></item> + <item><ggp-game match_id="breakthrough.1297204058168" + name="Breakthrough 19"/></item> + <item><ggp-game match_id="breakthrough.1297204063753" + name="Breakthrough 20"/></item> + </itemize> + </section> + + <section title="Gomoku Games"> + <itemize> + <item><ggp-game match_id="connect5.1297281103161" + name="Gomoku 1"/></item> + <item><ggp-game match_id="connect5.1297281122315" + name="Gomoku 2"/></item> + <item><ggp-game match_id="connect5.1297281150565" + name="Gomoku 3"/></item> + <item><ggp-game match_id="connect5.1297281152908" + name="Gomoku 4"/></item> + <item><ggp-game match_id="connect5.1297281195920" + name="Gomoku 5"/></item> + <item><ggp-game match_id="connect5.1297281206285" + name="Gomoku 6"/></item> + <item><ggp-game match_id="connect5.1297281221465" + name="Gomoku 7"/></item> + <item><ggp-game match_id="connect5.1297281224813" + name="Gomoku 8"/></item> + <item><ggp-game match_id="connect5.1297281227319" + name="Gomoku 9"/></item> + <item><ggp-game match_id="connect5.1297281243181" + name="Gomoku 10"/></item> + <item><ggp-game match_id="connect5.1297281310683" + name="Gomoku 11"/></item> + <item><ggp-game match_id="connect5.1297281313978" + name="Gomoku 12"/></item> + <item><ggp-game match_id="connect5.1297281334093" + name="Gomoku 13"/></item> + <item><ggp-game match_id="connect5.1297281339581" + name="Gomoku 14"/></item> + <item><ggp-game match_id="connect5.1297290598634" + name="Gomoku 15"/></item> + <item><ggp-game match_id="connect5.1297290600817" + name="Gomoku 16"/></item> + <item><ggp-game match_id="connect5.1297290603544" + name="Gomoku 17"/></item> + <item><ggp-game match_id="connect5.1297290606415" + name="Gomoku 18"/></item> + <item><ggp-game match_id="connect5.1297335418504" + name="Gomoku 19"/></item> + <item><ggp-game match_id="connect5.1297339843897" + name="Gomoku 20"/></item> + </itemize> + </section> + + + <section title="Pawn Whopping Games"> + <itemize> + <item><ggp-game match_id="pawn_whopping_corrected.1297079331820" + name="Pawn Whopping 1"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079335327" + name="Pawn Whopping 2"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079338617" + name="Pawn Whopping 3"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079342087" + name="Pawn Whopping 4"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079344774" + name="Pawn Whopping 5"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079349729" + name="Pawn Whopping 6"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079352247" + name="Pawn Whopping 7"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079356298" + name="Pawn Whopping 8"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079360056" + name="Pawn Whopping 9"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297079363440" + name="Pawn Whopping 10"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297111697272" + name="Pawn Whopping 11"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297111700788" + name="Pawn Whopping 12"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297111705440" + name="Pawn Whopping 13"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297111708081" + name="Pawn Whopping 14"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297111712776" + name="Pawn Whopping 15"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297111715521" + name="Pawn Whopping 16"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297111730245" + name="Pawn Whopping 17"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297111733976" + name="Pawn Whopping 18"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297173802992" + name="Pawn Whopping 19"/></item> + <item><ggp-game match_id="pawn_whopping_corrected.1297173805830" + name="Pawn Whopping 20"/></item> + </itemize> + </section> + </personal> Property changes on: trunk/Toss/www/reference ___________________________________________________________________ Added: svn:ignore + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html *.html.de *.html.en *.png *.css reference.pdf *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ Added: trunk/Toss/www/reference/.cvsignore =================================================================== --- trunk/Toss/www/reference/.cvsignore (rev 0) +++ trunk/Toss/www/reference/.cvsignore 2011-03-12 17:51:51 UTC (rev 1354) @@ -0,0 +1,24 @@ +# We are still using .cvsignore files as we find them easier to manage +# than svn properties. Therefore if you change .cvsignore do the following. +# svn propset svn:ignore -F .cvsignore . + +*.html +*.html.de +*.html.en +*.png +*.css +reference.pdf +*.ps +*.dvi +*.aux +*.out +*.log +*.bbl +*.blg +*.idx +*.thm +*.snm +*.nav +*.toc +*.flc +*~ Added: trunk/Toss/www/reference/Makefile =================================================================== --- trunk/Toss/www/reference/Makefile (rev 0) +++ trunk/Toss/www/reference/Makefile 2011-03-12 17:51:51 UTC (rev 1354) @@ -0,0 +1,23 @@ +all: reference.pdf index.html + +reference.pdf: reference.tex reference.bib + pdflatex reference.tex + bibtex reference + pdflatex reference.tex + pdflatex reference.tex + rm -f *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav \ + *.toc *.lof *.flc + +reference.html: reference.tex reference.bib + htlatex reference.tex + rm -r reference.dvi *.log *.aux *.4ct *.4tc *.tmp *.idv *.lg *.xref + +index.html: reference.html + cp reference.html index.html + cp reference.html index.html.en + cp reference.html index.html.de + +.PHONY: + +clean: + rm -f *~ *.html *.png *.css reference.dvi reference.pdf Copied: trunk/Toss/www/reference/reference.bib (from rev 1353, trunk/Toss/www/reference.bib) =================================================================== --- trunk/Toss/www/reference/reference.bib (rev 0) +++ trunk/Toss/www/reference/reference.bib 2011-03-12 17:51:51 UTC (rev 1354) @@ -0,0 +1,189 @@ +@article{SUB96, + author = {Marcos Salganicoff and Lyle H. Ungar and Ruzena Bajcsy}, + title = {Active Learning for Vision-Based Robot Grasping}, + journal = {Machine Learning}, + volume = {23}, + year = {1996}, + pages = {251--278}, + publisher = {Kluwer Academic Publishers}, + url = {http://www.springerlink.com/index/L738U7026765L077.pdf} +} + +@book{PLN, + author = {Ben Goertzel and Matthew Ikle and Izabela Lyon Freire Goertzel}, + title = {Probabilistic Logic Networks: A Comprehensive Framework + for Uncertain Inference}, + publisher = {Springer}, + year = {2008}, + isbn = {0-387-76871-8} +} + + +@inproceedings{LG09, + author = {Moshe Looks and Ben Goertzel}, + title = {Program Representation for General Intelligence}, + booktitle = {Proceedings of AGI'09}, + year = {2009}, + url = {http://agi-conf.org/2009/papers/paper_69.pdf} +} + +@inproceedings{K09, + author = {{\L}ukasz Kaiser}, + title = {Synthesis for Structure Rewriting Systems}, + booktitle = {Proceedings of the 34th International Symposium on Mathematical Foundations of Computer Science, MFCS '09}, + publisher = {Springer}, + series = {LNCS}, + volume = {5734}, + year = {2009}, + pages = {415--427}, + url = {http://logic.rwth-aachen.de/~kaiser/graph_games_short.pdf}, +} + +@misc{toss, + title={Toss}, + howpublished={\url{http://toss.sourceforge.net}} +} + +@inproceedings{AS94, + author = {Rakesh Agrawal and + Ramakrishnan Srikant}, + title = {Fast Algorithms for Mining Association Rules in Large Databases}, + booktitle = {VLDB'94, Proceedings of 20th International Conference on Very + Large Data Bases}, + publisher = {Morgan Kaufmann}, + year = {1994}, + pages = {487--499}, + url = {http://ifsc.ualr.edu/xwxu/Teaching/SciDB/vldb94Apriori.pdf} +} + +@phdthesis{Gel07, + author = {Sylvain Gelly}, + title = {A Contribution to Reinforcement Learning; Application to Computer-Go}, + school = {University of Paris Sud}, + type = {Dissertation}, + year = {2007}, + url = {http://www.lri.fr/~gelly/paper/SylvainGellyThesis.pdf} +} + +@inproceedings{HP09, + author = {Joseph Y. Halpern and Rafeal Pass}, + title = {Iterated regret minimization: A new solution concept}, + booktitle = {Proceedings of the 21st International Joint Conference on + Artificial Intelligence (IJCAI 2009)}, + year = {2009}, + pages = {153--158}, + url = {http://www.cs.cornell.edu/~rafael/papers/regret.pdf} +} + +@incollection{T97, + author = {Wolfgang Thomas}, + title = {Ehrenfeucht Games, the Composition Method, and the Monadic + Theory of Ordinal Words}, + booktitle = {Structures in Logic and Computer Science}, + series = {LNCS}, + year = {1997}, + publisher = {Springer}, + pages = {118--143}, + volume = {1261}, + url = {http://automata.rwth-aachen.de/download/papers/thomas/ehrfeu.pdf} +} + +@inproceedings{FB08, + author = {Hilmar Finnsson and Yngvi Bj{\"o}rnsson}, + title = {Simulation-based Approach to General Game Playing}, + booktitle = {Proc.~of AAAI'08}, + publisher = {{AAAI} Press}, + year = {2008}, + url = {http://ru.is/faculty/hif/papers/cadiaplayer_aaai08.pdf} +} + +@article{GLP05, + author = {Michael R. Genesereth and Nathaniel Love and Barney Pell}, + title = {General Game Playing: Overview of the {AAAI} Competition}, + journal = {AI Magazine}, + year = {2005}, + volume = {26}, + number = {2}, + pages = {62--72}, + url = {http://games.stanford.edu/competition/misc/aaai.pdf} +} + +@article{GH06D_ag, + author = {Holger Giese and Stefan Henkler}, + title = {A Survey of Approaches for the Visual Model-Driven Development + of Next Generation Software-Intensive Systems}, + journal = {Journal of Visual Languages and Computing}, + year = {2006}, + volume = {17}, + number = {6}, + pages = {528--550}, + month = {12} +} + +@article{BGMOKS06_ag, + author = {Sven Burmester and Holger Giese and Eckehard M{\"u}nch and + Oliver Oberschelp and Florian Klein and Peter Scheideler }, + title = {Tool Support for the Design of Self-Optimizing Mechatronic + Multi-Agent Systems}, + journal = {International Journal on Software Tools for Technology Transfer}, + year = {2008}, + volume = {10}, + number = {3}, + pages = {207--222}, + month = {6}, + publisher = {Springer}, +} + +@inproceedings{G06, + author = {Ben Goertzel}, + title = {Patterns, Hypergraphs and Embodied General Intelligence}, + booktitle = {Proceedings of the International Joint Conference on Neural + Networks, IJCNN 2006, part of the IEEE World Congress on + Computational Intelligence, WCCI 2006, Vancouver, BC, Canada, + 16-21 July 2006}, + year = {2006}, + pages = {451--458}, + url = {http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.99.2741&rep=rep1&type=pdf} +} + +@inproceedings{DRDM03, + author = {Mehdi Dastani and + Birna van Riemsdijk and + Frank Dignum and + John-Jules Ch. Meyer}, + title = {A Programming Language for Cognitive Agents: Goal Directed 3APL}, + booktitle = {Proceedings of Programming Multi-Agent Systems, First + International Workshop, ProMAS 2003, Melbourne, Australia, + July 15, 2003, Selected Revised and Invited Papers}, + pages = {111--130}, + publisher = {Springer}, + series = {LNCS}, + volume = {3067}, + year = {2003} +} + +@inproceedings{AFHMS03, + author = {Luca de Alfaro and + Marco Faella and + Thomas A. Henzinger and + Rupak Majumdar and + Mari{\"e}lle Stoelinga}, + title = {The Element of Surprise in Timed Games}, + booktitle = {Proceedings of CONCUR 2003, France, 2003}, + pages = {142--156}, + publisher = {Springer}, + series = {LNCS}, + volume = {2761}, + year = {2003}, + url = {http://mtc.epfl.ch/~tah/Publications/the_element_of_surprise_in_timed_games.pdf} +} + +@article{GrGu98, + author = {Erich Gr{\"a}del and Yuri Gurevich}, + title = {Metafinite Model Theory}, + journal = {Information and Computation}, + volume = {140}, + year = {1998}, + pages = {26--81}, + url = {http://www.logic.rwth-aachen.de/pub/graedel/infcomp.ps}, +} Copied: trunk/Toss/www/reference/reference.tex (from rev 1353, trunk/Toss/www/reference.tex) =================================================================== --- trunk/Toss/www/reference/reference.tex (rev 0) +++ trunk/Toss/www/reference/reference.tex 2011-03-12 17:51:51 UTC (rev 1354) @@ -0,0 +1,729 @@ +\documentclass{scrbook} + +% Font choice +\usepackage[sc]{mathpazo} +\usepackage{bera} + +% Abbreviations for \calX, \frakX, \bbX etc. in math mode +\makeatletter +\newcommand{\@abbrev}[3]{ + \def\c@a@def##1{ + \if ##1. + \relax + \else + \@ifdefinable{\@nameuse{#1##1}}{\@namedef{#1##1}{#2##1}} + \expandafter\c@a@def + \fi + } + \c@a@def #3. +} +\@abbrev{bb}{\mathbb}{ABCDEFGHIJKLMNOPQRSTUVWXYZ} +\@abbrev{bf}{\mathbf}{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz} +\@abbrev{bit}{\boldsymbol}{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz} +\@abbrev{cal}{\mathcal}{ABCDEFGHIJKLMNOPQRSTUVWXYZ} +\@abbrev{frak}{\mathfrak}{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz} +\@abbrev{rm}{\mathrm}{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz} +\@abbrev{scr}{\mathscr}{ABCDEFGHIJKLMNOPQRSTUVWXYZ} +\@abbrev{sf}{\mathsf}{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz} +\makeatother + +% Simple item labels +\renewcommand{\labelitemi}{--} +\renewcommand{\labelitemii}{--} +\renewcommand{\labelitemiii}{--} + +% Packages +\usepackage{amsmath,amssymb,amsthm} +\usepackage{enumerate} +\usepackage{xspace} +\usepackage{tikz} +\usetikzlibrary{shapes,snakes,arrows} +\usepackage[draft]{fixme} + +% Additional commands +\newcommand{\cf}{cf.\xspace} +\newcommand{\ea}{\& al.\xspace} +\newcommand{\eg}{e.g.\xspace} +\newcommand{\ie}{i.e.\xspace} +\newcommand{\mr}[1]{\mathrm{#1}} +\newcommand{\ol}[1]{\overline{#1}} +\renewcommand{\phi}{\varphi} + + +% Start +\newcommand\thetitle{Toss Design and Specification} +\title{\thetitle} +\date{} +\author{Toss Team} + +\begin{document} + +\maketitle + +\setcounter{tocdepth}{1} + +\tableofcontents +\clearpage +\listoffigures + +\cleardoublepage + + +\chapter{Specification} + +\section{Discrete Structure Rewriting} + +To represent a state of our model in a fixed moment of time +we use finite relational structures, \ie labelled directed hypergraphs. +A relational structure $\frakA = (A, R_1, \ldots, R_k)$ is composed of +a universe $A$ and a number of relations $R_1, \ldots, R_k$. +We denote the arity of $R_i$ by $r_i$, so $R_i \subseteq A^{r_i}$. +The \emph{signature} of $\frakA$ is the set of symbols $\{R_1, \ldots, R_k\}$. + +The dynamics of the model, \ie the way the structure can change, +is described by \emph{structure rewriting rules}, a generalized form of +term and graph rewriting. Extended graph rewriting is recently viewed as +the programming model of choice for complex multi-agent systems, +especially ones with real-valued components \cite{BGMOKS06_ag}. +%Practical utility of such models was verified in a german project developing +%automomous railway vehicle control, the Collaborative Research Center 614. +Moreover, this form of rewriting is well suited for visual programming and +helps to make the systems understandable. %(see \cite{GH06D_ag} for a survey). + +In the most basic setting, a rule $\frakL \to_s \frakR$ consists of +two finite relational structures $\frakL$ and $\frakR$ over the same +signature and a partial function $s : \frakR \to \frakL$ specifying which +elements of $\frakL$ will be substituted by which elements of $\frakR$. + +Let $\frakA, \frakB$ be two structures, $\tau_{\mr{e}}$ a set of relations +symbols to be matched exactly and $\tau_{\mr{h}}$ a set of relations to +be matched only positively. In practice, we also allow some +tuples in $\frakL$ to be optional; this is a shorthand +for multiple rules with the same right-hand side. Optional tuples can +also appear in $\frakR$ if all elements in the tuple have corresponding +elements in $\frakL$. In such case, the tuple is included in $\frakR$ if +and only if a corresponding optional tuple appeared in $\frakL$. +A function $f : \frakA \hookrightarrow \frakB$ is +a $(\tau_{\mr{e}}, \tau_{\mr{h}})$-\emph{embedding} if $f$ is injective, +for each $R_i \in \tau_{\mr{e}}$ it holds that + $(a_1, \ldots, a_{r_i}) \in R^\frakA_i \Leftrightarrow + (f(a_1), \ldots, f(a_{r_i})) \in R^\frakB_i$, +and for $R_j \in \tau_{\mr{h}}$ it holds that + $(a_1, \ldots, a_{r_i}) \in R^\frakA_j \Rightarrow + (f(a_1), \ldots, f(a_{r_i})) \in R^\frakB_j$. +A $(\tau_{\mr{e}}, \tau_{\mr{h}})$-\emph{match} of the rule $\frakL \to_s \frakR$ +in another structure $\frakA$ is an $(\tau_{\mr{e}}, \tau_{\mr{h}})$-embedding +$\sigma : \frakL \hookrightarrow \frakA$. +We define the result of an application of $\frakL \to_s \frakR$ to $\frakA$ +on the match $\sigma$ as $\frakB = \frakA[\frakL \to_s \frakR / \sigma]$, +such that the universe of $\frakB$ is given by +$(A \setminus \sigma(L)) \dot\cup R$, and the relations as follows. +A tuple $(b_1, \ldots, b_{r_i})$ is in the new relation $R^\frakB_i$ +if and only if either it is in the relation in $\frakR$ already, +$(b_1, \ldots, b_{r_i}) \in R^\frakR_i$, or there exists a tuple in +the previous structure, $(a_1, \ldots, a_{r_i}) \in R^\frakA_i$, +such that for each $i$ either $a_i = b_i$ or $a_i = \sigma(s(b_i))$, +\ie either the element was there before or it was matched and $b_i$ +is the replacement as specified by the rule. Moreover, +if $R_i \in \tau_{\mr{e}}$ then we require in the second case that +at least one $b_i$ was already in the original structure, \ie $b_i = a_i$. +To understand this definition it is best to consider an example, +and one is given in Figure~\ref{fig-rewriting}. + +\begin{figure} +$\phantom{ll}$ +\begin{tikzpicture}[scale=0.7] +\node (a) at (-6, 1) {Rewriting Rule:}; +\node[draw, circle] (lhs1) at (-2.6, 1) {\tiny $a$}; +\node[draw, circle] (lhs2) at (-1.5, 1) {\tiny $b$}; +\path (lhs1) edge[->] node[above] {\tiny $R$} (lhs2); + +\node (t) at (-0.5, 1) {$\leadsto$}; + +\node[draw, circle, fill=black!15] (rhs1) at (0.6, 1.5) {\tiny $a$}; +\node[draw, circle, fill=black!15] (rhs2) at (1.8, 1.5) {\tiny $b$}; +\node[draw, circle, fill=black!15] (rhs3) at (3, 1.5) {\tiny $b$}; +\node[draw, circle, fill=black!15] (rhs4) at (1.8, 0.5) {\tiny $\phantom{a}$}; +\draw[->] (rhs2) -- (rhs1); +\draw[->] (rhs2) -- (rhs3); +\draw[->] (rhs2) -- (rhs4); +\end{tikzpicture} +\begin{center} +\vskip -1em +\begin{tikzpicture}[scale=0.59] +\scriptsize + +% Graph to be rewritten. +\node[draw, circle] (v) at (-7, 0) {$a$}; +\node[draw, circle] (v1) at (-6, 2) {}; +\node[draw, circle] (v2) at (-6, -2) {}; +\node[draw, circle] (w) at (-4, 0) {$b$}; +\node[draw, circle] (w1) at (-5, 2) {}; +\node[draw, circle] (w2) at (-5, -2) {}; +\node[draw, circle] (vu) at (-8, 2) {}; +\node[draw, circle] (vd) at (-8, -2) {}; +\node[draw, circle] (wu) at (-3, 2) {}; +\node[draw, circle] (wd) at (-3, -2) {}; + +\path (v) edge[thick,->] node[midway,above] {$R$} (w); +\draw[->] (v) -- (v1); +\draw[->] (v) -- (v2); +\draw[->] (w1) -- (w); +\draw[->] (w2) -- (w); +\draw[->] (vu) -- (v); +\draw[->] (vd) -- (v); +\draw[->] (w) -- (wu); +\draw[->] (w) -- (wd); + +\node (lto) at (-2.5, 0) {\normalsize $\leadsto$}; + +% Resulting graph +\node[draw, circle, fill=black!15] (rr1) at (-1.2, 0) {}; +\node[draw, circle, fill=black!15] (rr2) at (0.8, 0) {}; +\node[draw, circle, fill=black!15] (rr3) at (2.8, 0) {}; +\node[draw, circle, fill=black!15] (rr4) at (0.8, -1) {}; + +\node[draw, circle] (rv1u) at (-1.9, 2) {}; +\node[draw, circle] (rv1d) at (-1.9, -2) {}; +\node[draw, circle] (rv2u) at (-0.5, 2) {}; +\node[draw, circle] (rv2d) at (-0.5, -2) {}; +\node[draw, circle] (rw1u) at (2.1, 2) {}; +\node[draw, circle] (rw1d) at (2.1, -2) {}; +\node[draw, circle] (rw2u) at (3.5, 2) {}; +\node[draw, circle] (rw2d) at (3.5, -2) {}; + +\draw[thick,->] (rr2) -- (rr1); +\draw[thick,->] (rr2) -- (rr3); +\draw[thick,->] (rr2) -- (rr4); + +\draw[->] (rv1u) -- (rr1); +\draw[->] (rv1d) -- (rr1); +\draw[->] (rr1) -- (rv2u); +\draw[->] (rr1) -- (rv2d); + +%\draw[->] (rr2) -- (rv2u); +%\draw[->] (rr2) -- (rv2d); +\draw[->] (rr2) .. controls (1.8, 2.5) .. (rw2u); +\draw[->] (rr2) .. controls (1.8, -2.5) .. (rw2d); +\draw[->] (rw1u) -- (rr2); +\draw[->] (rw1d) -- (rr2); +%\path (rv1u) edge[->,bend left=60] (rr2); +%\draw[->] (rv1d) .. controls (0.5, -2.5) .. (rr2); + +\draw[->] (rw1u) -- (rr3); +\draw[->] (rw1d) -- (rr3); +\draw[->] (rr3) -- (rw2u); +\draw[->] (rr3) -- (rw2d); +\end{tikzpicture} +\end{center} +\caption{Rewriting rule and its application to a structure.} +\label{fig-rewriting} +\end{figure} + + +\section{Continuous Evolution} + +To model continuous dynamics in our system, we supplement relational +structures with a number of labeling functions $f_1, \ldots, f_l$, +each $f_i : A \to \bbR$ ($A$ is the universe).\footnote{In fact $f_i(a)$ is not +in $\bbR$; it is a function $\epsilon \to (x,x+\delta), \delta < \epsilon$.} +Accordingly, each rewriting rule is extended by a system of ordinary +differential equations (ODEs) and a set of right-hand update equations. +We use a standard form of ODEs: +$f^k_{i,l} = t(f^0_{i,l}, \ldots, f^{k-1}_{i,l})$, where $f_i$ are +the above-mentioned functions, $l$ can be any element of the left-hand +side structure and $f^k$ denotes the $k$-th derivative of $f$. +The term $t(\ol{x})$ is constructed using standard arithmetic functions +$+, -, \cdot, /$, natural roots $\sqrt[n]{\phantom{a}}$ for $n > 1$ +and rational numbers $r \in \bbQ$ in addition to the variables $\ol{x}$ and +a set of parameters $\ol{p}$ fixed for each rule. +%This form is enough to express most ODEs used in physics and economics. +The set of right-hand side update equations contains one equation of +the form $f_{i, r} = t(\ol{f_{i,l}})$ for each function $f_i$ and +each $r$ from the right-hand side structure. + +Let $\calR = \{ (\frakL_i \to_{s_i} \frakR_i, \calD_i, \calT_i) \mid i < n \}$ +be a set of rules extended with ODEs $\calD_i$ and update equations $\calT_i$ +as described above. +Given, for each rule in $\calR$, a match $\sigma_i$ of the rule in a structure +$\frakA$, the required parameters $\ol{p_i}$ and a time bound $t_i$, we define +the result of a \emph{simultaneous application} of $\calR$ to $\frakA$, +denoted $\frakA[\calR/\{\sigma_i, t_i\}]$, as follows. +We assume that no two intersecting rules have identical time bounds. + +First, the structure $\frakA$ evolves in a continuous way as given by +the \emph{sum} of all equations $\calD_i$. More precisely, let $\calD$ be +a system of differential equations where for each $a \in \frakA$ there +exists an equation defining $f^k_{i,a}$ if and only if there exists an +equation in some $\calD_j$ for $f^k_{i,l}$ for some $l$ with $\sigma_j(l) = a$. +In such case, the term for $f^k_{i,a}$ is the sum of all terms for such $l$, +with each $f^m_{i, l}$ replaced by the appropriate $f^m_{i, \sigma_j(l)}$. +Assuming that all functions $f_i$ and all their derivatives are given at +the beginning, there is a unique solution for these variables which satisfies +$\calD$ and has all other, undefined derivatives set by the starting condition +from $\frakA$. This solution defines the value of $f_{i,a}(t)$ for +each $a \in \frakA$ at any time moment $t$. + +Let $t^0 = \min_{i<n} t_i$ be the lowest chosen time bound and let +$i_0, \ldots, i_k$ be all rules with this bound, \ie each $t_{i_m} = t^0$. +We apply each of these rules independently$^1$ to the structure $\frakA$ +at time $t^0$. Formally, the relational part of +$\frakA[\calR/\{\sigma_i, t_i\}]$ is equal to +$\frakA[\frakL_{i_0} \to_{s_{i_0}} \frakR_{i_0}/\sigma_{i_0}] \cdots + [\frakL_{i_k} \to_{s_{i_k}} \frakR_{i_k}/\sigma_{i_k}]$ and the function values +$f_i(a)$ are defined as follows. If the element $a$ was not changed, +$a \in \frakA$, then we keep the function value from the solution of $\calD$, +\ie $f_i(a) = f_{i,a}(t^0)$. In the other case $a$ was on the right-hand side +of some rule, $a \in \frakR_m$. Let $f_{i,a} = t(\ol{f_{j,l}})$ be the +equation in $\calT_m$ defining $f_{i,a}$. The new value of $f_i(a)$ is then +computed by inserting the appropriate values for $f_{j,l}$ from the solution +of $\calD$ into $t(\ol{f_{j,l}})$, \ie $f_i(a) = t(\ol{y_{j,l}})$ where +each $y_{j,l} = f_{j,\sigma_m(l)}(t^0)$. %with $\ol{p_j}$ used as parameters. + +\emph{Example.} +Let us define a simple two-dimensional model of a cat chasing a mouse. +The structure we use, $\frakA = (\{c, m\}, C, M, x, y)$, has two elements +$c$ and $m$, unary relations $C = \{c\}$ and $M = \{m\}$ used to identify +which element is which and two real-valued functions $x$ and $y$. +Both rewriting rules have only one element, both on the left-hand side and +on the right-hand side, and the element is in $C$ for the cat rule and +in $M$ for the mouse rule. The ODEs for both rules are of the form +$x' = p_x, y' = p_y$, where $p_x, p_y$ are parameters. The update +equations just keep the left-hand side values, $x_r = x_l, y_r = y_l$. +In this setting, simultaneous application of the cat rule with parameters +$p^c_x, p^c_y$ for time $t^c$ and the mouse rule with parameters $p^m_x, p^m_y$ +for time $t^m$ will have the following effect: The cat will move with +speed $p^c_x$ along the $x$-axis and $p^c_y$ along the $y$-axis and the mouse +analogously with $p^m_x$ and $p^m_y$, both for time $t^0 = \min(t^c, t^m)$. + + +\section{Logic and Constraints} + +The logic we use for specifying properties of states is an extension of +monadic second-order logic with real-valued terms and counting operators. +%(\cf \cite{GrGu98}). +The main motivation for the choice of such logic is \emph{compositionality}: +To evaluate a formula on a large structure $\frakA$ which is composed in +a regular way from substructures $\frakB$ and $\frakC$ it is enough +to evaluate certain formulas on $\frakB$ and $\frakC$ independently. +Monadic second-order logic is one of the most expressive logics +with this property and allows to define various useful patterns such as stars, +connected components or acyclic subgraphs. (Additional syntactic +shorthands can be provided for useful patterns.) + +In the syntax of our logic, we use first-order variables +($x_1, x_2, \ldots$) ranging over elements of the structure, second-order +variables ($X_1, X_2, \ldots$) ranging over \emph{sets} of elements, +and real-valued variables $(\alpha_1, \alpha_2, \ldots)$ ranging over $\bbR$, +and we distinguish boolean formulas $\phi$ and real-valued terms $\rho$: +\begin{eqnarray*} + \phi := & \!\!\!\!\! R_i(x_1, \ldots, x_{r_i}) \, |\, x_i=x_j \, |\, + x_i \in X_j \, | \, \rho <_\epsilon \rho \, | \, \phi \land \phi \ | \\ + & \!\!\! \phi \lor \phi \, | \, \neg \phi \, | \, + \exists x_i \phi \, | \, \forall x_i \phi \, | \, + \exists X_i \phi \, | \, \forall X_i \phi \, | \, + \exists \alpha_i \phi \, | \, \forall \alpha_i \phi, +\end{eqnarray*} +\vskip -1.1em +\begin{eqnarray*} +\rho := & \!\!\!\! \alpha_i \: | \: f_i(x_j) \: | \: %\rho + \rho \ | \ + \rho \dotplus \rho \: | \: \chi[\phi] \: | \: \min_{\alpha_i}\!\phi \: | \: + \sum_{\ol{x} \mid \phi} \rho \: | \: \prod_{\ol{x} \mid \phi} \rho. +\end{eqnarray*} + +Semantics of most of the above operators is defined in the well known way, \eg +$\rho+\rho$ is the sum and $\rho \cdot \rho$ the product of real-valued terms, +and $\exists X \phi(X)$ means that there exists a set of elements $S$ such +that $\phi(S)$ holds. Among less known operators, +the term $\chi[\phi]$ denotes the characteristic function of $\phi$, \ie +the real-valued term which is $1$ for all assignments for which $\phi$ holds +and $0$ for all other. To evaluate $\min_{\alpha_i}\phi$ we take the minimal +$\alpha_i$ for which $\phi$ holds (we allow $\pm \infty$ as values +of terms as well). The terms $\sum_{\ol{x} \mid \phi} \rho$ and +$\prod_{\ol{x} \mid \phi} \rho$ denote the sum and product of the values of +$\rho(\ol{x})$ for all assignments of elements of the structure to $\ol{x}$ +for which $\phi(\ol{x})$ holds. Note that both these terms can have free +variables, \eg the set of free variables of $\sum_{\ol{x} \mid \phi} \rho$ +is the union of free variables of $\phi$ and free variables of $\rho$, minus +the set $\{\ol{x}\}$. Observe also the $\epsilon$ in $<_\epsilon$: +the values $f(a)$ are given with arbitrary small but non-zero error +and $\rho_1 <_\epsilon \rho_2$ holds only if the upper +bound of $\rho_1$ lies below the lower bound of $\rho_2$. +%both terms queried with error bound $\epsilon$. + +The logic defined above is used in structure rewriting rules in two ways. +First, it is possible to define a new relation $R(\ol{x})$ using a formula +$\phi(\ol{x})$ with free variables contained in~$\ol{x}$. +Defined relations can be used on left-hand sides of structure +rewriting rules, but are not allowed on right-hand sides. +The second way is to add \emph{constraints} to a rule. +A rule $\frakL \to_s \frakR$ can be constrained using +three sentences (\ie formulas without free variables): +$\phi_{\mr{pre}}$, $\phi_{\mr{inv}}$ and $\phi_{\mr{post}}$. +In both $\phi_{\mr{pre}}$ and $\phi_{\mr{inv}}$ we allow additional constants $l$ +for each $l \in \frakL$ and in $\phi_{\mr{post}}$ special constants for each +$r \in \frakR$ can be used. A rule $\frakL \to_s \frakR$ with such constraints +can be applied on a match $\sigma$ in $\frakA$ only if the following holds: +At the beginning, the formula $\phi_{\mr{pre}}$ must hold in $\frakA$ with +the constants $l$ interpreted as $\sigma(l)$. Later, during the whole +continuous evolution, the formula $\phi_{\mr{inv}}$ must hold in the structure +$\frakA$ with continuous values changed as prescribed by the solution of +the system $\calD$ (defined above). +Finally, the formula $\phi_{\mr{post}}$ must hold in the resulting +structure after rewriting. During simultaneous execution of a few rules with +constraints and with given time bounds $t_i$, one of the invariants +$\phi_{\mr{inv}}$ may cease to hold. In such case, the rule is applied at +that moment of time, even before $t^0 = \min t_i$ is reached --- but of +course only if $\phi_{\mr{post}}$ holds afterwards. If $\phi_{\mr{post}}$ +does not hold, the rule is ignored and time goes on for the remaining rules. + + +\section{Structure Rewriting Games} + +As you could judge from the cat and mouse example, one can describe +a structure rewriting game simply by providing a set of allowed rules for +each player. Still, in many cases it is necessary to have more control +over the flow of the game and to model probabilistic events. +For this reason, we use labelled directed graphs with probabilities +in the definition of the games. The labels for each player are of the form: +\[ \lambda = (\frakL \to_s \frakR, \calD, \calT, + \phi_{\mr{pre}}, \phi_{\mr{inv}}, \phi_{\mr{post}}, + I_t, \ol{I_p}, \mr{m}, \tau_{\mr{e}}). \] +Except for a rewriting rule with invariants, the label $\lambda$ specifies +a time interval $I_t \subseteq [0, \infty)$ from which the player can +choose the time bound for the rule and, if there are other continuous +parameters $p_1, \ldots, p_n$, also an interval $I_{p_j} \subseteq \bbR$ +for each parameter. The element $\mr{m} \in \{1, \ast, \infty\}$ +specifies if the player must choose a single match of the rule ($\mr{m} = 1$), +apply it simultaneously to all possible matches ($\mr{m} = \infty$, useful for +modeling nature) or if any number of non-intersecting matches might be chosen +($\mr{m} = \ast$); $\tau_{\mr{e}}$ tells which relations must be matched +exactly (all other are in $\tau_{\mr{h}}$). + +We define a \emph{general structure rewriting game} with $k$ players as +a directed graph in which each vertex is labelled by $k$ sets of labels +denoting possible actions of the players. +For each $k$-tuple of labels, one from each set, there must be an outgoing edge +labelled by this tuple, pointing to the next location of the game if these +actions are chosen by the players. There can be more than one outgoing edge +with the same label in a vertex: In such case, all edges with this label must +be assigned probabilities (\ie positive real numbers which sum up to~$1$). +Moreover, an end-point of an interval $I_t$ or $I_p$ in a label can be given +by a parameter, \eg $x$. Then, each outgoing edge with this label must +be marked by $x \! \sim \! \calN(\mu,\sigma)$, $x \! \sim \! \calU(a,b)$ or +$x \! \sim \! \calE(\lambda)$, meaning that $x$ will be drawn from the normal, +uniform or exponential distribution (these $3$ chosen for convenience). +Additionally, in each vertex there are $k$ real-valued terms of the logic +presented above which denote the payoff for each player if the game +ends at this vertex. + +A play of a structure rewriting game starts in a fixed first vertex of +the game graph and in a state represented by a given starting structure. +All players choose rules, matches and time bounds allowed by the labels of +the current vertex such that the tuple of rules can be applied simultaneously. +The play proceeds to the next vertex (given by the labeling of the edges) +in the changed state (after the application of the rules). +If in some vertex and state it is not possible to apply any tuple of rules, +either because no match is found or because of the constraints, then the play +ends and payoff terms are evaluated giving the outcome for each player. + +\begin{figure} +\begin{center} +\begin{tikzpicture}[scale=0.71] \tiny +% Game Graph +\node (gg) at (-6.2, 2) {\small Game Graph:}; +\node[draw, circle, fill=black!15] (p0) at (-4, 2) {}; +\node[draw, circle, fill=black!15] (p1) at (-4, 0) {}; +\draw[->] (-4, 2.5) -- (p0); +\path (p0) edge[bend right=30,->] (p1); +\path (p1) edge[bend right=30,->] (p0); + +\node[draw,circle] (r0l) at (-5.8, 1) {$\phantom{a}$}; +\node (r0m) at (-5.3, 0.98) {$\leadsto$}; +\node[draw,circle] (r0r) at (-4.8, 1) {$P$}; + +\node[draw,circle] (r1l) at (-3.2, 1) {$\phantom{a}$}; +\node (r0m) at (-2.7, 0.98) {$\leadsto$}; +\node[draw,circle] (r0r) at (-2.2, 1) {$Q$}; + +% Starting Structure +\node (ss) at (-1.5, 2) {\small Starting Structure:}; +\foreach \x in {1, ..., 3} \foreach \y in {0, ..., 2} { + \node[draw, circle] (n\x\y) at (\x, \y) {$\phantom{a}$}; +} + +\foreach \x in {1, ..., 3} \foreach \y / \n in {0/1, 1/2} { + \path (n\x\n) edge[->] node[right] {$C$} (n\x\y); +} + +\foreach \y in {0, ..., 2} \foreach \x / \n in {1/2, 2/3} { + \path (n\x\y) edge[->] node[above] {$R$} (n\n\y); +} +\end{tikzpicture} +\end{center} +\caption{Tic-tac-toe as a structure rewriting game.} +\label{fig-tic-tac-toe} +\end{figure} + +\emph{Example.} Let us define tic-tac-toe in our framework. +The state of the game is represented by a structure with $9$ elements +connected by binary row and column relations, $R$ and $C$, as depicted +on the right in Figure~\ref{fig-tic-tac-toe}. To mark the moves of the players +we use unary relations $P$ and $Q$. The allowed move of the first player +is to m... [truncated message content] |
From: <luk...@us...> - 2011-03-12 19:24:46
|
Revision: 1355 http://toss.svn.sourceforge.net/toss/?rev=1355&view=rev Author: lukstafi Date: 2011-03-12 19:24:32 +0000 (Sat, 12 Mar 2011) Log Message: ----------- TossFullTest: new test modules, put module tests together. DiscreteRule: remember which LHS tuples required to be absent (useful for analysis); fixes in rule-from-precondition generation. FormulaOps: new partial simplification functions. GGP/tests: targets for GDL translation and GameSimpl simplification tests. GDL translation: much better branch pruning, fixes in erasure branch generation. GameSimpl: specification; removing redundant equivalent relations (still broken effect on rule LHS structures). Various modules: helper functions. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/Arena/ContinuousRule.ml trunk/Toss/Arena/ContinuousRule.mli trunk/Toss/Arena/DiscreteRule.ml trunk/Toss/Arena/DiscreteRule.mli trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/Formula/FormulaOps.ml trunk/Toss/Formula/FormulaOps.mli trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDLTest.ml trunk/Toss/GGP/examples/breakthrough.gdl trunk/Toss/Server/ServerGDLTest.in trunk/Toss/TossFullTest.ml trunk/Toss/TossTest.ml Added Paths: ----------- trunk/Toss/GGP/GameSimpl.ml trunk/Toss/GGP/GameSimpl.mli trunk/Toss/GGP/GameSimplTest.ml trunk/Toss/GGP/tests/ trunk/Toss/GGP/tests/breakthrough-raw.toss trunk/Toss/GGP/tests/breakthrough-simpl.toss trunk/Toss/GGP/tests/connect5-raw.toss trunk/Toss/GGP/tests/connect5-simpl.toss Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Arena/Arena.ml 2011-03-12 19:24:32 UTC (rev 1355) @@ -377,6 +377,20 @@ } in (game, state), player +let map_to_formulas f game = + {game with + rules = List.map (fun (rn, r) -> + rn, ContinuousRule.map_to_formulas f r + ) game.rules; + graph = Array.map (fun loc -> + {loc with + payoffs = + Array.map (FormulaOps.map_to_formulas_expr f) loc.payoffs; + }) game.graph; + defined_rels = List.map (fun (drel, (args, def)) -> + drel, (args, f def)) game.defined_rels; + } + (* ------------------ REQUESTS TO THE ARENA USED IN OPERATION --------------- *) (* Location of a structure: either arena or left or right-hand side of a rule *) Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Arena/Arena.mli 2011-03-12 19:24:32 UTC (rev 1355) @@ -108,6 +108,8 @@ val process_definition : ?extend_state:game * game_state -> definition list -> game * game_state +val map_to_formulas : (Formula.formula -> Formula.formula) -> game -> game + (** ------------------ REQUESTS TO THE ARENA USED IN OPERATION --------------- *) (** Location of a structure: either arena or left or right-hand side of a rule *) Modified: trunk/Toss/Arena/ContinuousRule.ml =================================================================== --- trunk/Toss/Arena/ContinuousRule.ml 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Arena/ContinuousRule.ml 2011-03-12 19:24:32 UTC (rev 1355) @@ -41,7 +41,7 @@ -(* ------------------ APPLYING FUNCTIONS TO SIDE STRUCTURES ----------------- *) +(* ------------------ APPLYING FUNCTIONS TO PARTS OF A RULE ----------------- *) (* Apply [f] to left (if [to_left]) or right side of the given named rule. Return the new rule and an additional result which [f] returns. *) @@ -59,6 +59,16 @@ let lhs r = r.discrete.DiscreteRule.lhs_struc let rhs r = r.discrete.DiscreteRule.rhs_struc +let map_to_formulas f r = + {r with + discrete = {r.discrete with DiscreteRule.pre = + f r.discrete.DiscreteRule.pre}; + compiled = {r.compiled with DiscreteRule.lhs_form = + f r.compiled.DiscreteRule.lhs_form}; + inv = f r.inv; + post = f r.post; + } + (* ---------------------- FINDING APPLICABLE MATCHES ------------------------ *) (* Find all matches of [r] in [struc] which satisfy [r]'s precondition. *) Modified: trunk/Toss/Arena/ContinuousRule.mli =================================================================== --- trunk/Toss/Arena/ContinuousRule.mli 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Arena/ContinuousRule.mli 2011-03-12 19:24:32 UTC (rev 1355) @@ -54,8 +54,8 @@ val lhs : rule -> Structure.structure val rhs : rule -> Structure.structure +val map_to_formulas : (Formula.formula -> Formula.formula) -> rule -> rule - (** {2 Finding applicable matches} *) Modified: trunk/Toss/Arena/DiscreteRule.ml =================================================================== --- trunk/Toss/Arena/DiscreteRule.ml 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Arena/DiscreteRule.ml 2011-03-12 19:24:32 UTC (rev 1355) @@ -35,6 +35,10 @@ lhs_elem_names : elem_names; lhs_elem_inv_names : elem_inv_names; lhs_elem_vars : string list; + lhs_neg_tups : (string * int array list) list; + (* Tuples of relations over the LHS structure elements that are + required to be absent for embedding; this is "meta-data" not + needed for matching and rewriting but useful for other purposes. *) lhs_form : Formula.formula; (* gets instantiated in the model *) (* the precondition [pre] is compiled as part of [lhs_form] *) @@ -558,21 +562,6 @@ let signat = List.filter (fun (rel,_) -> special_rel_of rel = None && not (List.mem_assoc rel defined_rels)) signat in - let expand_def_rels rel = - if List.mem_assoc rel defined_rels then - let args, rphi = List.assoc rel defined_rels in - List.map fst (List.filter (fun (rel, ar) -> - let selector = Structure.free_for_rel rel ar in - let res = Solver.M.check selector rphi in - (* {{{ log entry *) - if !debug_level > 3 then ( - Printf.printf "compile_rule.expand_def_rels: %s on %s = %b\n%!" - rel (Structure.str selector) res - ); - (* }}} *) - res - ) signat) - else [rel] in let expand_defrel_tups (drel, tups) = if List.mem_assoc drel defined_rels then @@ -613,7 +602,23 @@ else [drel, tups] in (* expand defined rels in embedding list *) let base_emb_rels = - unique (=) (concat_map expand_def_rels rule_src.emb_rels) in + let expand_def_rels rel = + if List.mem_assoc rel defined_rels then + let args, rphi = List.assoc rel defined_rels in + List.map fst (List.filter (fun (rel, ar) -> + let selector = Structure.free_for_rel rel ar in + let res = Solver.M.check selector rphi in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "compile_rule.expand_def_rels: %s on %s = %b\n%!" + rel (Structure.str selector) res + ); + (* }}} *) + res + ) signat) + else [rel] in + unique(*_sorted *) (=) + (concat_map expand_def_rels rule_src.emb_rels) in (* {{{ log entry *) if !debug_level > 1 then ( Printf.printf "compile_rule: emb=%s -- base_emb_rels=%s\n%!" @@ -723,8 +728,8 @@ let lhs_opt_rels, lhs_pos_tups, lhs_pos_expanded = compile_opt_rels lhs_rels in let lhs_all_tups n = - List.map Array.of_list (Aux.product - (Aux.fold_n (fun acc -> lhs_elems::acc) [] n)) in + List.map Array.of_list (Aux.product ( + Aux.fold_n (fun acc -> lhs_elems::acc) [] n)) in (* let lhs_all_tups n = List.fold_left (fun tups tup -> STups.add tup tups) @@ -818,8 +823,8 @@ ) tups) rhs_rels in let rhs_all_tups n = - List.map Array.of_list (Aux.product - (Aux.fold_n (fun acc -> rhs_elems::acc) [] n)) in + List.map Array.of_list (Aux.product ( + Aux.fold_n (fun acc -> rhs_elems::acc) [] n)) in (* a tuple is negative when it has to be removed: it is in $\tau_e$ and in the LHS, but it does not occur on the RHS even optionally *) let rhs_neg_tuples = @@ -861,6 +866,7 @@ lhs_elem_names = lhs_elem_names; lhs_elem_inv_names = lhs_elem_inv_names; lhs_elem_vars = lhs_elem_vars; + lhs_neg_tups = lhs_neg_tups; lhs_form = emb; rhs_elem_names = rule_src.rhs_struc.Structure.names; rhs_elem_vars = rhs_elem_vars; @@ -887,26 +893,32 @@ (* Build a rule by translating the "add" list into the RHS structure directly, and separating out from a precondition the LHS structure - over the [struc_vars] variables. All relations are - considered embedded. (Obviously, not all rules can be generated in - this way.) *) -let translate_from_precond ~precond ~add ~embed ~struc_elems = + over the [struc_vars] variables. Only and all the [emb_rels] relations + are embedded (usually the fluents). (Not all rules can be generated + using this function.) Caution: simplifies the precondition. + + The partition of embedded relations into positive and negative + tuples (literals) is extracted from the precondition. If the + partition does not cover all tuples, fail. *) +let translate_from_precond ~precond ~add ~emb_rels ~signat ~struc_elems = let rhs_names = Aux.unique_sorted (Aux.concat_map (fun (_,arg) -> Array.to_list arg) add) in assert (Aux.list_diff rhs_names struc_elems = []); let rewritable args = Aux.array_for_all (fun v -> List.mem (Formula.var_str v) struc_elems) args in - let conjs = FormulaOps.flatten_ands precond in - let literals, conjs = Aux.partition_map (function + let conjs = + FormulaOps.flatten_ands (FormulaOps.remove_redundant precond) in + let posi, conjs = Aux.partition_map (function | Formula.Rel (rel, args) when rewritable args -> - Left (Left (rel,args)) - | Not (Formula.Rel (rel, args)) when rewritable args -> - Left (Right (rel,args)) + Left (rel,args) | phi -> Right phi) conjs in - let posi, nega = Aux.partition_choice literals in - (* FIXME: TODO: check and at least warn when [nega] is smaller than - the complement of [posi] over embedded rels *) + let nega, conjs = Aux.partition_map (function + | Formula.Not (Formula.Rel (rel, args)) + when List.mem rel emb_rels && rewritable args -> + Left (rel,args) + | phi -> Right phi) conjs in + let lhs_extracted = posi @ nega in let precond = Formula.And conjs in let fvars = FormulaOps.free_vars precond in let local_vars = @@ -915,12 +927,39 @@ let precond = if local_vars = [] then precond else Formula.Ex (local_vars, precond) in - let emb_rels = Aux.list_inter embed - (Aux.unique_sorted - (List.map fst add @ List.map fst (posi @ nega))) in let posi_s = List.map (fun (rel, args) -> rel, Array.map Formula.var_str args) posi in + let opt_s = + Aux.concat_map (fun rel -> + try + let arity = signat rel in + let tups = + List.map + Array.of_list + (*Aux.array_map_of_list Formula.var_str*) + (Aux.product ( + Aux.fold_n (fun acc -> struc_elems::acc) [] arity)) in + let extracted = + List.map (Array.map Formula.var_str) + (Aux.assoc_all rel lhs_extracted) in + (* {{{ log entry *) + if !debug_level > 4 then ( + Printf.printf "translate_from_precond: _opt_%s -- extracted %s -- \ + remaining %s\n%!" rel + (String.concat "; " + (List.map (fun args -> + String.concat " " (Array.to_list args)) extracted)) + (String.concat "; " + (List.map (fun args -> + String.concat " " (Array.to_list args)) + (Aux.list_diff tups extracted))) + ); + (* }}} *) + let tups = Aux.list_diff tups extracted in + List.map (fun args -> "_opt_"^rel, args) tups + with Not_found -> []) + emb_rels in let rhs_struc, struc_elems = List.fold_left (fun (rhs_struc, struc_elems) name -> let rhs_struc, elem = @@ -933,7 +972,7 @@ let lhs_struc = rhs_struc in let rhs_struc = add_rels rhs_struc add in let lhs_struc = add_rels lhs_struc posi_s in - (* no relations are optional, righ? *) + let lhs_struc = add_rels lhs_struc opt_s in { lhs_struc = lhs_struc; rhs_struc = rhs_struc; @@ -942,6 +981,7 @@ pre = precond; } + (** {2 Printing and parsing.} *) let matching_str matching = Modified: trunk/Toss/Arena/DiscreteRule.mli =================================================================== --- trunk/Toss/Arena/DiscreteRule.mli 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Arena/DiscreteRule.mli 2011-03-12 19:24:32 UTC (rev 1355) @@ -30,14 +30,19 @@ lhs_elem_names : elem_names; lhs_elem_inv_names : elem_inv_names; lhs_elem_vars : string list; + lhs_neg_tups : (string * int array list) list; + (** Tuples of relations over the LHS structure elements that are + required to be absent for embedding; this is "meta-data" not + needed for matching and rewriting but useful for other + purposes. *) lhs_form : Formula.formula; - (* gets instantiated in the model *) - (* the precondition [pre] is compiled as part of [lhs_form] *) + (** gets instantiated in the model *) + (** the precondition [pre] is compiled as part of [lhs_form] *) rhs_elem_names : elem_names; - rhs_elem_vars : string list; (* replaces the embedding *) - rhs_pos_tuples : (string * var_tuples) list; (* gets added *) - rhs_neg_tuples : (string * var_tuples) list; (* gets removed *) - rlmap : (string * string) list option; (* rule_s on variables (?) *) + rhs_elem_vars : string list; (** replaces the embedding *) + rhs_pos_tuples : (string * var_tuples) list; (** gets added *) + rhs_neg_tuples : (string * var_tuples) list; (** gets removed *) + rlmap : (string * string) list option; (** rule_s on variables *) } val elemvar_of_elem : elem_inv_names -> int -> string @@ -113,9 +118,21 @@ val changeable_rels : rule_obj list -> string list +(** Build a rule by translating the "add" list into the RHS structure + directly, and separating out from a precondition the LHS structure + over the [struc_vars] variables. Only and all the [emb_rels] + relations are embedded (usually the fluents). (Not all rules can be + generated using this function.) Caution: simplifies the + precondition. + + The partition of embedded relations into positive and negative + tuples (literals) is extracted from the precondition. If the + partition does not cover all tuples, fail. *) val translate_from_precond : precond:Formula.formula -> add:(string * string array) list -> - embed:string list -> struc_elems:string list -> rule + (* del:(string * string array) list -> *) + emb_rels:string list -> signat:(string -> int) -> + struc_elems:string list -> rule (** {2 Printing.} *) val matching_str : matching -> string Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Formula/Aux.ml 2011-03-12 19:24:32 UTC (rev 1355) @@ -36,6 +36,14 @@ let intmap_filter p m = IntMap.fold (fun k v acc -> if p k v then (k,v)::acc else acc) m [] +let int_pow x n = + let rec aux acc res n = + if n = 0 then res + else if n mod 2 = 0 then aux (acc*acc) res (n/2) + else aux (acc*acc) (res*acc) (n/2) in + if n < 0 then 0 + else aux x 1 n + let is_digit c = (c = '0') || (c = '1') || (c = '2') || (c = '3') || (c = '4') || (c = '5') || (c = '6') || (c = '7') || (c = '8') || (c = '9') @@ -44,6 +52,12 @@ let snd3 (_,a,_) = a let trd3 (_,_,a) = a +module BasicOperators = struct + let (-|) f g x = f (g x) +end + +open BasicOperators + (* {2 Helper functions on lists and other functions lacking from the standard library.} *) Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Formula/Aux.mli 2011-03-12 19:24:32 UTC (rev 1355) @@ -21,6 +21,14 @@ val intmap_filter : (int -> 'a -> bool) -> 'a IntMap.t -> (int * 'a) list +module BasicOperators : +sig + (** Function composition. *) + val ( -| ) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b +end + +val int_pow : int -> int -> int + val is_digit : char -> bool val fst3 : 'a * 'b * 'c -> 'a Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Formula/FormulaOps.ml 2011-03-12 19:24:32 UTC (rev 1355) @@ -142,7 +142,19 @@ | Sum (vs, phi, r) -> Sum (vs, map_to_literals f g phi, map_to_literals_expr f g r) +(* Map [f] to top-level formulas in the real expression ([Char]s and + [Sum] guards). *) +let rec map_to_formulas_expr f = function + | RVar _ | Const _ | Fun _ as x -> x + | Times (r1, r2) -> + Times (map_to_formulas_expr f r1, map_to_formulas_expr f r2) + | Plus (r1, r2) -> + Plus (map_to_formulas_expr f r1, map_to_formulas_expr f r2) + | Char (phi) -> Char (f phi) + | Sum (vs, phi, r) -> + Sum (vs, f phi, map_to_formulas_expr f r) + (* Map [f] to all atoms in the given formula. *) let map_to_atoms_full f g phi = map_to_literals (function Not (x) -> Not (f x) | x -> f x) g phi @@ -673,12 +685,62 @@ | Not phi -> Not (flatten_formula phi) | (Rel _ | Eq _ | In _ | RealExpr _) as atom -> atom -(* Formula as a list of conjuncts. *) +let rec flatten_ors = function + | Or disjs -> Aux.concat_map flatten_ors disjs + | phi -> [phi] + +(* Formula as a list of conjuncts, with one level of distributing + negation over disjunction and pushing quantifiers inside. *) let rec flatten_ands = function - | Formula.And conjs -> Aux.concat_map flatten_ands conjs + | And conjs -> Aux.concat_map flatten_ands conjs + | Not (Or disjs) -> + List.map (fun d -> Not d) + (Aux.concat_map flatten_ors disjs) + | All (vs, phi) -> + List.map (fun phi -> All (vs, phi)) (flatten_ands phi) + | Ex (vs, phi) as arg -> + (match flatten_ands phi with + | [] -> [] | [_] -> [arg] + | conjs -> + let free_conjs, bound_conjs = List.partition (fun conj -> + Aux.list_inter vs (free_vars conj) = []) conjs in + let bound_phi = match bound_conjs with + | [phi] -> phi | _ -> And bound_conjs in + free_conjs @ [Ex (vs, bound_phi)]) | phi -> [phi] +(* Remove literals from disjunctions in positive positions + (conjunctions in negative positions) that already occur conjoined + to the disjucntion. (Does not descend the real part currently.) *) +let remove_redundant phi = + let rec aux base neg = function + | And conjs when not neg -> + let more_base, subtasks = List.partition (function + | Rel _ | Not (Rel _) -> true | _ -> false) conjs in + And (more_base @ List.map (aux (more_base @ base) neg) subtasks) + | Or conjs when neg -> + let more_base, subtasks = List.partition (function + | Rel _ | Not (Rel _) -> true | _ -> false) conjs in + Or (more_base @ List.map (aux (more_base @ base) neg) subtasks) + | Or disjs (* when not neg *) -> + let literals, subtasks = List.partition (function + | Rel _ | Not (Rel _) -> true | _ -> false) disjs in + let disjs = + Aux.list_diff literals base @ List.map (aux base neg) subtasks in + (match disjs with [disj] -> disj | _ -> Or disjs) + | And disjs (* when neg *) -> + let literals, subtasks = List.partition (function + | Rel _ | Not (Rel _) -> true | _ -> false) disjs in + let disjs = + Aux.list_diff literals base @ List.map (aux base neg) subtasks in + (match disjs with [disj] -> disj | _ -> And disjs) + | Not phi -> Not (aux base (not neg) phi) + | Ex (vs, phi) -> Ex (vs, aux base neg phi) + | All (vs, phi) -> All (vs, aux base neg phi) + | phi -> phi in + aux [] false (flatten_formula phi) + (* Compute size of a formula (currently w/o descending the real part). *) let rec size = function | Or js | And js -> List.fold_left (+) 1 (List.map size js) Modified: trunk/Toss/Formula/FormulaOps.mli =================================================================== --- trunk/Toss/Formula/FormulaOps.mli 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/Formula/FormulaOps.mli 2011-03-12 19:24:32 UTC (rev 1355) @@ -26,6 +26,10 @@ val map_to_literals_expr : (formula -> formula) -> (real_expr -> real_expr) -> real_expr -> real_expr +(** Map [f] to top-level formulas in the real expression ([Char]s and + [Sum] guards). *) +val map_to_formulas_expr : (formula -> formula) -> real_expr -> real_expr + (** Map [f] to all atoms in the given formula. *) val map_to_atoms_full : (formula -> formula) -> (real_expr -> real_expr) -> formula -> formula @@ -84,9 +88,15 @@ (** Flatten "and"s and "or"s in a formula -- i.e. associativity. *) val flatten_formula : formula -> formula -(** Formula as a list of conjuncts. *) +(** Formula as a list of conjuncts, with one level of distributing + negation over disjunction and pushing quantifiers inside. *) val flatten_ands : formula -> formula list +(** Remove literals from disjunctions in positive positions + (conjunctions in negative positions) that already occur conjoined + to the disjucntion. (Does not descend the real part currently.) *) +val remove_redundant : formula -> formula + (** Compute size of a formula (currently w/o descending the real part). *) val size : formula -> int Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/GGP/GDL.ml 2011-03-12 19:24:32 UTC (rev 1355) @@ -320,21 +320,17 @@ negated subformulas are "let free"). (7f4) Drop the erasure branches that contradict the "legal" - condition of their rule. + condition of their rule. (Add the "legal" condition for early pruning.) (7f5) Redistribute the erasure branches in case they were substituted with the "not distinct" unifier to proper equivalence classes (remove equivalence classes that become empty). - (7g) Instantiate remaining unfixed variables. Implementation TODO. + (7g) Instantiate remaining unfixed variables: Duplicate non-frame + rules with unfixed variables for each instantiation of the unfixed + variables warranted by the aggregate playout. (Perhaps can be done + "symbolically" to avoid explosion.) - (7g1) Duplicate non-frame rules with unfixed variables for each - instantiation of the unfixed variables warranted by the aggregate - playout. (Perhaps can be done "symbolically" to avoid explosion.) - - (7g2) Then, add instantiations of frame rules for each case their - head term unifies with one from all the non-frame rules. - (7h) Introduce a new element variable for each class of "next" and "true" terms equal modulo mask (i.e. there is a mask matching them and they differ only at-or-below metavariables). (Remember the @@ -544,8 +540,10 @@ (** Generate all tuples for equivalences, to faciliate further transformations of formulas in the game definition (outside of translation). *) -let equivalences_all_tuples = ref false +let equivalences_all_tuples = ref false (* true *) +open Aux.BasicOperators + type term = | Const of string | Var of string @@ -1502,7 +1500,7 @@ if more_state = [] then static_rels, state_rels else separate static (more_state @ state_rels) in let static_rels, state_rels = - separate (List.map (fun ((r,_),_,_)->r) rules) + separate (Aux.unique (=) (List.map (fun ((r,_),_,_)->r) rules)) ["init"; "does"; "true"; "next"; "terminal"; "goal"] in let static_rules, dynamic_rules = List.partition (fun ((rel,_),_,_) -> List.mem rel static_rels) rules in @@ -1707,32 +1705,7 @@ let translate_branches struc masks playout_terms static_rnames dyn_rels (brs : exp_def_branch list) = (* 7i *) - let pos_state_terms = - List.fold_left (fun acc -> function - | [next_arg], body, _ -> - let res = - List.fold_left (fun acc -> function - | "true", [true_arg] -> Terms.add true_arg acc - | "true", _ -> assert false - | _ -> acc) acc body in - if next_arg = Const "_IGNORE_RHS_" - then res - else Terms.add next_arg res - | _ -> assert false - ) Terms.empty brs in - let pos_state_terms = Terms.elements pos_state_terms in - (* {{{ log entry *) - if !debug_level > 2 then ( - Printf.printf "pos_state_terms: %s\n%!" - (String.concat ", " (List.map term_str pos_state_terms)) - ); - (* }}} *) - let pos_state_subterms = - Aux.concat_map (fun term -> - let mask, sb, m_sb, blanked = term_to_blank masks term in - List.map (fun (v,t) -> t, (mask, v, term)) sb - ) pos_state_terms in - let pos_conjs_4a (rel, args) = + let pos_conjs_4a pos_state_subterms (rel, args) = let ptups = List.map (fun arg -> Aux.assoc_all arg pos_state_subterms) args in (* {{{ log entry *) @@ -1760,7 +1733,8 @@ ); (* }}} *) res in - let neg_conjs_4a neg_state_terms neg_state_subterms (rel, args) = + let neg_conjs_4a pos_state_subterms + neg_state_terms neg_state_subterms (rel, args) = let ptups = List.map (fun arg -> Aux.assoc_all arg pos_state_subterms @ Aux.assoc_all arg neg_state_subterms) args in @@ -1785,18 +1759,9 @@ (* }}} *) res in (* 7i-4b *) - let pos_path_subterms = - Aux.concat_map (fun term -> - let mask, sb, m_sb, blanked = term_to_blank masks term in - Aux.map_some (function - | v, Var t -> - Some ((mask, v), (t, term)) - | _ -> None) sb - ) pos_state_terms in - let pos_path_subterms = Aux.collect pos_path_subterms in let constrained_vars = ref [] in - let pos_conjs_4b = - Aux.concat_map (fun ((mask, v), terms) -> + let pos_conjs_4b pos_path_subterms = + Aux.unique_sorted (Aux.concat_map (fun ((mask, v), terms) -> let rname = "EQ___" ^ term_to_name mask ^ "_" ^ v in let terms = Aux.collect terms in Aux.concat_map (fun (_,terms) -> @@ -1817,9 +1782,8 @@ | v::vs -> List.map (fun w -> [|v; w|]) vs in List.map (fun tup -> Formula.Rel (rname, tup)) tups ) terms - ) pos_path_subterms in - let pos_conjs_4b = Aux.unique_sorted pos_conjs_4b in - let neg_conjs_4b nterm = + ) pos_path_subterms) in + let neg_conjs_4b pos_path_subterms nterm = let nmask, nsb, _, _ = term_to_blank masks nterm in let _,ntossvar = toss_var masks nterm in Aux.concat_map (fun ((mask, v), terms) -> @@ -1839,25 +1803,65 @@ if !equivalences_all_tuples then Aux.concat_map - (fun v -> [[|v; ntossvar|]; [|ntossvar; v|]]) tossvars + (fun v -> + if v = ntossvar then [] + else [[|v; ntossvar|]; [|ntossvar; v|]]) tossvars else - List.map (fun v -> [|v; ntossvar|]) tossvars in + Aux.map_some (fun v -> + if v = ntossvar then None + else Some [|v; ntossvar|]) tossvars in List.map (fun tup -> Formula.Rel (rname, tup)) tups | _ -> [] ) pos_path_subterms in + (* calculate state terms twice: before and after filtering branches *) + let pos_state_terms = + List.fold_left (fun acc -> function + | [next_arg], body, _ -> + let res = + List.fold_left (fun acc -> function + | "true", [true_arg] -> Terms.add true_arg acc + | "true", _ -> assert false + | _ -> acc) acc body in + if next_arg = Const "_IGNORE_RHS_" + then res + else Terms.add next_arg res + | _ -> assert false + ) Terms.empty brs in + let pos_state_terms = Terms.elements pos_state_terms in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "pos_state_terms: %s\n%!" + (String.concat ", " (List.map term_str pos_state_terms)) + ); + (* }}} *) + let pos_state_subterms = + Aux.concat_map (fun term -> + let mask, sb, m_sb, blanked = term_to_blank masks term in + List.map (fun (v,t) -> t, (mask, v, term)) sb + ) pos_state_terms in + let pos_path_subterms = + Aux.concat_map (fun term -> + let mask, sb, m_sb, blanked = term_to_blank masks term in + Aux.map_some (function + | v, Var t -> + Some ((mask, v), (t, term)) + | _ -> None) sb + ) pos_state_terms in + let pos_path_subterms = Aux.collect pos_path_subterms in + (* only compute the static part to filter-out inconsistent branches *) + let pconjs_4b = pos_conjs_4b pos_path_subterms in let brs = Aux.map_some (function - | [next_arg],body,neg_body -> - let phi, lvars = - if next_arg = Const "_IGNORE_RHS_" then [], ref [] + | [next_arg],body,neg_body as br -> + let phi = + if next_arg = Const "_IGNORE_RHS_" then [] else let mask, sb, m_sb, blanked = term_to_blank masks next_arg in let rname = term_to_name mask in let _, svar = toss_var masks next_arg in - if List.mem svar !constrained_vars then [], ref [] + if List.mem svar !constrained_vars then [] else let phi = Formula.Rel (rname, [|svar|]) in - let lvars = ref [svar] in - [phi], lvars in + [phi] in let conjs = Aux.concat_map (fun (rel, args as fact) -> if rel = "true" then @@ -1866,7 +1870,6 @@ let mask, sb, m_sb, blanked = term_to_blank masks true_arg in let rname = term_to_name mask in let _, svar = toss_var masks true_arg in - lvars := svar :: !lvars; let phi = Formula.Rel (rname, [|svar|]) in let conjs = Aux.map_some (function @@ -1878,12 +1881,12 @@ then conjs else [phi] else if List.mem rel static_rnames then (* 7i-4a *) - pos_conjs_4a fact + pos_conjs_4a pos_state_subterms fact else [] ) body in - (* only to prune early -- we cannot get more than negated - relations for positive elements, because stuff related to - negative elements is under common negations/disjunctions *) + (* to prune early, we cannot get more than negated relations for + positive elements, because stuff related to negative elements + is under common negations/disjunctions *) let neg_conjs = Aux.concat_map (function | _, [rel, args as fact] -> @@ -1892,7 +1895,8 @@ then [] else if List.mem rel static_rnames then (* 7i-4a *) - List.map (fun c -> Formula.Not c) (pos_conjs_4a fact) + List.map (fun c -> Formula.Not c) + (pos_conjs_4a pos_state_subterms fact) else if rel = "distinct" then (* 7i0 *) if Aux.not_unique args then [Formula.Or []] @@ -1903,42 +1907,137 @@ "translate_game: (7i) unexpected dynamic %s\n%!" rel; assert false) | _ -> []) neg_body in - let all_conjs = phi @ conjs @ neg_conjs in + let all_conjs = phi @ conjs @ pconjs_4b @ neg_conjs in let phi = Formula.And all_conjs in - let lvars = (!lvars :> Formula.var list) in - let optim_conjs = List.filter (fun c-> - List.for_all (fun v->List.mem v lvars) - (FormulaOps.free_vars c)) (pos_conjs_4b @ all_conjs) in - let rphi = Formula.And optim_conjs in + let phi = Formula.Ex (FormulaOps.free_vars phi, phi) in (* {{{ log entry *) - if !debug_level > 4 then ( - Printf.printf "evaluating: %s\n%!" + if !debug_level > 3 then ( + Printf.printf "evaluating:\nbranch=%s\nphi=%s\n%!" + (exp_def_str ("eval", [br])) (Formula.str phi) ); - (* }}} *) - if Solver.M.check struc rphi + (* }}} *) + if Solver.M.check struc phi then ( (* {{{ log entry *) - if !debug_level > 4 then ( + if !debug_level > 3 then ( Printf.printf "holds\n%!" ); - (* }}} *) - Some (all_conjs, (next_arg,body,neg_body))) + (* }}} *) + Some (next_arg,body,neg_body)) else None | _ -> assert false) brs in (* 7j *) let check_brs = expand_branch_vars masks playout_terms ~freshen_unfixed:(Aux.Left false) - (List.map (fun (_,(head,body,neg_body))-> + (List.map (fun (head,body,neg_body)-> [head], body, neg_body) brs) in if List.exists (fun (sb,_)-> sb <> []) check_brs then failwith ("GDL.translate_game: expanding variables resulting in "^ "duplicating Toss rules not implemented yet"); - (* 7k *) + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "Filtered-branches:\n%s\n%!" + (exp_def_str ("filtered", + List.map (fun (next_arg,body,neg_body) -> + [next_arg], body, neg_body) brs)); + ); + (* }}} *) + + (* 7i and 7k *) + let pos_state_terms = + List.fold_left (fun acc -> function + | (next_arg, body, _) -> + let res = + List.fold_left (fun acc -> function + | "true", [true_arg] -> Terms.add true_arg acc + | "true", _ -> assert false + | _ -> acc) acc body in + if next_arg = Const "_IGNORE_RHS_" + then res + else Terms.add next_arg res + ) Terms.empty brs in + let pos_state_terms = Terms.elements pos_state_terms in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "pos_state_terms: %s\n%!" + (String.concat ", " (List.map term_str pos_state_terms)) + ); + (* }}} *) + let pos_state_subterms = + Aux.concat_map (fun term -> + let mask, sb, m_sb, blanked = term_to_blank masks term in + List.map (fun (v,t) -> t, (mask, v, term)) sb + ) pos_state_terms in + let pos_path_subterms = + Aux.concat_map (fun term -> + let mask, sb, m_sb, blanked = term_to_blank masks term in + Aux.map_some (function + | v, Var t -> + Some ((mask, v), (t, term)) + | _ -> None) sb + ) pos_state_terms in + let pos_path_subterms = Aux.collect pos_path_subterms in + let pconjs_4b = pos_conjs_4b pos_path_subterms in let brs = - List.map (fun (static_conjs, (next_arg,body,neg_body)) -> + List.map (fun (next_arg,body,neg_body) -> + let phi = + if next_arg = Const "_IGNORE_RHS_" then [] + else + let mask, sb, m_sb, blanked = term_to_blank masks next_arg in + let rname = term_to_name mask in + let _, svar = toss_var masks next_arg in + if List.mem svar !constrained_vars then [] + else + let phi = Formula.Rel (rname, [|svar|]) in + [phi] in + let conjs = + Aux.concat_map (fun (rel, args as fact) -> + if rel = "true" then + (* 7i-4c *) + let true_arg = List.hd args in + let mask, sb, m_sb, blanked = term_to_blank masks true_arg in + let rname = term_to_name mask in + let _, svar = toss_var masks true_arg in + let phi = Formula.Rel (rname, [|svar|]) in + let conjs = + Aux.map_some (function + | _, Var _ -> None + | v, t as v_sb -> + let rname = term_to_name (subst_one v_sb mask) in + Some (Formula.Rel (rname, [|svar|]))) sb in + if conjs <> [] || List.mem svar !constrained_vars + then conjs else [phi] + else if List.mem rel static_rnames then + (* 7i-4a *) + pos_conjs_4a pos_state_subterms fact + else [] + ) body in + (* to prune early, we cannot get more than negated relations for + positive elements, because stuff related to negative elements + is under common negations/disjunctions *) + let neg_conjs = + Aux.concat_map (function + | _, [rel, args as fact] -> + if rel = "true" then [] + else if rel = "_DOES_PLACEHOLDER_" + then [] + else if List.mem rel static_rnames then + (* 7i-4a *) + List.map (fun c -> Formula.Not c) + (pos_conjs_4a pos_state_subterms fact) + else if rel = "distinct" then + (* 7i0 *) + if Aux.not_unique args then [Formula.Or []] + else [] + else ( + (* dynamic relations have been expanded *) + Printf.printf + "translate_game: (7i) unexpected dynamic %s\n%!" rel; + assert false) + | _ -> []) neg_body in let rhs_pos_preds = if next_arg = Const "_IGNORE_RHS_" then [] else @@ -1952,7 +2051,7 @@ let rname = term_to_name (subst_one v_sb mask) in Some (rname, [|rhs_elem|]) ) m_sb in - let static_conjs = ref static_conjs in + let static_conjs = ref (phi @ conjs @ neg_conjs) in let dyn_conjs = Aux.concat_map (fun (rel, args) -> if rel = "true" then @@ -1961,6 +2060,7 @@ let _, svar = toss_var masks true_arg in let mask_rname = term_to_name mask in let mask_phi = Formula.Rel (mask_rname, [|svar|]) in + (* the mask formula would be redundant *) static_conjs := Aux.list_remove mask_phi !static_conjs; Aux.map_some (fun (v,t as v_sb) -> if t = Const "_BLANK_" then @@ -2005,7 +2105,8 @@ Aux.concat_map (fun (rel,_ as fact) -> if rel <> "true" && List.mem rel static_rnames - then neg_conjs_4a neg_state_terms neg_state_subterms fact + then neg_conjs_4a pos_state_subterms + neg_state_terms neg_state_subterms fact else []) body in (* 7k-4b *) let neg_path_subterms = @@ -2033,14 +2134,16 @@ if v=w then None else Some [|v; w|]) vars) vars else match vars with [] -> [] - | v::vs -> List.map (fun w -> [|v; w|]) vs in + | v::vs -> Aux.map_some (fun w -> + if v=w then None else Some [|v; w|]) vs in List.map (fun tup -> Formula.Rel (rname, tup)) tups ) terms ) neg_path_subterms in let negonly_conjs_4b = Aux.unique_sorted negonly_conjs_4b in (* the mixed part *) let mixed_conjs_4b = - Aux.concat_map neg_conjs_4b neg_state_terml in + Aux.concat_map (neg_conjs_4b pos_path_subterms) + neg_state_terml in let nconjs_4b = negonly_conjs_4b @ mixed_conjs_4b in let disjs = Aux.concat_map (fun (rel, args as fact) -> @@ -2056,7 +2159,8 @@ | v, t as v_sb -> let rname = term_to_name (subst_one v_sb mask) in Some (Formula.Rel (rname, [|svar|]))) sb in - let conjs_4b = neg_conjs_4b true_arg in + let conjs_4b = + neg_conjs_4b pos_path_subterms true_arg in let conjs_5 = List.map (fun (v,t as v_sb) -> if t = Const "_BLANK_" then @@ -2073,14 +2177,15 @@ else if List.mem rel static_rnames then (* 7i-4a-2-3 *) let conjs_4a_2 = - match pos_conjs_4a fact with + match pos_conjs_4a pos_state_subterms fact with | [] -> [] | [rel_conseq] -> [rel_conseq] | rel_conseqs -> (* negation turns it into a conjunction *) [Formula.Or rel_conseqs] in let conjs_4a_3 = - neg_conjs_4a neg_state_terms neg_state_subterms fact in + neg_conjs_4a pos_state_subterms + neg_state_terms neg_state_subterms fact in conjs_4a_2 @ conjs_4a_3 else if rel = "distinct" then (* 7i0 *) @@ -2105,7 +2210,7 @@ let all_conjs = !static_conjs @ dyn_conjs @ neg_conjs in (rhs_pos_preds, !static_conjs, all_conjs), (next_arg, body, neg_body)) brs in - pos_conjs_4b, brs + pconjs_4b, brs let translate_game player_term game_descr = @@ -2355,8 +2460,8 @@ | mask, (sb,_)::_ -> List.map (fun (v,_)->mask, v) sb) elements in (* 4a *) let static_rels = - List.map (fun (rname,args) -> - rname, List.map (fun _ -> ()) args) static_rules in + Aux.unique_sorted (List.map (fun (rname,args) -> + rname, List.map (fun _ -> ()) args) static_rules) in let static_rels = List.map (fun (rel,args) -> rel, List.length args, @@ -2678,6 +2783,9 @@ let rules_brs = List.map (fun ((lead_head, lead_body, lead_neg_body), branches) -> + let lead_does = + "_DOES_PLACEHOLDER_", [loc_players.(loc); lead_head] in + let lead_body = lead_does::lead_body in let fixed_vars = term_vars lead_head in let fixed_brs, other_brs = List.partition (function @@ -2698,7 +2806,7 @@ ) frame_brs in let unfixed_brs = to_expand @ more_to_expand in - (* 7g1 *) + (* 7g *) let expanded_brs = expand_branch_vars masks element_terms ~freshen_unfixed:(Aux.Right (Aux.Strings.elements fixed_vars)) @@ -2726,7 +2834,7 @@ | _ -> assert false) l)) frames)) ); (* }}} *) - (* collect and rename multi-bodies *) + (* collect and rename multi-bodies, i.e. form disjunctions *) let frames = List.map (function | [] -> assert false | [head, body, neg_body] -> head, [body, neg_body] @@ -2754,7 +2862,7 @@ (* 7f3 *) (* TODO: minimize the number of branches by keeping negations over conjunctions like in (6b1) *) - let erasure_brs : lit_def_branch list = Aux.concat_map + let erasure_brs = Aux.concat_map (function | [next_arg] as next_args,multi_body -> let mask, _, _, blank_arg = term_to_blank masks next_arg in @@ -2824,7 +2932,7 @@ (subst_rels sb neg_body) in let head = subst sb blank_arg in if - (* TODO: (7g) instead *) + (* TODO: what about expanding as in (7g)? *) Aux.Strings.subset (term_vars head) fixed_vars && (* (7f4) *) @@ -2833,9 +2941,27 @@ List.mem pos neg_conjs) lead_neg_body ) body) && not (List.exists (fun (_,neg) -> - List.mem neg lead_body + List.mem neg lead_body ) neg_body) - then Some ([head], body, neg_body) + then ( + (* {{{ log entry *) + if !debug_level > 4 then ( + Printf.printf "erasure:\n%s\n%s\n%!" + (lit_def_str ("erasure", [ + [head], body, neg_body])) + (exp_def_str ("lead", [ + [lead_head], lead_body, lead_neg_body])) + ); + (* }}} *) + let neg_body = + List.map (fun (vs,lit)->vs,[lit]) + neg_body in + (* we could add "pruning" conditions:*) + Some ([head], lead_body @ body, + lead_neg_body @ neg_body) + (*or not + Some ([head], body, neg_body)*) + ) else None with Not_found -> None) erasures in let erasures = Aux.unique_sorted @@ -2843,13 +2969,12 @@ head, Aux.unique_sorted body, Aux.unique_sorted neg_body) erasures) in erasures - (* TODO: (7g2) *) | _ -> assert false) frames in (* TODO: (7f5) we ignore the possibility that "lead" is instantiated by some of erasure substitutions, since we already ignore non-maximal "legal" classes *) - lead_head, fixed_brs @ expanded_brs @ - exp_brs_of_lit_brs erasure_brs + let nonframe_brs = fixed_brs @ expanded_brs in + lead_head, nonframe_brs @ erasure_brs ) rules_brs in (* let rules_inds = Array.of_list rules_brs in *) rules_brs @@ -2912,7 +3037,7 @@ let body = List.filter ( function "_DOES_PLACEHOLDER_",_ -> false | _ -> true) body in lead, (head, body, neg_body)) brs in - let table = List.map (fun atom -> + let table = Aux.map_some (fun atom -> let positives = Array.mapi (fun i (_,(_,body,_)) -> if List.mem atom body then Some i else None) brs in let positives = Aux.map_some (fun x->x) @@ -2932,9 +3057,15 @@ (String.concat ", "(List.map string_of_int negatives)) ); (* }}} *) + (* since artificial branches were introduced for all atoms, + if some case isn't specifically selected for, it means + that the corresponding literal is not satisfiable *) + if negatives = [] || positives = [] + then None + else (* first those that allow "P" then those that allow "not P" *) - [Aux.Ints.diff full_set (Aux.ints_of_list negatives); - Aux.Ints.diff full_set (Aux.ints_of_list positives)] + Some [Aux.Ints.diff full_set (Aux.ints_of_list negatives); + Aux.Ints.diff full_set (Aux.ints_of_list positives)] ) atoms in let cases = Aux.product table in let cases = @@ -2957,7 +3088,6 @@ Aux.array_existsi (fun ply states -> if ply mod loc_n = loc then ( (* {{{ log entry *) - if !debug_level > 4 then ( let posi = Aux.map_some (function @@ -2967,7 +3097,6 @@ "Checking branch at states:\n%s\npositives:\n%s\n" (terms_str states) (terms_str posi) ); - (* }}} *) let res = List.for_all (function @@ -3018,11 +3147,11 @@ Aux.unique_sorted rhs_pos, static_phis, phis)) cases in let cases = - Aux.map_some ( - fun (var_elems,struc_elems,rhs_pos,static_phis,phis) -> - let rphi = Formula.And static_phis in + Aux.map_some ( + fun (var_elems,struc_elems,rhs_pos,static_phis,phis) -> + let rphi = Formula.And static_phis in (* {{{ log entry *) - if !debug_level > 4 then ( + if !debug_level > 4 then ( (* do not print, because it generates too many answers -- too little constraints per number of variables when considering a single branch *) @@ -3033,21 +3162,21 @@ let atups = AssignmentSet.tuples struc.Structure.elements avars assgn in *) - Printf.printf "evaluating: %s\n%!" - (Formula.str rphi) + Printf.printf "evaluating: %s\n%!" + (Formula.str rphi) (* (List.length atups) *) - ); + ); (* }}} *) - let res = Solver.M.check struc rphi in + let res = Solver.M.check struc rphi in (* {{{ log entry *) - if !debug_level > 4 && res then ( - Printf.printf "holds\n%!" - ); + if !debug_level > 4 && res then ( + Printf.printf "holds\n%!" + ); (* }}} *) - if res then - let precond = Formula.And phis in - Some (var_elems, struc_elems, rhs_pos, precond) - else None) cases in + if res then + let precond = Formula.And phis in + Some (var_elems, struc_elems, rhs_pos, precond) + else None) cases in List.map (fun (var_elems, struc_elems, rhs_pos, precond) -> lead, (var_elems, struc_elems, rhs_pos, precond)) cases ) rules_brs @@ -3134,11 +3263,10 @@ ) goals in (* 8c *) let sized = - List.map (fun (score,phi) -> FormulaOps.size phi, score) payoff in - let cmp (s1,v1) (s2,v2) = - if s2-s1 = 0 then Pervasives.compare v1 v2 else s2-s1 in + List.map (fun (score,phi) -> GameSimpl.niceness phi, score) payoff in + (* Sort in increasing niceness. *) let base_score = - match List.sort cmp sized with [] -> 0. + match List.sort Pervasives.compare sized with [] -> 0. | (_, score)::_ -> score in let payoff = match payoff with | [score, guard] -> @@ -3155,8 +3283,11 @@ ); (* }}} *) sum) - else Formula.Plus (sum, Formula.Times ( - Formula.Const (score -. base_score), Formula.Char guard))) + else + let guarded = Formula.Times ( + Formula.Const (score -. base_score), Formula.Char guard) in + if sum = Formula.Const 0. then guarded + else Formula.Plus (sum, guarded)) (Formula.Const base_score) scores in player, payoff ) player_goals in @@ -3251,9 +3382,11 @@ rname ); (* }}} *) + let signat rel = + Structure.StringMap.find rel struc.Structure.rel_signature in let discrete = DiscreteRule.translate_from_precond ~precond - ~add:rhs_pos ~embed:fluents ~struc_elems in + ~add:rhs_pos ~emb_rels:fluents ~signat ~struc_elems in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "Making rule %s of:\n%s\n%!" rname @@ -3297,6 +3430,18 @@ time = 0.; cur_loc = 0; } in + (* {{{ log entry *) + (* * + let file = open_out "./GGP/tests/connect5-raw.toss" in + output_string file (Arena.state_str result); + close_out file; + * *) + if !debug_level > 1 then ( + Printf.printf "\n\nGDL.translate_game: before simplification --\n%s\n%!" + (Arena.sprint_state result) + ); + (* }}} *) + let result = GameSimpl.simplify result in let playing_as = find_player player_term in let noop_actions = Array.mapi (fun loc noops-> @@ -3305,9 +3450,14 @@ | Some ([_; lead_term], _, _) -> Some lead_term | _ -> None ) loc_noop_legal in - (* {{{ log entry *) + (* {{{ log entry *) + (* * + let file = open_out "./GGP/tests/connect5-simpl.toss" in + output_string file (Arena.state_str result); + close_out file; + * *) if !debug_level > 1 then ( - Printf.printf "\n\nGDL.translate_game:\n%s\n%!" + Printf.printf "\n\nGDL.translate_game: after simplification --\n%s\n%!" (Arena.sprint_state result) ); (* }}} *) @@ -3400,9 +3550,11 @@ (Formula.sprint precond) ); (* }}} *) + let signat rel = + Structure.StringMap.find rel struc.Structure.rel_signature in let rule = DiscreteRule.translate_from_precond ~precond ~add - ~embed:gdl.fluents ~struc_elems in + ~emb_rels:gdl.fluents ~signat ~struc_elems in let lhs_struc = rule.DiscreteRule.lhs_struc in let rule = DiscreteRule.compile_rule (Structure.rel_signature struc) [] rule in Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-03-12 17:51:51 UTC (rev 1354) +++ trunk/Toss/GGP/GDLTest.ml 2011-03-12 19:24:32 UTC (rev 1355) @@ -75,22 +75,40 @@ (String.concat "\n" (List.map GDL.exp_def_str res)); ); +] +let bigtests = "GDLBig" >::: [ + "connect5" >:: (fun () -> - todo "soon"; - (* GDL.debug_level := 3; *) let connect5 = load_rules "./GGP/examples/connect5.gdl" in - let gtransl, gdef = GDL.translate_game (Const "x") connect5 in - ignore (gtransl, gdef) + let _, res = GDL.translate_game (Const "x") connect5 in + let goalf = open_in "./GGP/tests/connect5-simpl.toss" in + let resf = open_out "./GGP/tests/connect5-temp.toss" in + let goal_str = Aux.input_file goalf in + let res_str = Arena.state_str res in + output_string resf res_str; + close_in goalf; close_out resf; + assert_equal + ~msg:"GGP/examples/connect5.gdl to GGP/tests/connect5-simpl.toss, see GGP/tests/connect5-temp.toss" + goal_str res_str; + Sys.remove "./GGP/tests/connect5-temp.toss" ); "breakthrough" >:: (fun () -> - todo "soon"; let breakthrough = load_rules "./GGP/examples/breakthrough.gdl" in - let gdef = GDL.translate_game (Const "white") breakthrough in - ignore gdef; + let _, res = GDL.translate_game (Const "white") breakthrough in + let goalf = open_in "./GGP/tests/breakthrough-simpl.toss" in + let resf = open_out "./GGP/tests/breakthrough-temp.toss" in + let goal_str = Aux.input_file goalf in + let res_str = Arena.state_str res in + output_string resf res_str; + close_in goalf; close_out resf; + assert_equal + ~msg:"GGP/examples/breakthrough.gdl to GGP/tests/breakthrough-simpl.toss, see GGP/tests/breakthrough-temp.toss" + goal_str res_str; + Sys.remove "./GGP/tests/breakthrough-temp.toss" ); @@ -100,6 +118,9 @@ let a = Aux.run_test_if_target "GDLTest" tests +let a = + Aux.run_test_if_target "GDLTest" bigtests + let a () = match test_filter ["GDL:2:masks"] @@ -110,9 +131,10 @@ let a () = GDL.debug_level := 4; + GameSimpl.debug_level := 4; DiscreteRule.debug_level := 4; let breakthrough = load_rules "./GGP/examples/breakthrough.gdl" in let connect5 = load_rules "./GGP/examples/connect5.gdl" in let tictactoe = load_rules "./GGP/examples/tictactoe.gdl" in - let gdef = GDL.translate_game (Const "x") connect5 in - ignore gdef; ignore connect5; ignore breakthrough; ignore tictactoe + let gdl_def, toss_def = GDL.translate_game (Const "x") connect5 in + ignore gdl_def; ignore connect5; ignore breakthrough; ignore tictactoe Added: trunk/Toss/GGP/GameSimpl.ml =================================================================== --- trunk/Toss/GGP/GameSimpl.ml (rev 0) +++ trunk/Toss/GGP/GameSimpl.ml 2011-03-12 19:24:32 UTC (rev 1355) @@ -0,0 +1,292 @@ +(** {2 Simplification of Toss Games.} + + Whole-game simplifications and helper functions that consider both + a structure and a formula. + + The simplification of structures, associated formulas and Toss + rules is specified by transformations described below. Rules can + be refined or new rules added to each stage. + + (1) Identify relations in the structure that are not fluents nor + defined relations and that are equal to or are complements of + other relations in the structure. Select a single relation / a + predicate (called "the original" below), that is smaller than its + complement (if the complement is in the signature), and replace + all selected relations with it (or its negation), in all formulas + of the definition. Remove the other relations from the structure. + + (1a) We need to update LHS structures of rules (for presentation + and game modification purposes, since the simple transformation + above of the "embedding formula" suffices for the "compiled" rule + representation). Replace the identified relations in the "embedded + set" with their originals, and add to the embedded set relations + that occur positively in the LHS and are complements of their + original. Derive all the tuples of embedded relations that are + required to be absent for a match (not present, even optionally, + in the LHS). Remove the non-optional tuples for relations that are + complements of their originals and add tuples of originals that + are complements of relations that are required to be + absent. Rename relations equivalent to their originals. + + (2) Locate relations that subsume, or are subsumed by others (in + terms of inclusion relations between their graphs). Simplify + conjunctions and disjunctions of literals by removing literals + that are weaker/stronger than another present over the same tuple + in the given conjunction/disjunction. + + (3) For each pair of static unary predicates with nonempty + intersection, introduce new predicate for their conjunction. For + each pair of static binary predicates, introduce two new + predicates: one for their conjunction and the other for + conjunction of one of the predicates and the inverse of the other. + + (3a) Replace each conjunction of pair of unary/binary predicates + over the same variables, with one of introduced predicates. For + several possibilities of replacement pick one arbitrarily + (currently, in the order of occurrence in the formula). +*) + +open Formula +open Aux.BasicOperators + +let debug_level = ref 0 + + + +(* Collect universally quantified subformulas and compute the size of + the "existential" trunk (counting only atomic formulas). *) +let separate_univ phi = + let rec aux neg = function + | Or js | And js -> + List.fold_left (fun (a,b) (c,d) -> a+c,b@d) (0,[]) + (List.map (aux neg) js) + | All (_, phi) -> + if neg then aux neg phi + else 0, [phi] + | Ex (_, phi) -> + if not neg then aux neg phi + else 0, [phi] + | Not phi -> aux (not neg) phi + | Rel _ | Eq _ | In _ | RealExpr _ -> 1, [] in + aux false phi + + +(* A heuristic measure of how easy a formula is to solve or provide a + good heuristic. Very crude for now, not using the structure yet. *) +let niceness phi = + let trunk, univs = separate_univ phi in + trunk - List.fold_left (+) 0 (List.map FormulaOps.size univs) + + +let simplify ?(join_rel_names=fun x _ -> x) (game, state) = + let struc = state.Arena.struc in + let signat = Structure.rel_signature struc in + let nelems = Structure.Elems.cardinal struc.Structure.elements in + let tcard tups = Structure.Tuples.cardinal tups in + let fluents = + Aux.unique_sorted + (Aux.concat_map (fun (_,r) -> + DiscreteRule.fluents r.ContinuousRule.compiled) + game.Arena.rules) in + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "GameSimpl: fluents = %s\n%!" + (String.concat ", " fluents) + ); + (* }}} *) + (* prepare for (3) and (1) *) + let subset_table = + List.fold_left (fun table (rel,arity) -> + let rel_tups = + Structure.StringMap.find rel struc.Structure.relations in + let row = + List.fold_left (fun row (rel2,arity2) -> + if arity2 = arity && + Structure.Tuples.subset rel_tups + (Structure.StringMap.find rel2 struc.Structure.relations) + then Aux.Strings.add rel2 row + else row + ) Aux.Str... [truncated message content] |
From: <luk...@us...> - 2011-03-13 00:10:01
|
Revision: 1356 http://toss.svn.sourceforge.net/toss/?rev=1356&view=rev Author: lukaszkaiser Date: 2011-03-13 00:09:53 +0000 (Sun, 13 Mar 2011) Log Message: ----------- Corrections to web sites, rename rules in pawn whopping. Modified Paths: -------------- trunk/Toss/Arena/Arena.mli trunk/Toss/GGP/GDL.ml trunk/Toss/Play/Heuristic.ml trunk/Toss/Server/Server.ml trunk/Toss/WebClient/Handler.py trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/Style.css trunk/Toss/WebClient/Wrapper.py trunk/Toss/WebClient/contact.html trunk/Toss/examples/Pawn-Whopping.toss trunk/Toss/www/contact.xml trunk/Toss/www/create.xml trunk/Toss/www/docs.xml trunk/Toss/www/ideas.xml trunk/Toss/www/index.xml Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/Arena/Arena.mli 2011-03-13 00:09:53 UTC (rev 1356) @@ -110,8 +110,9 @@ val map_to_formulas : (Formula.formula -> Formula.formula) -> game -> game -(** ------------------ REQUESTS TO THE ARENA USED IN OPERATION --------------- *) +(** {2 Requests to the Arena used in Operation} *) + (** Location of a structure: either arena or left or right-hand side of a rule *) type struct_loc = Struct | Left of string | Right of string Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/GGP/GDL.ml 2011-03-13 00:09:53 UTC (rev 1356) @@ -3713,7 +3713,6 @@ game_description := game_descr; let pterms = [|Const "WHITE"; Const "RED"|] in let noops = [|Some (Const "NOOP"); Some (Const "NOOP")|] in - Heuristic.use_monotonic := false; let (* effort, horizon, heur_adv_ratio *) params = 10, 100, 4.0 in pterms, noops, state, Some params @@ -3849,36 +3848,36 @@ match actions with | [Func ("MOVE", [Const x1; Const y1; Const x2; Const y2]); Const "NOOP"] when x1 = x2 && (s2i y2) - (s2i y1) = 1 -> - "WhiteStraight", + "WhiteMove", ["a1", Structure.board_coords_name (s2i x1, s2i y1); "a2", Structure.board_coords_name (s2i x2, s2i y2)] | [Func ("MOVE", [Const x1; Const y1; Const x2; Const y2]); Const "NOOP"] when x1 = x2 && (s2i y2) - (s2i y1) = 2 -> - "WhiteStraightTwo", + "WhiteMoveTwo", ["a1", Structure.board_coords_name (s2i x1, s2i y1); "a2", Structure.board_coords_name (s2i x1, (s2i y1) + 1); "a3", Structure.board_coords_name (s2i x2, s2i y2)] | [Func ("CAPTURE", [Const x1; Const y1; Const x2; Const y2]); Const "NOOP"] -> - "WhiteDiag", + "WhiteBeat", ["a", Structure.board_coords_name (s2i x1, s2i y1); "b", Structure.board_coords_name (s2i x2, s2i y2)] | [Const "NOOP"; Func ("MOVE", [Const x1; Const y1; Const x2; Const y2])] when x1 = x2 && (s2i y1) - (s2i y2) = 1 -> - "BlackStraight", + "BlackMove", ["a2", Structure.board_coords_name (s2i x1, s2i y1); "a1", Structure.board_coords_name (s2i x2, s2i y2)] | [Const "NOOP"; Func ("MOVE", [Const x1; Const y1; Const x2; Const y2])] when x1 = x2 && (s2i y1) - (s2i y2) = 2 -> - "BlackStraightTwo", + "BlackMoveTwo", ["a3", Structure.board_coords_name (s2i x1, s2i y1); "a2", Structure.board_coords_name (s2i x1, (s2i y1) - 1); "a1", Structure.board_coords_name (s2i x2, s2i y2)] | [Const "NOOP"; Func ("CAPTURE", [Const x1; Const y1; Const x2; Const y2])] -> - "BlackDiag", + "BlackBeat", ["a", Structure.board_coords_name (s2i x1, s2i y1); "b", Structure.board_coords_name (s2i x2, s2i y2)] | _ -> assert false Modified: trunk/Toss/Play/Heuristic.ml =================================================================== --- trunk/Toss/Play/Heuristic.ml 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/Play/Heuristic.ml 2011-03-13 00:09:53 UTC (rev 1356) @@ -959,7 +959,10 @@ List.map (fun r -> (snd r).ContinuousRule.compiled) rules in let fluents = Aux.concat_map DiscreteRule.fluents drules in let frels = Aux.strings_of_list fluents in - let monotonic = !use_monotonic && + let free_pre r = + let pre = (snd r).ContinuousRule.discrete.DiscreteRule.pre in + FormulaOps.free_vars pre = [] in + let monotonic = !use_monotonic && List.for_all free_pre rules && List.for_all DiscreteRule.monotonic drules in let advr = match advr with Some r -> r | None -> Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/Server/Server.ml 2011-03-13 00:09:53 UTC (rev 1356) @@ -205,9 +205,10 @@ let heur = match !game_modified, !g_heur with | false, Some h -> h | true, _ | _, None -> + let adr = match advr with Some a -> a | None -> 4. in g_heur := Some (Heuristic.default_heuristic ~struc:(snd !state).Arena.struc - ~advr:4. (fst !state)); + ~advr:adr (fst !state)); Aux.unsome !g_heur in let (move, _) = Play.maximax_unfold_choose effort (fst !state) (snd !state) heur in Modified: trunk/Toss/WebClient/Handler.py =================================================================== --- trunk/Toss/WebClient/Handler.py 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/WebClient/Handler.py 2011-03-13 00:09:53 UTC (rev 1356) @@ -256,9 +256,9 @@ client.set_cur_loc (loc) #depth = client.get_data ("depth") #if depth == "none": depth = 2 - #adv_ratio = client.get_data ("adv_ratio") - #if adv_ratio == "none": adv_ratio = 2 - return (client.suggest (offset)) + adv_ratio = client.get_data ("adv_ratio") + if adv_ratio == "none": adv_ratio = 4 + return (client.suggest (offset, adv_ratio)) def suggest (db, client, g, p1, p2, pid, m): return (suggest_offset (5, db, client, g, p1, p2, pid, m)) Modified: trunk/Toss/WebClient/Main.js =================================================================== --- trunk/Toss/WebClient/Main.js 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/WebClient/Main.js 2011-03-13 00:09:53 UTC (rev 1356) @@ -55,6 +55,16 @@ svg_e.parentNode.removeChild (svg_e); } +// Substitute players for 0 and 1 in a payoff string. +function subst_pl (s) { + var s1 = s.replace (/0:/g, disp_name(PLAYS[CUR_PLAY_I][0]) + ":"); + var s2 = s1.replace (/1:/g, disp_name(PLAYS[CUR_PLAY_I][1]) + ":"); + var s3 = s2.replace (/1.,/g, "1,"); + var s4 = s3.replace (/0.,/g, "0,"); + var s5 = s4.replace (/1.$/g, "1"); + return (s5.replace (/0.$/g, "0")); +} + // Full redraw. function full_redraw () { clear_svg (); @@ -67,7 +77,7 @@ document.getElementById('cur-move').innerHTML = "none"; } else { document.getElementById('movebt').innerHTML = "Payoffs:"; - document.getElementById('cur-move').innerHTML = PAYOFF_STR; + document.getElementById('cur-move').innerHTML = subst_pl(PAYOFF_STR); } document.getElementById("working").style.display = "none"; } Modified: trunk/Toss/WebClient/Style.css =================================================================== --- trunk/Toss/WebClient/Style.css 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/WebClient/Style.css 2011-03-13 00:09:53 UTC (rev 1356) @@ -712,7 +712,8 @@ stroke-width: 3px; } -.chessW .chess-path-A { +.Game-Chess .chessW .chess-path-A, .Game-Pawn-Whopping .chessW .chess-path-A, + .Game-Checkers .chessB .chess-path-A { opacity: 1; fill: #fff1d4; fill-opacity: 1; @@ -727,7 +728,8 @@ stroke-opacity: 1; } -.chessB .chess-path-A { +.Game-Chess .chessB .chess-path-A, .Game-Pawn-Whopping .chessB .chess-path-A, + .Game-Checkers .chessW .chess-path-A { opacity: 1; fill: #400827; fill-opacity: 1; @@ -742,7 +744,8 @@ stroke-opacity: 1; } -.chessW .chess-path-B { +.Game-Chess .chessW .chess-path-B, .Game-Pawn-Whopping .chessW .chess-path-B, + .Game-Checkers .chessB .chess-path-B { opacity: 1; fill: #fff1d4; fill-opacity: 1; @@ -756,7 +759,8 @@ stroke-opacity: 1; } -.chessB .chess-path-B { +.Game-Chess .chessB .chess-path-B, .Game-Pawn-Whopping .chessB .chess-path-B, + .Game-Checkers .chessW .chess-path-B { opacity: 1; fill: #400827; fill-opacity: 1; @@ -770,7 +774,9 @@ stroke-opacity: 1; } -.chessW .chess-path-Bx { + +.Game-Chess .chessW .chess-path-Bx, .Game-Pawn-Whopping .chessW .chess-path-Bx, + .Game-Checkers .chessB .chess-path-Bx { opacity: 1; fill: #fff1d4; fill-opacity: 1; @@ -784,7 +790,8 @@ stroke-opacity: 1; } -.chessB .chess-path-Bx { +.Game-Chess .chessB .chess-path-Bx, .Game-Pawn-Whopping .chessB .chess-path-Bx, + .Game-Checkers .chessW .chess-path-Bx { opacity: 1; fill: #fff1d4; fill-opacity: 1; @@ -798,7 +805,8 @@ stroke-opacity: 1; } -.chessW .chess-path-C { +.Game-Chess .chessW .chess-path-C, .Game-Pawn-Whopping .chessW .chess-path-C, + .Game-Checkers .chessB .chess-path-C { opacity: 1; fill: #400827; fill-opacity: 1; @@ -811,7 +819,8 @@ stroke-opacity: 1; } -.chessB .chess-path-C { +.Game-Chess .chessB .chess-path-C, .Game-Pawn-Whopping .chessB .chess-path-C, + .Game-Checkers .chessW .chess-path-C { opacity:1; fill: #fff1d4; fill-opacity: 1; @@ -824,7 +833,8 @@ stroke-opacity: 1; } -.chessW .chess-path-D { +.Game-Chess .chessW .chess-path-D, .Game-Pawn-Whopping .chessW .chess-path-D, + .Game-Checkers .chessB .chess-path-D { fill: #fff1d4; fill-opacity: 0.75; fill-rule: evenodd; @@ -837,7 +847,8 @@ stroke-opacity: 1; } -.chessB .chess-path-D { +.Game-Chess .chessB .chess-path-D, .Game-Pawn-Whopping .chessB .chess-path-D, + .Game-Checkers .chessW .chess-path-D { fill: #400827; fill-opacity: 0.75; fill-rule: evenodd; Modified: trunk/Toss/WebClient/Wrapper.py =================================================================== --- trunk/Toss/WebClient/Wrapper.py 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/WebClient/Wrapper.py 2011-03-13 00:09:53 UTC (rev 1356) @@ -218,10 +218,10 @@ t = [s.strip() for s in m.split('/')] return ((float(t[0]), float(t[1]))) - def suggest (self, timeout): + def suggest (self, timeout, advr): loc = self.get_cur_loc () (ts, t) = self.get_time () - m = self.msg ("EVAL LOC MOVES 4.0 " + str(loc) + + m = self.msg ("EVAL LOC MOVES " + str(advr) + ".0 " + str(loc) + " TIMEOUT "+ str(timeout) + " 55500 alpha_beta_ord") self.set_time (ts, t) msg = [s.strip() for s in m.split(';')] Modified: trunk/Toss/WebClient/contact.html =================================================================== --- trunk/Toss/WebClient/contact.html 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/WebClient/contact.html 2011-03-13 00:09:53 UTC (rev 1356) @@ -32,7 +32,8 @@ <ul> <li><a class="ta" href="http://toss.sourceforge.net/">Toss Homepage</a></li> <li><a class="ta" href="http://www.playok.com/">Online games on PlayOK</a></li> -<li><a class="ta" href="http://apronus.com/chess/index.htm">Chess on Apronus</a></li> +<li><a class="ta" href="http://www.apronus.com/chess/wbeditor.php">Chess + on Apronus</a></li> </ul> </div> Modified: trunk/Toss/examples/Pawn-Whopping.toss =================================================================== --- trunk/Toss/examples/Pawn-Whopping.toss 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/examples/Pawn-Whopping.toss 2011-03-13 00:09:53 UTC (rev 1356) @@ -8,10 +8,10 @@ REL IsSeventh(x) = ex y (C(x, y) and IsEight(y)) REL WhiteEnds() = (ex x (wP(x) and not ex y C(x, y))) or (not ex z bP(z)) REL BlackEnds() = (ex x (bP(x) and not ex y C(y, x))) or (not ex z wP(z)) -RULE WhiteDiag: +RULE WhiteBeat: [ a, b | wP { a }; bP { b } | - ] -> [ a, b | wP { b } | - ] emb wP, bP pre DiagW(a, b) and not BlackEnds() -RULE WhiteStraight: +RULE WhiteMove: [ | bP:1 {}; R:2 {} | ] " . @@ -23,7 +23,7 @@ . " emb wP, bP pre not BlackEnds() -RULE WhiteStraightTwo: +RULE WhiteMoveTwo: [ | bP:1 {}; R:2 {} | ] " . @@ -39,7 +39,7 @@ . " emb wP, bP pre IsSecond(a1) and not BlackEnds() -RULE WhitePawnRightDbl: +RULE WhiteRightPassant: [ | | ] " ... ?..-bP @@ -55,7 +55,7 @@ ... .... " emb wP, bP pre not BlackEnds() -RULE WhitePawnLeftDbl: +RULE WhiteLeftPassant: [ | | ] " ... -bP? @@ -71,10 +71,10 @@ ... .... " emb wP, bP pre not BlackEnds() -RULE BlackDiag: +RULE BlackBeat: [ a, b | bP { a }; wP { b } | - ] -> [ a, b | bP { b } | - ] emb wP, bP pre DiagB(a, b) and not WhiteEnds() -RULE BlackStraight: +RULE BlackMove: [ | R:2 {}; wP:1 {} | ] " bP @@ -86,7 +86,7 @@ bP " emb wP, bP pre not WhiteEnds() -RULE BlackStraightTwo: +RULE BlackMoveTwo: [ | R:2 {}; wP:1 {} | ] " bP @@ -102,7 +102,7 @@ bP " emb wP, bP pre IsSeventh(a3) and not WhiteEnds() -RULE BlackPawnRightDbl: +RULE BlackRightPassant: [ | | ] " ... bP.wP @@ -118,7 +118,7 @@ ... ?... " emb wP, bP pre not WhiteEnds() -RULE BlackPawnLeftDbl: +RULE BlackLeftPassant: [ | | ] " ... wP.bP @@ -140,7 +140,8 @@ 1: :(WhiteEnds()) - :(BlackEnds()); 2: :(BlackEnds()) - :(WhiteEnds()) } - MOVES [WhiteDiag -> 1]; [WhiteStraight -> 1]; [WhiteStraightTwo -> 1] + MOVES [WhiteBeat -> 1]; [WhiteMove -> 1]; [WhiteMoveTwo -> 1]; + [WhiteRightPassant -> 1]; [WhiteLeftPassant -> 1] } LOC 1 { PLAYER 2 @@ -148,7 +149,8 @@ 1: :(WhiteEnds()) - :(BlackEnds()); 2: :(BlackEnds()) - :(WhiteEnds()) } - MOVES [BlackDiag -> 0]; [BlackStraight -> 0]; [BlackStraightTwo -> 0] + MOVES [BlackBeat -> 0]; [BlackMove -> 0]; [BlackMoveTwo -> 0]; + [BlackRightPassant -> 0]; [BlackLeftPassant -> 0] } MODEL [ | | ] " ... ... ... ... Modified: trunk/Toss/www/contact.xml =================================================================== --- trunk/Toss/www/contact.xml 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/www/contact.xml 2011-03-13 00:09:53 UTC (rev 1356) @@ -32,46 +32,57 @@ <section title="Game Playing Links"> - <par><a href="http://www.dozingcatsoftware.com/Gridlock/">Gridlock</a><br/> - Gridlock is a collection of open-source board games. It is nice to play - but is does not allow you to change the game in any easy way.</par> + <itemize> + <item><a href="http://www.apronus.com/chess/wbeditor.php">Apronus Chess + Board Editor</a> is our favorite site for simple chess boards. + </item> - <par><br/><a href="http://www.zillions-of-games.com/">Zillions of Games</a><br/> - Zillions of Games is a language for defining games together with a - simulator and a large library of games. It is very nice but unluckily - not open source.</par> + <item><a href="http://www.dozingcatsoftware.com/Gridlock/">Gridlock</a> + is a collection of open-source board games. It is nice to play + but is does not allow you to change the game in any easy way. + </item> - <par><br/><a href="http://www.kurnik.pl/">Kurnik</a><br/> - Kurnik is a polish site on which you can play various games.</par> + <item><a href="http://www.zillions-of-games.com/">Zillions of Games</a> + is a language for defining games together with a simulator and a large + library of games. It is very nice but unluckily not open source. + </item> - <par><br/><a href="http://abstractstrategy.com/main.html">Abstract Strategy - Games</a><br/> Abstract Strategy Games site allows you to learn and - play such games.</par> + <item><a href="http://www.kurnik.pl/">Kurnik</a> + is a polish site on which you can play various games.</item> - <par><br/><a href="http://www.yourturnmyturn.com/">Your Turn My Turn</a><br/> - On Your-Turn-My-Turn you can play various board games online.</par> + <item><a href="http://abstractstrategy.com/main.html">Abstract + Strategy Games</a> site allows you to learn and play such games. + </item> + + <item><a href="http://www.yourturnmyturn.com/">Your Turn My + Turn</a> allows you to play various board games online.</item> + </itemize> </section> <section title="Modelling Links"> - <par><a href="http://edu.kde.org/step/">Step</a><br/> - Step is an open-source physics simulator, a part of the KDE Education - Project. It can be used for simulation of systems with continuous - dynamics.</par> + <itemize> + <item><a href="http://edu.kde.org/step/">Step</a> + is an open-source physics simulator, a part of the KDE Education + Project. It can be used for simulation of systems with continuous + dynamics. + </item> - <par><br/><a href="http://www.iseesystems.com/softwares/Education/StellaSoftware.aspx">STELLA</a><br/> - STELLA is a commercial simulator allowing both continuous and discrete - dynamics.</par> + <item><a href="http://www.iseesystems.com/softwares/Education/StellaSoftware.aspx">STELLA</a> is a commercial simulator allowing both continuous + and discrete dynamics. + </item> - <par><br/><a href="http://ptolemy.eecs.berkeley.edu/">Ptolemy</a><br/> - The Ptolemy project studies modelling, simulation, and design of - concurrent, real-time, embedded systems. This advanced project - allows to use various models of computation that govern - the interactions between components.</par> + <item><a href="http://ptolemy.eecs.berkeley.edu/">Ptolemy</a> project + studies modelling, simulation, and design of concurrent, real-time, + embedded systems. This advanced project allows to use various models + of computation that govern the interactions between components. + </item> - <par><br/><a href="http://www.microsoft.com/esp/about_esp/overview.htm" - >Microsoft ESP</a><br/>ESP is a visual simulation platform - that applies game-based technology to some more complex problems.</par> + <item><a href="http://www.microsoft.com/esp/about_esp/overview.htm" + >Microsoft ESP</a> is a visual simulation platform + that applies game-based technology to some more complex problems. + </item> + </itemize> </section> <section title="Team"> @@ -85,7 +96,7 @@ <item>Michał Wójcik</item> </itemize> - <par>Friends who helped us a lot with dicussion and code.</par> + <par>Friends who helped us a lot with discussion and code.</par> <itemize> <item>Dietmar Berwanger</item> <item>Matko Botincan</item> Modified: trunk/Toss/www/create.xml =================================================================== --- trunk/Toss/www/create.xml 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/www/create.xml 2011-03-13 00:09:53 UTC (rev 1356) @@ -20,7 +20,7 @@ </itemize> If you plan to make small changes or an easy experiment, the GUI might be the better option. For larger or completely new games, it is more - convenient to edit the files in your favourite text editor. + convenient to edit the files in your favorite text editor. </section> <section title="Creating Games in Toss GUI"> @@ -28,7 +28,7 @@ <itemize> <item><em>Download</em> Toss from the <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> - Sourceforge Download Page</a>.</item> + SourceForge Download Page</a>.</item> <item><em>Run Toss</em> by clicking <em>Toss.py</em>. You can start by opening a file from the <em>examples</em> directory.</item> @@ -47,7 +47,7 @@ form than from the GUI. To understand the meaning of the fields in the text file, you should probably first be acquainted with Toss (e.g. go through the tutorial above) and at least skim through - the <a href="reference/reference.pdf">referece.pdf</a> file, look + the <a href="reference/reference.pdf">reference.pdf</a> file, look at our <a href="docs.html">documentation</a>. After this, you can simply edit the .toss file, maybe starting with one of these. </par> Modified: trunk/Toss/www/docs.xml =================================================================== --- trunk/Toss/www/docs.xml 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/www/docs.xml 2011-03-13 00:09:53 UTC (rev 1356) @@ -5,7 +5,7 @@ <personal> <title lang="en">Documentation</title> - <title lang="de">Dokumantation</title> + <title lang="de">Dokumentation</title> <history> <link id="docs" href="/docs.html">Documentation</link> </history> Modified: trunk/Toss/www/ideas.xml =================================================================== --- trunk/Toss/www/ideas.xml 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/www/ideas.xml 2011-03-13 00:09:53 UTC (rev 1356) @@ -81,8 +81,8 @@ project, but it can become very interesting in the last phase! <br/><br/></par> <par><em>Possible Mentors (in order of preference):</em> - Łukasz Stafiniak, Łukasz Kaiser, - Michał Wójcik, Tobias Ganzow + Michał Wójcik, Tobias Ganzow, + Łukasz Stafiniak, Łukasz Kaiser </par> </section> @@ -204,8 +204,8 @@ defined in GDL, the Game Description Language used in GGP Competitions, to the Toss format. This allows to compete against GGP players, and we even won quite a few games already! But the GGP translation is not - complete and some games are translated to very inefficient variants, - on which it is almost impossible to play well. The idea is to improve + complete, games with recursive definitions cannot be translated yet, + and some translated definitions can be large. The idea is to improve this, but also to cooperate with the GGP guys, especially with the <a href="http://code.google.com/p/ggp-galaxy/">GGP Galaxy Project</a>, to make General Game Playing truly accessible for everyone! @@ -238,4 +238,76 @@ </section> + <section title="Idea: Feature Learning"> + <par><em>Description and Goals.</em> + Currently, Toss generates functions for position evaluation form + the payoffs and rules of the game in one way, fixed in the code. + It would be better to use a weighted mix of various evaluation functions + or their parts (which we call <em>features</em>) and learn + the appropriate weights by playing them against each other. + We expect that this will improve Toss strength significantly. + <br/><br/></par> + <par><em>Deliverables.</em> + By mid-term the basic framework for feature learning should be present, + and demonstrated e.g. by learning weights for pieces in chess. By the + end, the goals is to replace the default play mode of Toss by one which + uses feature learning. + <br/><br/></par> + <par><em>Modules (in planned construction order).</em> + <enumerate> + <item>Implement weighted mixing of heuristics (easy)</item> + <item>Hook up multi-dimensional optimization (medium, use GSL?)</item> + <item>Test weight learning, minimize needed playouts (easy)</item> + <item>Create features from various game parts (hard)</item> + <item>Memorize learned weights, replace default playout (medium)</item> + </enumerate> + <br/></par> + <par><em>Needed Skills and Difficulty.</em> + This is a medium to hard project – a lot depends how many + features will be generated and how, but even using just a few should + already improve playing strength. OCaml experience is required. + <br/><br/></par> + <par><em>Possible Mentors (in order of preference):</em> + Łukasz Stafiniak, Łukasz Kaiser + </par> + </section> + + <section title="Idea: Games with Imperfect Information"> + <par><em>Description and Goals.</em> + At present Toss only allows to define games with perfect information, + i.e. the complete state is known to all players. The idea to extend + Toss to imperfect information games is based on <em>views</em>, which + are tuples of formulas which convert the true state into a new structure, + which the player sees. Such extension should allow to define some well + know games with imperfect information such as a card game or Minesweeper. + <br/><br/></par> + <par><em>Deliverables.</em> + To add views it is necessary to extend the core game definition in Arena, + and to adapt many things which rely on this. Such extension, together + with a toy example and of course preserving the current functionality + should be ready by mid-term. After that, it will be necessary to adapt + automatic playing algorithms to take imperfect information into account, + and at least one full game with imperfect information should be defined + by the end of the project. + <br/><br/></par> + <par><em>Modules (in planned construction order).</em> + <enumerate> + <item>Add views to Arena, update everything (medium)</item> + <item>Adapt interfaces to account for views (medium)</item> + <item>Testing, a toy imperfect information game (easy)</item> + <item>Generalize automatic play to imperfect information (hard)</item> + <item>Define a full game with imperfect information (medium)</item> + </enumerate> + <br/></par> + <par><em>Needed Skills and Difficulty.</em> + Good knowledge of OCaml and some understanding of games with + imperfect information will be necessary. This project is medium + to hard, depending on how much effort one makes to adapt automatic play. + <br/><br/></par> + <par><em>Possible Mentors (in order of preference):</em> + Łukasz Kaiser, Dietmar Berwanger, Tobias Ganzow + </par> + </section> + + </personal> Modified: trunk/Toss/www/index.xml =================================================================== --- trunk/Toss/www/index.xml 2011-03-12 19:24:32 UTC (rev 1355) +++ trunk/Toss/www/index.xml 2011-03-13 00:09:53 UTC (rev 1356) @@ -14,7 +14,7 @@ For example, did you ever wonder how your favorite game would feel if you removed the middle of the board? With Toss, it is easy to experiment! And after your game is ready, you can play it online - and compete with friends! + against a computer or compete with your friends! </par> </section> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-13 17:36:54
|
Revision: 1357 http://toss.svn.sourceforge.net/toss/?rev=1357&view=rev Author: lukaszkaiser Date: 2011-03-13 17:36:46 +0000 (Sun, 13 Mar 2011) Log Message: ----------- Web work, async moves, chess correction. Modified Paths: -------------- trunk/Toss/WebClient/Connect.js trunk/Toss/WebClient/Main.js trunk/Toss/examples/Chess.toss trunk/Toss/www/docs.xml trunk/Toss/www/index.xml trunk/Toss/www/navigation.xml trunk/Toss/www/styles/screen.css trunk/Toss/www/xsl/include/common.xsl Added Paths: ----------- trunk/Toss/www/develop.xml Modified: trunk/Toss/WebClient/Connect.js =================================================================== --- trunk/Toss/WebClient/Connect.js 2011-03-13 00:09:53 UTC (rev 1356) +++ trunk/Toss/WebClient/Connect.js 2011-03-13 17:36:46 UTC (rev 1357) @@ -28,6 +28,8 @@ var PAYOFF_STR = "" var PLAYER_STR = "" +var ASYNC_REQ_PENDING = 0; + // Helper function: sign of a number. function sign (x) { if (x > 0.01) { return (1); } @@ -76,19 +78,21 @@ } // Send [msg] to server asynchronously, ignore response text. -function async_server_msg (msg) { +function async_server_msg (msg, f) { var xml_request = new XMLHttpRequest (); xml_request.open ('POST', 'Handler.py', true); xml_request.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xml_request.onreadystatechange = function () { if (xml_request.readyState == 4) { + ASYNC_REQ_PENDING -= 1; resp = xml_request.responseText; if (resp.indexOf ("MOD_PYTHON ERROR") > -1) { alert (resp.substring(resp.indexOf("Traceback"))); - } + } else { f(resp) }; } }; + ASYNC_REQ_PENDING += 1; xml_request.send (msg); } @@ -98,10 +102,15 @@ } // Send [msg] to server attaching prefix '[cmd]#' async., ignore response. -function async_srv (cmd, msg) { - return (async_server_msg (cmd + '#' + msg)); +function async_srv_ignore (cmd, msg) { + return (async_server_msg (cmd + '#' + msg, function(x) { } )); } +// Send [msg] to server attaching prefix '[cmd]#' async., run f on return. +function async_srv (cmd, msg, f) { + return (async_server_msg (cmd + '#' + msg, f )); +} + // Strip [c1] and [c2] from beginning and end of [str]. function strip (c1, c2, str) { if (str.length == 0) return (str); Modified: trunk/Toss/WebClient/Main.js =================================================================== --- trunk/Toss/WebClient/Main.js 2011-03-13 00:09:53 UTC (rev 1356) +++ trunk/Toss/WebClient/Main.js 2011-03-13 17:36:46 UTC (rev 1357) @@ -119,6 +119,7 @@ // Handler for clicks on elements. function handle_elem_click (elem) { + if (ASYNC_REQ_PENDING != 0) { return; } var moves = get_moves (elem, LAST_CLICKED_ELEM); if (moves.length == 0) { LAST_CLICKED_ELEM = ""; @@ -209,6 +210,7 @@ } function play_click (game, play_id, pi) { + document.getElementById("opponents").style.display = "none"; list_plays (game); game_click (game); document.getElementById ("game-title").innerHTML = game; @@ -232,7 +234,11 @@ return; } document.getElementById("working").style.display = "block"; - var info = srv("MOVE_PLAY", 'c, '+ CUR_MOVE +', '+ play_py_id (CUR_PLAY_I)); + async_srv("MOVE_PLAY", 'c, '+ CUR_MOVE +', '+ play_py_id (CUR_PLAY_I), + make_move_continue); +} + +function make_move_continue (info) { set_info (info); CUR_MOVE = ""; CUR_ELEMS = []; @@ -242,14 +248,15 @@ disp_name(PLAYS[CUR_PLAY_I][PLAYER_STR]); document.getElementById("working").style.display = "none"; full_redraw (); - async_srv ("UPD_SVG", play_py_id(CUR_PLAY_I) + ", " + svg_string()); + async_srv_ignore ("UPD_SVG", play_py_id(CUR_PLAY_I) + ", " + svg_string()); var old_li = document.getElementById ("plays-list-" + GAME_NAME + "-elem-" + CUR_PLAY_I); var li = new_play_item (GAME_NAME, CUR_PLAY_I); old_li.parentNode.replaceChild (li, old_li); if (PLAYS[CUR_PLAY_I][PLAYER_STR] == "computer") { - var m = suggest_move (); - if (m != "") { make_move (); } + //var m = suggest_move (); + //if (m != "") { make_move (); } + suggest_move_async (make_move); } } @@ -380,7 +387,7 @@ PLAYS.push(p); set_info(info_nbr.substring(info_idx+1)); full_redraw (); - async_srv ("UPD_SVG", play_py_id(CUR_PLAY_I) + ", " + svg_string()); + async_srv_ignore ("UPD_SVG", play_py_id(CUR_PLAY_I) + ", " + svg_string()); li = new_play_item (GAME_NAME, CUR_PLAY_I); document.getElementById("plays-list-" + GAME_NAME).appendChild(li); } @@ -400,6 +407,25 @@ return (m); } +function decrease_moving (n) { + document.getElementById("working").innerHTML = "Moving in " + n + " ..."; + if (n > 0) { + setTimeout("decrease_moving(" + (n-1) + ")", 1000); + } +} + +function suggest_move_async (f) { + document.getElementById("working").innerHTML = "Moving in 5 ..."; + document.getElementById("working").style.display = "block"; + setTimeout("decrease_moving(4)", 1000) + var fm = function (m) { + document.getElementById("working").style.display = "none"; + document.getElementById("working").innerHTML = "Working..."; + if (m != "") { show_move (m); f() } + }; + async_srv("SUGGEST", 'c, '+ play_py_id (CUR_PLAY_I), fm); +} + function suggest_move_better () { document.getElementById("working").innerHTML = "Calculating move..."; document.getElementById("working").style.display = "block"; Modified: trunk/Toss/examples/Chess.toss =================================================================== --- trunk/Toss/examples/Chess.toss 2011-03-13 00:09:53 UTC (rev 1356) +++ trunk/Toss/examples/Chess.toss 2011-03-13 17:36:46 UTC (rev 1357) @@ -49,7 +49,7 @@ wP . -" emb w, b post not CheckW() +" emb w, b pre not IsEight(a2) post not CheckW() RULE BlackPawnMove: [ | | ] " ... @@ -61,7 +61,7 @@ ... bP -" emb w, b post not CheckB() +" emb w, b pre not IsFirst(a1) post not CheckB() RULE WhitePawnMoveDbl: [ | | ] " @@ -98,7 +98,16 @@ [ a, b | wP { a }; b { b } | - ] -> [ a, b | wP { b } | - ] - emb w, b pre ex z (C(a, z) and (R(z, b) or R(b, z))) post not CheckW() + emb w, b + pre not IsEight(b) and ex z (C(a, z) and (R(z, b) or R(b, z))) + post not CheckW() +RULE WhitePawnBeatPromote: + [ a, b | wP { a }; b { b } | - ] + -> + [ a, b | wQ { b } | - ] + emb w, b + pre IsEight(b) and ex z (C(a, z) and (R(z, b) or R(b, z))) + post not CheckW() RULE WhitePawnBeatRDbl: [ | | ] " ... @@ -135,7 +144,16 @@ [ a, b | bP { a }; w { b } | - ] -> [ a, b | bP { b } | - ] - emb w, b pre ex z (C(z, a) and (R(z, b) or R(b, z))) post not CheckB() + emb w, b + pre not IsFirst(b) and ex z (C(z, a) and (R(z, b) or R(b, z))) + post not CheckB() +RULE BlackPawnBeatPromote: + [ a, b | bP { a }; w { b } | - ] + -> + [ a, b | bQ { b } | - ] + emb w, b + pre IsFirst(b) and ex z (C(z, a) and (R(z, b) or R(b, z))) + post not CheckB() RULE BlackPawnBeatRDbl: [ | | ] " ... @@ -304,6 +322,7 @@ [WhitePawnMove -> 1]; [WhitePawnMoveDbl -> 1]; [WhitePawnBeat -> 1]; + [WhitePawnBeatPromote -> 1]; [WhitePawnBeatLDbl -> 1]; [WhitePawnBeatRDbl -> 1]; [WhitePawnPromote -> 1]; @@ -327,6 +346,7 @@ [BlackPawnMove -> 0]; [BlackPawnMoveDbl -> 0]; [BlackPawnBeat -> 0]; + [BlackPawnBeatPromote -> 0]; [BlackPawnBeatLDbl -> 0]; [BlackPawnBeatRDbl -> 0]; [BlackPawnPromote -> 0]; @@ -350,6 +370,7 @@ [WhitePawnMove -> 3]; [WhitePawnMoveDbl -> 3]; [WhitePawnBeat -> 3]; + [WhitePawnBeatPromote -> 3]; [WhitePawnBeatLDbl -> 3]; [WhitePawnBeatRDbl -> 3]; [WhitePawnPromote -> 3]; @@ -372,6 +393,7 @@ [BlackPawnMove -> 2]; [BlackPawnMoveDbl -> 2]; [BlackPawnBeat -> 2]; + [BlackPawnBeatPromote -> 2]; [BlackPawnBeatLDbl -> 2]; [BlackPawnBeatRDbl -> 2]; [BlackPawnPromote -> 2]; @@ -395,6 +417,7 @@ [WhitePawnMove -> 5]; [WhitePawnMoveDbl -> 5]; [WhitePawnBeat -> 5]; + [WhitePawnBeatPromote -> 5]; [WhitePawnBeatLDbl -> 5]; [WhitePawnBeatRDbl -> 5]; [WhitePawnPromote -> 5]; @@ -417,6 +440,7 @@ [BlackPawnMove -> 4]; [BlackPawnMoveDbl -> 4]; [BlackPawnBeat -> 4]; + [BlackPawnBeatPromote -> 4]; [BlackPawnBeatLDbl -> 4]; [BlackPawnBeatRDbl -> 4]; [BlackPawnPromote -> 4]; @@ -440,6 +464,7 @@ [WhitePawnMove -> 7]; [WhitePawnMoveDbl -> 7]; [WhitePawnBeat -> 7]; + [WhitePawnBeatPromote -> 7]; [WhitePawnBeatLDbl -> 7]; [WhitePawnBeatRDbl -> 7]; [WhitePawnPromote -> 7]; @@ -461,6 +486,7 @@ [BlackPawnMove -> 6]; [BlackPawnMoveDbl -> 6]; [BlackPawnBeat -> 6]; + [BlackPawnBeatPromote -> 6]; [BlackPawnBeatLDbl -> 6]; [BlackPawnBeatRDbl -> 6]; [BlackPawnPromote -> 6]; @@ -484,6 +510,7 @@ [WhitePawnMove -> 9]; [WhitePawnMoveDbl -> 9]; [WhitePawnBeat -> 9]; + [WhitePawnBeatPromote -> 9]; [WhitePawnBeatLDbl -> 9]; [WhitePawnBeatRDbl -> 9]; [WhitePawnPromote -> 9]; @@ -507,6 +534,7 @@ [BlackPawnMove -> 8]; [BlackPawnMoveDbl -> 8]; [BlackPawnBeat -> 8]; + [BlackPawnBeatPromote -> 8]; [BlackPawnBeatLDbl -> 8]; [BlackPawnBeatRDbl -> 8]; [BlackPawnPromote -> 8]; @@ -529,6 +557,7 @@ [WhitePawnMove -> 11]; [WhitePawnMoveDbl -> 11]; [WhitePawnBeat -> 11]; + [WhitePawnBeatPromote -> 11]; [WhitePawnBeatLDbl -> 11]; [WhitePawnBeatRDbl -> 11]; [WhitePawnPromote -> 11]; @@ -551,6 +580,7 @@ [BlackPawnMove -> 10]; [BlackPawnMoveDbl -> 10]; [BlackPawnBeat -> 10]; + [BlackPawnBeatPromote -> 10]; [BlackPawnBeatLDbl -> 10]; [BlackPawnBeatRDbl -> 10]; [BlackPawnPromote -> 10]; @@ -573,6 +603,7 @@ [WhitePawnMove -> 13]; [WhitePawnMoveDbl -> 13]; [WhitePawnBeat -> 13]; + [WhitePawnBeatPromote -> 13]; [WhitePawnBeatLDbl -> 13]; [WhitePawnBeatRDbl -> 13]; [WhitePawnPromote -> 13]; @@ -595,6 +626,7 @@ [BlackPawnMove -> 12]; [BlackPawnMoveDbl -> 12]; [BlackPawnBeat -> 12]; + [BlackPawnBeatPromote -> 12]; [BlackPawnBeatLDbl -> 12]; [BlackPawnBeatRDbl -> 12]; [BlackPawnPromote -> 12]; @@ -617,6 +649,7 @@ [WhitePawnMove -> 15]; [WhitePawnMoveDbl -> 15]; [WhitePawnBeat -> 15]; + [WhitePawnBeatPromote -> 15]; [WhitePawnBeatLDbl -> 15]; [WhitePawnBeatRDbl -> 15]; [WhitePawnPromote -> 15]; @@ -638,6 +671,7 @@ [BlackPawnMove -> 14]; [BlackPawnMoveDbl -> 14]; [BlackPawnBeat -> 14]; + [BlackPawnBeatPromote -> 14]; [BlackPawnBeatLDbl -> 14]; [BlackPawnBeatRDbl -> 14]; [BlackPawnPromote -> 14]; @@ -660,6 +694,7 @@ [WhitePawnMove -> 17]; [WhitePawnMoveDbl -> 17]; [WhitePawnBeat -> 17]; + [WhitePawnBeatPromote -> 17]; [WhitePawnBeatLDbl -> 17]; [WhitePawnBeatRDbl -> 17]; [WhitePawnPromote -> 17]; @@ -683,6 +718,7 @@ [BlackPawnMove -> 16]; [BlackPawnMoveDbl -> 16]; [BlackPawnBeat -> 16]; + [BlackPawnBeatPromote -> 16]; [BlackPawnBeatLDbl -> 16]; [BlackPawnBeatRDbl -> 16]; [BlackPawnPromote -> 16]; @@ -705,6 +741,7 @@ [WhitePawnMove -> 19]; [WhitePawnMoveDbl -> 19]; [WhitePawnBeat -> 19]; + [WhitePawnBeatPromote -> 19]; [WhitePawnBeatLDbl -> 19]; [WhitePawnBeatRDbl -> 19]; [WhitePawnPromote -> 19]; @@ -727,6 +764,7 @@ [BlackPawnMove -> 18]; [BlackPawnMoveDbl -> 18]; [BlackPawnBeat -> 18]; + [BlackPawnBeatPromote -> 18]; [BlackPawnBeatLDbl -> 18]; [BlackPawnBeatRDbl -> 18]; [BlackPawnPromote -> 18]; @@ -749,6 +787,7 @@ [WhitePawnMove -> 21]; [WhitePawnMoveDbl -> 21]; [WhitePawnBeat -> 21]; + [WhitePawnBeatPromote -> 21]; [WhitePawnBeatLDbl -> 21]; [WhitePawnBeatRDbl -> 21]; [WhitePawnPromote -> 21]; @@ -771,6 +810,7 @@ [BlackPawnMove -> 20]; [BlackPawnMoveDbl -> 20]; [BlackPawnBeat -> 20]; + [BlackPawnBeatPromote -> 20]; [BlackPawnBeatLDbl -> 20]; [BlackPawnBeatRDbl -> 20]; [BlackPawnPromote -> 20]; @@ -793,6 +833,7 @@ [WhitePawnMove -> 23]; [WhitePawnMoveDbl -> 23]; [WhitePawnBeat -> 23]; + [WhitePawnBeatPromote -> 23]; [WhitePawnBeatLDbl -> 23]; [WhitePawnBeatRDbl -> 23]; [WhitePawnPromote -> 23]; @@ -814,6 +855,7 @@ [BlackPawnMove -> 22]; [BlackPawnMoveDbl -> 22]; [BlackPawnBeat -> 22]; + [BlackPawnBeatPromote -> 22]; [BlackPawnBeatLDbl -> 22]; [BlackPawnBeatRDbl -> 22]; [BlackPawnPromote -> 22]; @@ -836,6 +878,7 @@ [WhitePawnMove -> 25]; [WhitePawnMoveDbl -> 25]; [WhitePawnBeat -> 25]; + [WhitePawnBeatPromote -> 25]; [WhitePawnBeatLDbl -> 25]; [WhitePawnBeatRDbl -> 25]; [WhitePawnPromote -> 25]; @@ -859,6 +902,7 @@ [BlackPawnMove -> 24]; [BlackPawnMoveDbl -> 24]; [BlackPawnBeat -> 24]; + [BlackPawnBeatPromote -> 24]; [BlackPawnBeatLDbl -> 24]; [BlackPawnBeatRDbl -> 24]; [BlackPawnPromote -> 24]; @@ -880,6 +924,7 @@ [WhitePawnMove -> 27]; [WhitePawnMoveDbl -> 27]; [WhitePawnBeat -> 27]; + [WhitePawnBeatPromote -> 27]; [WhitePawnBeatLDbl -> 27]; [WhitePawnBeatRDbl -> 27]; [WhitePawnPromote -> 27]; @@ -902,6 +947,7 @@ [BlackPawnMove -> 26]; [BlackPawnMoveDbl -> 26]; [BlackPawnBeat -> 26]; + [BlackPawnBeatPromote -> 26]; [BlackPawnBeatLDbl -> 26]; [BlackPawnBeatRDbl -> 26]; [BlackPawnPromote -> 26]; @@ -923,6 +969,7 @@ [WhitePawnMove -> 29]; [WhitePawnMoveDbl -> 29]; [WhitePawnBeat -> 29]; + [WhitePawnBeatPromote -> 29]; [WhitePawnBeatLDbl -> 29]; [WhitePawnBeatRDbl -> 29]; [WhitePawnPromote -> 29]; @@ -945,6 +992,7 @@ [BlackPawnMove -> 28]; [BlackPawnMoveDbl -> 28]; [BlackPawnBeat -> 28]; + [BlackPawnBeatPromote -> 28]; [BlackPawnBeatLDbl -> 28]; [BlackPawnBeatRDbl -> 28]; [BlackPawnPromote -> 28]; @@ -966,6 +1014,7 @@ [WhitePawnMove -> 31]; [WhitePawnMoveDbl -> 31]; [WhitePawnBeat -> 31]; + [WhitePawnBeatPromote -> 31]; [WhitePawnBeatLDbl -> 31]; [WhitePawnBeatRDbl -> 31]; [WhitePawnPromote -> 31]; @@ -987,6 +1036,7 @@ [BlackPawnMove -> 30]; [BlackPawnMoveDbl -> 30]; [BlackPawnBeat -> 30]; + [BlackPawnBeatPromote -> 30]; [BlackPawnBeatLDbl -> 30]; [BlackPawnBeatRDbl -> 30]; [BlackPawnPromote -> 30]; Added: trunk/Toss/www/develop.xml =================================================================== --- trunk/Toss/www/develop.xml (rev 0) +++ trunk/Toss/www/develop.xml 2011-03-13 17:36:46 UTC (rev 1357) @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE lecture SYSTEM "xsl/xhtml1-lat1.ent"> + +<?xml-stylesheet type="text/xsl" href="xsl/main.xsl" charset="UTF-8"?> + +<personal> + <title lang="en">Develop Toss</title> + <title lang="de">Toss Ausbauen</title> + <history> + <link id="develop" href="/develop.html">Develop Toss</link> + </history> + + <section title="Preparation"> + <itemize> + <item>Except for the interfaces, most of Toss is programmed in + <a href="http://caml.inria.fr/">Objective Caml</a>. You will need + a good understanding of OCaml and a full OCaml installation + to work on the Toss Engine. + </item> + <item>Toss <em>build system</em> is based on <em>ocamlbuild</em> + and uses <em>Makefiles</em> for compilation of the C parts. + You will need a system which supports these to build Toss. + </item> + <item>If you want to develop Toss on Ubuntu, here is a command with + a list of packages to install.<br/> + sudo apt-get install g++ python-qt4 python-dev pyqt4-dev-tools + ocaml-findlib menhir libounit-ocaml-dev libapache2-mod-python + sqlite3 python-pysqlite2 + </item> + <item>This command will checkout the + <a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/">Toss + SVN Repository</a> to the <em>Toss</em> directory.<br/> + svn co https://toss.svn.sourceforge.net/svnroot/toss/trunk/Toss Toss + </item> + <item>In the Toss directory run <em>make</em> and check that + it succeeds.</item> + </itemize> + </section> + + <section title="Understanding Toss"> + <itemize> + <item><a href="create.html">Create</a> at least one simple game + to get started.</item> + <item>Get acquainted with <a href="docs.html">Toss documentation</a>. + </item> + <item>Do not forget to read the <a href="reference/reference.pdf"> + reference.pdf</a> document.</item> + <item>When you start looking at the code, you might find + the <a href="code_doc/">interface documentation</a> handy.</item> + <item>Skim through the <a href="Publications/">papers and talks</a> + about Toss to get an idea where the ideas come from.</item> + </itemize> + </section> + + <section title="Working with the Toss Team"> + <par>If you have an idea for Toss, a request, want to become a developer + or just want to talk, contact us! Most engaged Toss developers do + respond to Toss questions on their private emails every + day (see below), but <em>toss-devel</em> is the place we prefer.</par> + <itemize> + <item>Toss Mailing List: + <mailto address="tos...@li..."/></item> + <item>Łukasz Kaiser: + <mailto address="luk...@gm..."/></item> + <item>Łukasz Stafiniak: + <mailto address="luk...@gm..."/></item> + <item>Michał Wójcik: + <mailto address="mic...@gm..."/></item> + </itemize> + </section> + +</personal> Modified: trunk/Toss/www/docs.xml =================================================================== --- trunk/Toss/www/docs.xml 2011-03-13 00:09:53 UTC (rev 1356) +++ trunk/Toss/www/docs.xml 2011-03-13 17:36:46 UTC (rev 1357) @@ -52,6 +52,9 @@ <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> watched</a> online. </item> + <item><em>Shorter presentation</em> focusing on the AI side was given at + <em>AGI 2010</em> and can also be + <a href="http://www.vimeo.com/15326245">watched</a> online.</item> </itemize> </section> Modified: trunk/Toss/www/index.xml =================================================================== --- trunk/Toss/www/index.xml 2011-03-13 00:09:53 UTC (rev 1356) +++ trunk/Toss/www/index.xml 2011-03-13 17:36:46 UTC (rev 1357) @@ -11,10 +11,12 @@ <section title="About" lang="en"> <par><em>Toss</em> is a program to create, modify and play games. + It includes a general game playing engine so that you can play any + game you create against the computer. For example, did you ever wonder how your favorite game would feel if you removed the middle of the board? With Toss, it is easy to experiment! And after your game is ready, you can play it online - against a computer or compete with your friends! + and compete with your friends! </par> </section> @@ -82,20 +84,30 @@ <par>To learn more about the mathematical background and the design of Toss, use the following links.</par> <itemize> -<item><em>Compact description</em> of the mathematical model behind Toss and -our game playing algorithm can be found in the paper -<a href="http://logic.rwth-aachen.de/~kaiser/playing_structure_rewriting_games.pdf">Playing Structure Rewriting Games</a>.</item> + <item><em>Compact description</em> of the mathematical model behind Toss + and our game playing algorithm can be found in the paper + <a href="http://logic.rwth-aachen.de/~kaiser/playing_structure_rewriting_games.pdf">Playing Structure Rewriting Games</a>. + </item> -<item><em>Design and specification</em> of Toss are described in - the <a href="reference.pdf">reference.pdf</a> document.</item> + <item><em>Design and specification</em> of Toss are described in + the <a href="reference.pdf">reference.pdf</a> document. + </item> -<item> <em>Complexity</em> of a syntactic fragment of Toss was analyzed in - the paper <a href="http://logic.rwth-aachen.de/~kaiser/graph_games_short.pdf"> - Synthesis for Structure Rewriting Systems</a>.</item> -<item><em>Presentation</em> on the mathematics behind Toss was given at - <em>IIT Kanpur</em> and can be - <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> - watched</a> online.</item> + <item> <em>Complexity</em> of a syntactic fragment of Toss was analyzed in + the paper <a href="http://logic.rwth-aachen.de/~kaiser/graph_games_short.pdf"> + Synthesis for Structure Rewriting Systems</a>. + </item> + + <item><em>Presentation</em> on the mathematics behind Toss was given at + <em>IIT Kanpur</em> and can be + <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> + watched</a> online. + </item> + + <item><em>Shorter presentation</em> focusing on the AI side was given at + <em>AGI 2010</em> and can also be + <a href="http://www.vimeo.com/15326245">watched</a> online. + </item> </itemize> </section> Modified: trunk/Toss/www/navigation.xml =================================================================== --- trunk/Toss/www/navigation.xml 2011-03-13 00:09:53 UTC (rev 1356) +++ trunk/Toss/www/navigation.xml 2011-03-13 17:36:46 UTC (rev 1357) @@ -20,6 +20,7 @@ <item href="/code_doc/" id="code">Code Documentation</item> </menu> <item href="/Publications/" id="Publications">Papers and Talks</item> + <item href="/develop.html" id="develop">Develop Toss</item> <item href="/contact.html" id="contact">Contact and Links</item> </menu> @@ -39,8 +40,8 @@ <menu title="Dokumentation" href="/docs.html" id="docs"> <item href="/background.html" id="background">Hintergrund</item> </menu> - - <item href="/Publications/" id="Publications">Publikationen und Vorträge</item> + <item href="/Publications/" id="Publications">Papers und Talks</item> + <item href="/develop.html" id="develop">Toss Ausbauen</item> <item href="/contact.html" id="contact">Kontakt und Links</item> </menu> Modified: trunk/Toss/www/styles/screen.css =================================================================== --- trunk/Toss/www/styles/screen.css 2011-03-13 00:09:53 UTC (rev 1356) +++ trunk/Toss/www/styles/screen.css 2011-03-13 17:36:46 UTC (rev 1357) @@ -120,6 +120,7 @@ position: absolute; bottom: 0px; right: 0px; + /*display: none;*/ } #parentnav ul { Modified: trunk/Toss/www/xsl/include/common.xsl =================================================================== --- trunk/Toss/www/xsl/include/common.xsl 2011-03-13 00:09:53 UTC (rev 1356) +++ trunk/Toss/www/xsl/include/common.xsl 2011-03-13 17:36:46 UTC (rev 1357) @@ -69,12 +69,12 @@ <xsl:template match="games-section"> <xsl:choose> <xsl:when test="$lang='de'"> - <h3><a href="http://tplay.org">Online Spielen</a></h3> + <h3><a href="http://tplay.org">Online Spielen gegen Toss</a></h3> <xsl:apply-templates /> <p><a href="http://tplay.org">Weitere Spiele</a></p> </xsl:when> <xsl:otherwise> - <h3><a href="http://tplay.org">Play Online</a></h3> + <h3><a href="http://tplay.org">Play Online against Toss</a></h3> <xsl:apply-templates /> <p><a href="http://tplay.org">More Games</a></p> </xsl:otherwise> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-14 03:24:42
|
Revision: 1358 http://toss.svn.sourceforge.net/toss/?rev=1358&view=rev Author: lukaszkaiser Date: 2011-03-14 03:24:33 +0000 (Mon, 14 Mar 2011) Log Message: ----------- Translations and many tiny corrections. Modified Paths: -------------- trunk/Toss/Server/Server.ml trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/index.html trunk/Toss/www/.cvsignore trunk/Toss/www/Publications/.cvsignore trunk/Toss/www/Publications/Makefile trunk/Toss/www/contact.xml trunk/Toss/www/create.xml trunk/Toss/www/default.mak trunk/Toss/www/develop.xml trunk/Toss/www/docs.xml trunk/Toss/www/examples.xml trunk/Toss/www/gui_interface.xml trunk/Toss/www/index.xml trunk/Toss/www/navigation.xml trunk/Toss/www/play.xml trunk/Toss/www/styles/screen.css trunk/Toss/www/xsl/books.xsl trunk/Toss/www/xsl/include/common.xsl trunk/Toss/www/xsl/include/layout.xsl trunk/Toss/www/xsl/main.xsl trunk/Toss/www/xsl/publications.xsl Property Changed: ---------------- trunk/Toss/www/ trunk/Toss/www/Publications/ Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/Server/Server.ml 2011-03-14 03:24:33 UTC (rev 1358) @@ -30,8 +30,8 @@ let g_heur = ref None let no_gtree = ref false -let exp_p1_timeout = ref 9000 -let exp_p2_timeout = ref 9000 +let exp_p1_timeout = ref 10000 +let exp_p2_timeout = ref 10000 (* -------------------- GENERAL SERVER AND REQUEST HANDLER ------------------ *) Modified: trunk/Toss/WebClient/Main.js =================================================================== --- trunk/Toss/WebClient/Main.js 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/WebClient/Main.js 2011-03-14 03:24:33 UTC (rev 1358) @@ -219,7 +219,7 @@ CUR_PLAY_I = pi; VIEW_MIRROR = (PLAYS[CUR_PLAY_I][0] == UNAME) ? 0 : 1; document.getElementById("cur-player").innerHTML = - disp_name(PLAYS[CUR_PLAY_I][PLAYS[CUR_PLAY_I][3] % 2]); + disp_name(PLAYS[CUR_PLAY_I][PLAYS[CUR_PLAY_I][3]]); toss_open_db (play_py_id(pi)); full_redraw (); } @@ -408,14 +408,14 @@ } function decrease_moving (n) { - document.getElementById("working").innerHTML = "Moving in " + n + " ..."; + document.getElementById("working").innerHTML = "Moving in " + n + "s ..."; if (n > 0) { setTimeout("decrease_moving(" + (n-1) + ")", 1000); } } function suggest_move_async (f) { - document.getElementById("working").innerHTML = "Moving in 5 ..."; + document.getElementById("working").innerHTML = "Moving in 5s ..."; document.getElementById("working").style.display = "block"; setTimeout("decrease_moving(4)", 1000) var fm = function (m) { @@ -426,6 +426,10 @@ async_srv("SUGGEST", 'c, '+ play_py_id (CUR_PLAY_I), fm); } +function suggest_move_click () { + suggest_move_async (function () {}); +} + function suggest_move_better () { document.getElementById("working").innerHTML = "Calculating move..."; document.getElementById("working").style.display = "block"; @@ -436,6 +440,18 @@ return (m); } +function suggest_move_better_click () { + document.getElementById("working").innerHTML = "Moving in 10s ..."; + document.getElementById("working").style.display = "block"; + setTimeout("decrease_moving(9)", 1000) + var fm = function (m) { + document.getElementById("working").style.display = "none"; + document.getElementById("working").innerHTML = "Working..."; + if (m != "") { show_move (m); f() } + }; + async_srv("SUGGESTX", 'c, '+ play_py_id (CUR_PLAY_I), fm); +} + function toggle_suggestions () { var txt = document.getElementById("suggestions-toggle").innerHTML; if (txt.indexOf ("Show") == -1) { Modified: trunk/Toss/WebClient/index.html =================================================================== --- trunk/Toss/WebClient/index.html 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/WebClient/index.html 2011-03-14 03:24:33 UTC (rev 1358) @@ -226,10 +226,10 @@ <p id="player-info-par"> Moving: <span id="cur-player">?</span> - <button id="sugbt" class="bt" onclick="suggest_move()"> + <button id="sugbt" class="bt" onclick="suggest_move_click()"> Suggest (weak, fast) </button> - <button id="sugbts" class="bt" onclick="suggest_move_better()"> + <button id="sugbts" class="bt" onclick="suggest_move_better_click()"> Suggest (stronger, slow) </button> </p> Property changes on: trunk/Toss/www ___________________________________________________________________ Modified: svn:ignore - # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html *.html.de *.html.en *.texml *.xml.de *.xml.en reference.xml code_doc *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html *.html.de *.html.en *.html.pl *.texml *.xml.de *.xml.en *.xml.pl reference.xml code_doc *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ Modified: trunk/Toss/www/.cvsignore =================================================================== --- trunk/Toss/www/.cvsignore 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/.cvsignore 2011-03-14 03:24:33 UTC (rev 1358) @@ -5,9 +5,11 @@ *.html *.html.de *.html.en +*.html.pl *.texml *.xml.de *.xml.en +*.xml.pl reference.xml code_doc *.ps Property changes on: trunk/Toss/www/Publications ___________________________________________________________________ Modified: svn:ignore - # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.xml.de *.xml.en *.html *.html.de *.html.en all.texml all.xml *~ + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.xml.de *.xml.en *.xml.pl *.html *.html.de *.html.en *.html.pl all.texml all.xml *~ Modified: trunk/Toss/www/Publications/.cvsignore =================================================================== --- trunk/Toss/www/Publications/.cvsignore 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/Publications/.cvsignore 2011-03-14 03:24:33 UTC (rev 1358) @@ -4,9 +4,11 @@ *.xml.de *.xml.en +*.xml.pl *.html *.html.de *.html.en +*.html.pl all.texml all.xml Modified: trunk/Toss/www/Publications/Makefile =================================================================== --- trunk/Toss/www/Publications/Makefile 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/Publications/Makefile 2011-03-14 03:24:33 UTC (rev 1358) @@ -1,6 +1,6 @@ TOPDIR = .. BINDIR = $(TOPDIR)/bin -LANGS = de en +LANGS = de en pl BIB_FILES = $(wildcard ./*.bib) BIBTEXML_TEX_FILES = $(patsubst %.bib,%.texml,$(BIB_FILES)) Modified: trunk/Toss/www/contact.xml =================================================================== --- trunk/Toss/www/contact.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/contact.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -6,13 +6,14 @@ <personal> <title lang="en">Contact and Links</title> <title lang="de">Kontakt und Links</title> + <title lang="pl">Kontakt i Linki</title> <history> <link id="contact" href="/contact.html">Contact</link> </history> <portrait src="http://sflogo.sourceforge.net/sflogo.php?group_id=115606&type=15"/> - <section title="Email"> + <section title="Email" lang="en"> <par>Toss is an open source project hosted by <a href="http://sourceforge.net">SourceForge</a> and distributed under the BSD licence.<br/></par> @@ -20,8 +21,24 @@ <mailto address="tos...@li..."/> </par> </section> + <section title="Email" lang="de"> + <par>Toss ist ein Open-Source Projekt, wird auf + <a href="http://sourceforge.net">SourceForge</a> + gehosted und eine BSD Licence disribuiert.<br/></par> + <par>Man kann uns unter folgener Addresse erreichen: + <mailto address="tos...@li..."/> + </par> + </section> + <section title="Email" lang="pl"> + <par>Toss jest projektem open source z hostem na + <a href="http://sourceforge.net">SourceForge</a> + i pod licencja BSD.<br/></par> + <par>Najłatwiej się z nami skontaktować pisząc na + <mailto address="tos...@li..."/> + </par> + </section> - <section title="Toss Links"> + <section title="Toss Links" lang="en"> <itemize> <item><a href="http://sourceforge.net/projects/toss/">Toss Project at SourceForge.net</a></item> @@ -29,6 +46,22 @@ Toss Subversion Repository</a></item> </itemize> </section> + <section title="Links von Toss" lang="de"> + <itemize> + <item><a href="http://sourceforge.net/projects/toss/">Toss Project at + SourceForge.net</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/"> + Toss Subversion Repository</a></item> + </itemize> + </section> + <section title="Linki Tossa" lang="pl"> + <itemize> + <item><a href="http://sourceforge.net/projects/toss/">Toss Project at + SourceForge.net</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/"> + Toss Subversion Repository</a></item> + </itemize> + </section> <section title="Game Playing Links"> Modified: trunk/Toss/www/create.xml =================================================================== --- trunk/Toss/www/create.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/create.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -6,24 +6,55 @@ <personal> <title lang="en">Create New Games</title> <title lang="de">Neue Spiele Erzeugen</title> + <title lang="pl">Stwórz Nową Grę</title> <history> <link id="create" href="/create.html">Create</link> </history> - <section title="Two Ways to Create a New Game"> + + <section title="Two Ways to Create a New Game" lang="en"> <par>When you are done playing the games already defined in Toss, it's time to start the real fun – create your own game! There are two ways to create a game in Toss.</par> <itemize> - <item>You can use the GUI to edit and create games</item> - <item>You can edit the .toss files directly</item> + <item>You can use the GUI to edit and create games.</item> + <item>You can edit the .toss files directly.</item> </itemize> - If you plan to make small changes or an easy experiment, the GUI might - be the better option. For larger or completely new games, it is more - convenient to edit the files in your favorite text editor. + <par>If you plan to make small changes or an easy experiment, the GUI might + be the better option. For larger or completely new games, it is more + convenient to edit the files in your favorite text editor.</par> </section> + + <section title="Zwei Methoden um ein neues Spiel in Toss zu erzeugen" + lang="de"> + <par>Wenn man schon genug online gespielt hat, kann man mit den wirklichen + Spass in Toss anfangen und ein neues Spiel erschaffen. Zwei Wege + kann man dazu nutzen.</par> + <itemize> + <item>Die Toss GUI erlaubt es, Spiele zu erzeugen.</item> + <item>Die .toss Files kann man auch direkt editieren.</item> + </itemize> + <par>Um kleine Änderungen zu machen oder ein einfaches Beispiel zu + definieren kann man wohl die GUI benutzen. Um kompliziertere Spiele zu + erzeugen und ganz neue Ideen zu realisieren ist es bequemer, die .toss + Files direkt in einem Editor zu bearbeiten.</par> + </section> - <section title="Creating Games in Toss GUI"> + <section title="Dwa Sposoby Tworzenia Nowych Gier w Tossie" lang="pl"> + <par>Gdy już znudzi Ci się granie online, czas na prawdziwą zabawę + z Tossem – stwórz swoją własną grę! W Tossie są dwa sposoby + na tworzenie własnych gier.</par> + <itemize> + <item>Można użyć interfejsu graficznego Tossa (GUI).</item> + <item>Możliwa jest też bezpośrednia edycja plików .toss.</item> + </itemize> + <par>Do małych zmian i prostych eksperymentów wystarczy użycie GUI, + natomiast dla nowych i bardziej skomplikowanych gier wygodniej jest + bezpośrednio edytować pliki .toss w edytorze tekstu.</par> + </section> + + + <section title="Creating Games the in the Toss GUI" lang="en"> <par>To start the Toss GUI do the following.</par> <itemize> <item><em>Download</em> Toss from the @@ -36,13 +67,47 @@ <par>When you have the GUI running, we recommend that you watch the <a href="http://vimeo.com/10110495">Toss Tutorial</a> below, which shows all the steps needed to define a simple game in Toss and explains - several other features. Alternatively, you can take a look at our - <a href="gui_interface.html">GUI interface</a> description page - and play with the examples.<br/></par> + several other features.<br/></par> <par><br/><toss-video/></par> </section> - <section title="Creating Games in Text Editor" lang="en"> + <section title="Spiele im Toss GUI Erzeugen" lang="de"> + <par>Um die Toss GUI zu starten, muss man:</par> + <itemize> + <item>Toss <em>runterladen</em> von der + <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> + SourceForge Seite</a>.</item> + <item><em>Toss ausführen</em>, indem man auf <em>Toss.py</em> clickt. + Man kann am Anfang einer der Files im <em>examples</em> Verzeichniss + öffnen.</item> + </itemize> + <par>Wenn die GUI schon läuft, kann man am besten den + <a href="http://vimeo.com/10110495">Toss Tutorial</a> unten angucken, + wo es gezeigt wird, wie man ein einfaches Spiel in Toss vollständig + definiert und wo auch andere Features erklärt sind.<br/></par> + <par><br/><toss-video/></par> + </section> + + + <section title="Tworzenie Gier w Interfejsie Graficznym Tossa" lang="pl"> + <par>Aby uruchomić interfejs graficzny Tossa:</par> + <itemize> + <item><em>Ściągnij</em> Tossa ze + <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> + strony SourceForge</a>.</item> + <item><em>Uruchom Tossa</em> klikając na <em>Toss.py</em>. + Na początek najlepiej otworzyć przykład z katalogu <em>examples</em>. + </item> + </itemize> + <par>Gdy GUI Tossa już działa, polecamy obejrzeć i wykonać poniższy + <a href="http://vimeo.com/10110495">Toss Tutorial</a>. + Pokazane tam są wszystkie kroki do zdefiniowania prostej gry w Tossie, + a także wyjaśnione niektóre bardziej zaawansowane możliwości.<br/></par> + <par><br/><toss-video/></par> + </section> + + + <section title="Creating Games in your Text Editor" lang="en"> <par>For larger games, we find it easier to edit them in text form than from the GUI. To understand the meaning of the fields in the text file, you should probably first be acquainted with @@ -58,5 +123,40 @@ </itemize> </section> + <section title="Spiele in Text Form erschaffen" lang="de"> + <par>Wir glauben, dass es für kompliziertere Spiele einfacher ist, + ein Texteditor zu benutzen als die Toss GUI immer zu starten. + Um die verschiedenen Felder im .toss Files zu verstehen ist es aber + nötig, erstmal die Grundlagen von Toss durchzuarbeiten, z.B. indem + man das Tutorial oben durchgeht, und auch das + <a href="reference/reference.pdf">reference.pdf</a> File wenigstens + durchzublättert, und auch die <a href="docs.html">Dokumentation</a>. + Danach kann man einfach die .toss Files im Editor + bearbeiten, Mit einer von den folgenden kann man gut anfangen. + </par> + <itemize> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss?revision=1349">Chess</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss?revision=1349">Tic-Tac-Toe</a></item> + </itemize> + </section> + <section title="Tworzenie Gier w Edytorze Tekstu" lang="pl"> + <par>Gdy gry stają się bardziej skomplikowane, łatwiej bezpośrednio + edytować pliki .toss niż za każdym razem uruchamiać GUI Tossa. + Jednak żeby zrozumieć co znaczą poszczególne pola w pliku .toss trzeba + znać już podstawy Tossa – np. obejrzeć tutorial powyżej, oraz + przynajmniej przekartkować plik + <a href="reference/reference.pdf">reference.pdf</a> i zerknąć na + <a href="docs.html">dokumentację</a>. Potem można po prostu + edytować pliki .toss, być może zaczynając od jednego z tych. + </par> + <itemize> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss?revision=1349">Chess</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss?revision=1349">Tic-Tac-Toe</a></item> + </itemize> + </section> + + </personal> Modified: trunk/Toss/www/default.mak =================================================================== --- trunk/Toss/www/default.mak 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/default.mak 2011-03-14 03:24:33 UTC (rev 1358) @@ -1,5 +1,5 @@ BINDIR = $(TOPDIR)/bin -LANGS = de en +LANGS = de en pl BIB_FILES = $(wildcard ./*.bib) BIBTEXML_TEX_FILES = $(patsubst %.bib,%.texml,$(BIB_FILES)) @@ -75,6 +75,14 @@ chmod 664 $@ ;\ fi +%.html.pl : LANG=pl +%.html.pl : %.xml.pl $(AUXILIARY_FILES) $(XSL_FILES) $(BIBTEXML_FILES) + lang=$(LANG) ; if [ -n "$$lang" ] ; then \ + xsltproc $(XSLTPROC_PARAM) --stringparam "lang" "$(LANG)" --stringparam "uri" "$<" $< \ + | $(BINDIR)/hrefprocess "$(TOPDIR)" "$(LANG)" > $@ ;\ + chmod 664 $@ ;\ + fi + %.html : %.html.en @echo Modified: trunk/Toss/www/develop.xml =================================================================== --- trunk/Toss/www/develop.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/develop.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -6,11 +6,12 @@ <personal> <title lang="en">Develop Toss</title> <title lang="de">Toss Ausbauen</title> + <title lang="pl">Programuj Tossa</title> <history> <link id="develop" href="/develop.html">Develop Toss</link> </history> - <section title="Preparation"> + <section title="Preparation" lang="en"> <itemize> <item>Except for the interfaces, most of Toss is programmed in <a href="http://caml.inria.fr/">Objective Caml</a>. You will need @@ -36,7 +37,60 @@ it succeeds.</item> </itemize> </section> - + <section title="Vorbereitung" lang="de"> + <itemize> + <item>Except for the interfaces, most of Toss is programmed in + <a href="http://caml.inria.fr/">Objective Caml</a>. You will need + a good understanding of OCaml and a full OCaml installation + to work on the Toss Engine. + </item> + <item>Toss <em>build system</em> is based on <em>ocamlbuild</em> + and uses <em>Makefiles</em> for compilation of the C parts. + You will need a system which supports these to build Toss. + </item> + <item>If you want to develop Toss on Ubuntu, here is a command with + a list of packages to install.<br/> + sudo apt-get install g++ python-qt4 python-dev pyqt4-dev-tools + ocaml-findlib menhir libounit-ocaml-dev libapache2-mod-python + sqlite3 python-pysqlite2 + </item> + <item>This command will checkout the + <a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/">Toss + SVN Repository</a> to the <em>Toss</em> directory.<br/> + svn co https://toss.svn.sourceforge.net/svnroot/toss/trunk/Toss Toss + </item> + <item>In the Toss directory run <em>make</em> and check that + it succeeds.</item> + </itemize> + </section> + <section title="Przygotowanie" lang="pl"> + <itemize> + <item>Except for the interfaces, most of Toss is programmed in + <a href="http://caml.inria.fr/">Objective Caml</a>. You will need + a good understanding of OCaml and a full OCaml installation + to work on the Toss Engine. + </item> + <item>Toss <em>build system</em> is based on <em>ocamlbuild</em> + and uses <em>Makefiles</em> for compilation of the C parts. + You will need a system which supports these to build Toss. + </item> + <item>If you want to develop Toss on Ubuntu, here is a command with + a list of packages to install.<br/> + sudo apt-get install g++ python-qt4 python-dev pyqt4-dev-tools + ocaml-findlib menhir libounit-ocaml-dev libapache2-mod-python + sqlite3 python-pysqlite2 + </item> + <item>This command will checkout the + <a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/">Toss + SVN Repository</a> to the <em>Toss</em> directory.<br/> + svn co https://toss.svn.sourceforge.net/svnroot/toss/trunk/Toss Toss + </item> + <item>In the Toss directory run <em>make</em> and check that + it succeeds.</item> + </itemize> + </section> + + <section title="Understanding Toss"> <itemize> <item><a href="create.html">Create</a> at least one simple game Modified: trunk/Toss/www/docs.xml =================================================================== --- trunk/Toss/www/docs.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/docs.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -6,18 +6,34 @@ <personal> <title lang="en">Documentation</title> <title lang="de">Dokumentation</title> + <title lang="pl">Dokumentacja</title> <history> <link id="docs" href="/docs.html">Documentation</link> </history> - <section title="Using Toss"> + <section title="Using Toss" lang="en"> <par>If you want to learn how to use Toss to create games, go to the <a href="create.html">Create Games</a> page or just watch the video tutorial below to get started.<br/></par> <par><br/><toss-video/></par> </section> - <section title="Reference"> + <section title="Toss Benutzen" lang="de"> + <par>Um zu lehrnen wie man Toss benutzt um neue Spiele zu erschaffen, + besuche die <a href="create.html">Neue Spiele Erzeugen</a> Seite oder + fange schnell an mit dem Video Tutorial unten.<br/></par> + <par><br/><toss-video/></par> + </section> + + <section title="Używanie Tossa" lang="pl"> + <par>Żeby nauczyć się tworzyć gry w Tossie najlepiej odwiedzić stronę + o <a href="create.html">Tworzeniu Nowych Gier</a> albo szybko obejrzeć + poniższy tutorial.<br/></par> + <par><br/><toss-video/></par> + </section> + + + <section title="Reference" lang="en"> <par>The Toss Design and Specification reference is an evolving document in which we try to describe the high-level mathematical model of Toss and the main ideas used in the implementation. The document is best @@ -25,37 +41,127 @@ a <a href="reference/">html version</a> is available as well for fast fact-checking.</par> </section> + <section title="Referenz" lang="de"> + <par>"Toss Design and Specification" ist ein oft erneuerter Dokument + in dem wir versuchen, ein Übersicht über die mathematische Grundlagen + von Toss und die Hauptideen der Algorithmen die wir implementiert haben + zu geben. Es ist am besten als + <a href="reference/reference.pdf">reference.pdf</a> zu lesen, aber + eine <a href="reference/">html Version</a> mit niedriegerer Qualität + steht auch zur Verfügung falls man etwas ganz schnell finden muss.</par> + </section> + <section title="Opis" lang="pl"> + <par>"Toss Design and Specification" to ciągle zmieniający się dokument, + w którym próbujemy opisać matematyczny model Tossa i najważniejsze + idee i algorytmy użyte w implementacji. Najlepiej oglądać ten opis + jako <a href="reference/reference.pdf">reference.pdf</a>, ale wersja + <a href="reference/">html</a> w niższej jakości też jest dostępna gdy + trzeba coś szybko sprawdzić.</par> + </section> - <section title="Code Documentation"> + + <section title="Code Documentation" lang="en"> We generate <a href="code_doc/">documentation from code comments</a> using <a href="http://caml.inria.fr/pub/docs/manual-ocaml/manual029.html"> ocamldoc</a>. It gives the most up-to date information on our code, modules and their interfaces. </section> + <section title="Quellcode Dokumentation" lang="de"> + Wir erzeugen <a href="code_doc/">Quellcode Dokumentation</a> von + Kommentaren mit Hilfe von + <a href="http://caml.inria.fr/pub/docs/manual-ocaml/manual029.html"> + ocamldoc</a>. Es ist die aktuellste Information über Toss Quellcode, + die Modulen und deren Zussamenhänge.</section> + <section title="Dokumentacja Kodu" lang="pl"> + <a href="code_doc/">Dokumentację z komentarzy w kodzie</a> generujemy + przy pomocy + <a href="http://caml.inria.fr/pub/docs/manual-ocaml/manual029.html"> + ocamldoca</a>. To najbardziej aktualna informacja o kodzie Tossa, + naszych modułach i ich interfejsach. + </section> - <section title="Scientific Background"> + + <section title="Scientific Background of Toss" lang="en"> <par>To learn more about the mathematical background and - the design of Toss, go to the <a href="Publications/">Papers - and Talks</a> page or use the following links.</par> + the design of Toss, use the following links.</par> <itemize> - <item><em>Compact description</em> of the mathematical model behind - Toss and our game playing algorithm can be found in the paper + <item><em>Compact description</em> of the mathematical model behind Toss + and our UCT game playing algorithm can be found in the paper <a href="pub/playing_structure_rewriting_games.pdf">Playing Structure Rewriting Games</a>. </item> - <item> <em>Complexity</em> of a syntactic fragment of Toss was - analyzed in the paper <a href="pub/graph_games_short.pdf"> - Synthesis for Structure Rewriting Systems</a>. + + <item> <em>Complexity</em> of a syntactic fragment of Toss was analyzed in + the paper <a href="pub/graph_games_short.pdf">Synthesis + for Structure Rewriting Systems</a>. </item> + <item><em>Presentation</em> on the mathematics behind Toss was given at <em>IIT Kanpur</em> and can be <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> watched</a> online. </item> + <item><em>Shorter presentation</em> focusing on the AI side was given at <em>AGI 2010</em> and can also be - <a href="http://www.vimeo.com/15326245">watched</a> online.</item> + <a href="http://www.vimeo.com/15326245">watched</a> online. + </item> </itemize> </section> + + <section title="Mathematische Grundlagen von Toss" lang="de"> + <par>Um mehr über Toss zu erfahren, folge diese Links.</par> + <itemize> + <item><em>Eine kompakte Darstellung</em> der mathematischen Modell hinter + Toss findet man in <a href="pub/playing_structure_rewriting_games.pdf"> + Playing Structure Rewriting Games</a>. + </item> + + <item><em>Komplexität</em> einer syntaktischen Fragment of Toss wurde + in dem Paper <a href="pub/graph_games_short.pdf"> + Synthesis for Structure Rewriting Systems</a> analysiert. + </item> + + <item><em>Eine Presentation</em> über die Mathematik von Toss wurde bei + <em>IIT Kanpur</em> gegeben und man kann sie + <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> + online sehen</a>. + </item> + + <item><em>Eine kürzere Presentation</em> über Toss als AI Programm wurde + bei <em>AGI 2010</em> gegeben und man kann die auch + <a href="http://www.vimeo.com/15326245">online sehen</a>. + </item> + </itemize> + </section> + + <section title="Matematyczne Podstawy Tossa" lang="pl"> + <par>Matematyczne podstawy Tossa są bardzo bogate. Poniższe linki + pozwalają zapoznać się z częścią z nich.</par> + <itemize> + <item><em>Zwięzły opis</em> matematycznego modelu używanego w Tossie + i algorytmu UCT znajduje się w pracy + <a href="pub/playing_structure_rewriting_games.pdf">Playing + Structure Rewriting Games</a>. + </item> + + <item><em>Złożoność</em> pewnego składniowego fragmentu Tossa została + opisana w pracy <a href="pub/graph_games_short.pdf">Synthesis + for Structure Rewriting Systems</a>. + </item> + + <item><em>Prezentacja</em> matematycznego modelu Tossa udzielona w + <em>IIT Kanpur</em> w Indiach w 2010 jest + <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> + dostępna online</a>. + </item> + + <item><em>Krótsza prezentacje</em> Tossa skupiająca się na sztucznej + inteligencji była częścią <em>AGI 2010</em> i też jest + <a href="http://www.vimeo.com/15326245">dostępna online</a>. + </item> + </itemize> + </section> + </personal> Modified: trunk/Toss/www/examples.xml =================================================================== --- trunk/Toss/www/examples.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/examples.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -6,51 +6,127 @@ <personal> <title lang="en">Examples</title> <title lang="de">Beispiele</title> + <title lang="pl">Przykłady</title> <history> <link id="create" href="/create.html">Create New Games</link> <link id="examples" href="/examples.html">Examples</link> </history> - <section title="Simple Games"> - <par>We use tic-tac-toe as the simplest example of a game. + <section title="Tic-Tac-Toe" lang="en"> + <par>We use Tic-Tac-Toe as the simplest example of a game. The players play by assigning P and Q to blank positions and the winning condition is given as a formula. You can click - <i>Hint</i> to get a move suggestion from Toss.</par> + <i>Hint</i> to get a move suggestion from Toss. + </par> + <itemize> + <item><em>(1) Tic-Tac-Toe.</em> + A simple Tic-Tac-Toe game modelled using a structure.</item> + </itemize> + <a href="tic_tac_toe_screen.png"> + <image src="tic_tac_toe_screen_small.png" /> + </a> + </section> + <section title="Drei Gewinnt (Tic-Tac-Toe)" lang="de"> + <par>Tic-Tac-Toe ist das einfachste Spiel in Toss. + Die Spieler müssen nur die P und Q Prädikate an leere Positionen + plazieren und die Gewinnbedingug ist durch eine einfache Formel gegeben. + Man kann in Toss auch auf <i>Hint</i> klicken um ein Hinweis zu + bekommen.</par> <itemize> - <item><em>(1) Tic Tac Toe</em> - A simple tic-tac-toe game modelled using a structure.</item> + <item><em>(1) Tic Tac Toe.</em> + Ein einfaches Tic-Tac-Toe Spiel in Toss.</item> </itemize> <a href="tic_tac_toe_screen.png"> <image src="tic_tac_toe_screen_small.png" /> </a> </section> - <section title="Basic Board Games"> + <section title="Kółko i Krzyżyk (Tic-Tac-Toe)" lang="pl"> + <par>Kółko i Krzyżyk to jedna z najprostszych gier w Tossie. + Gracze muszą tylko używac predykatów P i Q i wstawiać je na + odpowiednie elementy w strukturze. Wypłaty są też zadane bardzo + prostymi formułami. Można kliknąć na <i>Hint</i> w Tossie aby + dostać wskazówkę ruchu.</par> + <itemize> + <item><em>(1) Kółko i Krzyżyk.</em> + Bardzo prosta gra w Kółko i Krzyżyk w Tossie.</item> + </itemize> + <a href="tic_tac_toe_screen.png"> + <image src="tic_tac_toe_screen_small.png" /> + </a> + </section> + + + <section title="Basic Board Games" lang="en"> <par>Here are more examples of board games which you can construct - with Toss.</par> - + with the Toss GUI easily.</par> <itemize> - <item><em>(2) Gomoku</em> + <item><em>(2) Gomoku.</em> This is the Gomoku (Connect-5) game played on an 8x8 board.</item> - <item><em>(3) Breakthrough</em> - Standard breakthrough game.</item> + <item><em>(3) Breakthrough.</em> + Standard Breakthrough game.</item> </itemize> + <a href="imgs/gomoku_screen.png"> + <image src="gomoku_screen_small.png" /></a> + <a href="imgs/breakthrough_screen.png"> + <image src="breakthrough_screen_small.png" /></a> + </section> + <section title="Einfache Brettspiele" lang="de"> + <par>Hier geben wir einige andere Beispiele von Brettspiele, + die man leicht in Toss GUI erschaffen kann.</par> + <itemize> + <item><em>(2) Gomoku.</em> + Das ist Gomoku (Fünf in eine Reihe) auf einem 8x8 Brett.</item> + <item><em>(3) Breakthrough.</em> + Das Spiel Durchbruch (Breakthrough).</item> + </itemize> <a href="imgs/gomoku_screen.png"> <image src="gomoku_screen_small.png" /></a> + <a href="imgs/breakthrough_screen.png"> + <image src="breakthrough_screen_small.png" /></a> + </section> + <section title="Proste Gry Planszowe" lang="pl"> + <par>Kilka dalszych przykładów gier planszowych które łatwo + stworzyć w GUI Tossa.</par> + <itemize> + <item><em>(2) Gomoku.</em> + Gomoku (5 punktów), japońska gra na planszy 8x8.</item> + <item><em>(3) Breakthrough.</em> + Zwyczajna plansza Breakthrough.</item> + </itemize> + <a href="imgs/gomoku_screen.png"> + <image src="gomoku_screen_small.png" /></a> <a href="imgs/breakthrough_screen.png"> <image src="breakthrough_screen_small.png" /></a> </section> - <section title="More Complex Games"> + + <section title="More Complex Games" lang="en"> <par>To create more complex games, like Chess, it may be more convenient to edit directly the textual game definition files, rather than using only the GUI. Here are a few standard games defined in Toss. You can them use as a starting point for your own definitions.</par> + </section> + <section title="Kompliziertere Spiele" lang="de"> + <par>Um kompliziertere Spiele, wie Schach, zu definieren, kann es + bequemer sein, direkt die text Files (.toss) zu bearbeiten. + Unten geben wir die .toss Files für einige der Standardspiele an. + Man kann diese Files auch als Anfangspunkt für eigene Spiele nutzen.</par> + </section> + + <section title="Bardziej Złożone Gry" lang="pl"> + <par>Gdy definiuje się w Tossie bardziej złożone gry, takie jak szachy, + wygodniej edytować bezpośrednio pliki .toss niż używać tylko GUI. + Poniżej podajemy pliki .toss dla kilku znanych gier, możesz ich + też użyć jako podstawy do stworzenia własnej gry.</par> + </section> + + <section> <itemize> <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Checkers.toss?revision=1349">Checkers</a></item> Modified: trunk/Toss/www/gui_interface.xml =================================================================== --- trunk/Toss/www/gui_interface.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/gui_interface.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -6,6 +6,7 @@ <personal> <title lang="en">GUI Interface Guide</title> <title lang="de">GUI Interface Guide</title> + <title lang="pl">GUI Interface Guide</title> <history> <link id="create" href="/create.html">Create New Games</link> <link id="examples" href="/examples.html">Examples</link> Modified: trunk/Toss/www/index.xml =================================================================== --- trunk/Toss/www/index.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/index.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -21,12 +21,24 @@ </section> <section title="Über Toss" lang="de"> - <par><em>Toss</em> erlaubt es Spiele zu erzeugen, zu analysieren - und zu spielen. Experimentiere mit deine Spielideen und trete + <par><em>Toss</em> erlaubt es, Spiele zu erzeugen, zu analysieren + und zu spielen. Dank einem allgeminen Algorithmus ist es möglich, + ein Spiel zu Bauen und direkt gegen dem Computer zu spielen. + Hast du schon mal gewundert, wie man Schach spielt wenn die Brettmitte + fehlt? Experimentiere mit deine Spielideen und trete gegen deine Freunde online an! </par> </section> + <section title="O Tossie" lang="pl"> + <par><em>Toss</em> jest programem do tworzenia, analizowania + i grania w gry. Dzięki ogólnemu algorytmowi możesz stworzyc grę + i od razu zagrać w nią z komputerem. Na przykład, jak grałoby + się w szachy bez środka planszy? Z Tossem łatwo to sprawdzić! + </par> + </section> + + <games-section> <game-div> <game-link game="Breakthrough"/> @@ -40,62 +52,138 @@ </game-div> </games-section> + <section title="Create New Games" lang="en"> <par>The <a href="http://vimeo.com/10110495">Toss Tutorial</a> below shows all the steps needed to define a simple game in Toss and explains - several other features. Alternatively, you can just take a look at our - <a href="interface.php">Interface</a> page and play with the examples. + several other features. With Toss, you can make your game ideas come + true! Go to the <a href="create.html">Create Games</a> page to learn + how to build new games with Toss. <br/></par> <par><br/><toss-video/></par> </section> <section title="Neue Spiele Erzeugen" lang="de"> - <par>The <a href="http://vimeo.com/10110495">Toss Tutorial</a> below - shows all the steps needed to define a simple game in Toss and explains - several other features. Alternatively, you can just take a look at our - <a href="interface.php">Interface</a> page and play with the examples. + <par>Das <a href="http://vimeo.com/10110495">Toss Tutorial</a> unten + zeigt, wie man in Toss ein einfaches Spiel definieren kann, und es + erklärt auch einige andere Features von Toss. Mit Toss ist es möglich, + deine Spielideen zu realisieren! Lehrne wie man mit Toss neue + <a href="create.html">Spiele erzeugt.</a> + <br/></par> + <par><br/><toss-video/></par> + </section> + + <section title="Stwórz Nową Grę" lang="pl"> + <par><a href="http://vimeo.com/10110495">Tutorial Tossa</a> poniżej + pokazuje, jak zdefiniować prostą grę w Kółko i Krzyżyk w Tossie, + wyjaśnia też inne możliwości Tossa. Dzięki Tossowi możesz zrealizować + swój pomysł na nową grę! Zobacz poniższą stronę i dowiedz się jak + <a href="create.html">stworzyć nową grę</a>. <br/></par> <par><br/><toss-video/></par> </section> - <section title="Features"> + + <section title="Toss Features" lang="en"> <par>Games in Toss are defined as mathematical structures and moves by structure rewriting rules. Payoffs are given by formulas of monadic second-order logic with real values.</par> <itemize> -<item><em>Structures</em> can have an arbitrary number of relations of any arity - and additional real-valued functions.</item> -<item><em>Rules</em> work by matching arbitrary left-hand side structures - and replacing them with a right-hand side structure.</item> -<item><em>Continuous dynamics</em> can be specified using ODEs. - This allows for example to simulate movements and collisions.</item> -<item><em>Constraints</em> can be put on the rule, including preconditions, - invariants and postconditions.</item> -<item><em>Logic</em> is used for constraints and payoffs. We support full monadic - second-order logic with additional real arithmetic.</item> -<item><em>Solver</em> in Toss is optimized: it does quantifier elimination and - formula decomposition (with <a href="http://minisat.se/">MiniSat</a>).</item> -<item><em>Move hints</em> are given in all games using our general - game playing algorithm based on UCT or Maximax.</item> + <item><em>Structures</em> can have an arbitrary number of relations of + any arity and additional real-valued functions.</item> + <item><em>Rules</em> work by matching arbitrary left-hand side structures + and replacing them with the right-hand side structure.</item> + <item><em>Continuous dynamics</em> can be specified using ODEs. + This allows for example to simulate movements and collisions.</item> + <item><em>Constraints</em> can be put on the rule, including + preconditions, invariants and postconditions.</item> + <item><em>Logic</em> is used for constraints and payoffs. We support + full monadic second-order logic with additional real arithmetic.</item> + <item><em>Solver</em> in Toss is optimized: it does quantifier + elimination and formula decomposition + (with <a href="http://minisat.se/">MiniSat</a>).</item> + <item><em>Move hints</em> are given in all games using our general + game playing algorithm based on UCT or Maximax.</item> </itemize> </section> - <section title="Background"> + + <section title="Eigenschaften von Toss" lang="de"> + <par>Die Spiele in Toss sind durch relationale Strukturen definiert, + und die Züge durch Graphersetzungregeln. Das Ergebniss eines Spiels + wird durch Formeln der monadischer Logik zweiter Stufe definiert, die + in Toss mit Zählquantoren erweitert ist, um reele Werte zu liefern.</par> + <itemize> + <item><em>Strukturen</em> in Toss können beliebiege Relationen beinhalten + und dazu noch zusätzliche Funktionen mir reelen Werte.</item> + <item><em>Ersetzungsregeln</em> werden ausgeführt indem die Struktur + auf der linken Seite mit der Hauptstruktur gematcht wird und danach + mit der auf der rechten Seite ersetzt wird.</item> + <item><em>Kontinuerliche dynamik</em> kann durch ein ODE System + eingegeben werden. Das erlaubt die Simulation von Bewegung und + andere physykalischen Eigenschaften der Objekte.</item> + <item><em>Zusätzliche Bedingungen</em> können die Ersetzungsregeln + beschränken. Dazu gehören Prekonditionen, Invarianten, und + Postkonditionen.</item> + <item><em>Logik</em> wird benutzt, um die Bedingungen und die Ergebnisse + zu definieren. In Toss ist die vollständige monadische Logik zweiter + Stufe implementiert, mit zusätzlichen Zählquantoren.</item> + <item><em>Der Solver</em> in Toss ist stark optimiert. Es eliminiert + die Quantoren wenn möglich und dekomponiert die Formel + (mit Hilfe von <a href="http://minisat.se/">MiniSat</a>).</item> + <item><em>Hinweise</em> können dadurch allgemein in allen Spielen + gegeben werden, der Zugauswahl passiert durch UCT oder Maximax.</item> + </itemize> + </section> + + <section title="Funkcje Tossa" lang="pl"> + <par>Gry w Tossie są zdefiniowane jako matematyczne struktury, + a ruchy zadane przez reguły przepisywania struktur. Wypłaty na + końcu gry definiujemy formułami monadycznej logiki drugiego rzędu, + rozszerzonej o termy z wartościami rzeczywistymi, np. zliczaniem.</par> + <itemize> + <item><em>Struktury</em> mogą zawierać dowolne relacje i dodatkowo + funkcje w wartościami rzeczywistymi.</item> + <item><em>Reguły przepisywania</em> dopasowują dowolną strukturę z + lewej strony reguły do głównej struktury i zastępują ją strukturą + z prawej strony reguły.</item> + <item><em>Dynamika</em> (ciągła) układu może być zadana systemem + zwyczajnych równań różniczkowych (ODE), co pozwala symulować ruch + i inne własności fizyczne układu.</item> + <item><em>Więzy</em> dla reguł mogą być zadane jako dowolne formuły. + Dopuszczalne są zarówno pre-kondycje, niezmienniki, jak i post-kondycje. + </item> + <item><em>Logika</em> służy do definiowania więzów jak i wyników gier + i reguł. W Tossie dopuszczmy pełną monadyczną logikę drugiego rzędu z + dodatkowymi kwantyfikatorami o wartościach rzeczywistch, + jak np. zliczanie.</item> + <item><em>Solver</em> w Tossie jest zoptymalizowany dla naszych formuł. + Wykonuje eliminację kwantyfikatorów gdzie to możliwe i rozkład formuł + (przy pomocy <a href="http://minisat.se/">MiniSata</a>).</item> + <item>Dzięki temu <em>Podpowiedzi Ruchu</em> są automatycznie generowane + dla każdej gry w Tossie. Ruch jest wybierany na bazie + UCT lub Maximaxa.</item> + </itemize> + </section> + + + <section title="Scientific Background of Toss" lang="en"> <par>To learn more about the mathematical background and the design of Toss, use the following links.</par> <itemize> <item><em>Compact description</em> of the mathematical model behind Toss - and our game playing algorithm can be found in the paper - <a href="http://logic.rwth-aachen.de/~kaiser/playing_structure_rewriting_games.pdf">Playing Structure Rewriting Games</a>. + and our UCT game playing algorithm can be found in the paper + <a href="pub/playing_structure_rewriting_games.pdf">Playing + Structure Rewriting Games</a>. </item> - + <item><em>Design and specification</em> of Toss are described in - the <a href="reference.pdf">reference.pdf</a> document. + the <a href="reference/reference.pdf">reference.pdf</a> document. </item> <item> <em>Complexity</em> of a syntactic fragment of Toss was analyzed in - the paper <a href="http://logic.rwth-aachen.de/~kaiser/graph_games_short.pdf"> - Synthesis for Structure Rewriting Systems</a>. + the paper <a href="pub/graph_games_short.pdf">Synthesis + for Structure Rewriting Systems</a>. </item> <item><em>Presentation</em> on the mathematics behind Toss was given at @@ -111,4 +199,66 @@ </itemize> </section> + <section title="Mathematische Grundlagen von Toss" lang="de"> + <par>Um mehr über Toss zu erfahren, folge diese Links.</par> + <itemize> + <item><em>Eine kompakte Darstellung</em> der mathematischen Modell hinter + Toss findet man in <a href="pub/playing_structure_rewriting_games.pdf"> + Playing Structure Rewriting Games</a>. + </item> + + <item><em>Design und Specifikation</em> von Toss sind im + <a href="reference/reference.pdf">reference.pdf</a> beschrieben. + </item> + + <item><em>Komplexität</em> einer syntaktischen Fragment of Toss wurde + in dem Paper <a href="pub/graph_games_short.pdf"> + Synthesis for Structure Rewriting Systems</a> analysiert. + </item> + + <item><em>Eine Presentation</em> über die Mathematik von Toss wurde bei + <em>IIT Kanpur</em> gegeben und man kann sie + <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> + online sehen</a>. + </item> + + <item><em>Eine kürzere Presentation</em> über Toss als AI Programm wurde + bei <em>AGI 2010</em> gegeben und man kann die auch + <a href="http://www.vimeo.com/15326245">online sehen</a>. + </item> + </itemize> + </section> + + <section title="Matematyczne Podstawy Tossa" lang="pl"> + <par>Matematyczne podstawy Tossa są bardzo bogate. Poniższe linki + pozwalają zapoznać się z częścią z nich.</par> + <itemize> + <item><em>Zwięzły opis</em> matematycznego modelu używanego w Tossie + i algorytmu UCT znajduje się w pracy + <a href="pub/playing_structure_rewriting_games.pdf">Playing + Structure Rewriting Games</a>. + </item> + + <item><em>Design i specyfikacja</em> Tossa są opisane w + <a href="reference/reference.pdf">reference.pdf</a>. + </item> + + <item><em>Złożoność</em> pewnego składniowego fragmentu Tossa została + opisana w pracy <a href="pub/graph_games_short.pdf">Synthesis + for Structure Rewriting Systems</a>. + </item> + + <item><em>Prezentacja</em> matematycznego modelu Tossa udzielona w + <em>IIT Kanpur</em> w Indiach w 2010 jest + <a href="http://www2.cse.iitk.ac.in/~fsttcs/2009/videos/star/LukaszKaiser.avi"> + dostępna online</a>. + </item> + + <item><em>Krótsza prezentacje</em> Tossa skupiająca się na sztucznej + inteligencji była częścią <em>AGI 2010</em> i też jest + <a href="http://www.vimeo.com/15326245">dostępna online</a>. + </item> + </itemize> + </section> + </personal> Modified: trunk/Toss/www/navigation.xml =================================================================== --- trunk/Toss/www/navigation.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/navigation.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -10,7 +10,7 @@ >Download Toss</item> <menu title="Create Games" href="/create.html" id="create"> <item href="http://vimeo.com/10110495" id="tut">Video Tutorial</item> - <item href="/examples.html" id="examples">Basic Examples</item> + <item href="/examples.html" id="examples">Examples</item> <item href="/gui_interface.html" id="gui_interface">GUI Interface Guide</item> </menu> <item href="/play.html" id="play">Watch Toss Play</item> @@ -36,13 +36,38 @@ <item href="/examples.html" id="examples">Beispiele</item> <item href="/gui_interface.html" id="gui_interface">GUI Interface Guide</item> </menu> - <item href="/play.html" id="play">Toss Spielt</item> + <item href="/play.html" id="play">Wie Toss Spielt</item> <menu title="Dokumentation" href="/docs.html" id="docs"> - <item href="/background.html" id="background">Hintergrund</item> + <item href="/reference/reference.pdf" id="refpdf">Referenz (pdf)</item> + <item href="/reference/" id="refhtml">Referenz (html)</item> + <item href="/code_doc/" id="code">Quellcode Dokumentation</item> </menu> <item href="/Publications/" id="Publications">Papers und Talks</item> <item href="/develop.html" id="develop">Toss Ausbauen</item> <item href="/contact.html" id="contact">Kontakt und Links</item> </menu> + +<menu lang="pl"> + <item href="/" id="Home">Strona Domowa</item> + <item href="/ideas.html" id="ideas">Pomysły na GSoC</item> + <item href="http://tplay.org">Graj Online</item> + <item href="http://sourceforge.net/project/showfiles.php?group_id=115606" + >Ściągnij Tossa</item> + <menu title="Twórz Nowe Gry" href="/create.html" id="create"> + <item href="http://vimeo.com/10110495" id="tut">Tutorial Video</item> + <item href="/examples.html" id="examples">Przykłady</item> + <item href="/gui_interface.html" id="gui_interface">Interfejs GUI</item> + </menu> + <item href="/play.html" id="play">Jak Toss Gra</item> + <menu title="Dokumentacja" href="/docs.html" id="docs"> + <item href="/reference/reference.pdf" id="refpdf">Opis (pdf)</item> + <item href="/reference/" id="refhtml">Opis (html)</item> + <item href="/code_doc/" id="code">Dokumentacja Kodu</item> + </menu> + <item href="/Publications/" id="Publications">Prace i Referaty</item> + <item href="/develop.html" id="develop">Programuj Tossa</item> + <item href="/contact.html" id="contact">Kontakt i Linki</item> +</menu> + </navigation> Modified: trunk/Toss/www/play.xml =================================================================== --- trunk/Toss/www/play.xml 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/play.xml 2011-03-14 03:24:33 UTC (rev 1358) @@ -5,12 +5,13 @@ <personal> <title lang="en">Watch Toss Play</title> - <title lang="de">Toss Spielt</title> + <title lang="de">Wie Toss Spielt</title> + <title lang="pl">Jak Toss Gra</title> <history> <link id="play" href="/play.html">Toss Play</link> </history> - <section title="General Game Playing"> + <section title="General Game Playing" lang="en"> <a href="http://en.wikipedia.org/wiki/General_Game_Playing">General Game Playing</a>, GGP in short, is a name for the task of playing a previously unknown game. GGP is currently a popular field of AI, @@ -19,6 +20,7 @@ doing great work. Players which accept games in the GDL format can play on the <a href="http://euklid.inf.tu-dresden.de:8180/ggpserver/"> Dresden GGP Server</a> and Toss recently started competing there as well. + <br/> Games in GDL format are not directly suited for online presentation, but the <a href="http://code.google.com/p/ggp-galaxy/">GGP Galaxy Project</a> has recently started to work on bringing them online – something @@ -26,8 +28,44 @@ the games played by Toss against Fluxplayer on the Dresden Server. </section> + <section title="Allgemeines Spielen (General Game Playing)" lang="de"> + <a href="http://en.wikipedia.org/wiki/General_Game_Playing">General + Game Playing</a>, kurz GGP, fördert von einem Computer dass er + ein vorher unbekanntes Spiel spielt. Es ist ein stark wachsendes KI Feld + mit Wissenschaftler bei <a href="http://games.stanford.edu/">Stanford</a> + und in <a href="http://www.general-game-playing.de/">Deutschland</a>. + Programme, die Spiele in GDL-Format spielen können kann man auf dem + <a href="http://euklid.inf.tu-dresden.de:8180/ggpserver/"> + Dresden GGP Server</a> gegeneinander spielen lassen, und Toss hat + da letztens auch einiger Erfolgreiche Partien gespielt. + <br/> + Spiele im GDL-Format lassen sich nicht direkt Online darstellen, aber + das <a href="http://code.google.com/p/ggp-galaxy/">GGP Galaxy Project</a> + hat letztens angefangen zu versuchen, dieses Problem zu beseitigen. + Die Spiele im Toss-Format kann man dagegen direkt Online ansehen und + spielen. Darunter zeigen wir einige Spiele von Toss gegen Fluxplayer. + </section> - <section title="Breakthrough Games"> + <section title="Ogólne Programy do Gier (General Game Playing)" lang="pl"> + <a href="http://en.wikipedia.org/wiki/General_Game_Playing">General + Game Playing</a> (GGP) to nazwa problemu w którym program komputerowy + musi grać w nieznaną mu wcześniej grę. GGP to obecnie popularny kierunek + AI nad którym pracują w <a href="http://games.stanford.edu/">Stanfordzie</a> + oraz w <a href="http://www.general-game-playing.de/">Niemczech</a>. + Programy grające w gry w formacie GDL mogą rywalizować ze sobą na serwerze + <a href="http://euklid.inf.tu-dresden.de:8180/ggpserver/"> + Dresden GGP Server</a>, gdzie Toss ostatnio też odnosił pewne sukcesy. + <br/> + Gry w formacie GDL nie są niestety przystosowane do bezpośredniego + oglądania i grania przez ludzi, w przeciwieństwie do gier Tossa, choć + <a href="http://code.google.com/p/ggp-galaxy/">GGP Galaxy Project</a> + próbuje ostatnio przystosować nieco GGP do gry online. Toss nie ma tego + problemów, a kilka gier przeciwko dobremu programowi GGP (Fluxplayer) + z serwera z Dresna zostalo przedstawionych ponizej. + </section> + + + <section title="Breakthrough"> <itemize> <item><ggp-game match_id="breakthrough.1297045579170" name="Breakthrough 1"/></item> @@ -72,7 +110,7 @@ </itemize> </section> - <section title="Gomoku Games"> + <section title="Gomoku"> <itemize> <item><ggp-game match_id="connect5.1297281103161" name="Gomoku 1"/></item> @@ -118,7 +156,7 @@ </section> - <section title="Pawn Whopping Games"> + <section title="Pawn Whopping"> <itemize> <item><ggp-game match_id="pawn_whopping_corrected.1297079331820" name="Pawn Whopping 1"/></item> Modified: trunk/Toss/www/styles/screen.css =================================================================== --- trunk/Toss/www/styles/screen.css 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/styles/screen.css 2011-03-14 03:24:33 UTC (rev 1358) @@ -156,7 +156,7 @@ } #parentnav li.selected { - background: url("../img/tabon1.png") no-repeat left top; + background: url("../img/tabon1.png") no-repeat left top; } #parentnav li.selected a, #parentnav li.selected span { Modified: trunk/Toss/www/xsl/books.xsl =================================================================== --- trunk/Toss/www/xsl/books.xsl 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/xsl/books.xsl 2011-03-14 03:24:33 UTC (rev 1358) @@ -29,6 +29,9 @@ <xsl:if test="$lang='en'"> <h1 property="dc:title">Books</h1> </xsl:if> + <xsl:if test="$lang='pl'"> + <h1 property="dc:title">Ksiazki</h1> + </xsl:if> <!-- <xsl:if test="$lang='de'"> <p><em>Der Inhalt dieser Seite ist nur auf Englisch verfügbar.</em></p> Modified: trunk/Toss/www/xsl/include/common.xsl =================================================================== --- trunk/Toss/www/xsl/include/common.xsl 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/xsl/include/common.xsl 2011-03-14 03:24:33 UTC (rev 1358) @@ -73,8 +73,13 @@ <xsl:apply-templates /> <p><a href="http://tplay.org">Weitere Spiele</a></p> </xsl:when> + <xsl:when test="$lang='pl'"> + <h3><a href="http://tplay.org">Zagraj Online z Tossem</a></h3> + <xsl:apply-templates /> + <p><a href="http://tplay.org">Więcej gier</a></p> + </xsl:when> <xsl:otherwise> - <h3><a href="http://tplay.org">Play Online against Toss</a></h3> + <h3><a href="http://tplay.org">Play Online Against Toss</a></h3> <xsl:apply-templates /> <p><a href="http://tplay.org">More Games</a></p> </xsl:otherwise> @@ -170,11 +175,29 @@ </xsl:template> <xsl:template match="game-link"> - <a href="http://tplay.org/index_{@game}.html" - title="Play {@game}" class="game-link" id="game-link-{@game}"> - <img class="game-img" src="{$topdir}/img/{@game}.png" - alt="{@game} Board Image" id="game-img-{@game}" /> - </a> + <xsl:choose> + <xsl:when test="$lang='de'"> + <a href="http://tplay.org/index_{@game}.html" + title="Spiel {@game}" class="game-link" id="game-link-{@game}"> + <img class="game-img" src="{$topdir}/img/{@game}.png" + alt="{@game}Brett" id="game-img-{@game}" /> + </a> + </xsl:when> + <xsl:when test="$lang='pl'"> + <a href="http://tplay.org/index_{@game}.html" + title="Graj w {@game}" class="game-link" id="game-link-{@game}"> + <img class="game-img" src="{$topdir}/img/{@game}.png" + alt="Plansza {@game}" id="game-img-{@game}" /> + </a> + </xsl:when> + <xsl:otherwise> + <a href="http://tplay.org/index_{@game}.html" + title="Play {@game}" class="game-link" id="game-link-{@game}"> + <img class="game-img" src="{$topdir}/img/{@game}.png" + alt="{@game} Board Image" id="game-img-{@game}" /> + </a> + </xsl:otherwise> + </xsl:choose> </xsl:template> <xsl:template match="flag"> Modified: trunk/Toss/www/xsl/include/layout.xsl =================================================================== --- trunk/Toss/www/xsl/include/layout.xsl 2011-03-13 17:36:46 UTC (rev 1357) +++ trunk/Toss/www/xsl/include/layout.xsl 2011-03-14 03:24:33 UTC (rev 1358) @@ -26,8 +26,8 @@ <html xmlns='http://www.w3.org/1999/xhtml' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:foaf='http://xmlns.com/foaf/0.1/' - xml:lang="en" - lang="en"> + xml:lang="{$lang}" + lang="{$lang}"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" type="text/css" href="{$topdir}/styles/common.css" media="all"/> @@ -55,6 +55,9 @@ <xsl:if test="$lang='en'"> <title>Publications</title> </xsl:if> + <xsl:if test="$lang='pl'"> + <title>Publikacje</title> + </xsl:if> </xsl:when> <xsl:when test="$title='Publications' and $author!='all'"> <xsl:variable name="fullname" select="normalize-space(concat(document('../../people.xml')/people/person[@id=$author]/first,' ',document('../../people.xml')/people/person[@id=$author]/last))"/> @@ -64,6 +67,9 @@ <xsl:if test="$lang='en'"> <title>Publications: <xsl:value-of select="$fullname"/></title> </xsl:if> + <xsl:if test="$lang='pl'"> + <title>Publikacje: <xsl:value-of select="$fullname"/></title> + </xsl:if> </xsl:when> <xsl:otherwise> <title><xsl:value-of select="$title"/></title> @@ -126,... [truncated message content] |
From: <luk...@us...> - 2011-03-14 11:11:18
|
Revision: 1359 http://toss.svn.sourceforge.net/toss/?rev=1359&view=rev Author: lukstafi Date: 2011-03-14 11:11:08 +0000 (Mon, 14 Mar 2011) Log Message: ----------- Removed printing of empty relations in rule LHS and RHS structures as these are required to share signature with the model. Comparison of games modulo numbering of elements in structures, flattening of formulas, etc., display the first difference met. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/Arena/ContinuousRule.ml trunk/Toss/Arena/ContinuousRule.mli trunk/Toss/Arena/ContinuousRuleTest.ml trunk/Toss/Arena/DiscreteRule.ml trunk/Toss/Arena/DiscreteRule.mli trunk/Toss/Arena/DiscreteRuleTest.ml trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDLTest.ml trunk/Toss/GGP/GameSimplTest.ml trunk/Toss/Solver/Solver.ml trunk/Toss/Solver/Structure.ml trunk/Toss/Solver/Structure.mli trunk/Toss/Solver/StructureTest.ml trunk/Toss/caml_extensions/pa_backtrace.ml trunk/Toss/examples/rewriting_example.toss Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Arena/Arena.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -347,7 +347,8 @@ Array.iter (fun loc -> Format.fprintf ppf "@[<1>LOC %d@ {@,@[<1>@,%a@]@,}@]@ " loc.id (fprint_loc_body struc player_names) loc) graph; - Format.fprintf ppf "@[<1>MODEL@ %a@]@ " Structure.fprint struc; + Format.fprintf ppf "@[<1>MODEL@ %a@]@ " + (Structure.fprint ~show_empty:true) struc; if cur_loc <> 0 then Format.fprintf ppf "@[<1>STATE LOC@ %d@]@ " cur_loc; if time <> 0. then @@ -391,6 +392,58 @@ drel, (args, f def)) game.defined_rels; } +(* Compare two (game, state) pairs and explain the first difference + met. Formulas and expressions are compared for syntactical + equality. Players need to be given in the same order. Data is ignored. *) +exception Diff_result of string + +let compare_diff ?(cmp_funs=(=)) (g1,s1) (g2,s2) = + try + let eq, msg = + Structure.compare_diff ~cmp_funs s1.struc s2.struc in + if not eq then raise (Diff_result ("Game state models differ: "^msg)); + if not (cmp_funs s1.time s2.time) then raise + (Diff_result ( + Printf.sprintf "Game state times %F and %F differ" s1.time s2.time)); + if s1.cur_loc <> s2.cur_loc then raise + (Diff_result ( + Printf.sprintf "Game state locations %d and %d differ" + s1.cur_loc s2.cur_loc)); + let rules = + try List.combine (List.sort Pervasives.compare g1.rules) + (List.sort Pervasives.compare g2.rules) + with Invalid_argument _ -> raise ( + Diff_result "Games have different number of rules") in + List.iter (fun ((rn1,r1),(rn2,r2))-> + if rn1 < rn2 then + raise (Diff_result ("Second game lacks rule "^rn1)); + if rn2 < rn1 then + raise (Diff_result ("First game lacks rule "^rn2)); + let eq, msg = + ContinuousRule.compare_diff ~cmp_funs r1 r2 in + if not eq then raise (Diff_result ( + "Games differ at rule "^rn1^": "^ msg)) + ) rules; + let cmp_pn (_,i) (_,j) = i-j in + let pnames1 = List.sort cmp_pn g1.player_names in + let pnames2 = List.sort cmp_pn g2.player_names in + if pnames1 <> pnames2 then + raise (Diff_result "Game players are given in different order."); + let norm_loc loc = + {loc with + moves = List.sort Pervasives.compare loc.moves; + payoffs = Array.map ( + FormulaOps.map_to_formulas_expr FormulaOps.flatten_formula) + loc.payoffs} in + if Array.map norm_loc g1.graph <> Array.map norm_loc g2.graph + then raise (Diff_result "Games have different graphs"); + if List.sort Pervasives.compare g1.defined_rels <> + List.sort Pervasives.compare g2.defined_rels + then raise (Diff_result "Games have different defined relations"); + true, "equal" + with Diff_result expl -> false, expl + + (* ------------------ REQUESTS TO THE ARENA USED IN OPERATION --------------- *) (* Location of a structure: either arena or left or right-hand side of a rule *) Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Arena/Arena.mli 2011-03-14 11:11:08 UTC (rev 1359) @@ -111,6 +111,15 @@ val map_to_formulas : (Formula.formula -> Formula.formula) -> game -> game +(** Compare two (game, state) pairs and explain the first difference + met. Formulas and expressions are compared for syntactical + equality. Players need to be given in the same order. Data is + ignored. *) +val compare_diff : + ?cmp_funs:(float -> float -> bool) -> + game * game_state -> game * game_state -> bool * string + + (** {2 Requests to the Arena used in Operation} *) (** Location of a structure: either arena or left or right-hand side of a rule *) Modified: trunk/Toss/Arena/ContinuousRule.ml =================================================================== --- trunk/Toss/Arena/ContinuousRule.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Arena/ContinuousRule.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -239,3 +239,25 @@ ignore (Format.flush_str_formatter ()); fprint Format.str_formatter r; Format.flush_str_formatter () + + +(* Compare two rules and explain the first difference + met. Formulas and expressions are compared for structural equality. *) +exception Diff_result of string + +let compare_diff ?(cmp_funs=(=)) r1 r2 = + try + let eq, msg = + DiscreteRule.compare_diff ~cmp_funs r1.discrete r2.discrete in + if not eq then raise (Diff_result msg); + if List.sort Pervasives.compare r1.dynamics <> + List.sort Pervasives.compare r2.dynamics + then raise (Diff_result "Rule dynamics differ"); + if List.sort Pervasives.compare r1.update <> + List.sort Pervasives.compare r2.update + then raise (Diff_result "Rule update functions differ"); + if r1.inv <> r2.inv then raise (Diff_result "Rule invariants differ"); + if r1.post <> r2.post then + raise (Diff_result "Rule postconditions differ"); + true, "equal" + with Diff_result expl -> false, expl Modified: trunk/Toss/Arena/ContinuousRule.mli =================================================================== --- trunk/Toss/Arena/ContinuousRule.mli 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Arena/ContinuousRule.mli 2011-03-14 11:11:08 UTC (rev 1359) @@ -88,3 +88,9 @@ (int * int) list -> rule -> float -> (string * float) list -> (Structure.structure * float * ((string * string) * Term.term list) list) option + +(** Compare two rules and explain the first difference + met. Formulas and expressions are compared for structural equality. *) +val compare_diff : + ?cmp_funs:(float -> float -> bool) -> + rule -> rule -> bool * string Modified: trunk/Toss/Arena/ContinuousRuleTest.ml =================================================================== --- trunk/Toss/Arena/ContinuousRuleTest.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Arena/ContinuousRuleTest.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -128,6 +128,42 @@ ); + "compare_diff" >:: + (fun () -> + let discr = + "[a, b | R (a, b) | ] -> [c, d | R (c, d) | ] emb R with [c <- a, d <- b] " in + let s = discr ^ " pre true inv true post true" in + let signat = ["R", 2] in + let r1 = rule_of_str s signat [] "rule1" in + let r2 = rule_of_str s signat [] "rule2" in + assert_equal ~printer:(fun (_,x)->x) ~msg:"1. no continuous" + (true,"equal") + (ContinuousRule.compare_diff r1 r2); + + let upd_eq = " f(c) = 2. * f(a);\n f(d) = f(b)\n" in + let s = discr ^ "\nupdate\n" ^ upd_eq ^ " pre true inv true post true" in + let r1 = rule_of_str s signat [] "rule2" in + let upd_eq = " f(c) = 3. * f(a);\n f(d) = f(b)\n" in + let s = discr ^ "\nupdate\n" ^ upd_eq ^ " pre true inv true post true" in + let r2 = rule_of_str s signat [] "rule3" in + assert_equal ~printer:(fun (_,x)->x) ~msg:"2. update" + (false,"Rule update functions differ") + (ContinuousRule.compare_diff r1 r2); + + let upd_eq = " f(c) = 2. * f(a);\n f(d) = f(b)\n" in + let dyn_eq = " f(a)' = (2. * f(a)) + t;\n f(b)' = f(b)" in + let s = discr ^ "\ndynamics\n" ^ dyn_eq ^ "\nupdate\n" ^ upd_eq ^ + " pre true inv true post true" in + let r1 = rule_of_str s signat [] "rule4" in + let dyn_eq = " f(a)' = (3. * f(a)) + t;\n f(b)' = f(b)" in + let s = discr ^ "\ndynamics\n" ^ dyn_eq ^ "\nupdate\n" ^ upd_eq ^ + " pre true inv true post true" in + let r2 = rule_of_str s signat [] "rule5" in + assert_equal ~printer:(fun (_,x)->x) ~msg:"3. dynamics" + (false,"Rule dynamics differ") + (ContinuousRule.compare_diff r1 r2); + ); + ] let a = Modified: trunk/Toss/Arena/DiscreteRule.ml =================================================================== --- trunk/Toss/Arena/DiscreteRule.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Arena/DiscreteRule.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -933,7 +933,7 @@ let opt_s = Aux.concat_map (fun rel -> try - let arity = signat rel in + let arity = List.assoc rel signat in let tups = List.map Array.of_list @@ -965,7 +965,7 @@ let rhs_struc, elem = Structure.add_new_elem rhs_struc ~name () in rhs_struc, (name, elem)::struc_elems) - (Structure.empty_structure (), []) struc_elems in + (Structure.empty_with_signat signat, []) struc_elems in let add_rels = List.fold_left (fun struc (rel, args) -> Structure.add_rel struc rel (Array.map (fun n -> List.assoc n struc_elems) args)) in @@ -1040,8 +1040,8 @@ let fprint_rule f r = Format.fprintf f "@[<1>%a@ ->@ %a" - Structure.fprint r.lhs_struc - Structure.fprint r.rhs_struc; + (Structure.fprint ~show_empty:false) r.lhs_struc + (Structure.fprint ~show_empty:false) r.rhs_struc; if r.emb_rels <> [] then Format.fprintf f "@ @[<1>emb@ %a@]" (Aux.fprint_sep_list "," Format.pp_print_string) r.emb_rels; @@ -1089,3 +1089,58 @@ rhs.Structure.elements [] | Some rs -> List.map (fun (re,le) -> r_elem re, l_elem le) rs + + +(* Compare two rules and explain the first difference + met. Preconditions are compared for structural equality. *) +exception Diff_result of string + +let compare_diff ?(cmp_funs=(=)) r1 r2 = + try + let eq, msg = + Structure.compare_diff ~cmp_funs r1.lhs_struc r2.lhs_struc in + if not eq then raise (Diff_result ( + "Rule LHS structures differ: "^msg)); + let eq, msg = + Structure.compare_diff ~cmp_funs r1.rhs_struc r2.rhs_struc in + if not eq then raise (Diff_result ( + "Rule RHS structures differ: "^msg)); + let pre1 = FormulaOps.flatten_formula r1.pre in + let pre2 = FormulaOps.flatten_formula r2.pre in + if pre1 <> pre2 then raise (Diff_result ( + Printf.sprintf "Rule preconditions differ:\n%s\n =/=\n%s" + (Formula.sprint pre1) (Formula.sprint pre2))); + let embs1 = Aux.list_diff r1.emb_rels r2.emb_rels in + if embs1 <> [] then raise ( + Diff_result ("Relation "^List.hd embs1^ + " is embedded only in the first rule")); + let embs2 = Aux.list_diff r1.emb_rels r2.emb_rels in + if embs2 <> [] then raise ( + Diff_result ("Relation "^List.hd embs2^ + " is embedded only in the second rule")); + (* enough to check that "the diagram commutes" in one direction... *) + List.iter (fun (rhs_e,lhs_e) -> + let lhs_n = Structure.elem_str r1.lhs_struc lhs_e in + let rhs_n = Structure.elem_str r1.rhs_struc rhs_e in + let rhs_e2 = Structure.find_elem r2.rhs_struc rhs_n in + (let try lhs_e2 = List.assoc rhs_e2 r2.rule_s in + let lhs_n2 = Structure.elem_str r2.lhs_struc lhs_e2 in + if lhs_n <> lhs_n2 then raise (Diff_result ( + Printf.sprintf + "RHS element %s is mapped to LHS %s instead of %s in the second rule" + rhs_n lhs_n2 lhs_n)) + with Not_found -> raise (Diff_result ( + Printf.sprintf "Element %s is fresh only in the second rule" + rhs_n))) + ) r1.rule_s; + (* if we check the domain *) + List.iter (fun (rhs_e2,lhs_e2) -> + let rhs_n2 = Structure.elem_str r2.rhs_struc rhs_e2 in + let rhs_e1 = Structure.find_elem r1.rhs_struc rhs_n2 in + if not (List.mem_assoc rhs_e1 r1.rule_s) + then raise (Diff_result ( + Printf.sprintf "RHS element %s is fresh only in the first rule" + rhs_n2)) + ) r2.rule_s; + true, "equal" + with Diff_result expl -> false, expl Modified: trunk/Toss/Arena/DiscreteRule.mli =================================================================== --- trunk/Toss/Arena/DiscreteRule.mli 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Arena/DiscreteRule.mli 2011-03-14 11:11:08 UTC (rev 1359) @@ -131,7 +131,7 @@ val translate_from_precond : precond:Formula.formula -> add:(string * string array) list -> (* del:(string * string array) list -> *) - emb_rels:string list -> signat:(string -> int) -> + emb_rels:string list -> signat:(string * int) list -> struc_elems:string list -> rule (** {2 Printing.} *) @@ -152,3 +152,9 @@ val build_rule_s : ?rule_s:(string * string) list -> Structure.structure -> Structure.structure -> (int * int) list + +(** Compare two rules and explain the first difference + met. Preconditions are compared for structural equality. *) +val compare_diff : + ?cmp_funs:(float -> float -> bool) -> + rule -> rule -> bool * string Modified: trunk/Toss/Arena/DiscreteRuleTest.ml =================================================================== --- trunk/Toss/Arena/DiscreteRuleTest.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Arena/DiscreteRuleTest.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -36,11 +36,11 @@ "sprint: simple" >:: (fun () -> let s= - "[a | P:1 {}; Q (a) | ] -> [b | P (b); Q:1 {} | ] emb Q with [b <- a]" in + "[a | Q (a) | ] -> [b | P (b) | ] emb Q with [b <- a]" in let r = rule_of_str ["Q",1;"P",1] s in assert_equal s ~printer:(fun x->x) (sprint_rule r); - let s="[a | P:1 {}; Q (a) | ] -> [a | P (a); Q:1 {} | ]" in + let s="[a | Q (a) | ] -> [a | P (a) | ]" in let r = rule_of_str ["Q",1;"P",1] s in assert_equal ~printer:(fun x->x) s (sprint_rule r); ); @@ -51,7 +51,7 @@ D {(c, c); (c, a); (c, b); (b, a); (b, b)}; P {c; b}; Q {a; b}; R {(c, c); (a, c); (a, b); (b, c); (b, b)} | f {b->3., a->2., c->4.}; g {a->1., c->5.} - ] -> [b, c | D {(c, b); (c, c)}; P (b); Q:1 {}; R (c, c) | ] emb Q + ] -> [b, c | D {(c, b); (c, c)}; P (b); R (c, c) | ] emb Q with [c <- c, b <- a]" in let r = rule_of_str ["D",2;"R",2;"Q",1;"P",1] s in assert_equal ~printer:(fun x->x) s (sprint_rule r); @@ -683,6 +683,44 @@ (rule_obj_str rule_obj); ); + + "compare_diff" >:: + (fun () -> + let r1 = rule_of_str ["Q",1;"P",1] + "[a | P:1 {}; Q (a) | ] -> [b | P (b); Q:1 {} | ] emb Q with [b <- a]" in + let r2 = rule_of_str ["Q",1;"P",1] + "[a | Q (a) | ] -> [b | P (b) | ] emb Q with [b <- a]" in + assert_equal ~printer:(fun (_,x)->x) + (true,"equal") + (DiscreteRule.compare_diff r1 r2); + + let r1 = rule_of_str ["Q",1;"P",1] + "[a | P (a); Q (a) | ] -> [b | P (b) | ] emb Q with [b <- a]" in + let r2 = rule_of_str ["Q",1;"P",1] + "[a | Q (a) | ] -> [b | P (b) | ] emb Q with [b <- a]" in + assert_equal ~printer:(fun (_,x)->x) + (false,"Rule LHS structures differ: Relation tuple P(a) not found in the second structure") + (DiscreteRule.compare_diff r1 r2); + + let r1 = rule_of_str ["Q",1;"P",1] + "[a | Q (a) | ] -> [b | P (b) | ] emb Q with [b <- a]" in + let r2 = rule_of_str ["Q",1;"P",1] + "[a | Q (a) | ] -> [b | P (b) | ] emb P with [b <- a]" in + assert_equal ~printer:(fun (_,x)->x) + (false,"Relation Q is embedded only in the first rule") + (DiscreteRule.compare_diff r1 r2); + + let r1 = rule_of_str ["Q",1;"P",1] + "[a,b | Q (a); P(b) | ] -> [b | P (b) | ] emb Q with [b <- a]" in + let r2 = rule_of_str ["Q",1;"P",1] + "[a,b | Q (a); P(b) | ] -> [b | P (b) | ] emb Q with [b <- b]" in + assert_equal ~printer:(fun (_,x)->x) + (false, + "RHS element b is mapped to LHS b instead of a in the second rule") + (DiscreteRule.compare_diff r1 r2); + + ); + ] let a = Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/GGP/GDL.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -3382,8 +3382,7 @@ rname ); (* }}} *) - let signat rel = - Structure.StringMap.find rel struc.Structure.rel_signature in + let signat = Structure.rel_signature struc in let discrete = DiscreteRule.translate_from_precond ~precond ~add:rhs_pos ~emb_rels:fluents ~signat ~struc_elems in @@ -3432,7 +3431,7 @@ } in (* {{{ log entry *) (* * - let file = open_out "./GGP/tests/connect5-raw.toss" in + let file = open_out "./GGP/tests/breakthrough-raw.toss" in output_string file (Arena.state_str result); close_out file; * *) @@ -3452,7 +3451,7 @@ ) loc_noop_legal in (* {{{ log entry *) (* * - let file = open_out "./GGP/tests/connect5-simpl.toss" in + let file = open_out "./GGP/tests/breakthrough-simpl.toss" in output_string file (Arena.state_str result); close_out file; * *) @@ -3550,8 +3549,7 @@ (Formula.sprint precond) ); (* }}} *) - let signat rel = - Structure.StringMap.find rel struc.Structure.rel_signature in + let signat = Structure.rel_signature struc in let rule = DiscreteRule.translate_from_precond ~precond ~add ~emb_rels:gdl.fluents ~signat ~struc_elems in Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/GGP/GDLTest.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -5,6 +5,13 @@ GDLParser.parse_game_description KIFLexer.lex (Lexing.from_string s) +let state_of_file s = + let f = open_in s in + let res = + ArenaParser.parse_game_state Lexer.lex + (Lexing.from_channel f) in + res + let load_rules fname = let f = open_in fname in let descr = @@ -83,15 +90,16 @@ (fun () -> let connect5 = load_rules "./GGP/examples/connect5.gdl" in let _, res = GDL.translate_game (Const "x") connect5 in - let goalf = open_in "./GGP/tests/connect5-simpl.toss" in + let goal = state_of_file "./GGP/tests/connect5-simpl.toss" in let resf = open_out "./GGP/tests/connect5-temp.toss" in - let goal_str = Aux.input_file goalf in let res_str = Arena.state_str res in output_string resf res_str; - close_in goalf; close_out resf; - assert_equal - ~msg:"GGP/examples/connect5.gdl to GGP/tests/connect5-simpl.toss, see GGP/tests/connect5-temp.toss" - goal_str res_str; + close_out resf; + let eq, msg = Arena.compare_diff goal res in + assert_bool + ("GGP/examples/connect5.gdl to GGP/tests/connect5-simpl.toss, \ + see GGP/tests/connect5-temp.toss: "^msg) + eq; Sys.remove "./GGP/tests/connect5-temp.toss" ); @@ -99,15 +107,17 @@ (fun () -> let breakthrough = load_rules "./GGP/examples/breakthrough.gdl" in let _, res = GDL.translate_game (Const "white") breakthrough in - let goalf = open_in "./GGP/tests/breakthrough-simpl.toss" in + let goal = state_of_file "./GGP/tests/breakthrough-simpl.toss" in let resf = open_out "./GGP/tests/breakthrough-temp.toss" in - let goal_str = Aux.input_file goalf in let res_str = Arena.state_str res in output_string resf res_str; - close_in goalf; close_out resf; - assert_equal - ~msg:"GGP/examples/breakthrough.gdl to GGP/tests/breakthrough-simpl.toss, see GGP/tests/breakthrough-temp.toss" - goal_str res_str; + close_out resf; + let eq, msg = Arena.compare_diff goal res in + assert_bool + ("GGP/examples/breakthrough.gdl to \ + GGP/tests/breakthrough-simpl.toss, see + GGP/tests/breakthrough-temp.toss: "^msg) + eq; Sys.remove "./GGP/tests/breakthrough-temp.toss" ); @@ -136,5 +146,5 @@ let breakthrough = load_rules "./GGP/examples/breakthrough.gdl" in let connect5 = load_rules "./GGP/examples/connect5.gdl" in let tictactoe = load_rules "./GGP/examples/tictactoe.gdl" in - let gdl_def, toss_def = GDL.translate_game (Const "x") connect5 in + let gdl_def, toss_def = GDL.translate_game (Const "white") breakthrough in ignore gdl_def; ignore connect5; ignore breakthrough; ignore tictactoe Modified: trunk/Toss/GGP/GameSimplTest.ml =================================================================== --- trunk/Toss/GGP/GameSimplTest.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/GGP/GameSimplTest.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -14,15 +14,16 @@ (fun () -> let connect5 = state_of_file "./GGP/tests/connect5-raw.toss" in let res = GameSimpl.simplify connect5 in - let goalf = open_in "./GGP/tests/connect5-simpl.toss" in + let goal = state_of_file "./GGP/tests/connect5-simpl.toss" in let resf = open_out "./GGP/tests/connect5-temp.toss" in - let goal_str = Aux.input_file goalf in let res_str = Arena.state_str res in output_string resf res_str; - close_in goalf; close_out resf; - assert_equal - ~msg:"tests/connect5-raw.toss to tests/connect5-simpl.toss, see GGP/tests/connect5-temp.toss" - goal_str res_str; + close_out resf; + let eq, msg = Arena.compare_diff goal res in + assert_bool + ("tests/connect5-raw.toss to tests/connect5-simpl.toss, see \ + GGP/tests/connect5-temp.toss: "^msg) + eq; Sys.remove "./GGP/tests/connect5-temp.toss" ); @@ -30,15 +31,16 @@ (fun () -> let breakthrough = state_of_file "./GGP/tests/breakthrough-raw.toss" in let res = GameSimpl.simplify breakthrough in - let goalf = open_in "./GGP/tests/breakthrough-simpl.toss" in + let goal = state_of_file "./GGP/tests/breakthrough-simpl.toss" in let resf = open_out "./GGP/tests/breakthrough-temp.toss" in - let goal_str = Aux.input_file goalf in let res_str = Arena.state_str res in output_string resf res_str; - close_in goalf; close_out resf; - assert_equal - ~msg:"tests/breakthrough-raw.toss to tests/breakthrough-simpl.toss, see GGP/tests/breakthrough-temp.toss" - goal_str res_str; + close_out resf; + let eq, msg = Arena.compare_diff goal res in + assert_bool + ("tests/breakthrough-raw.toss to tests/breakthrough-simpl.toss, see \ + GGP/tests/breakthrough-temp.toss: "^msg) + eq; Sys.remove "./GGP/tests/breakthrough-temp.toss" ); Modified: trunk/Toss/Solver/Solver.ml =================================================================== --- trunk/Toss/Solver/Solver.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Solver/Solver.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -142,8 +142,9 @@ if List.exists (fun v -> List.mem v aset_vars) vl then let asg_s = AssignmentSet.str aset in let form_s = Formula.str (Ex (vl, phi)) in - let msg_s = "solver: multiple vars?\n "^ asg_s ^ "\n "^ form_s in - (* failwith msg_s *) Any + (*let msg_s = + "solver: multiple vars?\n "^ asg_s ^ "\n "^ form_s in + failwith msg_s *) Any else aset in let phi_asgn = eval model elems in_aset phi in report (join aset (project_list elems phi_asgn vl)) @@ -153,8 +154,9 @@ if List.exists (fun v -> List.mem v aset_vars) vl then let asg_s = AssignmentSet.str aset in let form_s = Formula.str (Ex (vl, phi)) in - let msg_s = "solver: multiple vars?\n "^ asg_s ^ "\n "^ form_s in - (* failwith msg_s *) Any + (*let msg_s = + "solver: multiple vars?\n "^ asg_s ^ "\n "^ form_s in + failwith msg_s *) Any else aset in let phi_asgn = eval model elems in_aset phi in report (join aset (universal_list elems phi_asgn vl)) Modified: trunk/Toss/Solver/Structure.ml =================================================================== --- trunk/Toss/Solver/Structure.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Solver/Structure.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -483,13 +483,15 @@ (* Print the structure [struc] as string, in extensive form (not using condensed representations like boards). *) -let ext_str struc = +let ext_str ?(show_empty=true) struc = let elem_s = String.concat ", " (List.map (elem_str struc) (Elems.elements struc.elements)) in let (rel_s, fun_s) = (ref "", ref "") in StringMap.iter - (fun rn ts -> rel_s := !rel_s ^ "; " ^ rel_str struc rn ts) + (fun rn ts -> + if show_empty || not (Tuples.is_empty ts) then + rel_s := !rel_s ^ "; " ^ rel_str struc rn ts) struc.relations; StringMap.iter (fun fn vals -> fun_s := !fun_s ^ "; " ^ fun_str struc fn vals) @@ -998,9 +1000,9 @@ board ^ "\"", gc_elems !ret -let str struc = +let str ?(show_empty=true) struc = let board, struc = board_to_string struc in - ext_str struc ^ (if board = "" then "" else " " ^ board) + ext_str ~show_empty struc ^ (if board = "" then "" else " " ^ board) let fprint_rel ?(print_arity=true) struc f (rel_name, ts) = if print_arity && Tuples.is_empty ts then @@ -1023,9 +1025,12 @@ Format.fprintf f "@[<1>%s@ {@,@[<1>%a@]@,}@]" fun_name (Aux.fprint_sep_list "," update) elements -let fprint_ext_structure f struc = +let fprint_ext_structure ~show_empty f struc = let rels = - StringMap.fold (fun k v acc -> (k,v)::acc) struc.relations [] in + StringMap.fold (fun k v acc -> + if show_empty || not (Tuples.is_empty v) then + (k,v)::acc + else acc) struc.relations [] in let funs = StringMap.fold (fun k v acc -> (k,v)::acc) struc.functions [] in let rels = List.rev rels and funs = List.rev funs in @@ -1037,19 +1042,20 @@ (Aux.fprint_sep_list ";" (fprint_rel struc)) rels (Aux.fprint_sep_list ";" (fprint_fun struc)) funs -let fprint f struc = +let fprint ~show_empty f struc = let board, struc = board_to_string struc in - if board = "" then fprint_ext_structure f struc + if board = "" then fprint_ext_structure ~show_empty f struc else (* no line break after the closing bracket to stress that it is the same structure; no formatter breaks inside the board *) Format.fprintf f "%a @[<h 1>%s@]" - fprint_ext_structure struc board + (fprint_ext_structure ~show_empty) struc board -let print struc = fprint Format.std_formatter struc -let sprint struc = +let print ?(show_empty=true) struc = + fprint ~show_empty Format.std_formatter struc +let sprint ?(show_empty=true) struc = ignore (Format.flush_str_formatter ()); - Format.fprintf Format.str_formatter "%a" fprint struc; + Format.fprintf Format.str_formatter "%a" (fprint ~show_empty) struc; Format.flush_str_formatter () let board_elem_coords name = @@ -1066,6 +1072,56 @@ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" in Char.escaped col_index.[col-1] ^ string_of_int row +(* Compare two structures and explain the first difference met. *) +exception Diff_result of string +let contained_in cmp_funs s1 s2 other = + let map_elem e1 = + let name = elem_str s1 e1 in + try find_elem s2 name + with Not_found -> raise (Diff_result ( + "Element "^name^" not found in the "^other^" structure")) in + Elems.iter (fun e -> ignore (map_elem e)) s1.elements; + StringMap.iter (fun rel tups -> + (let try tups2 = StringMap.find rel s2.relations in + Tuples.iter (fun tup -> + let tup2 = Array.map map_elem tup in + if not (Tuples.mem tup2 tups2) + then raise (Diff_result ( + Printf.sprintf + "Relation tuple %s(%s) not found in the %s structure" + rel (String.concat ", " + (List.map (elem_str s1) (Array.to_list tup))) + other)) + ) tups + with Not_found -> raise (Diff_result ( + "Relation "^rel^" not found in the "^other^" structure")) + )) s1.relations; + StringMap.iter (fun fn vals -> + (let try vals2 = StringMap.find fn s2.functions in + IntMap.iter (fun e v -> + let v2 = IntMap.find (map_elem e) vals2 in + try + if not (cmp_funs v v2) + then raise (Diff_result ( + Printf.sprintf + "Function %s(%s)->%F is %F instead in the %s structure" + fn (elem_str s1 e) v v2 other)) + with Not_found -> raise (Diff_result ( + Printf.sprintf + "Function %s(%s) not found in the second structure" + fn (elem_str s1 e))) + ) vals + with Not_found -> raise (Diff_result ( + "Function "^fn^" not found in the "^other^" structure")) + )) s1.functions + +let compare_diff ?(cmp_funs=(=)) s1 s2 = + try + contained_in cmp_funs s1 s2 "second"; + contained_in cmp_funs s2 s1 "first"; + true, "equal" + with Diff_result expl -> false, expl + (* -------------------- PARSER HELPERS -------------------- *) let is_uppercase c = c >= 'A' && c <= 'Z' Modified: trunk/Toss/Solver/Structure.mli =================================================================== --- trunk/Toss/Solver/Structure.mli 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Solver/Structure.mli 2011-03-14 11:11:08 UTC (rev 1359) @@ -82,11 +82,12 @@ val sig_str : structure -> string (** Print the structure [struc] as string, in extensive form (not using - condensed representations like boards). *) -val ext_str : structure -> string + condensed representations like boards). If [show_empty] is false, + do not print the signatures of empty relations. *) +val ext_str : ?show_empty:bool -> structure -> string (** Print the structure [struc] as string. *) -val str : structure -> string +val str : ?show_empty:bool -> structure -> string val fprint_rel : @@ -97,14 +98,14 @@ structure -> Format.formatter -> string * float IntMap.t -> unit val fprint_ext_structure : - Format.formatter -> structure -> unit + show_empty:bool -> Format.formatter -> structure -> unit val fprint : - Format.formatter -> structure -> unit + show_empty:bool -> Format.formatter -> structure -> unit -val print : structure -> unit +val print : ?show_empty:bool -> structure -> unit -val sprint : structure -> string +val sprint : ?show_empty:bool -> structure -> string (** Coordinates, column first, of a board element name. Raises [Not_found] if the name is not of proper format. *) @@ -114,6 +115,11 @@ [Not_found] if the coordinates are out of bounds. *) val board_coords_name : int * int -> string +(** Compare two structures and explain the first difference met. *) +val compare_diff : + ?cmp_funs:(float -> float -> bool) -> + structure -> structure -> bool * string + (** {2 Adding elements possibly with string names} *) Modified: trunk/Toss/Solver/StructureTest.ml =================================================================== --- trunk/Toss/Solver/StructureTest.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/Solver/StructureTest.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -379,6 +379,50 @@ ]" ); + + "compare_diff" >:: + (fun () -> + assert_equal ~printer:(fun (_,x)->x) + (true, "equal") + (compare_diff + (struc_of_string "[a,b | R(a,b) | ]") + (struc_of_string "[a,b | R(a,b) | ]")); + assert_equal ~printer:(fun (_,x)->x) + (true, "equal") + (compare_diff + (struc_of_string "[a,b,c | R(a,b) | f {a->2.}; g{b->3.} ]") + (struc_of_string "[a,b,c | R(a,b) | f {a->2.}; g{b->3.} ]")); + assert_equal ~printer:(fun (_,x)->x) + (false, "Relation tuple R(a, b) not found in the second structure") + (compare_diff + (struc_of_string "[a,b | R(a,b) | ]") + (struc_of_string "[a,b | R(b,a) | ]")); + assert_equal ~printer:(fun (_,x)->x) + (false, "Function g(b)->3. is 4. instead in the second structure") + (compare_diff + (struc_of_string "[a,b,c | R(a,b) | f {a->2.}; g{b->3.} ]") + (struc_of_string "[a,b,c | R(a,b) | f {a->2.}; g{b->4.} ]")); + assert_equal ~printer:(fun (_,x)->x) + (false, "Relation R not found in the second structure") + (compare_diff + (struc_of_string "[a,b | R(a,b) | ]") + (struc_of_string "[a,b | C(a,b) | ]")); + assert_equal ~printer:(fun (_,x)->x) + (false, "Element b not found in the second structure") + (compare_diff + (struc_of_string "[a,b | P(a) | ]") + (struc_of_string "[a | P(a) | ]")); + assert_equal ~printer:(fun (_,x)->x) + (false, "Relation C not found in the first structure") + (compare_diff + (struc_of_string "[a,b | R(a,b) | ]") + (struc_of_string "[a,b | R(a,b); C(a,b) | ]")); + assert_equal ~printer:(fun (_,x)->x) + (false, "Relation tuple R(a, c) not found in the first structure") + (compare_diff + (struc_of_string "[a,b,c | R(a,b) | ]") + (struc_of_string "[a,b,c | R{(a,b); (a,c)} | ]")); + ); ] Modified: trunk/Toss/caml_extensions/pa_backtrace.ml =================================================================== --- trunk/Toss/caml_extensions/pa_backtrace.ml 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/caml_extensions/pa_backtrace.ml 2011-03-14 11:11:08 UTC (rev 1359) @@ -16,10 +16,10 @@ [ "backtrace"; "("; e = expr ; ")" -> <:expr< (try $e$ with exn -> ( print_endline "Backtracing exception:"; - List.map print_endline + List.iter print_endline (Str.split (Str.regexp_string "\\\\n") (Printexc.to_string exn)); print_endline "Exception backtrace:"; - List.map print_endline + List.iter print_endline (Str.split (Str.regexp_string "\\\\n") (Printexc.get_backtrace ())); raise exn ) ) >> Modified: trunk/Toss/examples/rewriting_example.toss =================================================================== --- trunk/Toss/examples/rewriting_example.toss 2011-03-14 03:24:33 UTC (rev 1358) +++ trunk/Toss/examples/rewriting_example.toss 2011-03-14 11:11:08 UTC (rev 1359) @@ -1,6 +1,6 @@ PLAYERS 1, 2 RULE Rewrite: - [1, 2 | R (1, 2); S:2 {} | + [1, 2 | R (1, 2) | vx {2->0., 1->0.}; vy {2->0., 1->0.}; x {2->12.1, 1->-56.1}; y {2->-16.5, 1->-19.8} ] -> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-15 00:46:20
|
Revision: 1360 http://toss.svn.sourceforge.net/toss/?rev=1360&view=rev Author: lukaszkaiser Date: 2011-03-15 00:46:12 +0000 (Tue, 15 Mar 2011) Log Message: ----------- WebClient debug, reference update, www translation fixes. Modified Paths: -------------- trunk/Toss/WebClient/Login.js trunk/Toss/WebClient/index.html trunk/Toss/www/Makefile trunk/Toss/www/contact.xml trunk/Toss/www/develop.xml trunk/Toss/www/reference/Makefile trunk/Toss/www/reference/reference.bib trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/WebClient/Login.js =================================================================== --- trunk/Toss/WebClient/Login.js 2011-03-14 11:11:08 UTC (rev 1359) +++ trunk/Toss/WebClient/Login.js 2011-03-15 00:46:12 UTC (rev 1360) @@ -46,13 +46,16 @@ } // Onload handler -function startup () { +function startup (game) { if (navigator.userAgent.indexOf('MSIE') !=-1) { document.getElementById("nosvg").style.display = "block"; } else { var udata = srv("USERPLAYS", "user"); if (udata != "") { setup_user (udata.split("$")) }; } + if (game != "") { + new_play_guest (game); + } } // Html of the list item for adding new opponents. Modified: trunk/Toss/WebClient/index.html =================================================================== --- trunk/Toss/WebClient/index.html 2011-03-14 11:11:08 UTC (rev 1359) +++ trunk/Toss/WebClient/index.html 2011-03-15 00:46:12 UTC (rev 1360) @@ -16,7 +16,7 @@ <script type="text/javascript" src="Login.js"> </script> </head> -<body onload="startup()"> +<body onload="startup('')"> <div id="main"> Modified: trunk/Toss/www/Makefile =================================================================== --- trunk/Toss/www/Makefile 2011-03-14 11:11:08 UTC (rev 1359) +++ trunk/Toss/www/Makefile 2011-03-15 00:46:12 UTC (rev 1360) @@ -6,3 +6,6 @@ ln -fs ../Toss.docdir code_doc cp code_doc/index.html code_doc/index.html.en cp code_doc/index.html code_doc/index.html.de + cp code_doc/index.html code_doc/index.html.de + cp code_doc/index.html code_doc/index.html.pl + cp code_doc/index.html code_doc/index.html.fr Modified: trunk/Toss/www/contact.xml =================================================================== --- trunk/Toss/www/contact.xml 2011-03-14 11:11:08 UTC (rev 1359) +++ trunk/Toss/www/contact.xml 2011-03-15 00:46:12 UTC (rev 1360) @@ -24,7 +24,7 @@ <section title="Email" lang="de"> <par>Toss ist ein Open-Source Projekt, wird auf <a href="http://sourceforge.net">SourceForge</a> - gehosted und eine BSD Licence disribuiert.<br/></par> + gehosted und unter der BSD Lizenz disribuiert.<br/></par> <par>Man kann uns unter folgener Addresse erreichen: <mailto address="tos...@li..."/> </par> @@ -32,9 +32,9 @@ <section title="Email" lang="pl"> <par>Toss jest projektem open source z hostem na <a href="http://sourceforge.net">SourceForge</a> - i pod licencja BSD.<br/></par> + i pod licencją BSD.<br/></par> <par>Najłatwiej się z nami skontaktować pisząc na - <mailto address="tos...@li..."/> + <mailto address="tos...@li..."/>. </par> </section> @@ -46,9 +46,9 @@ Toss Subversion Repository</a></item> </itemize> </section> - <section title="Links von Toss" lang="de"> + <section title="Links zu Toss" lang="de"> <itemize> - <item><a href="http://sourceforge.net/projects/toss/">Toss Project at + <item><a href="http://sourceforge.net/projects/toss/">Toss Projekt auf SourceForge.net</a></item> <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/"> Toss Subversion Repository</a></item> @@ -56,7 +56,7 @@ </section> <section title="Linki Tossa" lang="pl"> <itemize> - <item><a href="http://sourceforge.net/projects/toss/">Toss Project at + <item><a href="http://sourceforge.net/projects/toss/">Projekt Toss na SourceForge.net</a></item> <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/"> Toss Subversion Repository</a></item> @@ -64,7 +64,7 @@ </section> - <section title="Game Playing Links"> + <section title="Game Playing Links" lang="en"> <itemize> <item><a href="http://www.apronus.com/chess/wbeditor.php">Apronus Chess Board Editor</a> is our favorite site for simple chess boards. @@ -91,10 +91,65 @@ Turn</a> allows you to play various board games online.</item> </itemize> </section> + <section title="Links zu Spielprogrammen" lang="de"> + <itemize> + <item><a href="http://www.apronus.com/chess/wbeditor.php">Apronus Chess + Board Editor</a> ist unser beliebter einfacher Schachbretteditor. + </item> + <item><a href="http://www.dozingcatsoftware.com/Gridlock/">Gridlock</a> + ist eine Sammlung von Open-Source Spielen. Es spielt nett, erlaubt + es aber nicht das Spiel zu editieren. + </item> - <section title="Modelling Links"> + <item><a href="http://www.zillions-of-games.com/">Zillions of Games</a> + ist eine Sprache für Spieldefinitionen, ein Simulator und eine grosse + Bibliothek von Spielen. Leider ist es nicht Open-Source. + </item> + + <item><a href="http://www.kurnik.pl/">Kurnik</a> ist eine polnische + Spielseite mit verschiedenen Spielen.</item> + + <item><a href="http://abstractstrategy.com/main.html">Abstract + Strategy Games</a> erlaubt es, strategische Spiele zu lernen + und zu spielen. + </item> + + <item><a href="http://www.yourturnmyturn.com/">Your Turn My + Turn</a> erlaubt es, Brettspiele online zu spielen.</item> + </itemize> + </section> + <section title="Linki do Programów do Gier" lang="pl"> <itemize> + <item><a href="http://www.apronus.com/chess/wbeditor.php">Apronus Chess + Board Editor</a> to nasz ulubiony prosty edytor pozycji szachowych. + </item> + + <item><a href="http://www.dozingcatsoftware.com/Gridlock/">Gridlock</a> + to zbiór gier planszowych open-source. Miło z nim grać, ale nie + pozwala edytować gry ani stanu planszy. + </item> + + <item><a href="http://www.zillions-of-games.com/">Zillions of Games</a> + to język do definicji gier wraz z symulatorem i pokaźną biblioteką + przeróżnych gier. Niestety, nie jest to program open-source. + </item> + + <item><a href="http://www.kurnik.pl/">Kurnik</a> to polska strona + na której można grać w różne gry planszowe i karciane.</item> + + <item><a href="http://abstractstrategy.com/main.html">Abstract + Strategy Games</a> pozwala uczyć się i grać w gry strategiczne. + </item> + + <item>Na <a href="http://www.yourturnmyturn.com/">Your Turn My + Turn</a> możesz zagrać w różne gry planszowe.</item> + </itemize> + </section> + + + <section title="Modelling Links" lang="en"> + <itemize> <item><a href="http://edu.kde.org/step/">Step</a> is an open-source physics simulator, a part of the KDE Education Project. It can be used for simulation of systems with continuous @@ -110,15 +165,47 @@ embedded systems. This advanced project allows to use various models of computation that govern the interactions between components. </item> + </itemize> + </section> + <section title="Links zu Simulation- und Modellierungprogrammen" lang="de"> + <itemize> + <item><a href="http://edu.kde.org/step/">Step</a> + ist ein Open-Source Physiksimulator, teil der KDE Education Project. + Man kann damit Systeme mit kontiuerlicher Dynamik simulieren. + </item> - <item><a href="http://www.microsoft.com/esp/about_esp/overview.htm" - >Microsoft ESP</a> is a visual simulation platform - that applies game-based technology to some more complex problems. + <item><a href="http://www.iseesystems.com/softwares/Education/StellaSoftware.aspx">STELLA</a> ist ein kommerzieller Simulationsprogramm und erlaubt + sowohl diskrete als auch kontinuerliche Dynamik. </item> + + <item><a href="http://ptolemy.eecs.berkeley.edu/">Ptolemy</a> Projekt + erforscht Modelierung, Simulation und das Design von Nebenläufigen im + Echtzeit laufenden eingebeteten Systeme. Es erlaubt verschiedene + Modelle von Berechnungen gleichzeitig zu verknüpfen und zu nutzen. + </item> </itemize> </section> + <section title="Linki do Programów do Modelowania" lang="pl"> + <itemize> + <item><a href="http://edu.kde.org/step/">Step</a> to open-sourcowy + symulator fizyki, część KDE Education Project. Pozwala na + symulację systemów z ciągłą dynamiką. + </item> - <section title="Team"> + <item><a href="http://www.iseesystems.com/softwares/Education/StellaSoftware.aspx">STELLA</a> to komercyjny symulator pozwalający definiować zarówno + ciągłą jak i dyskretną dynamikę. + </item> + + <item><a href="http://ptolemy.eecs.berkeley.edu/">Ptolemy</a> to projekt + w którym badane jest modelowanie, symulacja i design równoległych + systemów czasu rzeczywistego. Ten zaawansowany projekt pozwala łączyć + różne modele obliczeń i używać ich w tym samym projekcie. + </item> + </itemize> + </section> + + + <section title="Team" lang="en"> <par>Toss originates from our work in the <a href="http://www.algosyn.rwth-aachen.de/">AlgoSyn</a> research group. Many people contributed, here we name just a few. Current leaders:</par> @@ -143,4 +230,56 @@ </itemize> </section> + <section title="Team" lang="de"> + <par>Toss hat angefangen während der Arbeit im + <a href="http://www.algosyn.rwth-aachen.de/">AlgoSyn</a> + Graduiertenkolleg. Viele haben dazu beigetragen, hier benennen wir + nur einige Mitwirkende. Zur Zeit programmieren am meisten:</par> + <itemize> + <item>Łukasz Kaiser (<mailto address="luk...@gm..."/>)</item> + <item>Tobias Ganzow</item> + <item>Łukasz Stafiniak</item> + <item>Michał Wójcik</item> + </itemize> + + <par>Freunde die uns sehr geholfen haben.</par> + <itemize> + <item>Dietmar Berwanger</item> + <item>Matko Botincan</item> + <item>Diana Fischer</item> + </itemize> + <par>Einige andere Mitarbeiter haben an der ältesten Version von + Toss (ca. 2004) gearbeitet.</par> + <itemize> + <item>Alexander Kharitonov</item> + <item>Peter Cholewinski</item> + </itemize> + </section> + + <section title="Team" lang="pl"> + <par>Toss wywodzi się z prac i dyskusji w gronie + <a href="http://www.algosyn.rwth-aachen.de/">AlgoSyn</a>. + Wiele osób pracowało nad Tossem w różnych okresach, tutaj + wymieniamy tylko niektóre z nich. Obecnie najwięcej pracują:</par> + <itemize> + <item>Łukasz Kaiser (<mailto address="luk...@gm..."/>)</item> + <item>Tobias Ganzow</item> + <item>Łukasz Stafiniak</item> + <item>Michał Wójcik</item> + </itemize> + + <par>Przyjaciele, którzy bardzo nam pomogli.</par> + <itemize> + <item>Dietmar Berwanger</item> + <item>Matko Botincan</item> + <item>Diana Fischer</item> + </itemize> + <par>Inna grupa osób pracowała nad najstarszą wersją Tossa + (około 2004).</par> + <itemize> + <item>Alexander Kharitonov</item> + <item>Peter Cholewinski</item> + </itemize> + </section> + </personal> Modified: trunk/Toss/www/develop.xml =================================================================== --- trunk/Toss/www/develop.xml 2011-03-14 11:11:08 UTC (rev 1359) +++ trunk/Toss/www/develop.xml 2011-03-15 00:46:12 UTC (rev 1360) @@ -39,63 +39,63 @@ </section> <section title="Vorbereitung" lang="de"> <itemize> - <item>Except for the interfaces, most of Toss is programmed in - <a href="http://caml.inria.fr/">Objective Caml</a>. You will need - a good understanding of OCaml and a full OCaml installation - to work on the Toss Engine. + <item>Ausser der Interfaces ist Toss fast vollständig in + <a href="http://caml.inria.fr/">Objective Caml</a> geschrieben. + Um an Toss zu arbeiten braucht man ein gutes Verständnis von + OCaml und eine vollständige OCaml Installation. </item> - <item>Toss <em>build system</em> is based on <em>ocamlbuild</em> - and uses <em>Makefiles</em> for compilation of the C parts. - You will need a system which supports these to build Toss. + <item>Das <em>Build System</em> von Toss basiert auf <em>ocamlbuild</em> + und nutzt <em>Makefiles</em> um die C Teile zu kompilieren. + Man muss diese Tools installiert haben um Toss zu bauen. </item> - <item>If you want to develop Toss on Ubuntu, here is a command with - a list of packages to install.<br/> + <item>Wenn man Toss unter Ubuntu kompilieren möchte, braucht man + Pakette, die mit folgender Zeile installiert werden können.<br/> sudo apt-get install g++ python-qt4 python-dev pyqt4-dev-tools ocaml-findlib menhir libounit-ocaml-dev libapache2-mod-python sqlite3 python-pysqlite2 </item> - <item>This command will checkout the + <item>Folgendes nutzt man, um die <a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/">Toss - SVN Repository</a> to the <em>Toss</em> directory.<br/> + SVN Repository</a> zum <em>Toss</em> Verzeichnis auszuchecken.<br/> svn co https://toss.svn.sourceforge.net/svnroot/toss/trunk/Toss Toss </item> - <item>In the Toss directory run <em>make</em> and check that - it succeeds.</item> + <item>Im Toss Verzeichnis führe <em>make</em> aus und überprüfe, + dass es erfolgreich funktioniert hat.</item> </itemize> </section> <section title="Przygotowanie" lang="pl"> <itemize> - <item>Except for the interfaces, most of Toss is programmed in - <a href="http://caml.inria.fr/">Objective Caml</a>. You will need - a good understanding of OCaml and a full OCaml installation - to work on the Toss Engine. + <item>Poza interfejsami większość Tossa jest napisana w + <a href="http://caml.inria.fr/">Objective Camlu</a>. Aby pracować + nad Enginem Tossa niezbędna jest dobra znajomosc OCamla oraz + jego pełna instalacja. </item> - <item>Toss <em>build system</em> is based on <em>ocamlbuild</em> - and uses <em>Makefiles</em> for compilation of the C parts. - You will need a system which supports these to build Toss. + <item><em>Build system</em> Tossa bazuje na <em>ocamlbuild</em>, + ale <em>Makefile</em> są używane do kompilacji niektórych części, + np. kodu C. Trzeba zainstalowac te programy żeby skompilować Tossa. </item> - <item>If you want to develop Toss on Ubuntu, here is a command with - a list of packages to install.<br/> + <item>Pod Ubuntu, poniższe polecenie zainstaluje pakiety niezbędne + do kompilacji Tossa.<br/> sudo apt-get install g++ python-qt4 python-dev pyqt4-dev-tools ocaml-findlib menhir libounit-ocaml-dev libapache2-mod-python sqlite3 python-pysqlite2 </item> - <item>This command will checkout the - <a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/">Toss - SVN Repository</a> to the <em>Toss</em> directory.<br/> + <item>Poniższe polecenie ściągnie + <a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/"> + Repozytorium SVN Tossa</a> do katalogu <em>Toss</em>.<br/> svn co https://toss.svn.sourceforge.net/svnroot/toss/trunk/Toss Toss </item> - <item>In the Toss directory run <em>make</em> and check that - it succeeds.</item> + <item>W katalogu Toss uruchom <em>make</em> i sprawdź czy dobrze + zadziałało.</item> </itemize> </section> - <section title="Understanding Toss"> + <section title="Understanding Toss" lang="en"> <itemize> <item><a href="create.html">Create</a> at least one simple game to get started.</item> - <item>Get acquainted with <a href="docs.html">Toss documentation</a>. + <item>Get acquainted with the <a href="docs.html">Toss documentation</a>. </item> <item>Do not forget to read the <a href="reference/reference.pdf"> reference.pdf</a> document.</item> @@ -105,8 +105,37 @@ about Toss to get an idea where the ideas come from.</item> </itemize> </section> + <section title="Toss Verstehen" lang="de"> + <itemize> + <item><a href="create.html">Erzeuge</a> wenigstens ein einfaches Spiel + mit Toss um die Grundlagen zu verstehen.</item> + <item>Lese die <a href="docs.html">Dokumentation</a> von Toss. + </item> + <item>Vergesse nicht die <a href="reference/reference.pdf"> + Reference.pdf</a> durchzublättern.</item> + <item>Wenn man Toss programmiert, ist die + <a href="code_doc/">Quellcode Dokumentation</a> oft nützlich.</item> + <item>Durch die <a href="Publications/">Papers und Talks</a> kann man + verstehen, woher die Ideen hinter Toss kommen.</item> + </itemize> + </section> + <section title="Zrozumieć Tossa" lang="pl"> + <itemize> + <item><a href="create.html">Stwórz</a> przynajmniej jedną prostą + grę w Tossie na początek.</item> + <item>Zapoznaj się z <a href="docs.html">dokumentacją Tossa</a>. + </item> + <item>Przejrzyj też <a href="reference/reference.pdf"> + reference.pdf</a>.</item> + <item>Podczas programowania poręczna jest + <a href="code_doc/">dokumentacja kodu</a>.</item> + <item>Oglądając <a href="Publications/">prace i referaty</a> + można dowiedzieć się, skąd czerpaliśmy pomysły w Tossie.</item> + </itemize> + </section> - <section title="Working with the Toss Team"> + + <section title="Working with the Toss Team" lang="en"> <par>If you have an idea for Toss, a request, want to become a developer or just want to talk, contact us! Most engaged Toss developers do respond to Toss questions on their private emails every @@ -122,5 +151,39 @@ <mailto address="mic...@gm..."/></item> </itemize> </section> + <section title="Mit Toss Team Zusammenarbeiten" lang="de"> + <par>Wenn du eine Idee für Toss hast, ein Vorschlag, eine Anfrage, + wenn du Toss programmieren möchtest oder einfach mit uns reden, + schreibe uns! Die angagiertesten Toss Developer beantworten + täglich Fragen über Toss auch auf privaten Emails (unten), aber es ist + am besten an <em>toss-devel</em> zu schreiben.</par> + <itemize> + <item>Toss Mailingliste: + <mailto address="tos...@li..."/></item> + <item>Łukasz Kaiser: + <mailto address="luk...@gm..."/></item> + <item>Łukasz Stafiniak: + <mailto address="luk...@gm..."/></item> + <item>Michał Wójcik: + <mailto address="mic...@gm..."/></item> + </itemize> + </section> + <section title="Praca z Nami" lang="pl"> + <par>Jeśli masz pomysł na zmiany w Tossie, prośbę o poprawienie buga, + chcesz zostać developerem Tossa albo po prostu z nami porozmawiac, + napisz! Najbardziej zaangażowani programiści Tossa odpowiadają + codziennie na maile nawet na swoich prywatnych adresach (poniżej), + ale najlepiej napisać na listę <em>toss-devel</em>.</par> + <itemize> + <item>Lista mailingowa Tossa: + <mailto address="tos...@li..."/></item> + <item>Łukasz Kaiser: + <mailto address="luk...@gm..."/></item> + <item>Łukasz Stafiniak: + <mailto address="luk...@gm..."/></item> + <item>Michał Wójcik: + <mailto address="mic...@gm..."/></item> + </itemize> + </section> </personal> Modified: trunk/Toss/www/reference/Makefile =================================================================== --- trunk/Toss/www/reference/Makefile 2011-03-14 11:11:08 UTC (rev 1359) +++ trunk/Toss/www/reference/Makefile 2011-03-15 00:46:12 UTC (rev 1360) @@ -16,6 +16,8 @@ cp reference.html index.html cp reference.html index.html.en cp reference.html index.html.de + cp reference.html index.html.pl + cp reference.html index.html.fr .PHONY: Modified: trunk/Toss/www/reference/reference.bib =================================================================== --- trunk/Toss/www/reference/reference.bib 2011-03-14 11:11:08 UTC (rev 1359) +++ trunk/Toss/www/reference/reference.bib 2011-03-15 00:46:12 UTC (rev 1360) @@ -1,3 +1,12 @@ +@inproceedings{GK10, + author = {T.~Ganzow and {\L}.~Kaiser}, + title = {New Algorithm for Weak Monadic Second-Order Logic on Inductive Structures}, + booktitle = {Proc.~of CSL'10}, + publisher = {Springer}, + series = {LNCS}, + year = {2010}, +} + @article{SUB96, author = {Marcos Salganicoff and Lyle H. Ungar and Ruzena Bajcsy}, title = {Active Learning for Vision-Based Robot Grasping}, Modified: trunk/Toss/www/reference/reference.tex =================================================================== --- trunk/Toss/www/reference/reference.tex 2011-03-14 11:11:08 UTC (rev 1359) +++ trunk/Toss/www/reference/reference.tex 2011-03-15 00:46:12 UTC (rev 1360) @@ -27,6 +27,29 @@ \@abbrev{sf}{\mathsf}{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz} \makeatother +\usepackage[ruled]{algorithm2e} +% tweak algorithm environment... +\makeatletter +%% at the end of algocf or figure environment +\renewcommand{\@algocf@finish}{% + \@algoinsideskip% + \egroup%end of vtop which contain all the text + \hfill\egroup%end of hbox wich contains [margin][vtop] + \ifthenelse{\boolean{algocf@slide}}{\DecMargin{\skipalgocfslide}}{}% + % + \egroup%end of main vbox + \end{lrbox}% + \algocf@makethealgo% print the algo +% \@algoskip% + \vskip-0.5em% + % restore dimension and macros + \setlength{\hsize}{\algowidth}% + \lineskip\normallineskip\setlength{\skiptotal}{\@defaultskiptotal}% + \let\;=\@mathsemicolon% +}% +\makeatother + + % Simple item labels \renewcommand{\labelitemi}{--} \renewcommand{\labelitemii}{--} @@ -49,7 +72,36 @@ \newcommand{\ol}[1]{\overline{#1}} \renewcommand{\phi}{\varphi} +% Formula forms and properties, boolean junctors +\newcommand{\Lor}{\bigvee} +\newcommand{\Land}{\bigwedge} +\newcommand{\BC}{\calB^+} +\newcommand{\CNF}{\ensuremath{\text{CNF}}\xspace} +\newcommand{\procCNF}{\ensuremath{\mathtt{CNF}}\xspace} +\newcommand{\DNF}{\ensuremath{\text{DNF}}\xspace} +\newcommand{\procDNF}{\ensuremath{\mathtt{DNF}}\xspace} +\newcommand{\TNF}{\ensuremath{\mathtt{TNF}}\xspace} +\DeclareMathOperator{\qr}{qr} +\DeclareMathOperator{\free}{free} +\newcommand{\fv}{\ensuremath{\mathtt{FreeVar}}\xspace} +\newcommand{\rank}{\ensuremath{\mathtt{rank}}\xspace} +\newcommand{\hitrank}{\ensuremath{\mathtt{hit}\text{-}\mathtt{rank}}\xspace} +% Theorem environments +\theoremstyle{plain} +\newtheorem{theorem}{Theorem} +\newtheorem{proposition}[theorem]{Proposition} +\newtheorem{corollary}[theorem]{Corollary} +\newtheorem{lemma}[theorem]{Lemma} + +\theoremstyle{definition} +\newtheorem{example}[theorem]{Example} +\newtheorem{claim}[theorem]{Claim} +\newtheorem{definition}[theorem]{Definition} + +% Rotated symbols +\newcommand\rotleadsto{\rotatebox{-90}{$\leadsto$}} + % Start \newcommand\thetitle{Toss Design and Specification} \title{\thetitle} @@ -60,7 +112,7 @@ \maketitle -\setcounter{tocdepth}{1} +\setcounter{tocdepth}{2} \tableofcontents \clearpage @@ -488,7 +540,7 @@ \chapter{Algorithms} -\section{Game Playing Algorithm} +\section{UCT Game Playing Algorithm} When playing a game, players need to decide what their next move is. To represent the preferences of each player, or rather her expectations @@ -684,8 +736,360 @@ The play in this iteration continues from one of those children, as depicted by the snaked line in Figure~\ref{fig-ttt-eval-uct}. -\section{Solver} +\section{Type Normal Form} +To derive evaluation heuristics from payoff terms, we first have to introduce +a normal form of formulas which we exploit later in the construction. This +normal form is in a sense a converse to the prenex normal form (PNF), because +the quantifiers are pushed as deep inside the formula as possible. A very +similar normal form has been used recently in a different +context \cite{GK10}. For a set of formulas $\Phi$ let us denote by +$\BC(\Phi)$ all positive Boolean combinations of formulas from $\Phi$, +\ie define $\BC(\Phi) \ = \ + \Phi \mid \BC(\Phi) \lor \BC(\Phi) \mid \BC(\Phi) \land \BC(\Phi)$. + +\begin{definition} +A formula is in TNF if and only if it is a positive Boolean combination +of formulas of the following form +\begin{align*} + \tau &= R_i(\ol{x}) \mid \neg R_i(\ol{x}) \mid x = y \mid x \neq y \mid + \exists x \BC(\tau) \mid \forall x \BC(\tau) +\end{align*} +satisfying the following crucial constraint: in +$\exists x \, \BC(\{\tau_i\})$ and $\forall x \, \BC(\{\tau_i\})$ +the free variables of \emph{each} $\tau_i$ +appearing in the Boolean combination \emph{must contain} $x$. +\end{definition} + +We claim that for each formula $\phi$ there exists an equivalent +formula $\psi$ in TNF, and the procedure \texttt{TNF}$(\phi)$ computes +$\psi$ given $\phi$ in negation normal form. Note that it uses sub-procedures +$\procDNF$ and $\procCNF$ which, given a Boolean combination of formulas, +convert it to disjunctive or respectively conjunctive normal form. + +As an example, consider $\phi=\exists x \big( P(x) \land (Q(y)\lor R(x)) \big)$; +This formula is not in TNF as $Q(y)$ appears under $\exists x$, and +\texttt{TNF}$(\phi) = \big( Q(y) \land \exists x P(x) \big) \lor + \exists x \big( P(x) \land R(x) \big)$. + +%\newcommand{\algoskip}{\vspace{0.5em}} +%\SetAlgoSkip{algoskip} +\begin{procedure}[h] +\caption{TNF($\phi$)} +\label{alg-tnf} +\lCase{$\phi$ is a literal}{\Return $\phi$}\; +\lCase{$\phi = \phi_1 \lor \phi_2$} + {\Return $\TNF(\phi_1) \lor \TNF(\phi_2)$}\; +\lCase{$\phi = \phi_1 \land \phi_2$} + {\Return $\TNF(\phi_1) \land \TNF(\phi_2)$}\; +\uCase{$\phi = \exists x \psi$} + {Let $\procDNF(\TNF(\psi)) = \Lor_i(\Land_j \psi^i_j)$\\ + and $F_i = \{j \mid x \in \free(\psi^i_j)\}$;\\ + \Return $\Lor_i\Big(\Land_{j \not\in F_i} \psi^i_j \land + \exists x (\Land_{j \in F_i} \psi^i_j)\Big)$\;} +\uCase{$\phi = \forall x \psi$} + {Let $\procCNF(\TNF(\psi)) = \Land_i(\Lor_j \psi^i_j)$\\ + and $F_i = \{j \mid x \in \free(\psi^i_j)\}$;\\ + \Return $\Land_i\Big(\Lor_{j \not\in F_i} \psi^i_j \lor + \forall x (\Lor_{j \in F_i} \psi^i_j)\Big)$\;} +\end{procedure} + + +\begin{theorem} \label{thm-tnf} +$\TNF(\phi)$ is equivalent to $\phi$ and in TNF. +\end{theorem} + +%\begin{proof} +% WARNING !!! REPLACE J by F !!! +%We proceed inductively on the structure of $\phi$. For literals all the claims +%are trivial since $\TNF$ is an identity. For Boolean combinations of formulas, +%the procedure $\TNF$ only calls itself recursively, +%thus all claims of the theorem follow inductively as well. +% +%Consider the case when $\phi = \exists x \psi$ and +%$\procDNF(\TNF(\psi)) = \Lor_i(\Land_j \psi^i_j)$. +%We convert $\TNF(\psi)$ to disjunctive normal form in this case +%since the existential quantifier is distributive over disjunction, +%and thus $\TNF(\phi) \equiv \Lor_i(\exists x \Land_j(\psi^i_j))$. +%Since quantifiers are also distributive over formulas which +%do not contain the quantified variable, we get that the result, +%$\Lor_i\Big(\Land_{j \in J_i} \psi^i_j \land +% \exists x (\Land_{j \not\in J_i} \psi^i_j)\Big)$, is equivalent +%to $\exists x \TNF(\psi)$, and thus by inductive hypothesis also to $\phi$. +%Since each formula $\psi^i_j$ is, by inductive hypothesis, in the form $\tau$, +%to show that the result is in TNF we only need to check that +%$\exists x (\Land_{j \in J_i} \psi^i_j)$ is in the form $\tau$. +%Syntactically this is trivial, and the constraint on variables in the TNF +%is indeed satisfied by the choice of $J_i$. The set of atoms does not increase +%by inductive hypothesis, and no new free variables appear by the choice of +%$J_i$ Furthermore, neither the quantifier rank nor the rank over +%any restricted variable increases. +%The case of universal quantification is analogous, +%modulo conversions between disjunctive and conjunctive normal forms +%(we assume that \procCNF and \procDNF do not create new atoms). +%\qed +%\end{proof} + +The proof of the above theorem is a simple argument by induction on +the structure of the formula, so we omit it here. Instead, let us give an +example which explains why it is useful to compute TNF for the goal formulas. + +\begin{example} +As already defined above, the payoff in Tic-tac-toe is given by +$\exists x,y,z (P(x) \land P(y) \land P(z) \land L(x, y, z))$. To simplify this +example, let us consider the payoff given only by row and column triples, \ie +\begin{align*} +\phi = \exists x,y,z \big( & P(x) \land P(y) \land P(z) \land \\ + & \big( (R(x,y) \land R(y, z)) \lor (C(x, y) \land C(y, z)) \big) \big). +\end{align*} +This formula is not in TNF and the DNF of the quantified part has the form +$\phi_1 \lor \phi_2$, where +\[ \phi_1 = P(x) \land P(y) \land P(z) \land R(x, y) \land R(y, z), \] +\[ \phi_2 = P(x) \land P(y) \land P(z) \land C(x, y) \land C(y, z). \] +The procedure \texttt{TNF} must now choose the variable to first split on +(this is discussed in the next section) and pushes the quantifiers inside, +resulting in $\TNF(\phi) = \psi_1 \lor \psi_2$ with +\[ \psi_1 = \exists x \big( P(x) \land \exists y \big( P(y) \land R(x, y) + \land \exists z (P(z) \land R(y, z)) \big) \big), \] +\[ \psi_2 = \exists x \big( P(x) \land \exists y \big( P(y) \land C(x, y) + \land \exists z (P(z) \land C(y, z)) \big) \big). \] +In spirit, the TNF formula is thus more ``step-by-step'' than the goal +formula we started with, and we exploit this to generate heuristics +for evaluating positions below. +\end{example} + + +\section{Heuristics from Existential Formulas} + +In this section, we present one method to generate a heuristic from +an existential goal formula. As a first important step, we divide all +relations appearing in the signature in our game into two sorts, +\emph{fluents} and \emph{stable relations}. A relation is called \emph{stable} +if it is not changed by any of the structure rewriting rules which appear +as possible moves, all other relations are \emph{fluent}. We detect +stable relations by a simple syntactic analysis of structure rewriting rules, +\ie we check which relations from the left-hand side remain unchanged +on the right-hand side of the rule. It is a big advantage of our formalism +in comparison to GDL that stable relations (such as row and column relations +used to represent the board) can so easily be separated from the fluents. + +After detecting the fluents, our first step in generating the heuristic +is to compute the TNF of the goal formula. As mentioned in the example +above, there is certain freedom in the \texttt{TNF} procedure as to +which quantified variable is to be resolved first. We use fluents to decide +this --- a variable which appears in a fluent will be resolved before +all other variables which do not appear in any fluent literal +(we choose arbitrarily in the remaining cases). + +After the TNF has been computed, we change each sequence of existential +quantifiers over conjunctions into a sum, counting how many +steps towards satisfying the whole conjunction have been made. Let us +fix a factor $\alpha < 1$ which we will discuss later. Our algorithm then +changes a formula in the following way. +\[ \exists x_1 \big( \vartheta_1(x_1) \land + \exists x_2 \big( \vartheta_1(x_2, x_1) \land \cdots \land + \exists x_n \big( \vartheta_n(x_n, \ol{x_i}) \big) \cdots \big) \big) +\] + +\vskip -2em + +\[ \rotleadsto \] +\[ \sum_{x_1 \mid \vartheta_1(x_1)} \!\! \big( \alpha^{n-1} + \!\!\! + \sum_{x_2 \mid \vartheta_2(x_2, x_1)} \!\! ( \alpha^{n-2} + \, \cdots ( \alpha \, + + \!\!\! \sum_{x_n \mid \vartheta_n(x_n, \ol{x_i})} \!\!\! 1 ) \cdots ) \big) \] + +The sub-formulas $\vartheta_i(x_i, \ol{x})$ are in this case conjunctions +of literals or formulas which contain universal quantifiers. The factor +$\alpha$ defines how much more making each next step is valued over +the previous one. %we call $\frac 1 \alpha$ the \emph{advancement factor}. +When a formula contains disjunctions, we use the above schema recursively +and sum the terms generated for each disjunct. + +To compute a heuristic for evaluating positions from a payoff term, +which is a real-valued expression in the logic defined above, we simply +substitute all characteristic functions, \ie expressions of the form +$\chi[\phi]$, by the sum generated for $\phi$ as described above. + +\begin{example} +Consider the TNF of the simplified goal formula for Tic-tac-toe presented +in the previous example and let $\alpha = \frac 1 4$. +Since the TNF of the goal formula for one player has +the form $\psi_1 \lor \psi_2$, we generate the following sums: +\[ s_1 = \sum_{x \mid P(x)} \big( {\frac 1 8} + \sum_{y \mid P(y) \land R(x, y)} ( + {\frac 1 4} + \sum_{z \mid P(z) \land R(y, z)} 1) \big), \] +\[ s_2 = \sum_{x \mid P(x)} \big( {\frac 1 8} + \sum_{y \mid P(y) \land C(x, y)} ( + {\frac 1 4} + \sum_{z \mid P(z) \land C(y, z)} 1) \big). \] +Since the payoff is defined by $\chi[\phi] - \chi[\phi']$, where $\phi'$ is +the goal formula for the other player, \ie with $Q$ in place of $P$, +the total generated heuristic has the form +\[ s_1 + s_2 - s'_1 - s'_2, \] +where $s_1'$ and $s_2'$ are as $s_1$ and $s_2$ but with $P$ replaced by $Q$. +\end{example} + + +\section{Finding Existential Descriptions} + +The method described above is effective if the TNF of the goal formulas +has a rich structure of existential quantifiers. But this is not always +the case, \eg in Breakthrough the goal formula for white has the form +$\exists x \, (W(x) \land \neg \exists y \, C(x, y))$, because +$\neg \exists y \, C(x, y)$ describes the last row which the player is +supposed to reach. The general question which presents itself in this +case is how, given an arbitrary relation $R(\ol{x})$ (as the last row above), +can one construct an existential formula describing this relation. +In this section, we present one method which turned out to yield useful +formulas at least for common board games. + +First of all, let us remark that the construction we present will be +done only for relations defined by formulas which do not contain fluents. +Thus, we can assume that the relation does not change during the game and +we use the starting structure in the construction of the existential formula. + +Our construction keeps a set $C$ of conjunctions of stable literals. +We say that a subset $\{ \phi_1, \ldots, \phi_n \} \subseteq C$ \emph{describes} +a relation $Q(\ol{x})$ in $\frakA$ if and only if $Q$ is equivalent +in $\frakA$ to the existentially quantified disjunction of $\phi_i$'s, \ie if +\[ \frakA \models Q(\ol{x}) \iff + \frakA \models \Lor_i\big( \exists \ol{y_i}\ \phi_i \big), \] +where $\ol{y_i}$ are all free variables of $\phi_i$ except for $\ol{x}$. + + +Our procedure extends the conjunctions from $C$ with new literals until +a subset which describes $Q$ is found. These extensions can in principle +be done in any order, but to obtain compact descriptions in reasonable +time we perform them in a greedy fashion. The conjunctions are +ordered by their hit-rank, defined as +\[ \hitrank_{\frakA, Q(\ol{x})}(\phi) = + \frac{|\{ \ol{x} \in Q \mid \frakA \models \exists \ol{y} \phi(\ol{x}) \}|} + {|\{ \ol{x} \mid \frakA \models \exists \ol{y} \phi(\ol{x}) \}|}, \] +where again $\ol{y} = \fv(\phi) \setminus \ol{x}$. Intuitively, the hit-rank is +the ratio of the tuples from $Q$ which satisfy (existentially quantified) $\phi$ +to the number of all such tuples. Thus, the hit-rank is $1$ if $\phi$ describes +$Q$ and we set the hit-rank to $0$ if $\phi$ is not satisfiable in $\frakA$. +We define the $\rank_{\frakA, Q}(\phi, R(\ol{y}))$ as the maximum of +the $\hitrank_{\frakA, Q}(\phi \land R(\ol{y}))$ and +the $\hitrank_{\frakA, Q}(\phi \land \neg R(\ol{y}))$. +The complete procedure is summarized below. + +%\renewcommand{\algoskip}{}%{\vspace{-1em}} +%\SetAlgoSkip{algoskip} +\begin{procedure}[h] +\caption{ExistentialDescription($\frakA$, $Q$)} +\label{alg-exd} +$C \longleftarrow \{ \top \}$\\ +\While{ no subset of $C$ describes $Q(\ol{x})$ in $\frakA$ }{ + \For{a stable relation $R(\ol{y})$, conjunction $\phi \in C$\\ + $\ \quad$ with maximal $\rank_{\frakA, Q}(\phi, R(\ol{y}))$}{ + %\lIf{($\fv(\phi) \cup \ol{x}) \cap \ol{y} = \emptyset$}{\Return}\\ + $\quad C \longleftarrow (C \setminus \{ \phi \}) \cup + \{ \phi \land R(\ol{y}), \ \phi \land \neg R (\ol{y}) \}$ + } +} +\end{procedure} + +Since it is not always possible to find an existential description +of a relation, let us remark that we stop the procedure if no description with +a fixed number of literals is found. We also use a tree-like data structure +for $C$ to check the existence of a describing subset efficiently. + +\begin{example} +As mentioned before, the last row on the board is defined by +the relation $Q(x) = \neg \exists y \, C(x, y)$. Assume that we search +for an existential description of this relation on a board with only +the binary row and column relations ($R$ and $C$) being stable, as +in Figure~\ref{fig-tic-tac-toe}. Since adding a row literal will +not change the hit-rank, our construction will be adding column literals +one after another and will finally arrive, on an $3 \times 3$ board, +at the following existential description: +$\exists y_1, y_2 ( C(y_1, y_2) \land C(y_2, x) )$. +Using such formula, the heuristic constructed in the previous section +can count the number of steps needed to reach the last row for each +pawn, which is a important \eg in Breakthrough. +\end{example} + + +\section{Alternative Heuristics with Rule Conditions} + +The algorithm presented above is only one method to derive heuristics, and it +uses only the payoff terms. In this section we present an alternative method, +which is simpler and uses also the rewriting rules and their constraints. +This simpler technique yields good heuristics only for games in which moves +are monotone and relatively free, \eg for Connect5. %(also known as Gomoku). +%We view this alternative heuristics as an example of other possibilities +%to exploit, which we discuss more thouroughly in the last section. + +Existential formulas are again the preferred input for the procedure, but this +time we put them in prenex normal form at the start. As before, all universally +quantified formulas are either treated as atomic relations or expanded, +as discussed above. The Boolean combination under the existential +quantifiers is then put in DNF and, in each conjunction in the DNF, +we separate fluents from stable relations. After such preprocessing, +the formula has the following form: +\[ \exists \ol{x} \, \big( + (\vartheta_1(\ol{x}) \land \psi_1(\ol{x})) \, \lor \, \cdots \, \lor \, + (\vartheta_n(\ol{x}) \land \psi_n(\ol{x})) \big), \] +where each $\vartheta_i(\ol{x})$ is a conjunction of fluents and +each $\psi_i(\ol{x})$ is a conjunction of stable literals. + +To construct the heuristic, we will retain the stable sub-formulas +$\psi_i(\ol{x})$ but change the fluent ones $\vartheta_i(\ol{x})$ from +conjunctions to sums. +Formally, if $\vartheta_i(\ol{x}) = F_1(\ol{x}) \land \cdots \land F_k(\ol{x})$ +then we define $s_i(\ol{x}) = \chi[F_1(\ol{x})] + \cdots + \chi[F_k(\ol{x})]$, +and let $\delta_i(\ol{x}) = F_1(\ol{x}) \lor \cdots \lor F_k(\ol{x})$ be +a formula checking if the sum $s_i(\ol{x}) > 0$. The guard for our heuristic +is defined as \[ \gamma(\ol{x}) = + \big( \psi_1(\ol{x}) \, \lor \, \cdots\, \lor \, \psi_n(\ol{x}) \big) \ \land + \ \big( \delta_1(\ol{x}) \, \lor \, \cdots \, \lor \, \delta_n(\ol{x}) \big) +\] and the heuristic with parameter $n$ by +\[ \sum_{\ol{x} \mid \gamma(\ol{x}) \land \mathtt{move}(\ol{x})} \big( + s_1(\ol{x}) + \cdots + s_n(\ol{x}) \big)^n. \] + +The additional formula $\mathtt{move}(\ol{x})$ is used to guarantee, +that at each element matched to one of the variables $\ol{x}$ it is +still possible to make a move. This is done by converting the rewrite +rule into a formula with free variables corresponding to the elements +of the left-hand side structure, removing all the fluents $F_i$ from +above if these appear negated, and quantifying existentially if a new +variable (not in $\ol{x}$) is created in the process. The following +example shows how the procedure is applied for Tic-tac-toe. + +\begin{example} +For Tic-tac-toe simplified as before (no diagonals), +the goal formula in PNF and DNF reads: +\begin{align*} + \exists x,y,z \ \big( & \, + (P(x) \, \land \, P(y) \, \land \, P(z) \, \land \, + R(x, y) \, \land \, R(y, z)) \\ + \lor & \, (P(x) \, \land \, P(y) \, \land \, P(z) \, \land \, + C(x, y) \, \land \, C(y, z)) \big). +\end{align*} +The resulting guard is thus, after simplification, +\begin{align*} +\gamma(x,y,z) = \big( & \, + (R(x, y) \, \land \, R(y, z))\, \lor\, (C(x, y) \, \land \, C(y, z)) \big)\\ + \land & \, \big( P(x) \, \lor \, P(y) \, \lor \, P(z) \big). +\end{align*} +Since the structure rewriting rule for the move has only one element, +say $u$, on its left-hand side, and $\tau_{\mr{e}} = \{P, Q\}$ for this rule, +the formula for the left-hand side reads $l(u) = \neg P(u) \land \neg Q(u)$. +Because $P$ appears as a fluent in $\gamma$ we remove all occurrences of +$\neg P$ from $l$ and are then left with $\mathtt{move}(u) = \neg Q(u)$. +Since we require that a move is possible from all variables, the derived +heuristic for one player with power $4$ has the form +\[ h \ \ = \!\!\!\! \!\!\!\! \!\! + \sum_{x, y, z \ \mid \ \gamma(x, y, z) \, \land \, \neg Q(x) + \, \land \, \neg Q(y) \, \land \, \neg Q(z)} \!\!\!\!\!\! + \!\!\!\!\!\! \!\!\!\!\!\! \!\!\!\!\!\! \!\!\!\!\!\! \!\!\!\!\!\! + (\chi[P(x)] + \chi[P(y)] + \chi[P(z)])^4. \] +Since the payoff expression is $\chi[\phi] - \chi[\phi']$, where $\phi'$ +is the goal formula for the other player, we use $h - h'$ as the final +heuristic to evaluate positions. +\end{example} + + +\section{Solver Techniques} + We used a SAT solver (MiniSAT) to operate on symbolic representations of MSO variables. We decided in favor of CNF representation instead of the more standard BDD approach as it seems to scale in a more consistent way. @@ -695,32 +1099,82 @@ (cylindrical algebraic decomposition) but works very consistently for many cases. +The main formula optimization is just performing the TNF, later we +only push predicates to the front. + + \chapter{Design} \section{Organization of Code} -Toss consists of a \emph{Client} module handling visualization and -a completely separate \emph{TossServer}. The communication is based -on socket requests, see the \texttt{Arena.mli} file for complete -specification of available server requests and response format. +Toss consists of the main \emph{TossServer} which is built from several +main modules explained in the sections below and corresponding to +directories in the code tree. The main modules contain OCaml modules +themselves. Toss additionally includes a few clients which provide +the user interface to Toss. At present there is a python GUI client +in \emph{Client} and a browser-based client in \emph{WebClient}. +Communication between the Server and the clients relies on +socket requests, see the \texttt{Arena.mli} file for complete +specification of available server requests and the response format. -\subsection{Server} -Toss server code is split in two parts, \emph{Solver} and \emph{Games} code. -The solver performs all functions related to structures, logic and constraint -solving, while the game code stores rules and games and implements the game -playing algorithm. The code is written in OCaml. +\section{Formula} +This most basic directory implements formulas as described above and various +operations on formulas which are necessary for other modules. It also +contains a parser for formulas and the lexing file used for all parsers. +The MiniSAT solver is included in this directory as it is used for formula +simplification. -\subsection{Client} -In general, it is possible to implement many Toss clients and there should -be no problem for them to interact with the same server. At present, we have -just one client which is written in python using the Qt4 library. +\section{Solver} +This directory contains the module which represents relational structures, +and the full Solver, including the elimination-based solver for the theory +of reals and the SAT-based solving algorithm for monadic second-order logic. +\section{Arena} + +This directory contains modules which implement the game definition, +including discrete and continuous structure rewriting, game file parser +and client-server communication parser and request type. + + +\section{Play} + +This directory contains modules responsible for automatic play, including +the heuristic generation module, the abstract game tree module and its +instantiations to Maximax and UCT. + + +\section{GGP} + +This directory contains the code which translates GDL files into Toss +format together with various needed simplifications. Multiple tests +and a Java GGP Server are also included there to facilitate testing +of the Toss-GGP code. + + +\section{Server} + +In this directory we simply keep the implementation of TossServer +together with several high-level tests to check that it works ok. + + +\section{Client} + +This stand-alone Toss client is written in python using the Qt4 library. + + +\section{WebClient} + +The browser-based client does not currently interface TossServer directly, +but uses a python request Handler.py as an intermediate step. This handler +also manages a database of users and games. + + %% Bibliography \bibliographystyle{plain} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-15 11:03:24
|
Revision: 1361 http://toss.svn.sourceforge.net/toss/?rev=1361&view=rev Author: lukstafi Date: 2011-03-15 11:03:16 +0000 (Tue, 15 Mar 2011) Log Message: ----------- GameSimpl: fixed optional relations bug in stage 1: replacing equivalent and complement relations. New simplification algorithm for FormulaOps.remove_redundant (will form the base of GameSimpl stage 2: removing subsumed atoms). Modified Paths: -------------- trunk/Toss/Formula/FormulaOps.ml trunk/Toss/Formula/FormulaOps.mli trunk/Toss/Formula/FormulaOpsTest.ml trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDLTest.ml trunk/Toss/GGP/GameSimpl.ml trunk/Toss/GGP/GameSimplTest.ml trunk/Toss/GGP/tests/breakthrough-simpl.toss trunk/Toss/GGP/tests/connect5-simpl.toss Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/Formula/FormulaOps.ml 2011-03-15 11:03:16 UTC (rev 1361) @@ -119,6 +119,10 @@ (* ----------------- MAPPING TO ATOMS AND VAR SUBSTITUTION ------------------ *) +let is_atom = function + | Rel _ | Eq _ | In _ -> true + | _ -> false + (* Map [f] to all literals (i.e. atoms or not(atom)'s) in the given formula. Preserves order of subformulas. *) let rec map_to_literals f g = function @@ -661,7 +665,8 @@ if simp_p = p && simp_q = q then Times (p, q) else simplify_re ~do_pnf ~do_formula (Times (simp_p, simp_q)) -(* Flatten "and"s and "or"s in a formula -- i.e. associativity. *) +(* Flatten "and"s and "or"s in a formula -- + i.e. associativity. Remove double negation along the way. *) let rec flatten_formula phi = let rec flat_and = function | And conjs -> Aux.concat_map flat_and conjs @@ -682,6 +687,7 @@ | And _ -> And (flat_and phi) | All (vs, phi) -> All (vs, flatten_formula phi) | Ex (vs, phi) -> Ex (vs, flatten_formula phi) + | Not (Not phi) -> flatten_formula phi | Not phi -> Not (flatten_formula phi) | (Rel _ | Eq _ | In _ | RealExpr _) as atom -> atom @@ -709,38 +715,124 @@ free_conjs @ [Ex (vs, bound_phi)]) | phi -> [phi] -(* Remove literals from disjunctions in positive positions - (conjunctions in negative positions) that already occur conjoined - to the disjucntion. (Does not descend the real part currently.) *) -let remove_redundant phi = - let rec aux base neg = function +(* Simplify the formula by removing relational literals, depending on + what literals they are conjoined with up the tree, whether they are + in a disjunction and what literals they are disjoined with, keeping + track of the sign (variance) of a position. (Does not descend the + real part currently.) [implies] is applied to atoms only. Repeat + the removal till fixpoint since it can "unpack" literals e.g. from + conjunctions to disjunctions. *) +let remove_redundant ?(implies=(=)) phi = + let implied_by x y = implies y x in + let literal neg phis = + if neg then List.map (fun phi->Not phi) phis + else phis in + (* FIXME: check if all is fine under [neg=false] *) + let rec aux_conjs posbase negbase neg conjs = + let more_posbase, subtasks = List.partition is_atom conjs in + let more_negbase, subtasks = Aux.partition_map (function + | Not phi when is_atom phi -> Aux.Left phi | phi -> Aux.Right phi + ) subtasks in + let more_posbase, more_negbase = + if neg then more_negbase, more_posbase + else more_posbase, more_negbase in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "aux_conjs: neg=%b; \ + posbase=%s -- negbase=%s\n\ + more_posbase=%s -- more_negbase=%s\n%!" + neg + (String.concat "; " (List.map Formula.str posbase)) + (String.concat "; " (List.map Formula.str negbase)) + (String.concat "; " (List.map Formula.str more_posbase)) + (String.concat "; " (List.map Formula.str more_negbase)) + ); + (* }}} *) + (* remove redundant *) + let more_posbase = List.filter + (fun more -> not (List.exists (implied_by more) posbase)) + more_posbase in + let more_posbase = Aux.maximal implied_by more_posbase in + let more_negbase = List.filter + (fun less -> not (List.exists (implies less) negbase)) + more_negbase in + let more_negbase = Aux.maximal implies more_negbase in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "aux_conjs: result more_posbase=%s -- more_negbase=%s\n%!" + (String.concat "; " (List.map Formula.str more_posbase)) + (String.concat "; " (List.map Formula.str more_negbase)) + ); + (* }}} *) + literal neg more_posbase @ literal (not neg) more_negbase @ + List.map (aux (more_posbase @ posbase) (more_negbase @ negbase) neg) + subtasks + + and aux_disjs posbase negbase neg disjs = + let poslits, subtasks = List.partition is_atom disjs in + let neglits, subtasks = Aux.partition_map (function + | Not phi when is_atom phi -> Aux.Left phi | phi -> Aux.Right phi + ) subtasks in + let poslits, neglits = + if neg then neglits, poslits else poslits, neglits in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "aux_disjs: neg=%b; \ + posbase=%s -- negbase=%s\n\ + poslits=%s -- neglits=%s\n%!" + neg + (String.concat "; " (List.map Formula.str posbase)) + (String.concat "; " (List.map Formula.str negbase)) + (String.concat "; " (List.map Formula.str poslits)) + (String.concat "; " (List.map Formula.str neglits)) + ); + (* }}} *) + (* remove contradicted *) + let poslits = List.filter + (fun more -> not (List.exists (implies more) negbase)) + poslits in + let poslits = Aux.maximal implies poslits in + let neglits = List.filter + (fun less -> not (List.exists (implied_by less) posbase)) + neglits in + let neglits = Aux.maximal implied_by neglits in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "aux_disjs: result poslits=%s -- neglits=%s\n%!" + (String.concat "; " (List.map Formula.str poslits)) + (String.concat "; " (List.map Formula.str neglits)) + ); + (* }}} *) + literal neg poslits @ literal (not neg) neglits @ + List.map (aux posbase negbase neg) subtasks + + and aux posbase negbase neg = function | And conjs when not neg -> - let more_base, subtasks = List.partition (function - | Rel _ | Not (Rel _) -> true | _ -> false) conjs in - And (more_base @ List.map (aux (more_base @ base) neg) subtasks) + And (aux_conjs posbase negbase neg conjs) | Or conjs when neg -> - let more_base, subtasks = List.partition (function - | Rel _ | Not (Rel _) -> true | _ -> false) conjs in - Or (more_base @ List.map (aux (more_base @ base) neg) subtasks) + Or (aux_conjs posbase negbase neg conjs) + | And disjs (* when neg *) -> + And (aux_disjs posbase negbase neg disjs) | Or disjs (* when not neg *) -> - let literals, subtasks = List.partition (function - | Rel _ | Not (Rel _) -> true | _ -> false) disjs in - let disjs = - Aux.list_diff literals base @ List.map (aux base neg) subtasks in - (match disjs with [disj] -> disj | _ -> Or disjs) - | And disjs (* when neg *) -> - let literals, subtasks = List.partition (function - | Rel _ | Not (Rel _) -> true | _ -> false) disjs in - let disjs = - Aux.list_diff literals base @ List.map (aux base neg) subtasks in - (match disjs with [disj] -> disj | _ -> And disjs) - | Not phi -> Not (aux base (not neg) phi) - | Ex (vs, phi) -> Ex (vs, aux base neg phi) - | All (vs, phi) -> All (vs, aux base neg phi) + Or (aux_disjs posbase negbase neg disjs) + + | Not phi -> Not (aux posbase negbase (not neg) phi) + | Ex (vs, phi) -> Ex (vs, aux posbase negbase neg phi) + | All (vs, phi) -> All (vs, aux posbase negbase neg phi) | phi -> phi in - aux [] false (flatten_formula phi) + let rec fixpoint phi = + (* {{{ log entry *) + if !debug_level > 1 then ( + Printf.printf "remove_redundant: step %s\n%!" + (Formula.str phi) + ); + (* }}} *) + let res = aux [] [] false (flatten_formula phi) in + if res = phi then res else fixpoint res in + fixpoint phi + (* Compute size of a formula (currently w/o descending the real part). *) let rec size = function | Or js | And js -> List.fold_left (+) 1 (List.map size js) Modified: trunk/Toss/Formula/FormulaOps.mli =================================================================== --- trunk/Toss/Formula/FormulaOps.mli 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/Formula/FormulaOps.mli 2011-03-15 11:03:16 UTC (rev 1361) @@ -85,17 +85,23 @@ val pnf : formula -> formula -(** Flatten "and"s and "or"s in a formula -- i.e. associativity. *) +(** Flatten "and"s and "or"s in a formula -- + i.e. associativity. Remove double negation along the way. *) val flatten_formula : formula -> formula (** Formula as a list of conjuncts, with one level of distributing negation over disjunction and pushing quantifiers inside. *) val flatten_ands : formula -> formula list -(** Remove literals from disjunctions in positive positions - (conjunctions in negative positions) that already occur conjoined - to the disjucntion. (Does not descend the real part currently.) *) -val remove_redundant : formula -> formula +(** Simplify the formula by removing relational literals, depending on + what literals they are conjoined with up the tree, whether they are + in a disjunction and what literals they are disjoined with, keeping + track of the sign (variance) of a position. (Does not descend the + real part currently.) [implies] is applied to atoms only. Repeat + the removal till fixpoint since it can "unpack" literals e.g. from + conjunctions to disjunctions. *) +val remove_redundant : + ?implies:(formula -> formula -> bool) -> formula -> formula (** Compute size of a formula (currently w/o descending the real part). *) val size : formula -> int Modified: trunk/Toss/Formula/FormulaOpsTest.ml =================================================================== --- trunk/Toss/Formula/FormulaOpsTest.ml 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/Formula/FormulaOpsTest.ml 2011-03-15 11:03:16 UTC (rev 1361) @@ -329,6 +329,39 @@ formula_eq id phi2 (FormulaOps.make_fo_tc_disj k x y) phi1 in tc_eq 2 "x" "y" "R(x, y)" "x = y or R(x, y) or ex t(R(x,t) and R(t,y))"; ); + + "remove_redundant default" >:: + (fun () -> + let rr_eq phi1 phi2 = + formula_eq id phi2 FormulaOps.remove_redundant phi1 in + rr_eq "P(x) and P(x)" "P(x)"; + rr_eq "P(x) and (not P(x) or Q(x))" "P(x) and Q(x)"; + rr_eq "not P(x) and (O(x) or Q(x) or P(x))" + "not P(x) and (O(x) or Q(x))"; + rr_eq "not P(x) and (not O(x) or Q(x) or P(x)) and O(x)" + "O(x) and Q(x) and not P(x)"; + rr_eq "not (P(x) or (not P(x) and Q(x)))" "not (P(x) or Q(x))"; + ); + + "remove_redundant P->Q,R->S" >:: + (fun () -> + let implies phi1 phi2 = + match phi1, phi2 with + | Formula.Rel ("P",xs), Formula.Rel ("Q",ys) when xs=ys -> true + | Formula.Rel ("R",xs), Formula.Rel ("S",ys) when xs=ys -> true + | _ when phi1 = phi2 -> true + | _ -> false in + let rr_eq phi1 phi2 = + formula_eq id phi2 (FormulaOps.remove_redundant ~implies) phi1 in + rr_eq "P(x) and Q(x)" "P(x)"; + rr_eq "P(x) and (not Q(x) or R(x,y))" "P(x) and R(x,y)"; + rr_eq "Q(x) and (not P(x) or R(x,y))" + "Q(x) and (R(x, y) or not P(x))"; + rr_eq "not Q(x) and (P(x) or R(x,y))" "R(x,y) and not Q(x)"; + rr_eq "not (S(x,y) or (P(x) and not R(x,y)))" + "not (S(x, y) or P(x))"; + ); + ] ;; let a = Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/GGP/GDL.ml 2011-03-15 11:03:16 UTC (rev 1361) @@ -3431,7 +3431,7 @@ } in (* {{{ log entry *) (* * - let file = open_out "./GGP/tests/breakthrough-raw.toss" in + let file = open_out "./GGP/tests/connect5-raw.toss" in output_string file (Arena.state_str result); close_out file; * *) @@ -3451,7 +3451,7 @@ ) loc_noop_legal in (* {{{ log entry *) (* * - let file = open_out "./GGP/tests/breakthrough-simpl.toss" in + let file = open_out "./GGP/tests/connect5-simpl.toss" in output_string file (Arena.state_str result); close_out file; * *) Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/GGP/GDLTest.ml 2011-03-15 11:03:16 UTC (rev 1361) @@ -146,5 +146,5 @@ let breakthrough = load_rules "./GGP/examples/breakthrough.gdl" in let connect5 = load_rules "./GGP/examples/connect5.gdl" in let tictactoe = load_rules "./GGP/examples/tictactoe.gdl" in - let gdl_def, toss_def = GDL.translate_game (Const "white") breakthrough in + let gdl_def, toss_def = GDL.translate_game (Const "x") connect5 in ignore gdl_def; ignore connect5; ignore breakthrough; ignore tictactoe Modified: trunk/Toss/GGP/GameSimpl.ml =================================================================== --- trunk/Toss/GGP/GameSimpl.ml 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/GGP/GameSimpl.ml 2011-03-15 11:03:16 UTC (rev 1361) @@ -23,10 +23,11 @@ that occur positively in the LHS and are complements of their original. Derive all the tuples of embedded relations that are required to be absent for a match (not present, even optionally, - in the LHS). Remove the non-optional tuples for relations that are - complements of their originals and add tuples of originals that - are complements of relations that are required to be - absent. Rename relations equivalent to their originals. + in the LHS). (1a1) Rename relations equivalent to their + originals. (1a2) Remove the non-optional tuples for relations that + are complements of their originals and (1a3) add tuples of + originals that are complements of relations that are required to + be absent. (2) Locate relations that subsume, or are subsumed by others (in terms of inclusion relations between their graphs). Simplify @@ -94,7 +95,7 @@ (String.concat ", " fluents) ); (* }}} *) - (* prepare for (3) and (1) *) + (* prepare for (1) and (2) *) let subset_table = List.fold_left (fun table (rel,arity) -> let rel_tups = @@ -109,6 +110,14 @@ ) Aux.Strings.empty signat in Aux.StrMap.add rel row table ) Aux.StrMap.empty signat in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "GameSimpl: subset table =\n%s\n%!" + (Aux.StrMap.fold (fun k v acc -> + acc^"\n"^k^" < "^ + String.concat ", " (Aux.Strings.elements v)) subset_table "") + ); + (* }}} *) let subsumed rel1 rel2 = Aux.Strings.mem rel2 (Aux.StrMap.find rel1 subset_table) in let compl_table = @@ -124,8 +133,8 @@ let ntups = tcard rel_tups and ntups2 = tcard rel2_tups in if ntups >= ntups2 && ntups + ntups2 = Aux.int_pow nelems arity && - Structure.Tuples.is_empty - (Structure.Tuples.inter rel_tups rel2_tups) + Structure.Tuples.is_empty + (Structure.Tuples.inter rel_tups rel2_tups) then Aux.Strings.add rel2 row else row ) Aux.Strings.empty signat in @@ -137,19 +146,30 @@ let equivalent = List.map (fun (rel1, arity) -> try - let rel2, _ = - List.find (fun (rel2, arity2) -> - rel1 <> rel2 && arity = arity2 && - (complement rel1 rel2 || - (subsumed rel1 rel2 && subsumed rel2 rel1)) - ) signat in - rel1, (rel2, complement rel1 rel2) + let rel2, _ = + List.find (fun (rel2, arity2) -> + arity = arity2 && + not (List.mem rel2 fluents || + List.mem_assoc rel2 game.Arena.defined_rels) && + (complement rel1 rel2 || + (subsumed rel1 rel2 && subsumed rel2 rel1)) + ) signat in + rel1, (rel2, complement rel1 rel2) with Not_found -> rel1, (rel1, false) ) signat in let removable rel = + let spec = DiscreteRule.special_rel_of rel in + let rel = + match spec with + | None -> rel + | Some spec -> DiscreteRule.orig_rel_of rel in not (List.mem rel fluents) && not (List.mem_assoc rel game.Arena.defined_rels) && - not (List.exists (fun (_,(rel2,_)) -> rel2=rel) equivalent) in + not (List.exists (fun (_,(rel2,_)) -> rel2=rel) equivalent) && + not (List.mem (fst (List.assoc rel equivalent)) fluents || + List.mem_assoc (fst (List.assoc rel equivalent)) + game.Arena.defined_rels) + in (* {{{ log entry *) if !debug_level > 0 then ( Printf.printf "GameSimpl: equivalent structures --\n%s\n%!" @@ -217,6 +237,7 @@ let ltups = Structure.Tuples.elements in let lhs_neg_tups = r.ContinuousRule.compiled.DiscreteRule.lhs_neg_tups in + (* 1a1: renaming removable relations to their originals *) let lhs_struc = Structure.StringMap.fold (fun rel tups lhs_struc -> let spec = DiscreteRule.special_rel_of rel in @@ -227,14 +248,17 @@ if not (removable rel) then lhs_struc else let orig, neg = List.assoc rel equivalent in - if not neg then - let orig = - match spec with - | None -> orig - | Some spec -> "_"^spec^"_"^orig in + let orig = + match spec with + | None -> orig + | Some spec -> "_"^spec^"_"^orig in + if not neg (* 1a1 *) + || (neg && spec = Some "opt") (* not-1a2 *) + then Structure.add_rels lhs_struc orig (ltups tups) else if List.mem_assoc rel lhs_neg_tups - then + && spec <> Some "opt" + then (* 1a3 *) Structure.add_rels lhs_struc orig (List.assoc rel lhs_neg_tups) else lhs_struc @@ -289,4 +313,8 @@ emb_rels = emb_rels; }}) game.Arena.rules} in + (* 2 *) + (*let game = + Arena.map_to_formulas (FormulaOps.)*) + game, state Modified: trunk/Toss/GGP/GameSimplTest.ml =================================================================== --- trunk/Toss/GGP/GameSimplTest.ml 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/GGP/GameSimplTest.ml 2011-03-15 11:03:16 UTC (rev 1361) @@ -58,3 +58,14 @@ with | Some tests -> ignore (run_test_tt ~verbose:true tests) | None -> () + +let a () = + let breakthrough = state_of_file "./GGP/tests/breakthrough-raw.toss" in + Printf.printf "\nINPUT:\n%s\n%!" (Arena.state_str breakthrough); + GameSimpl.debug_level := 4; + let res = GameSimpl.simplify breakthrough in + let resf = open_out "./GGP/tests/breakthrough-simpl.toss" in + let res_str = Arena.state_str res in + output_string resf res_str; + close_out resf; + Printf.printf "\nRESULT:\n%s\n%!" res_str Modified: trunk/Toss/GGP/tests/breakthrough-simpl.toss =================================================================== --- trunk/Toss/GGP/tests/breakthrough-simpl.toss 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/GGP/tests/breakthrough-simpl.toss 2011-03-15 11:03:16 UTC (rev 1361) @@ -1,10 +1,13 @@ PLAYERS white, black RULE move_x1_y1_x2_y2_0: [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | + _opt_cellholds_x2_y2_black { + cellholds_x1_y1__blank_; cellholds_x2_y2__blank_; control__blank_}; + _opt_cellholds_x2_y2_white (control__blank_); + _opt_control_black {cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; + _opt_control_white {cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; cellholds_x2_y2_white (cellholds_x1_y1__blank_); control_white (control__blank_); - index__cellholds_x2_y2_MV1_x2 { - cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; index__cellholds_x2_y2_MV1_y2 { cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; succ__cellholds_x2_y2_MV1_x2__cellholds_x2_y2_MV1_x2 @@ -24,31 +27,34 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x374_8__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and - not not ex cellholds_x377_y369__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x377_y369__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and cellholds_x2_y2_white(cellholds_x377_y369__blank_))) RULE move_x1_y1_x2_y2_00: [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | + _opt_cellholds_x2_y2_black { + cellholds_x1_y1__blank_; cellholds_x2_y2__blank_; control__blank_}; + _opt_cellholds_x2_y2_white (control__blank_); + _opt_control_black {cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; + _opt_control_white {cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; cellholds_x2_y2_white (cellholds_x1_y1__blank_); control_white (control__blank_); - index__cellholds_x2_y2_MV1_x2 { - cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; index__cellholds_x2_y2_MV1_y2 { cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; succ__cellholds_x2_y2_MV1_x2__cellholds_x2_y2_MV1_x2 @@ -68,42 +74,45 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x374_8__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and - not not ex cellholds_x377_y369__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x377_y369__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and cellholds_x2_y2_white(cellholds_x377_y369__blank_))) -RULE move_x_y1_x_y2_0: - [cellholds_x_y1__blank_, cellholds_x_y2__blank_, control__blank_ | - EQ___cellholds_x2_y2_MV1_x2 - (cellholds_x_y1__blank_, cellholds_x_y2__blank_); - cellholds_x2_y2_white (cellholds_x_y1__blank_); - control_white (control__blank_); - index__cellholds_x2_y2_MV1_x2 { - cellholds_x_y1__blank_; cellholds_x_y2__blank_}; +RULE move_x1_y1_x2_y2_1: + [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | + _opt_cellholds_x2_y2_black (control__blank_); + _opt_cellholds_x2_y2_white { + cellholds_x1_y1__blank_; cellholds_x2_y2__blank_; control__blank_}; + _opt_control_black {cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; + _opt_control_white {cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; + cellholds_x2_y2_black (cellholds_x1_y1__blank_); + control_black (control__blank_); index__cellholds_x2_y2_MV1_y2 { - cellholds_x_y1__blank_; cellholds_x_y2__blank_}; + cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; + succ__cellholds_x2_y2_MV1_x2__cellholds_x2_y2_MV1_x2 + (cellholds_x2_y2__blank_, cellholds_x1_y1__blank_); succ__cellholds_x2_y2_MV1_y2__cellholds_x2_y2_MV1_y2 - (cellholds_x_y1__blank_, cellholds_x_y2__blank_) + (cellholds_x2_y2__blank_, cellholds_x1_y1__blank_) | ] -> - [cellholds_x_y1__blank_, cellholds_x_y2__blank_, control__blank_ | - cellholds_x2_y2_white (cellholds_x_y2__blank_); - control_black (control__blank_) + [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | + cellholds_x2_y2_black (cellholds_x2_y2__blank_); + control_white (control__blank_) | ] emb cellholds_x2_y2_black, cellholds_x2_y2_white, control_black, @@ -112,35 +121,38 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x374_8__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and - not not ex cellholds_x377_y369__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x377_y369__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and cellholds_x2_y2_white(cellholds_x377_y369__blank_))) -RULE move_x1_y1_x2_y2_1: +RULE move_x1_y1_x2_y2_10: [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | + _opt_cellholds_x2_y2_black (control__blank_); + _opt_cellholds_x2_y2_white { + cellholds_x1_y1__blank_; cellholds_x2_y2__blank_; control__blank_}; + _opt_control_black {cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; + _opt_control_white {cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; cellholds_x2_y2_black (cellholds_x1_y1__blank_); control_black (control__blank_); - index__cellholds_x2_y2_MV1_x2 { - cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; index__cellholds_x2_y2_MV1_y2 { cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; succ__cellholds_x2_y2_MV1_x2__cellholds_x2_y2_MV1_x2 - (cellholds_x2_y2__blank_, cellholds_x1_y1__blank_); + (cellholds_x1_y1__blank_, cellholds_x2_y2__blank_); succ__cellholds_x2_y2_MV1_y2__cellholds_x2_y2_MV1_y2 (cellholds_x2_y2__blank_, cellholds_x1_y1__blank_) | @@ -156,42 +168,44 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x374_8__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and - not not ex cellholds_x377_y369__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x377_y369__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and cellholds_x2_y2_white(cellholds_x377_y369__blank_))) -RULE move_x1_y1_x2_y2_10: - [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | - cellholds_x2_y2_black (cellholds_x1_y1__blank_); - control_black (control__blank_); - index__cellholds_x2_y2_MV1_x2 { - cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; +RULE move_x_y1_x_y2_0: + [cellholds_x_y1__blank_, cellholds_x_y2__blank_, control__blank_ | + EQ___cellholds_x2_y2_MV1_x2 + (cellholds_x_y1__blank_, cellholds_x_y2__blank_); + _opt_cellholds_x2_y2_black {cellholds_x_y1__blank_; control__blank_}; + _opt_cellholds_x2_y2_white (control__blank_); + _opt_control_black {cellholds_x_y1__blank_; cellholds_x_y2__blank_}; + _opt_control_white {cellholds_x_y1__blank_; cellholds_x_y2__blank_}; + cellholds_x2_y2_white (cellholds_x_y1__blank_); + control_white (control__blank_); index__cellholds_x2_y2_MV1_y2 { - cellholds_x1_y1__blank_; cellholds_x2_y2__blank_}; - succ__cellholds_x2_y2_MV1_x2__cellholds_x2_y2_MV1_x2 - (cellholds_x1_y1__blank_, cellholds_x2_y2__blank_); + cellholds_x_y1__blank_; cellholds_x_y2__blank_}; succ__cellholds_x2_y2_MV1_y2__cellholds_x2_y2_MV1_y2 - (cellholds_x2_y2__blank_, cellholds_x1_y1__blank_) + (cellholds_x_y1__blank_, cellholds_x_y2__blank_) | ] -> - [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | - cellholds_x2_y2_black (cellholds_x2_y2__blank_); - control_white (control__blank_) + [cellholds_x_y1__blank_, cellholds_x_y2__blank_, control__blank_ | + cellholds_x2_y2_white (cellholds_x_y2__blank_); + control_black (control__blank_) | ] emb cellholds_x2_y2_black, cellholds_x2_y2_white, control_black, @@ -200,33 +214,35 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x374_8__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and - not not ex cellholds_x377_y369__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x377_y369__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and cellholds_x2_y2_white(cellholds_x377_y369__blank_))) RULE move_x_y1_x_y2_1: [cellholds_x_y1__blank_, cellholds_x_y2__blank_, control__blank_ | EQ___cellholds_x2_y2_MV1_x2 (cellholds_x_y1__blank_, cellholds_x_y2__blank_); + _opt_cellholds_x2_y2_black (control__blank_); + _opt_cellholds_x2_y2_white {cellholds_x_y1__blank_; control__blank_}; + _opt_control_black {cellholds_x_y1__blank_; cellholds_x_y2__blank_}; + _opt_control_white {cellholds_x_y1__blank_; cellholds_x_y2__blank_}; cellholds_x2_y2_black (cellholds_x_y1__blank_); control_black (control__blank_); - index__cellholds_x2_y2_MV1_x2 { - cellholds_x_y1__blank_; cellholds_x_y2__blank_}; index__cellholds_x2_y2_MV1_y2 { cellholds_x_y1__blank_; cellholds_x_y2__blank_}; succ__cellholds_x2_y2_MV1_y2__cellholds_x2_y2_MV1_y2 @@ -244,24 +260,24 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x374_8__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and + not + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and - not not ex cellholds_x377_y369__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x377_y369__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and cellholds_x2_y2_white(cellholds_x377_y369__blank_))) LOC 0 { PLAYER white @@ -271,12 +287,12 @@ :( ex cellholds_x26_8__blank_ (cellholds_x2_8_MV1(cellholds_x26_8__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x26_8__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x26_8__blank_) and cellholds_x2_y2_white(cellholds_x26_8__blank_)) or not ex cellholds_x27_y26__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x27_y26__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x27_y26__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x27_y26__blank_) and cellholds_x2_y2_black(cellholds_x27_y26__blank_)) ); black: @@ -284,12 +300,12 @@ :( ex cellholds_x30_1__blank_ (cellholds_x2_1_MV1(cellholds_x30_1__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x30_1__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x30_1__blank_) and cellholds_x2_y2_black(cellholds_x30_1__blank_)) or not ex cellholds_x31_y28__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x31_y28__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x31_y28__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x31_y28__blank_) and cellholds_x2_y2_white(cellholds_x31_y28__blank_)) ) } @@ -304,12 +320,12 @@ :( ex cellholds_x26_8__blank_ (cellholds_x2_8_MV1(cellholds_x26_8__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x26_8__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x26_8__blank_) and cellholds_x2_y2_white(cellholds_x26_8__blank_)) or not ex cellholds_x27_y26__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x27_y26__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x27_y26__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x27_y26__blank_) and cellholds_x2_y2_black(cellholds_x27_y26__blank_)) ); black: @@ -317,12 +333,12 @@ :( ex cellholds_x30_1__blank_ (cellholds_x2_1_MV1(cellholds_x30_1__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x30_1__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x30_1__blank_) and cellholds_x2_y2_black(cellholds_x30_1__blank_)) or not ex cellholds_x31_y28__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x31_y28__blank_) and - index__cellholds_x2_y2_MV1_x2(cellholds_x31_y28__blank_) and + index__cellholds_x2_y2_MV1_y2(cellholds_x31_y28__blank_) and cellholds_x2_y2_white(cellholds_x31_y28__blank_)) ) } @@ -1478,30 +1494,6 @@ }; control_MV1 (control_MV1); control_black:1 {}; control_white (control_MV1); - index__cellholds_x2_y2_MV1_x2 { - cellholds_8_8_MV1; cellholds_8_7_MV1; cellholds_8_6_MV1; - cellholds_8_5_MV1; cellholds_8_4_MV1; cellholds_8_3_MV1; - cellholds_8_2_MV1; cellholds_8_1_MV1; cellholds_7_8_MV1; - cellholds_7_7_MV1; cellholds_7_6_MV1; cellholds_7_5_MV1; - cellholds_7_4_MV1; cellholds_7_3_MV1; cellholds_7_2_MV1; - cellholds_7_1_MV1; cellholds_6_8_MV1; cellholds_6_7_MV1; - cellholds_6_6_MV1; cellholds_6_5_MV1; cellholds_6_4_MV1; - cellholds_6_3_MV1; cellholds_6_2_MV1; cellholds_6_1_MV1; - cellholds_5_8_MV1; cellholds_5_7_MV1; cellholds_5_6_MV1; - cellholds_5_5_MV1; cellholds_5_4_MV1; cellholds_5_3_MV1; - cellholds_5_2_MV1; cellholds_5_1_MV1; cellholds_4_8_MV1; - cellholds_4_7_MV1; cellholds_4_6_MV1; cellholds_4_5_MV1; - cellholds_4_4_MV1; cellholds_4_3_MV1; cellholds_4_2_MV1; - cellholds_4_1_MV1; cellholds_3_8_MV1; cellholds_3_7_MV1; - cellholds_3_6_MV1; cellholds_3_5_MV1; cellholds_3_4_MV1; - cellholds_3_3_MV1; cellholds_3_2_MV1; cellholds_3_1_MV1; - cellholds_2_8_MV1; cellholds_2_7_MV1; cellholds_2_6_MV1; - cellholds_2_5_MV1; cellholds_2_4_MV1; cellholds_2_3_MV1; - cellholds_2_2_MV1; cellholds_2_1_MV1; cellholds_1_8_MV1; - cellholds_1_7_MV1; cellholds_1_6_MV1; cellholds_1_5_MV1; - cellholds_1_4_MV1; cellholds_1_3_MV1; cellholds_1_2_MV1; - cellholds_1_1_MV1 - }; index__cellholds_x2_y2_MV1_y2 { cellholds_8_8_MV1; cellholds_8_7_MV1; cellholds_8_6_MV1; cellholds_8_5_MV1; cellholds_8_4_MV1; cellholds_8_3_MV1; @@ -1526,7 +1518,7 @@ cellholds_1_4_MV1; cellholds_1_3_MV1; cellholds_1_2_MV1; cellholds_1_1_MV1 }; - role__cellholds_x2_y2_MV1_x2:1 {}; role__cellholds_x2_y2_MV1_y2:1 {}; + role__cellholds_x2_y2_MV1_y2:1 {}; succ__cellholds_x2_y2_MV1_x2__cellholds_x2_y2_MV1_x2 { (cellholds_7_8_MV1, cellholds_8_8_MV1); (cellholds_7_8_MV1, cellholds_8_7_MV1); Modified: trunk/Toss/GGP/tests/connect5-simpl.toss =================================================================== --- trunk/Toss/GGP/tests/connect5-simpl.toss 2011-03-15 00:46:12 UTC (rev 1360) +++ trunk/Toss/GGP/tests/connect5-simpl.toss 2011-03-15 11:03:16 UTC (rev 1361) @@ -1,6 +1,11 @@ PLAYERS x, o RULE mark_x149_y149_0: [cell_x149_y149__blank_, control__blank_ | + _opt_cell_x_y_b (control__blank_); + _opt_cell_x_y_o {cell_x149_y149__blank_; control__blank_}; + _opt_cell_x_y_x {cell_x149_y149__blank_; control__blank_}; + _opt_control_o (cell_x149_y149__blank_); + _opt_control_x (cell_x149_y149__blank_); cell_x_y_b (cell_x149_y149__blank_); control_MV1 (control__blank_); control_x (control__blank_) | @@ -181,6 +186,11 @@ not not ex cell_x182_y182__blank_ cell_x_y_b(cell_x182_y182__blank_)) RULE mark_x159_y159_1: [cell_x159_y159__blank_, control__blank_ | + _opt_cell_x_y_b (control__blank_); + _opt_cell_x_y_o {cell_x159_y159__blank_; control__blank_}; + _opt_cell_x_y_x {cell_x159_y159__blank_; control__blank_}; + _opt_control_o (cell_x159_y159__blank_); + _opt_control_x (cell_x159_y159__blank_); cell_x_y_b (cell_x159_y159__blank_); control_MV1 (control__blank_); control_o (control__blank_) | @@ -1662,21 +1672,6 @@ }; cell_x_y_o:1 {}; cell_x_y_x:1 {}; control_MV1 (control_MV1); control_o:1 {}; control_x (control_MV1); - coordinate__cell_x_y_MV1_x { - cell_h_h_MV1; cell_h_g_MV1; cell_h_f_MV1; cell_h_e_MV1; cell_h_d_MV1; - cell_h_c_MV1; cell_h_b_MV1; cell_h_a_MV1; cell_g_h_MV1; cell_g_g_MV1; - cell_g_f_MV1; cell_g_e_MV1; cell_g_d_MV1; cell_g_c_MV1; cell_g_b_MV1; - cell_g_a_MV1; cell_f_h_MV1; cell_f_g_MV1; cell_f_f_MV1; cell_f_e_MV1; - cell_f_d_MV1; cell_f_c_MV1; cell_f_b_MV1; cell_f_a_MV1; cell_e_h_MV1; - cell_e_g_MV1; cell_e_f_MV1; cell_e_e_MV1; cell_e_d_MV1; cell_e_c_MV1; - cell_e_b_MV1; cell_e_a_MV1; cell_d_h_MV1; cell_d_g_MV1; cell_d_f_MV1; - cell_d_e_MV1; cell_d_d_MV1; cell_d_c_MV1; cell_d_b_MV1; cell_d_a_MV1; - cell_c_h_MV1; cell_c_g_MV1; cell_c_f_MV1; cell_c_e_MV1; cell_c_d_MV1; - cell_c_c_MV1; cell_c_b_MV1; cell_c_a_MV1; cell_b_h_MV1; cell_b_g_MV1; - cell_b_f_MV1; cell_b_e_MV1; cell_b_d_MV1; cell_b_c_MV1; cell_b_b_MV1; - cell_b_a_MV1; cell_a_h_MV1; cell_a_g_MV1; cell_a_f_MV1; cell_a_e_MV1; - cell_a_d_MV1; cell_a_c_MV1; cell_a_b_MV1; cell_a_a_MV1 - }; coordinate__cell_x_y_MV1_y { cell_h_h_MV1; cell_h_g_MV1; cell_h_f_MV1; cell_h_e_MV1; cell_h_d_MV1; cell_h_c_MV1; cell_h_b_MV1; cell_h_a_MV1; cell_g_h_MV1; cell_g_g_MV1; @@ -2596,6 +2591,6 @@ (cell_a_a_MV1, cell_d_b_MV1); (cell_a_a_MV1, cell_c_b_MV1); (cell_a_a_MV1, cell_b_b_MV1); (cell_a_a_MV1, cell_a_b_MV1) }; - role__cell_x_y_MV1_x:1 {}; role__cell_x_y_MV1_y:1 {} + role__cell_x_y_MV1_y:1 {} | ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-15 14:53:49
|
Revision: 1362 http://toss.svn.sourceforge.net/toss/?rev=1362&view=rev Author: lukstafi Date: 2011-03-15 14:53:40 +0000 (Tue, 15 Mar 2011) Log Message: ----------- Folding over formulas and atoms. GameSimpl stage 2: pruning subsumed atoms; stage 4: removing unused relations. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/Arena/ContinuousRule.ml trunk/Toss/Arena/ContinuousRule.mli trunk/Toss/Formula/FormulaOps.ml trunk/Toss/Formula/FormulaOps.mli trunk/Toss/GGP/GameSimpl.ml trunk/Toss/GGP/GameSimplTest.ml trunk/Toss/GGP/tests/breakthrough-simpl.toss trunk/Toss/GGP/tests/connect5-simpl.toss trunk/Toss/Solver/Solver.ml Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/Arena/Arena.ml 2011-03-15 14:53:40 UTC (rev 1362) @@ -392,6 +392,35 @@ drel, (args, f def)) game.defined_rels; } +let fold_over_formulas ~include_defined_rels f game acc = + let acc = + List.fold_right (fun (_, r) -> + ContinuousRule.fold_over_formulas f r + ) game.rules acc in + let acc = + Array.fold_right (fun loc -> + Array.fold_right (FormulaOps.fold_over_formulas_expr f) loc.payoffs + ) game.graph acc in + let acc = + if include_defined_rels then + List.fold_right (fun (_, (_, def)) -> f def) + game.defined_rels acc + else acc in + acc + +let map_to_structures f (game, state) = + {game with + rules = List.map (fun (rn, r) -> + rn, {r with ContinuousRule.discrete = + {r.ContinuousRule.discrete with + DiscreteRule.lhs_struc = + f r.ContinuousRule.discrete.DiscreteRule.lhs_struc; + DiscreteRule.rhs_struc = + f r.ContinuousRule.discrete.DiscreteRule.rhs_struc; + }}) game.rules}, + {state with + struc = f state.struc} + (* Compare two (game, state) pairs and explain the first difference met. Formulas and expressions are compared for syntactical equality. Players need to be given in the same order. Data is ignored. *) Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/Arena/Arena.mli 2011-03-15 14:53:40 UTC (rev 1362) @@ -109,7 +109,12 @@ ?extend_state:game * game_state -> definition list -> game * game_state val map_to_formulas : (Formula.formula -> Formula.formula) -> game -> game +val fold_over_formulas : include_defined_rels:bool -> + (Formula.formula -> 'a -> 'a) -> game -> 'a -> 'a +val map_to_structures : + (Structure.structure -> Structure.structure) -> game * game_state -> + game * game_state (** Compare two (game, state) pairs and explain the first difference met. Formulas and expressions are compared for syntactical Modified: trunk/Toss/Arena/ContinuousRule.ml =================================================================== --- trunk/Toss/Arena/ContinuousRule.ml 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/Arena/ContinuousRule.ml 2011-03-15 14:53:40 UTC (rev 1362) @@ -69,6 +69,16 @@ post = f r.post; } +let fold_over_formulas f r acc = + let acc = + f r.discrete.DiscreteRule.pre acc in + let acc = + f r.compiled.DiscreteRule.lhs_form acc in + let acc = f r.inv acc in + let acc = f r.post acc in + acc + + (* ---------------------- FINDING APPLICABLE MATCHES ------------------------ *) (* Find all matches of [r] in [struc] which satisfy [r]'s precondition. *) Modified: trunk/Toss/Arena/ContinuousRule.mli =================================================================== --- trunk/Toss/Arena/ContinuousRule.mli 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/Arena/ContinuousRule.mli 2011-03-15 14:53:40 UTC (rev 1362) @@ -55,6 +55,8 @@ val lhs : rule -> Structure.structure val rhs : rule -> Structure.structure val map_to_formulas : (Formula.formula -> Formula.formula) -> rule -> rule +val fold_over_formulas : + (Formula.formula -> 'a -> 'a) -> rule -> 'a -> 'a (** {2 Finding applicable matches} *) Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/Formula/FormulaOps.ml 2011-03-15 14:53:40 UTC (rev 1362) @@ -158,7 +158,17 @@ | Sum (vs, phi, r) -> Sum (vs, f phi, map_to_formulas_expr f r) +let rec fold_over_formulas_expr f r acc = + match r with + | RVar _ | Const _ | Fun _ -> acc + | Times (r1, r2) + | Plus (r1, r2) -> + fold_over_formulas_expr f r1 (fold_over_formulas_expr f r2 acc) + | Char (phi) -> f phi acc + | Sum (vs, phi, r) -> + fold_over_formulas_expr f r (f phi acc) + (* Map [f] to all atoms in the given formula. *) let map_to_atoms_full f g phi = map_to_literals (function Not (x) -> Not (f x) | x -> f x) g phi @@ -172,6 +182,25 @@ let map_to_atoms_expr f r = map_to_literals_expr (function Not (x) -> Not (f x) | x -> f x) (fun x -> x) r + +let rec fold_over_literals f phi acc = + match phi with + Rel _ | Eq _ | In _ as x -> f x acc + | Not (Rel _) | Not (Eq _) | Not (In _) as x -> f x acc + | Not phi -> fold_over_literals f phi acc + | Or flist + | And flist -> List.fold_right (fold_over_literals f) flist acc + | Ex (vs, phi) + | All (vs, phi) -> fold_over_literals f phi acc + | RealExpr (r, _) -> fold_over_literals_expr f r acc + +and fold_over_literals_expr f = + fold_over_formulas_expr (fold_over_literals f) + +let fold_over_atoms f phi = + fold_over_literals + (function Not x -> f x | x -> f x) phi + (* Map [f] to all variables occurring in the formula. Preserves order of subformulas. *) let rec map_to_all_vars (f : var -> var) = function Modified: trunk/Toss/Formula/FormulaOps.mli =================================================================== --- trunk/Toss/Formula/FormulaOps.mli 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/Formula/FormulaOps.mli 2011-03-15 14:53:40 UTC (rev 1362) @@ -30,6 +30,9 @@ [Sum] guards). *) val map_to_formulas_expr : (formula -> formula) -> real_expr -> real_expr +val fold_over_formulas_expr : + (formula -> 'a -> 'a) -> real_expr -> 'a -> 'a + (** Map [f] to all atoms in the given formula. *) val map_to_atoms_full : (formula -> formula) -> (real_expr -> real_expr) -> formula -> formula @@ -38,6 +41,11 @@ val map_to_atoms : (formula -> formula) -> formula -> formula val map_to_atoms_expr : (formula -> formula) -> real_expr -> real_expr +val fold_over_literals : + (formula -> 'a -> 'a) -> formula -> 'a -> 'a +val fold_over_atoms : + (formula -> 'a -> 'a) -> formula -> 'a -> 'a + (** Map @param f to all variables occurring in the formula. Preserves order of subformulas. @param phi The formula to substitute in. *) val map_to_all_vars : (var -> var) -> formula -> formula Modified: trunk/Toss/GGP/GameSimpl.ml =================================================================== --- trunk/Toss/GGP/GameSimpl.ml 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/GGP/GameSimpl.ml 2011-03-15 14:53:40 UTC (rev 1362) @@ -45,6 +45,8 @@ over the same variables, with one of introduced predicates. For several possibilities of replacement pick one arbitrarily (currently, in the order of occurrence in the formula). + + (4) Remove from the structure relations that are no longer used. *) open Formula @@ -118,7 +120,7 @@ String.concat ", " (Aux.Strings.elements v)) subset_table "") ); (* }}} *) - let subsumed rel1 rel2 = + let included_in rel1 rel2 = Aux.Strings.mem rel2 (Aux.StrMap.find rel1 subset_table) in let compl_table = List.fold_left (fun table (rel,arity) -> @@ -152,7 +154,7 @@ not (List.mem rel2 fluents || List.mem_assoc rel2 game.Arena.defined_rels) && (complement rel1 rel2 || - (subsumed rel1 rel2 && subsumed rel2 rel1)) + (included_in rel1 rel2 && included_in rel2 rel1)) ) signat in rel1, (rel2, complement rel1 rel2) with Not_found -> rel1, (rel1, false) @@ -314,7 +316,39 @@ }}) game.Arena.rules} in (* 2 *) - (*let game = - Arena.map_to_formulas (FormulaOps.)*) + let implies phi1 phi2 = + match phi1, phi2 with + | _ when phi1 = phi2 -> true + | Rel (rel1, args1), Rel (rel2, args2) when args1 = args2 -> + not (List.mem rel1 fluents) && + not (List.mem rel2 fluents) && + included_in rel1 rel2 + | _ -> false in + let game = + Arena.map_to_formulas (FormulaOps.remove_redundant ~implies) game in - game, state + (* 4 *) + let add_rel rel acc = + match rel with + | Rel (rel,_) -> Aux.Strings.add rel acc + | _ -> acc in + let used_rels = + Arena.fold_over_formulas ~include_defined_rels:false + (FormulaOps.fold_over_atoms add_rel) + game Aux.Strings.empty in + let clear_rel rel = + let rel = + if DiscreteRule.special_rel_of rel = None then rel + else DiscreteRule.orig_rel_of rel in + let res = + not (List.mem_assoc rel game.Arena.defined_rels) && + not (Aux.Strings.mem rel used_rels) in + (* {{{ log entry *) + if !debug_level > 2 && res then ( + Printf.printf "GameSimpl: removing relation %s\n%!" rel + ); + (* }}} *) + res in + Arena.map_to_structures + (fun struc -> Structure.clear_rels struc clear_rel) + (game, state) Modified: trunk/Toss/GGP/GameSimplTest.ml =================================================================== --- trunk/Toss/GGP/GameSimplTest.ml 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/GGP/GameSimplTest.ml 2011-03-15 14:53:40 UTC (rev 1362) @@ -69,3 +69,14 @@ output_string resf res_str; close_out resf; Printf.printf "\nRESULT:\n%s\n%!" res_str + +let a () = + let connect5 = state_of_file "./GGP/tests/connect5-raw.toss" in + Printf.printf "\nINPUT:\n%s\n%!" (Arena.state_str connect5); + GameSimpl.debug_level := 4; + let res = GameSimpl.simplify connect5 in + let resf = open_out "./GGP/tests/connect5-simpl.toss" in + let res_str = Arena.state_str res in + output_string resf res_str; + close_out resf; + Printf.printf "\nRESULT:\n%s\n%!" res_str Modified: trunk/Toss/GGP/tests/breakthrough-simpl.toss =================================================================== --- trunk/Toss/GGP/tests/breakthrough-simpl.toss 2011-03-15 11:03:16 UTC (rev 1361) +++ trunk/Toss/GGP/tests/breakthrough-simpl.toss 2011-03-15 14:53:40 UTC (rev 1362) @@ -27,25 +27,17 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not - not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and - not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and not - not - ex cellholds_x377_y369__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - cellholds_x2_y2_white(cellholds_x377_y369__blank_))) + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x377_y369__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and + cellholds_x2_y2_white(cellholds_x377_y369__blank_))) RULE move_x1_y1_x2_y2_00: [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | _opt_cellholds_x2_y2_black { @@ -74,25 +66,17 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not - not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and - not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and not - not - ex cellholds_x377_y369__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - cellholds_x2_y2_white(cellholds_x377_y369__blank_))) + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x377_y369__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and + cellholds_x2_y2_white(cellholds_x377_y369__blank_))) RULE move_x1_y1_x2_y2_1: [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | _opt_cellholds_x2_y2_black (control__blank_); @@ -121,25 +105,17 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not - not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and - not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and not - not - ex cellholds_x377_y369__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - cellholds_x2_y2_white(cellholds_x377_y369__blank_))) + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x377_y369__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and + cellholds_x2_y2_white(cellholds_x377_y369__blank_))) RULE move_x1_y1_x2_y2_10: [cellholds_x1_y1__blank_, cellholds_x2_y2__blank_, control__blank_ | _opt_cellholds_x2_y2_black (control__blank_); @@ -168,25 +144,17 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not - not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and - not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and not - not - ex cellholds_x377_y369__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - cellholds_x2_y2_white(cellholds_x377_y369__blank_))) + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x377_y369__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and + cellholds_x2_y2_white(cellholds_x377_y369__blank_))) RULE move_x_y1_x_y2_0: [cellholds_x_y1__blank_, cellholds_x_y2__blank_, control__blank_ | EQ___cellholds_x2_y2_MV1_x2 @@ -214,25 +182,17 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not - not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and - not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and not - not - ex cellholds_x377_y369__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - cellholds_x2_y2_white(cellholds_x377_y369__blank_))) + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x377_y369__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and + cellholds_x2_y2_white(cellholds_x377_y369__blank_))) RULE move_x_y1_x_y2_1: [cellholds_x_y1__blank_, cellholds_x_y2__blank_, control__blank_ | EQ___cellholds_x2_y2_MV1_x2 @@ -260,25 +220,17 @@ (not ex cellholds_x374_8__blank_ (cellholds_x2_8_MV1(cellholds_x374_8__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x374_8__blank_) and cellholds_x2_y2_white(cellholds_x374_8__blank_)) and - not - not - ex cellholds_x375_y368__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and - cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and - not - ex cellholds_x376_1__blank_ - (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x376_1__blank_) and - cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x375_y368__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x375_y368__blank_) and + cellholds_x2_y2_black(cellholds_x375_y368__blank_)) and not - not - ex cellholds_x377_y369__blank_ - (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and - cellholds_x2_y2_white(cellholds_x377_y369__blank_))) + ex cellholds_x376_1__blank_ + (cellholds_x2_1_MV1(cellholds_x376_1__blank_) and + cellholds_x2_y2_black(cellholds_x376_1__blank_)) and + ex cellholds_x377_y369__blank_ + (index__cellholds_x2_y2_MV1_y2(cellholds_x377_y369__blank_) and + cellholds_x2_y2_white(cellholds_x377_y369__blank_))) LOC 0 { PLAYER white PAYOFF { @@ -287,12 +239,10 @@ :( ex cellholds_x26_8__blank_ (cellholds_x2_8_MV1(cellholds_x26_8__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x26_8__blank_) and cellholds_x2_y2_white(cellholds_x26_8__blank_)) or not ex cellholds_x27_y26__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x27_y26__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x27_y26__blank_) and cellholds_x2_y2_black(cellholds_x27_y26__blank_)) ); black: @@ -300,12 +250,10 @@ :( ex cellholds_x30_1__blank_ (cellholds_x2_1_MV1(cellholds_x30_1__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x30_1__blank_) and cellholds_x2_y2_black(cellholds_x30_1__blank_)) or not ex cellholds_x31_y28__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x31_y28__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x31_y28__blank_) and cellholds_x2_y2_white(cellholds_x31_y28__blank_)) ) } @@ -320,12 +268,10 @@ :( ex cellholds_x26_8__blank_ (cellholds_x2_8_MV1(cellholds_x26_8__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x26_8__blank_) and cellholds_x2_y2_white(cellholds_x26_8__blank_)) or not ex cellholds_x27_y26__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x27_y26__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x27_y26__blank_) and cellholds_x2_y2_black(cellholds_x27_y26__blank_)) ); black: @@ -333,12 +279,10 @@ :( ex cellholds_x30_1__blank_ (cellholds_x2_1_MV1(cellholds_x30_1__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x30_1__blank_) and cellholds_x2_y2_black(cellholds_x30_1__blank_)) or not ex cellholds_x31_y28__blank_ (index__cellholds_x2_y2_MV1_y2(cellholds_x31_y28__blank_) and - index__cellholds_x2_y2_MV1_y2(cellholds_x31_y28__blank_) and cellholds_x2_y2_white(cellholds_x31_y28__blank_)) ) } @@ -882,595 +826,11 @@ (cellholds_1_1_MV1, cellholds_1_2_MV1); (cellholds_1_1_MV1, cellholds_1_1_MV1) }; - EQ___cellholds_x2_y2_MV1_y2 { - (cellholds_8_8_MV1, cellholds_8_8_MV1); - (cellholds_8_8_MV1, cellholds_7_8_MV1); - (cellholds_8_8_MV1, cellholds_6_8_MV1); - (cellholds_8_8_MV1, cellholds_5_8_MV1); - (cellholds_8_8_MV1, cellholds_4_8_MV1); - (cellholds_8_8_MV1, cellholds_3_8_MV1); - (cellholds_8_8_MV1, cellholds_2_8_MV1); - (cellholds_8_8_MV1, cellholds_1_8_MV1); - (cellholds_8_7_MV1, cellholds_8_7_MV1); - (cellholds_8_7_MV1, cellholds_7_7_MV1); - (cellholds_8_7_MV1, cellholds_6_7_MV1); - (cellholds_8_7_MV1, cellholds_5_7_MV1); - (cellholds_8_7_MV1, cellholds_4_7_MV1); - (cellholds_8_7_MV1, cellholds_3_7_MV1); - (cellholds_8_7_MV1, cellholds_2_7_MV1); - (cellholds_8_7_MV1, cellholds_1_7_MV1); - (cellholds_8_6_MV1, cellholds_8_6_MV1); - (cellholds_8_6_MV1, cellholds_7_6_MV1); - (cellholds_8_6_MV1, cellholds_6_6_MV1); - (cellholds_8_6_MV1, cellholds_5_6_MV1); - (cellholds_8_6_MV1, cellholds_4_6_MV1); - (cellholds_8_6_MV1, cellholds_3_6_MV1); - (cellholds_8_6_MV1, cellholds_2_6_MV1); - (cellholds_8_6_MV1, cellholds_1_6_MV1); - (cellholds_8_5_MV1, cellholds_8_5_MV1); - (cellholds_8_5_MV1, cellholds_7_5_MV1); - (cellholds_8_5_MV1, cellholds_6_5_MV1); - (cellholds_8_5_MV1, cellholds_5_5_MV1); - (cellholds_8_5_MV1, cellholds_4_5_MV1); - (cellholds_8_5_MV1, cellholds_3_5_MV1); - (cellholds_8_5_MV1, cellholds_2_5_MV1); - (cellholds_8_5_MV1, cellholds_1_5_MV1); - (cellholds_8_4_MV1, cellholds_8_4_MV1); - (cellholds_8_4_MV1, cellholds_7_4_MV1); - (cellholds_8_4_MV1, cellholds_6_4_MV1); - (cellholds_8_4_MV1, cellholds_5_4_MV1); - (cellholds_8_4_MV1, cellholds_4_4_MV1); - (cellholds_8_4_MV1, cellholds_3_4_MV1); - (cellholds_8_4_MV1, cellholds_2_4_MV1); - (cellholds_8_4_MV1, cellholds_1_4_MV1); - (cellholds_8_3_MV1, cellholds_8_3_MV1); - (cellholds_8_3_MV1, cellholds_7_3_MV1); - (cellholds_8_3_MV1, cellholds_6_3_MV1); - (cellholds_8_3_MV1, cellholds_5_3_MV1); - (cellholds_8_3_MV1, cellholds_4_3_MV1); - (cellholds_8_3_MV1, cellholds_3_3_MV1); - (cellholds_8_3_MV1, cellholds_2_3_MV1); - (cellholds_8_3_MV1, cellholds_1_3_MV1); - (cellholds_8_2_MV1, cellholds_8_2_MV1); - (cellholds_8_2_MV1, cellholds_7_2_MV1); - (cellholds_8_2_MV1, cellholds_6_2_MV1); - (cellholds_8_2_MV1, cellholds_5_2_MV1); - (cellholds_8_2_MV1, cellholds_4_2_MV1); - (cellholds_8_2_MV1, cellholds_3_2_MV1); - (cellholds_8_2_MV1, cellholds_2_2_MV1); - (cellholds_8_2_MV1, cellholds_1_2_MV1); - (cellholds_8_1_MV1, cellholds_8_1_MV1); - (cellholds_8_1_MV1, cellholds_7_1_MV1); - (cellholds_8_1_MV1, cellholds_6_1_MV1); - (cellholds_8_1_MV1, cellholds_5_1_MV1); - (cellholds_8_1_MV1, cellholds_4_1_MV1); - (cellholds_8_1_MV1, cellholds_3_1_MV1); - (cellholds_8_1_MV1, cellholds_2_1_MV1); - (cellholds_8_1_MV1, cellholds_1_1_MV1); - (cellholds_7_8_MV1, cellholds_8_8_MV1); - (cellholds_7_8_MV1, cellholds_7_8_MV1); - (cellholds_7_8_MV1, cellholds_6_8_MV1); - (cellholds_7_8_MV1, cellholds_5_8_MV1); - (cellholds_7_8_MV1, cellholds_4_8_MV1); - (cellholds_7_8_MV1, cellholds_3_8_MV1); - (cellholds_7_8_MV1, cellholds_2_8_MV1); - (cellholds_7_8_MV1, cellholds_1_8_MV1); - (cellholds_7_7_MV1, cellholds_8_7_MV1); - (cellholds_7_7_MV1, cellholds_7_7_MV1); - (cellholds_7_7_MV1, cellholds_6_7_MV1); - (cellholds_7_7_MV1, cellholds_5_7_MV1); - (cellholds_7_7_MV1, cellholds_4_7_MV1); - (cellholds_7_7_MV1, cellholds_3_7_MV1); - (cellholds_7_7_MV1, cellholds_2_7_MV1); - (cellholds_7_7_MV1, cellholds_1_7_MV1); - (cellholds_7_6_MV1, cellholds_8_6_MV1); - (cellholds_7_6_MV1, cellholds_7_6_MV1); - (cellholds_7_6_MV1, cellholds_6_6_MV1); - (cellholds_7_6_MV1, cellholds_5_6_MV1); - (cellholds_7_6_MV1, cellholds_4_6_MV1); - (cellholds_7_6_MV1, cellholds_3_6_MV1); - (cellholds_7_6_MV1, cellholds_2_6_MV1); - (cellholds_7_6_MV1, cellholds_1_6_MV1); - (cellholds_7_5_MV1, cellholds_8_5_MV1); - (cellholds_7_5_MV1, cellholds_7_5_MV1); - (cellholds_7_5_MV1, cellholds_6_5_MV1); - (cellholds_7_5_MV1, cellholds_5_5_MV1); - (cellholds_7_5_MV1, cellholds_4_5_MV1); - (cellholds_7_5_MV1, cellholds_3_5_MV1); - (cellholds_7_5_MV1, cellholds_2_5_MV1); - (cellholds_7_5_MV1, cellholds_1_5_MV1); - (cellholds_7_4_MV1, cellholds_8_4_MV1); - (cellholds_7_4_MV1, cellholds_7_4_MV1); - (cellholds_7_4_MV1, cellholds_6_4_MV1); - (cellholds_7_4_MV1, cellholds_5_4_MV1); - (cellholds_7_4_MV1, cellholds_4_4_MV1); - (cellholds_7_4_MV1, cellholds_3_4_MV1); - (cellholds_7_4_MV1, cellholds_2_4_MV1); - (cellholds_7_4_MV1, cellholds_1_4_MV1); - (cellholds_7_3_MV1, cellholds_8_3_MV1); - (cellholds_7_3_MV1, cellholds_7_3_MV1); - (cellholds_7_3_MV1, cellholds_6_3_MV1); - (cellholds_7_3_MV1, cellholds_5_3_MV1); - (cellholds_7_3_MV1, cellholds_4_3_MV1); - (cellholds_7_3_MV1, cellholds_3_3_MV1); - (cellholds_7_3_MV1, cellholds_2_3_MV1); - (cellholds_7_3_MV1, cellholds_1_3_MV1); - (cellholds_7_2_MV1, cellholds_8_2_MV1); - (cellholds_7_2_MV1, cellholds_7_2_MV1); - (cellholds_7_2_MV1, cellholds_6_2_MV1); - (cellholds_7_2_MV1, cellholds_5_2_MV1); - (cellholds_7_2_MV1, cellholds_4_2_MV1); - (cellholds_7_2_MV1, cellholds_3_2_MV1); - (cellholds_7_2_MV1, cellholds_2_2_MV1); - (cellholds_7_2_MV1, cellholds_1_2_MV1); - (cellholds_7_1_MV1, cellholds_8_1_MV1); - (cellholds_7_1_MV1, cellholds_7_1_MV1); - (cellholds_7_1_MV1, cellholds_6_1_MV1); - (cellholds_7_1_MV1, cellholds_5_1_MV1); - (cellholds_7_1_MV1, cellholds_4_1_MV1); - (cellholds_7_1_MV1, cellholds_3_1_MV1); - (cellholds_7_1_MV1, cellholds_2_1_MV1); - (cellholds_7_1_MV1, cellholds_1_1_MV1); - (cellholds_6_8_MV1, cellholds_8_8_MV1); - (cellholds_6_8_MV1, cellholds_7_8_MV1); - (cellholds_6_8_MV1, cellholds_6_8_MV1); - (cellholds_6_8_MV1, cellholds_5_8_MV1); - (cellholds_6_8_MV1, cellholds_4_8_MV1); - (cellholds_6_8_MV1, cellholds_3_8_MV1); - (cellholds_6_8_MV1, cellholds_2_8_MV1); - (cellholds_6_8_MV1, cellholds_1_8_MV1); - (cellholds_6_7_MV1, cellholds_8_7_MV1); - (cellholds_6_7_MV1, cellholds_7_7_MV1); - (cellholds_6_7_MV1, cellholds_6_7_MV1); - (cellholds_6_7_MV1, cellholds_5_7_MV1); - (cellholds_6_7_MV1, cellholds_4_7_MV1); - (cellholds_6_7_MV1, cellholds_3_7_MV1); - (cellholds_6_7_MV1, cellholds_2_7_MV1); - (cellholds_6_7_MV1, cellholds_1_7_MV1); - (cellholds_6_6_MV1, cellholds_8_6_MV1); - (cellholds_6_6_MV1, cellholds_7_6_MV1); - (cellholds_6_6_MV1, cellholds_6_6_MV1); - (cellholds_6_6_MV1, cellholds_5_6_MV1); - (cellholds_6_6_MV1, cellholds_4_6_MV1); - (cellholds_6_6_MV1, cellholds_3_6_MV1); - (cellholds_6_6_MV1, cellholds_2_6_MV1); - (cellholds_6_6_MV1, cellholds_1_6_MV1); - (cellholds_6_5_MV1, cellholds_8_5_MV1); - (cellholds_6_5_MV1, cellholds_7_5_MV1); - (cellholds_6_5_MV1, cellholds_6_5_MV1); - (cellholds_6_5_MV1, cellholds_5_5_MV1); - (cellholds_6_5_MV1, cellholds_4_5_MV1); - (cellholds_6_5_MV1, cellholds_3_5_MV1); - (cellholds_6_5_MV1, cellholds_2_5_MV1); - (cellholds_6_5_MV1, cellholds_1_5_MV1); - (cellholds_6_4_MV1, cellholds_8_4_MV1); - (cellholds_6_4_MV1, cellholds_7_4_MV1); - (cellholds_6_4_MV1, cellholds_6_4_MV1); - (cellholds_6_4_MV1, cellholds_5_4_MV1); - (cellholds_6_4_MV1, cellholds_4_4_MV1); - (cellholds_6_4_MV1, cellholds_3_4_MV1); - (cellholds_6_4_MV1, cellholds_2_4_MV1); - (cellholds_6_4_MV1, cellholds_1_4_MV1); - (cellholds_6_3_MV1, cellholds_8_3_MV1); - (cellholds_6_3_MV1, cellholds_7_3_MV1); - (cellholds_6_3_MV1, cellholds_6_3_MV1); - (cellholds_6_3_MV1, cellholds_5_3_MV1); - (cellholds_6_3_MV1, cellholds_4_3_MV1); - (cellholds_6_3_MV1, cellholds_3_3_MV1); - (cellholds_6_3_MV1, cellholds_2_3_MV1); - (cellholds_6_3_MV1, cellholds_1_3_MV1); - (cellholds_6_2_MV1, cellholds_8_2_MV1); - (cellholds_6_2_MV1, cellholds_7_2_MV1); - (cellholds_6_2_MV1, cellholds_6_2_MV1); - (cellholds_6_2_MV1, cellholds_5_2_MV1); - (cellholds_6_2_MV1, cellholds_4_2_MV1); - (cellholds_6_2_MV1, cellholds_3_2_MV1); - (cellholds_6_2_MV1, cellholds_2_2_MV1); - (cellholds_6_2_MV1, cellholds_1_2_MV1); - (cellholds_6_1_MV1, cellholds_8_1_MV1); - (cellholds_6_1_MV1, cellholds_7_1_MV1); - (cellholds_6_1_MV1, cellholds_6_1_MV1); - (cellholds_6_1_MV1, cellholds_5_1_MV1); - (cellholds_6_1_MV1, cellholds_4_1_MV1); - (cellholds_6_1_MV1, cellholds_3_1_MV1); - (cellholds_6_1_MV1, cellholds_2_1_MV1); - (cellholds_6_1_MV1, cellholds_1_1_MV1); - (cellholds_5_8_MV1, cellholds_8_8_MV1); - (cellholds_5_8_MV1, cellholds_7_8_MV1); - (cellholds_5_8_MV1, cellholds_6_8_MV1); - (cellholds_5_8_MV1, cellholds_5_8_MV1); - (cellholds_5_8_MV1, cellholds_4_8_MV1); - (cellholds_5_8_MV1, cellholds_3_8_MV1); - (cellholds_5_8_MV1, cellholds_2_8_MV1); - (cellholds_5_8_MV1, cellholds_1_8_MV1); - (cellholds_5_7_MV1, cellholds_8_7_MV1); - (cellholds_5_7_MV1, cellholds_7_7_MV1); - (cellholds_5_7_MV1, cellholds_6_7_MV1); - (cellholds_5_7_MV1, cellholds_5_7_MV1); - (cellholds_5_7_MV1, cellholds_4_7_MV1); - (cellholds_5_7_MV1, cellholds_3_7_MV1); - (cellholds_5_7_MV1, cellholds_2_7_MV1); - (cellholds_5_7_MV1, cellholds_1_7_MV1); - (cellholds_5_6_MV1, cellholds_8_6_MV1); - (cellholds_5_6_MV1, cellholds_7_6_MV1); - (cellholds_5_6_MV1, cellholds_6_6_MV1); - (cellholds_5_6_MV1, cellholds_5_6_MV1); - (cellholds_5_6_MV1, cellholds_4_6_MV1); - (cellholds_5_6_MV1, cellholds_3_6_MV1); - (cellholds_5_6_MV1, cellholds_2_6_MV1); - (cellholds_5_6_MV1, cellholds_1_6_MV1); - (cellholds_5_5_MV1, cellholds_8_5_MV1); - (cellholds_5_5_MV1, cellholds_7_5_MV1); - (cellholds_5_5_MV1, cellholds_6_5_MV1); - (cellholds_5_5_MV1, cellholds_5_5_MV1); - (cellholds_5_5_MV1, cellholds_4_5_MV1); - (cellholds_5_5_MV1, cellholds_3_5_MV1); - (cellholds_5_5_MV1, cellholds_2_5_MV1); - (cellholds_5_5_MV1, cellholds_1_5_MV1); - (cellholds_5_4_MV1, cellholds_8_4_MV1); - (cellholds_5_4_MV1, cellholds_7_4_MV1); - (cellholds_5_4_MV1, cellholds_6_4_MV1); - (cellholds_5_4_MV1, cellholds_5_4_MV1); - (cellholds_5_4_MV1, cellholds_4_4_MV1); - (cellholds_5_4_MV1, cellholds_3_4_MV1); - (cellholds_5_4_MV1, cellholds_2_4_MV1); - (cellholds_5_4_MV1, cellholds_1_4_MV1); - (cellholds_5_3_MV1, cellholds_8_3_MV1); - (cellholds_5_3_MV1, cellholds_7_3_MV1); - (cellholds_5_3_MV1, cellholds_6_3_MV1); - (cellholds_5_3_MV1, cellholds_5_3_MV1); - (cellholds_5_3_MV1, cellholds_4_3_MV1); - (cellholds_5_3_MV1, cellholds_3_3_MV1); - (cellholds_5_3_MV1, cellholds_2_3_MV1); - (cellholds_5_3_MV1, cellholds_1_3_MV1); - (cellholds_5_2_MV1, cellholds_8_2_MV1); - (cellholds_5_2_MV1, cellholds_7_2_MV1); - (cellholds_5_2_MV1, cellholds_6_2_MV1); - (cellholds_5_2_MV1, cellholds_5_2_MV1); - (cellholds_5_2_MV1, cellholds_4_2_MV1); - (cellholds_5_2_MV1, cellholds_3_2_MV1); - (cellholds_5_2_MV1, cellholds_2_2_MV1); - (cellholds_5_2_MV1, cellholds_1_2_MV1); - (cellholds_5_1_MV1, cellholds_8_1_MV1); - (cellholds_5_1_MV1, cellholds_7_1_MV1); - (cellholds_5_1_MV1, cellholds_6_1_MV1); - (cellholds_5_1_MV1, cellholds_5_1_MV1); - (cellholds_5_1_MV1, cellholds_4_1_MV1); - (cellholds_5_1_MV1, cellholds_3_1_MV1); - (cellholds_5_1_MV1, cellholds_2_1_MV1); - (cellholds_5_1_MV1, cellholds_1_1_MV1); - (cellholds_4_8_MV1, cellholds_8_8_MV1); - (cellholds_4_8_MV1, cellholds_7_8_MV1); - (cellholds_4_8_MV1, cellholds_6_8_MV1); - (cellholds_4_8_MV1, cellholds_5_8_MV1); - (cellholds_4_8_MV1, cellholds_4_8_MV1); - (cellholds_4_8_MV1, cellholds_3_8_MV1); - (cellholds_4_8_MV1, cellholds_2_8_MV1); - (cellholds_4_8_MV1, cellholds_1_8_MV1); - (cellholds_4_7_MV1, cellholds_8_7_MV1); - (cellholds_4_7_MV1, cellholds_7_7_MV1); - (cellholds_4_7_MV1, cellholds_6_7_MV1); - (cellholds_4_7_MV1, cellholds_5_7_MV1); - (cellholds_4_7_MV1, cellholds_4_7_MV1); - (cellholds_4_7_MV1, cellholds_3_7_MV1); - (cellholds_4_7_MV1, cellholds_2_7_MV1); - (cellholds_4_7_MV1, cellholds_1_7_MV1); - (cellholds_4_6_MV1, cellholds_8_6_MV1); - (cellholds_4_6_MV1, cellholds_7_6_MV1); - (cellholds_4_6_MV1, cellholds_6_6_MV1); - (cellholds_4_6_MV1, cellholds_5_6_MV1); - (cellholds_4_6_MV1, cellholds_4_6_MV1); - (cellholds_4_6_MV1, cellholds_3_6_MV1); - (cellholds_4_6_MV1, cellholds_2_6_MV1); - (cellholds_4_6_MV1, cellholds_1_6_MV1); - (cellholds_4_5_MV1, cellholds_8_5_MV1); - (cellholds_4_5_MV1, cellholds_7_5_MV1); - (cellholds_4_5_MV1, cellholds_6_5_MV1); - (cellholds_4_5_MV1, cellholds_5_5_MV1); - (cellholds_4_5_MV1, cellholds_4_5_MV1); - (cellholds_4_5_MV1, cellholds_3_5_MV1); - (cellholds_4_5_MV1, cellholds_2_5_MV1); - (cellholds_4_5_MV1, cellholds_1_5_MV1); - (cellholds_4_4_MV1, cellholds_8_4_MV1); - (cellholds_4_4_MV1, cellholds_7_4_MV1); - (cellholds_4_4_MV1, cellholds_6_4_MV1); - (cellholds_4_4_MV1, cellholds_5_4_MV1); - (cellholds_4_4_MV1, cellholds_4_4_MV1); - (cellholds_4_4_MV1, cellholds_3_4_MV1); - (cellholds_4_4_MV1, cellholds_2_4_MV1); - (cellholds_4_4_MV1, cellholds_1_4_MV1); - (cellholds_4_3_MV1, cellholds_8_3_MV1); - (cellholds_4_3_MV1, cellholds_7_3_MV1); - (cellholds_4_3_MV1, cellholds_6_3_MV1); - (cellholds_4_3_MV1, cellholds_5_3_MV1); - (cellholds_4_3_MV1, cellholds_4_3_MV1); - (cellholds_4_3_MV1, cellholds_3_3_MV1); - (cellholds_4_3_MV1, cellholds_2_3_MV1); - (cellholds_4_3_MV1, cellholds_1_3_MV1); - (cellholds_4_2_MV1, cellholds_8_2_MV1); - (cellholds_4_2_MV1, cellholds_7_2_MV1); - (cellholds_4_2_MV1, cellholds_6_2_MV1); - (cellholds_4_2_MV1, cellholds_5_2_MV1); - (cellholds_4_2_MV1, cellholds_4_2_MV1); - (cellholds_4_2_MV1, cellholds_3_2_MV1); - (cellholds_4_2_MV1, cellholds_2_2_MV1); - (cellholds_4_2_MV1, cellholds_1_2_MV1); - (cellholds_4_1_MV1, cellholds_8_1_MV1); - (cellholds_4_1_MV1, cellholds_7_1_MV1); - (cellholds_4_1_MV1, cellholds_6_1_MV1); - (cellholds_4_1_MV1, cellholds_5_1_MV1); - (cellholds_4_1_MV1, cellholds_4_1_MV1); - (cellholds_4_1_MV1, cellholds_3_1_MV1); - (cellholds_4_1_MV1, cellholds_2_1_MV1); - (cellholds_4_1_MV1, cellholds_1_1_MV1); - (cellholds_3_8_MV1, cellholds_8_8_MV1); - (cellholds_3_8_MV1, cellholds_7_8_MV1); - (cellholds_3_8_MV1, cellholds_6_8_MV1); - (cellholds_3_8_MV1, cellholds_5_8_MV1); - (cellholds_3_8_MV1, cellholds_4_8_MV1); - (cellholds_3_8_MV1, cellholds_3_8_MV1); - (cellholds_3_8_MV1, cellholds_2_8_MV1); - (cellholds_3_8_MV1, cellholds_1_8_MV1); - (cellholds_3_7_MV1, cellholds_8_7_MV1); - (cellholds_3_7_MV1, cellholds_7_7_MV1); - (cellholds_3_7_MV1, cellholds_6_7_MV1); - (cellholds_3_7_MV1, cellholds_5_7_MV1); - (cellholds_3_7_MV1, cellholds_4_7_MV1); - (cellholds_3_7_MV1, cellholds_3_7_MV1); - (cellholds_3_7_MV1, cellholds_2_7_MV1); - (cellholds_3_7_MV1, cellholds_1_7_MV1); - (cellholds_3_6_MV1, cellholds_8_6_MV1); - (cellholds_3_6_MV1, cellholds_7_6_MV1); - (cellholds_3_6_MV1, cellholds_6_6_MV1); - (cellholds_3_6_MV1, cellholds_5_6_MV1); - (cellholds_3_6_MV1, cellholds_4_6_MV1); - (cellholds_3_6_MV1, cellholds_3_6_MV1); - (cellholds_3_6_MV1, cellholds_2_6_MV1); - (cellholds_3_6_MV1, cellholds_1_6_MV1); - (cellholds_3_5_MV1, cellholds_8_5_MV1); - (cellholds_3_5_MV1, cellholds_7_5_MV1); - (cellholds_3_5_MV1, cellholds_6_5_MV1); - (cellholds_3_5_MV1, cellholds_5_5_MV1); - (cellholds_3_5_MV1, cellholds_4_5_MV1); - (cellholds_3_5_MV1, cellholds_3_5_MV1); - (cellholds_3_5_MV1, cellholds_2_5_MV1); - (cellholds_3_5_MV1, cellholds_1_5_MV1); - (cellholds_3_4_MV1, cellholds_8_4_MV1); - (cellholds_3_4_MV1, cellholds_7_4_MV1); - (cellholds_3_4_MV1, cellholds_6_4_MV1); - (cellholds_3_4_MV1, cellholds_5_4_MV1); - (cellholds_3_4_MV1, cellholds_4_4_MV1); - (cellholds_3_4_MV1, cellholds_3_4_MV1); - (cellholds_3_4_MV1, cellholds_2_4_MV1); - (cellholds_3_4_MV1, cellholds_1_4_MV1); - (cellholds_3_3_MV1, cellholds_8_3_MV1); - (cellholds_3_3_MV1, cellholds_7_3_MV1); - (cellholds_3_3_MV1, cellholds_6_3_MV1); - (cellholds_3_3_MV1, cellholds_5_3_MV1); - (cellholds_3_3_MV1, cellholds_4_3_MV1); - (cellholds_3_3_MV1, cellholds_3_3_MV1); - (cellholds_3_3_MV1, cellholds_2_3_MV1); - (cellholds_3_3_MV1, cellholds_1_3_MV1); - (cellholds_3_2_MV1, cellholds_8_2_MV1); - (cellholds_3_2_MV1, cellholds_7_2_MV1); - (cellholds_3_2_MV1, cellholds_6_2_MV1); - (cellholds_3_2_MV1, cellholds_5_2_MV1); - (cellholds_3_2_MV1, cellholds_4_2_MV1); - (cellholds_3_2_MV1, cellholds_3_2_MV1); - (cellholds_3_2_MV1, cellholds_2_2_MV1); - (cellholds_3_2_MV1, cellholds_1_2_MV1); - (cellholds_3_1_MV1, cellholds_8_1_MV1); - (cellholds_3_1_MV1, cellholds_7_1_MV1); - (cellholds_3_1_MV1, cellholds_6_1_MV1); - (cellholds_3_1_MV1, cellholds_5_1_MV1); - (cellholds_3_1_MV1, cellholds_4_1_MV1); - (cellholds_3_1_MV1, cellholds_3_1_MV1); - (cellholds_3_1_MV1, cellholds_2_1_MV1); - (cellholds_3_1_MV1, cellholds_1_1_MV1); - (cellholds_2_8_MV1, cellholds_8_8_MV1); - (cellholds_2_8_MV1, cellholds_7_8_MV1); - (cellholds_2_8_MV1, cellholds_6_8_MV1); - (cellholds_2_8_MV1, cellholds_5_8_MV1); - (cellholds_2_8_MV1, cellholds_4_8_MV1); - (cellholds_2_8_MV1, cellholds_3_8_MV1); - (cellholds_2_8_MV1, cellholds_2_8_MV1); - (cellholds_2_8_MV1, cellholds_1_8_MV1); - (cellholds_2_7_MV1, cellholds_8_7_MV1); - (cellholds_2_7_MV1, cellholds_7_7_MV1); - (cellholds_2_7_MV1, cellholds_6_7_MV1); - (cellholds_2_7_MV1, cellholds_5_7_MV1); - (cellholds_2_7_MV1, cellholds_4_7_MV1); - (cellholds_2_7_MV1, cellholds_3_7_MV1); - (cellholds_2_7_MV1, cellholds_2_7_MV1); - (cellholds_2_7_MV1, cellholds_1_7_MV1); - (cellholds_2_6_MV1, cellholds_8_6_MV1); - (cellholds_2_6_MV1, cellholds_7_6_MV1); - (cellholds_2_6_MV1, cellholds_6_6_MV1); - (cellholds_2_6_MV1, cellholds_5_6_MV1); - (cellholds_2_6_MV1, cellholds_4_6_MV1); - (cellholds_2_6_MV1, cellholds_3_6_MV1); - (cellholds_2_6_MV1, cellholds_2_6_MV1); - (cellholds_2_6_MV1, cellholds_1_6_MV1); - (cellholds_2_5_MV1, cellholds_8_5_MV1); - (cellholds_2_5_MV1, cellholds_7_5_MV1); - (cellholds_2_5_MV1, cellholds_6_5_MV1); - (cellholds_2_5_MV1, cellholds_5_5_MV1); - (cellholds_2_5_MV1, cellholds_4_5_MV1); - (cellholds_2_5_MV1, cellholds_3_5_MV1); - (cellholds_2_5_MV1, cellholds_2_5_MV1); - (cellholds_2_5_MV1, cellholds_1_5_MV1); - (cellholds_2_4_MV1, cellholds_8_4_MV1); - (cellholds_2_4_MV1, cellholds_7_4_MV1); - (cellholds_2_4_MV1, cellholds_6_4_MV1); - (cellholds_2_4_MV1, cellholds_5_4_MV1); - (cellholds_2_4_MV1, cellholds_4_4_MV1); - (cellholds_2_4_MV1, cellholds_3_4_MV1); - (cellholds_2_4_MV1, cellholds_2_4_MV1); - (cellholds_2_4_MV1, cellholds_1_4_MV1); - (cellholds_2_3_MV1, cellholds_8_3_MV1); - (cellholds_2_3_MV1, cellholds_7_3_MV1); - (cellholds_2_3_MV1, cellholds_6_3_MV1); - (cellholds_2_3_MV1, cellholds_5_3_MV1); - (cellholds_2_3_MV1, cellholds_4_3_MV1); - (cellholds_2_3_MV1, cellholds_3_3_MV1); - (cellholds_2_3_MV1, cellholds_2_3_MV1); - (cellholds_2_3_MV1, cellholds_1_3_MV1); - (cellholds_2_2_MV1, cellholds_8_2_MV1); - (cellholds_2_2_MV1, cellholds_7_2_MV1); - (cellholds_2_2_MV1, cellholds_6_2_MV1); - (cellholds_2_2_MV1, cellholds_5_2_MV1); - (cellholds_2_2_MV1, cellholds_4_2_MV1); - (cellholds_2_2_MV1, cellholds_3_2_MV1); - (cellholds_2_2_MV1, cellholds_2_2_MV1); - (cellholds_2_2_MV1, cellholds_1_2_MV1); - (cellholds_2_1_MV1, cellholds_8_1_MV1); - (cellholds_2_1_MV1, cellholds_7_1_MV1); - (cellholds_2_1_MV1, cellholds_6_1_MV1); - (cellholds_2_1_MV1, cellholds_5_1_MV1); - (cellholds_2_1_MV1, cellholds_4_1_MV1); - (cellholds_2_1_MV1, cellholds_3_1_MV1); - (cellholds_2_1_MV1, cellholds_2_1_MV1); - (cellholds_2_1_MV1, cellholds_1_1_MV1); - (cellholds_1_8_MV1, cellholds_8_8_MV1); - (cellholds_1_8_MV1, cellholds_7_8_MV1); - (cellholds_1_8_MV1, cellholds_6_8_MV1); - (cellholds_1_8_MV1, cellholds_5_8_MV1); - (cellholds_1_8_MV1, cellholds_4_8_MV1); - (cellholds_1_8_MV1, cellholds_3_8_MV1); - (cellholds_1_8_MV1, cellholds_2_8_MV1); - (cellholds_1_8_MV1, cellholds_1_8_MV1); - (cellholds_1_7_MV1, cellholds_8_7_MV1); - (cellholds_1_7_MV1, cellholds_7_7_MV1); - (cellholds_1_7_MV1, cellholds_6_7_MV1); - (cellholds_1_7_MV1, cellholds_5_7_MV1); - (cellholds_1_7_MV1, cellholds_4_7_MV1); - (cellholds_1_7_MV1, cellholds_3_7_MV1); - (cellholds_1_7_MV1, cellholds_2_7_MV1); - (cellholds_1_7_MV1, cellholds_1_7_MV1); - (cellholds_1_6_MV1, cellholds_8_6_MV1); - (cellholds_1_6_MV1, cellholds_7_6_MV1); - (cellholds_1_6_MV1, cellholds_6_6_MV1); - (cellholds_1_6_MV1, cellholds_5_6_MV1); - (cellholds_1_6_MV1, cellholds_4_6_MV1); - (cellholds_1_6_MV1, cellholds_3_6_MV1); - (cellholds_1_6_MV1, cellholds_2_6_MV1); - (cellholds_1_6_MV1, cellholds_1_6_MV1); - (cellholds_1_5_MV1, cellholds_8_5_MV1); - (cellholds_1_5_MV1, cellholds_7_5_MV1); - (cellholds_1_5_MV1, cellholds_6_5_MV1); - (cellholds_1_5_MV1, cellholds_5_5_MV1); - (cellholds_1_5_MV1, cellholds_4_5_MV1); - (cellholds_1_5_MV1, cellholds_3_5_MV1); - (cellholds_1_5_MV1, cellholds_2_5_MV1); - (cellholds_1_5_MV1, cellholds_1_5_MV1); - (cellholds_1_4_MV1, cellholds_8_4_MV1); - (cellholds_1_4_MV1, cellholds_7_4_MV1); - (cellholds_1_4_MV1, cellholds_6_4_MV1); - (cellholds_1_4_MV1, cellholds_5_4_MV1); - (cellholds_1_4_MV1, cellholds_4_4_MV1); - (cellholds_1_4_MV1, cellholds_3_4_MV1); - (cellholds_1_4_MV1, cellholds_2_4_MV1); - (cellholds_1_4_MV1, cellholds_1_4_MV1); - (cellholds_1_3_MV1, cellholds_8_3_MV1); - (cellholds_1_3_MV1, cellholds_7_3_MV1); - (cellholds_1_3_MV1, cellholds_6_3_MV1); - (cellholds_1_3_MV1, cellholds_5_3_MV1); - (cellholds_1_3_MV1, cellholds_4_3_MV1); - (cellholds_1_3_MV1, cellholds_3_3_MV1); - (cellholds_1_3_MV1, cellholds_2_3_MV1); - (cellholds_1_3_MV1, cellholds_1_3_MV1); - (cellholds_1_2_MV1, cellholds_8_2_MV1); - (cellholds_1_2_MV1, cellholds_7_2_MV1); - (cellholds_1_2_MV1, cellholds_6_2_MV1); - (cellholds_1_2_MV1, cellholds_5_2_MV1); - (cellholds_1_2_MV1, cellholds_4_2_MV1); - (cellholds_1_2_MV1, cellholds_3_2_MV1); - (cellholds_1_2_MV1, cellholds_2_2_MV1); - (cellholds_1_2_MV1, cellholds_1_2_MV1); - (cellholds_1_1_MV1, cellholds_8_1_MV1); - (cellholds_1_1_MV1, cellholds_7_1_MV1); - (cellholds_1_1_MV1, cellholds_6_1_MV1); - (cellholds_1_1_MV1, cellholds_5_1_MV1); - (cellholds_1_1_MV1, cellholds_4_1_MV1); - (cellholds_1_1_MV1, cellholds_3_1_MV1); - (cellholds_1_1_MV1, cellholds_2_1_MV1); - (cellholds_1_1_MV1, cellholds_1_1_MV1) - }; - cellholds_1_y2_MV1 { - cellholds_1_8_MV1; cellholds_1_7_MV1; cellholds_1_6_MV1; - cellholds_1_5_MV1; cellholds_1_4_MV1; cellholds_1_3_MV1; - cellholds_1_2_MV1; cellholds_1_1_MV1 - }; - cellholds_2_y2_MV1 { - cellholds_2_8_MV1; cellholds_2_7_MV1; cellholds_2_6_MV1; - cellholds_2_5_MV1; cellholds_2_4_MV1; cellholds_2_3_MV1; - cellholds_2_2_MV1; cellholds_2_1_MV1 - }; - cellholds_3_y2_MV1 { - cellholds_3_8_MV1; cellholds_3_7_MV1; cellholds_3_6_MV1; - cellholds_3_5_MV1; cellholds_3_4_MV1; cellholds_3_3_MV1; - cellholds_3_2_MV1; cellholds_3_1_MV1 - }; - cellholds_4_y2_MV1 { - cellholds_4_8_MV1; cellholds_4_7_MV1; cellholds_4_6_MV1; - cellholds_4_5_MV1; cellholds_4_4_MV1; cellholds_4_3_MV1; - cellholds_4_2_MV1; cellholds_4_1_MV1 - }; - cellholds_5_y2_MV1 { - cellholds_5_8_MV1; cellholds_5_7_MV1; cellholds_5_6_MV1; - cellholds_5_5_MV1; cellholds_5_4_MV1; cellholds_5_3_MV1; - cellholds_5_2_MV1; cellholds_5_1_MV1 - }; - cellholds_6_y2_MV1 { - cellholds_6_8_MV1; cellholds_6_7_MV1; cellholds_6_6_MV1; - cellholds_6_5_MV1; cellholds_6_4_MV1; cellholds_6_3_MV1; - cellholds_6_2_MV1; cellholds_6_1_MV1 - }; - cellholds_7_y2_MV1 { - cellholds_7_8_MV1; cellholds_7_7_MV1; cellholds_7_6_MV1; - cellholds_7_5_MV1; cellholds_7_4_MV1; cellholds_7_3_MV1; - cellholds_7_2_MV1; cellholds_7_1_MV1 - }; - cellholds_8_y2_MV1 { - cellholds_8_8_MV1; cellholds_8_7_MV1; cellholds_8_6_MV1; - cellholds_8_5_MV1; cellholds_8_4_MV1; cellholds_8_3_MV1; - cellholds_8_2_MV1; cellholds_8_1_MV1 - }; cellholds_x2_1_MV1 { cellholds_8_1_MV1; cellholds_7_1_MV1; cellholds_6_1_MV1; cellholds_5_1_MV1; cellholds_4_1_MV1; cellholds_3_1_MV1; cellholds_2_1_MV1; cellholds_1_1_MV1 }; - cellholds_x2_2_MV1 { - cellholds_8_2_MV1; cellholds_7_2_MV1; cellholds_6_2_MV1; - cellholds_5_2_MV1; cellholds_4_2_MV1; cellholds_3_2_MV1; - cellholds_2_2_MV1; cellholds_1_2_MV1 - }; - cellholds_x2_3_MV1 { - cellholds_8_3_MV1; cellholds_7_3_MV1; cellholds_6_3_MV1; - cellholds_5_3_MV1; cellholds_4_3_MV1; cellholds_3_3_MV1; - cellholds_2_3_MV1; cellholds_1_3_MV1 - }; - cellholds_x2_4_MV1 { - cellholds_8_4_MV1; cellholds_7_4_MV1; cellholds_6_4_MV1; - cellholds_5_4_MV1; cellholds_4_4_MV1; cellholds_3_4_MV1; - cellholds_2_4_MV1; cellholds_1_4_MV1 - }; - cellholds_x2_5_MV1 { - cellholds_8_5_MV1; cellholds_7_5_MV1; cellholds_6_5_MV1; - cellholds_5_5_MV1; cellholds_4_5_MV1; cellholds_3_5_MV1; - cellholds_2_5_MV1; cellholds_1_5_MV1 - }; - cellholds_x2_6_MV1 { - cellholds_8_6_MV1; cellholds_7_6_MV1; cellholds_6_6_MV1; - cellholds_5_6_MV1; cellholds_4_6_MV1; cellholds_3_6_MV1; - cellholds_2_6_MV1; cellholds_1_6_MV1 - }; - cellholds_x2_7_MV1 { - cellholds_8_7_MV1; cellholds_7_7_MV1; cellholds_6_7_MV1; - cellholds_5_7_MV1; cellholds_4_7_MV1; cellholds_3_7_MV1; - cellholds_2_7_MV1; cellholds_1_7_MV1 - }; cellholds_x2_8_MV1 { cellholds_8_8_MV1; cellholds_7_8_MV1; cellholds_6_8_MV1; cellholds_5_8_MV1; cellholds_4_8_MV1; cellholds_3_8_MV1; @@ -1492,8 +852,7 @@ cellholds_2_2_MV1; cellholds_2_1_MV1; cellholds_1_2_MV1; cellholds_1_1_MV1 }; - control_MV1 (control_MV1); control_black:1 {}; - control_white (control_MV1); + control_black:1 {}; control_white (control_MV1); index__cellholds_x2_y2_MV1_y2 { cellholds_8_8_MV1; cellholds_8_7_MV1; cellholds_8_6_MV1; cellholds_8_5_MV1; cellholds_8_4_MV1; cellholds_8_3_MV1; @@ -1518,7 +877,6 @@ cellholds_1_4_MV1; cellholds_1_3_MV1; cellholds_1_2_MV1; cellholds_1_1_MV1 }; - role__cellholds_x2_y2_MV1_y2:1 {}; succ__cellholds_x2_y2_MV1_x2__cellholds_x2_y2_MV1_x2 { (cellholds_7_8_MV1, cellholds_8_8_MV1); (cellholds_7_8_MV1, cellholds_8_7_MV1); @@ -1969,906 +1327,6 @@ (cellholds_1_1_MV1, cellholds_2_2_MV1); (cellholds_1_1_MV1, cellholds_2_1_MV1) }; - succ__cellholds_x2_y2_MV1_x2__cellholds_x2_y2_MV1_y2 { - (cellholds_7_8_MV1, cellholds_8_8_MV1); - (cellholds_7_8_MV1, cellholds_7_8_MV1); - (cellholds_7_8_MV1, cellholds_6_8_MV1); - (cellholds_7_8_MV1, cellholds_5_8_MV1); - (cellholds_7_8_MV1, cellholds_4_8_MV1); - (cellholds_7_8_MV1, cellholds_3_8_MV1); - (cellholds_7_8_MV1, cellholds_2_8_MV1); - (cellholds_7_8_MV1, cellholds_1_8_MV1); - (cellholds_7_7_MV1, cellholds_8_8_MV1); - (cellholds_7_7_MV1, cellholds_7_8_MV1); - (cellholds_7_7_MV1, cellholds_6_8_MV1); - (cellholds_7_7_MV1, cellholds_5_8_MV1); - (cellholds_7_7_MV1, cellholds_4_8_MV1); - (cellholds_7_7_MV1, cellholds_3_8_MV1); - (cellholds_7_7_MV1, cellholds_2_8_MV1); - (cellholds_7_7_MV1, cellholds_1_8_MV1); - (cellholds_7_6_MV1, cellholds_8_8_MV1); - (cellholds_7_6_MV1, cellholds_7_8_MV1); - (cellholds_7_6_MV1, cellholds_6_8_MV1); - (cellholds_7_6_MV1, cellholds_5_8_MV1); - (cellholds_7_6_MV1, cellholds_4_8_MV1); - (cellholds_7_6_MV1, cellholds_3_8_MV1); - (cellholds_7_6_MV1, cellholds_2_8_MV1); - (cellholds_7_6_MV1, cellholds_1_8_MV1); - (cellholds_7_5_MV1, cellholds_8_8_MV1); - (cellholds_7_5_MV1, cellholds_7_8_MV1); - (cellholds_7_5_MV1, cellholds_6_8_MV1); - (cellholds_7_5_MV1, cellholds_5_8_MV1); - (cellholds_7_5_MV1, cellholds_4_8_MV1); - (cellholds_7_5_MV1, cellholds_3_8_MV1); - (cellholds_7_5_MV1, cellholds_2_8_MV1); - (cellholds_7_5_MV1, cellholds_1_8_MV1); - (cellholds_7_4_MV1, cellholds_8_8_MV1); - (cellholds_7_4_MV1, cellholds_7_8_MV1); - (cellholds_7_4_MV1, cellholds_6_8_MV1); - (cellholds_7_4_MV1, cellholds_5_8_MV1); - (cellholds_7_4_MV1, cellholds_4_8_MV1); - (cellholds_7_4_MV1, cellholds_3_8_MV1); - (cellholds_7_4_MV1, cellholds_2_8_MV1); - (cellholds_7_4_MV1, cellholds_1_8_MV1); - (cellholds_7_3_MV1, cellholds_8_8_MV1); - (cellholds_7_3_MV1, cellholds_7_8_MV1); - (cellholds_7_3_MV1, cellholds_6_8_MV1); - (cellholds_7_3_MV1, cellholds_5_8_MV1); - (cellholds_7_3_MV1, cellholds_4_8_MV1); - (cellholds_7_3_MV1, cellholds_3_8_MV1); - (cellholds_7_3_MV1, cellholds_2_8_MV1); - (cellholds_7_3_MV1, cellholds_1_8_MV1); - (cellholds_7_2_MV1, cellholds_8_8_MV1); - (cellholds_7_2_MV1, cellholds_7_8_MV1); - (cellholds_7_2_MV1, cellholds_6_8_MV1); - (cellholds_7_2_MV1, cellholds_5_8_MV1); - (cellholds_7_2_MV1, cellholds_4_8_MV1); - (cellholds_7_2_MV1, cellholds_3_8_MV1); - (cellholds_7_2_MV1, cellholds_2_8_MV1); - (cellholds_7_2_MV1, cellholds_1_8_MV1); - (cellholds_7_1_MV1, cellholds_8_8_MV1); - (cellholds_7_1_MV1, cellholds_7_8_MV1); - (cellholds_7_1_MV1, cellholds_6_8_MV1); - (cellholds_7_1_MV1, cellholds_5_8_MV1); - (cellholds_7_1_MV1, cellholds_4_8_MV1); - (cellholds_7_1_MV1, cellholds_3_8_MV1); - (cellholds_7_1_MV1, cellholds_2_8_MV1); - (cellholds_7_1_MV1, cellholds_1_8_MV1); - (cellholds_6_8_MV1, cellholds_8_7_MV1); - (cellholds_6_8_MV1, cellholds_7_7_MV1); - (cellholds_6_8_MV1, cellholds_6_7_MV1); - (cellholds_6_8_MV1, cellholds_5_7_MV1); - (cellholds_6_8_MV1, cellholds_4_7_MV1); - (cellholds_6_8_MV1, cellholds_3_7_MV1); - (cellholds_6_8_MV1, cellholds_2_7_MV1); - (cellholds_6_8_MV1, cellholds_1_7_MV1); - (cellholds_6_7_MV1, cellholds_8_7_MV1); - (cellholds_6_7_MV1, cellholds_7_7_MV1); - (cellholds_6_7_MV1, cellholds_6_7_MV1); - (cellholds_6_7_MV1, cellholds_5_7_MV1); - (cellholds_6_7_MV1, cellholds_4_7_MV1); - (cellholds_6_7_MV1, cellholds_3_7_MV1); - (cellholds_6_7_MV1, cellholds_2_7_MV1); - (cellholds_6_7_MV1, cellholds_1_7_MV1); - (cellholds_6_6_MV1, cellholds_8_7_MV1); - (cellholds_6_6_MV1, cellholds_7_7_MV1); - (cellholds_6_6_MV1, cellholds_6_7_MV1); - (cellholds_6_6_MV1, cellholds_5_7_MV1); - (cellholds_6_6_MV1, cellholds_4_7_MV1); - (cellholds_6_6_MV1, cellholds_3_7_MV1); - (cellholds_6_6_MV1, cellholds_2_7_MV1); - (cellholds_6_6_MV1, cellholds_1_7_MV1); - (cellholds_6_5_MV1, cellholds_8_7_MV1); - (cellholds_6_5_MV1, cellholds_7_7_MV1); - (cellholds_6_5_MV1, cellholds_6_7_MV1); - (cellholds_6_5_MV1, cellholds_5_7_MV1); - (cellholds_6_5_MV1, cellholds_4_7_MV1); - (cellholds_6_5_MV1, cellholds_3_7_MV1); - (cellholds_6_5_MV1, cellholds_2_7_MV1); - (cellholds_6_5_MV1, cellholds_1_7_MV1); - (cellholds_6_4_MV1, cellholds_8_7_MV1); - (cellholds_6_4_MV1, cellholds_7_7_MV1); - (cellholds_6_4_MV1, cellholds_6_7_MV1); - (cellholds_6_4_MV1, cellholds_5_7_MV1); - (cellholds_6_4_MV1, cellholds_4_7_MV1); - (cellholds_6_4_MV1, cellholds_3_7_MV1); - (cellholds_6_4_MV1, cellholds_2_7_MV1); - (cellholds_6_4_MV1, cellholds_1_7_MV1); - (cellholds_6_3_MV1, cellholds_8_7_MV1); - (cellholds_6_3_MV1, cellholds_7_7_MV1); - (cellholds_6_3_MV1, cellholds_6_7_MV1); - (cellholds_6_3_MV1, cellholds_5_7_MV1); - (cellholds_6_3_MV1, cellholds_4_7_MV1); - (cellholds_6_3_MV1, cellholds_3_7_MV1); - (cellholds_6_3_MV1, cellholds_2_7_MV1); - (cellholds_6_3_MV1, cellholds_1_7_MV1); - (cellholds_6_2_MV1, cellholds_8_7_MV1); - (cellholds_6_2_MV1, cellholds_7_7_MV1); - (cellholds_6_2_MV1, cellholds_6_7_MV1); - (cellholds_6_2_MV1, cellholds_5_7_MV1); - (cellholds_6_2_MV1, cellholds_4_7_MV1); - (cellholds_6_2_MV1, cellholds_3_7_MV1); - (cellholds_6_2_MV1, cellholds_2_7_MV1); - (cellholds_6_2_MV1, cellholds_1_7_MV1); - (cellholds_6_1_MV1, cellholds_8_7_MV1); - (cellholds_6_1_MV1, cellholds_7_7_MV1); - (cellholds_6_1_MV1, cellholds_6_7_MV1); - (cellholds_6_1_MV1, cellholds_5_7_MV1); - (cellholds_6_1_MV1, cellholds_4_7_MV1); - (cellholds_6_1_MV1, cellholds_3_7_MV1); - (cellholds_6_1_MV1, cellholds_2_7_MV1); - (cellholds_6_1_MV1, cellholds_1_7_MV1); - (cellholds_5_8_MV1, cellholds_8_6_MV1); - (cellholds_5_8_MV1, cellholds_7_6_MV1); - (cellholds_5_8_MV1, cellholds_6_6_MV1); - (cellholds_5_8_MV1, cellholds_5_6_MV1); - (cellholds_5_8_MV1, cellholds_4_6_MV1); - (cellholds_5_8_MV1, cellholds_3_6_MV1); - (cellholds_5_8_MV1, cellholds_2_6_MV1); - (cellholds_5_8_MV1, cellholds_1_6_MV1); - (cellholds_5_7_MV1, cellholds_8_6_MV1); - (cellholds_5_7_MV1, cellholds_7_6_MV1); - (cellholds_5_7_MV1, cellholds_6_6_MV1); - (cellholds_5_7_MV1, cellholds_5_6_MV1); - (cellholds_5_7_MV1, cellholds_4_6_MV1); - (cellholds_5_7_MV1, cellholds_3_6_MV1); - (cellholds_5_7_MV1, cellholds_2_6_MV1); - (cellholds_5_7_MV1, cellholds_1_6_MV1); - (cellholds_5_6_MV1, cellholds_8_6_MV1); - (cellholds_5_6_MV1, cellholds_7_6_MV1); - (cellholds_5_6_MV1, cellholds_6_6_MV1); - (cellholds_5_6_MV1, cellholds_5_6_MV1); - (cellholds_5_6_MV1, cellholds_4_6_MV1); - (cellholds_5_6_MV1, cellholds_3_6_MV1); - (cellholds_5_6_MV1, cellholds_2_6_MV1); - (cellholds_5_6_MV1, cellholds_1_6_MV1); - (cellholds_5_5_MV1, cellholds_8_6_MV1); - (cellholds_5_5_MV1, cellholds_7_6_MV1); - (cellholds_5_5_MV1, cellholds_6_6_MV1); - (cellholds_5_5_MV1, cellholds_5_6_MV1); - (cellholds_5_5_MV1, cellholds_4_6_MV1); - (cellholds_5_5_MV1, cellholds_3_6_MV1); - (cellholds_5_5_MV1, cellholds_2_6_MV1); - (cellholds_5_5_MV1, cellholds_1_6_MV1); - (cellholds_5_4_MV1, cellholds_8_6_MV1); - (cellholds_5_4_MV1, cellholds_7_6_MV1); - (cellholds_5_4_MV1, cellholds_6_6_MV1); - (cellholds_5_4_MV1, cellholds_5_6_MV1); - (cellholds_5_4_MV1, cellholds_4_6_MV1); - (cellholds_5_4_MV1, cellholds_3_6_MV1); - (cellholds_5_4_MV1, cellholds_2_6_MV1); - (cellholds_5_4_MV1, cellholds_1_6_MV1); - (cellholds_5_3_MV1, cellholds_8_6_MV1); - (cellholds_5_3_MV1, cellholds_7_6_MV1); - (cellholds_5_3_MV1, cellholds_6_6_MV1); - (cellholds_5_3_MV1, cellholds_5_6_MV1); - (cellholds_5_3_MV1, cellholds_4_6_MV1); - (cellholds_5_3_MV1, cellholds_3_6_MV1); - (cellholds_5_3_MV1, cellholds_2_6_MV1); - (cellholds_5_3_MV1, cellholds_1_6_MV1); - (cellholds_5_2_MV1, cellholds_8_6_MV1); - (cellholds_5_2_MV1, cellholds_7_6_MV1); - (cellholds_5_2_MV1, cellholds_6_6_MV1); - (cellholds_5_2_MV1, cellholds_5_6_MV1); - (cellholds_5_2_MV1, cellholds_4_6_MV1); - (cellholds_5_2_MV1, cellholds_3_6_MV1); - (cellholds_5_2_MV1, cellholds_2_6_MV1); - (cellholds_5_2_MV1, cellholds_1_6_MV1); - (cellholds_5_1_MV1, cellholds_8_6_MV1); - (cellholds_5_1_MV1, cellholds_7_6_MV1); - (cellholds_5_1_MV1, cellholds_6_6_MV1); - (cellholds_5_1_MV1, cellholds_5_6_MV1); - (cellholds_5_1_MV1, cellholds_4_6_MV1); - (cellholds_5_1_MV1, cellholds_3_6_MV1); - (cellholds_5_1_MV1, cellholds_2_6_MV1); - (cellholds_5_1_MV1, cellholds_1_6_MV1); - (cellholds_4_8_MV1, cellholds_8_5_MV1); - (cellholds_4_8_MV1, cellholds_7_5_MV1); - (cellholds_4_8_MV1, cellholds_6_5_MV1); - (cellholds_4_8_MV1, cellholds_5_5_MV1); - (cellholds_4_8_MV1, cellholds_4_5_MV1); - (cellholds_4_8_MV1, cellholds_3_5_MV1); - (cellholds_4_8_MV1, cellholds_2_5_MV1); - (cellholds_4_8_MV1, cellholds_1_5_MV1); - (cellholds_4_7_MV1, cellholds_8_5_MV1); - (cellholds_4_7_MV1, cellholds_7_5_MV1); - (cellholds_4_7_MV1, cellholds_6_5_MV1); - (cellholds_4_7_MV1, cellholds_5_5_MV1); - (cellholds_4_7_MV1, cellholds_4_5_MV1); - (cellholds_4_7_MV1, cellholds_3_5_MV1); - (cellhol... [truncated message content] |
From: <luk...@us...> - 2011-03-16 00:05:10
|
Revision: 1363 http://toss.svn.sourceforge.net/toss/?rev=1363&view=rev Author: lukaszkaiser Date: 2011-03-16 00:05:04 +0000 (Wed, 16 Mar 2011) Log Message: ----------- WebClient, www and manual GGP corrections. Modified Paths: -------------- trunk/Toss/GGP/GDL.ml trunk/Toss/WebClient/Main.js trunk/Toss/www/Makefile trunk/Toss/www/ideas.xml Added Paths: ----------- trunk/Toss/www/img/favicon.ico Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-03-15 14:53:40 UTC (rev 1362) +++ trunk/Toss/GGP/GDL.ml 2011-03-16 00:05:04 UTC (rev 1363) @@ -3821,7 +3821,7 @@ match actions with | [Func ("MOVE", [Const x1; Const y1; Const x2; Const y2]); Const "NOOP"] when x1 = x2 -> - "WhiteStraight", + "WhiteMove", ["a1", Structure.board_coords_name (s2i x1, s2i y1); "a2", Structure.board_coords_name (s2i x2, s2i y2)] | [Func ("MOVE", [Const x1; Const y1; Const x2; Const y2]); @@ -3832,7 +3832,7 @@ | [Const "NOOP"; Func ("MOVE", [Const x1; Const y1; Const x2; Const y2])] when x1 = x2 -> - "BlackStraight", + "BlackMove", ["a2", Structure.board_coords_name (s2i x1, s2i y1); "a1", Structure.board_coords_name (s2i x2, s2i y2)] | [Const "NOOP"; @@ -3944,7 +3944,7 @@ let struc = (snd new_state).Arena.struc in match emb with | [(_,a); (_,b)] -> - let a, b = if rule = "BlackStraight" then a, b else b, a in + let a, b = if rule = "BlackMove" then a, b else b, a in let x1, y1 = Structure.board_elem_coords (Structure.elem_str struc a) and x2, y2 = @@ -3957,7 +3957,7 @@ match emb with | [(_,a); (_,b)] -> let a, b = - if rule = "BlackStraight" then a, b else b, a in + if rule = "BlackMove" then a, b else b, a in let x1, y1 = Structure.board_elem_coords (Structure.elem_str struc a) and x2, y2 = @@ -3967,7 +3967,7 @@ else Printf.sprintf "(CAPTURE %d %d %d %d)" x1 y1 x2 y2 | [(_,a); (_,b); (_, c)] -> - let a, b = if rule = "BlackStraightTwo" then a, c else c, a in + let a, b = if rule = "BlackMoveTwo" then a, c else c, a in let x1, y1 = Structure.board_elem_coords (Structure.elem_str struc a) and x2, y2 = Modified: trunk/Toss/WebClient/Main.js =================================================================== --- trunk/Toss/WebClient/Main.js 2011-03-15 14:53:40 UTC (rev 1362) +++ trunk/Toss/WebClient/Main.js 2011-03-16 00:05:04 UTC (rev 1363) @@ -227,6 +227,7 @@ // Apply current move. function make_move () { + if (ASYNC_REQ_PENDING != 0) return; if (CUR_MOVE == "") return; var m = PLAYS[CUR_PLAY_I][3]; if (PLAYS[CUR_PLAY_I][m] != UNAME && PLAYS[CUR_PLAY_I][m] != "computer") { Modified: trunk/Toss/www/Makefile =================================================================== --- trunk/Toss/www/Makefile 2011-03-15 14:53:40 UTC (rev 1362) +++ trunk/Toss/www/Makefile 2011-03-16 00:05:04 UTC (rev 1363) @@ -6,6 +6,5 @@ ln -fs ../Toss.docdir code_doc cp code_doc/index.html code_doc/index.html.en cp code_doc/index.html code_doc/index.html.de - cp code_doc/index.html code_doc/index.html.de cp code_doc/index.html code_doc/index.html.pl cp code_doc/index.html code_doc/index.html.fr Modified: trunk/Toss/www/ideas.xml =================================================================== --- trunk/Toss/www/ideas.xml 2011-03-15 14:53:40 UTC (rev 1362) +++ trunk/Toss/www/ideas.xml 2011-03-16 00:05:04 UTC (rev 1363) @@ -14,8 +14,10 @@ <par>Toss is applying to participate in <em>Google Summer of Code</em> in 2011. This page contains a few ideas for students who wish to work on Toss this summer. But, most importantly, we welcome new ideas from - students who wish to participate! We are very positive about suggestions - and we think that best proposals (and code) come from students who are + students who wish to participate! If you think of a complex strategic game + or a suite of simpler games, it may be a good idea to do them in Toss. + Make sure to contact us, we are very positive about suggestions and + we think that the best proposals (and code) come from students who are simply passionate about realizing their own ideas!<br/></par> </section> @@ -93,26 +95,27 @@ in current Toss code and GUI, these are not fully developed, tested, and not supported in the web interface. The good old <a href="http://en.wikipedia.org/wiki/Pac-Man">Pac-Man</a> is an ideal - test candidate for these features. + test candidate for these features, especially for concurrent moves. <br/><br/></par> <par><em>Deliverables.</em> By mid-term it will be possible to play Pac-Man in Toss in command line mode and in the GUI. By the end, it will be supported in the web - interface as well. + interface and automatic play will work as well. <br/><br/></par> <par><em>Modules (in planned construction order).</em> <enumerate> <item>Allow multiple players in one location in Toss (easy)</item> + <item>Implement missing concurrency features in Toss (medium)</item> <item>Test, debug and implement missing timing features (easy)</item> - <item>Relate Toss-internal time with real time (medium)</item> <item>Pac-Man in command line and GUI (easy after 1, 2)</item> <item>Make Toss web interface fully asynchronous (medium)</item> <item>Pac-Man in the web interface (easy after 5)</item> + <item>Adapt automatic playing algorithms to concurrency</item> </enumerate> <br/></par> <par><em>Needed Skills and Difficulty.</em> - This idea is straight-forward and does not contain any hard bits. - But it requires the student to know both OCaml and AJAX with JavaScript, + This idea is easy to medium depending on much one demands in point 7. + It requires the student to know both OCaml and AJAX with JavaScript, and to be able to use and debug them in parallel. <br/><br/></par> <par><em>Possible Mentors (in order of preference):</em> @@ -220,6 +223,8 @@ <enumerate> <item>Enrich Toss formulas with fixed-points (medium, needed)</item> <item>Generalize GGP translation using fixed-points (medium)</item> + <item>Generalize GDL translation to handle simultaneous moves and + arbitrary turn taking (depends on concurrency in Toss)</item> <item>Improve readability of translated games, test, debug</item> <item>Add some position detection or layouting to the translation</item> <item>Adapt web interface to be usable with translated games</item> Added: trunk/Toss/www/img/favicon.ico =================================================================== (Binary files differ) Property changes on: trunk/Toss/www/img/favicon.ico ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-03-16 16:04:54
|
Revision: 1364 http://toss.svn.sourceforge.net/toss/?rev=1364&view=rev Author: lukaszkaiser Date: 2011-03-16 16:04:48 +0000 (Wed, 16 Mar 2011) Log Message: ----------- Some more www and WebClient corrections. Modified Paths: -------------- trunk/Toss/WebClient/Login.js trunk/Toss/www/.cvsignore trunk/Toss/www/Publications/.cvsignore trunk/Toss/www/Publications/Makefile trunk/Toss/www/default.mak trunk/Toss/www/index.xml trunk/Toss/www/navigation.xml trunk/Toss/www/styles/common.css trunk/Toss/www/xsl/books.xsl trunk/Toss/www/xsl/include/common.xsl trunk/Toss/www/xsl/include/layout.xsl trunk/Toss/www/xsl/main.xsl trunk/Toss/www/xsl/publications.xsl Property Changed: ---------------- trunk/Toss/www/ trunk/Toss/www/Publications/ Modified: trunk/Toss/WebClient/Login.js =================================================================== --- trunk/Toss/WebClient/Login.js 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/WebClient/Login.js 2011-03-16 16:04:48 UTC (rev 1364) @@ -47,7 +47,7 @@ // Onload handler function startup (game) { - if (navigator.userAgent.indexOf('MSIE') !=-1) { + if (navigator.userAgent.indexOf('MSIE') !=-1 && navigator.userAgent.indexOf('MSIE 9') ==-1) { document.getElementById("nosvg").style.display = "block"; } else { var udata = srv("USERPLAYS", "user"); Property changes on: trunk/Toss/www ___________________________________________________________________ Modified: svn:ignore - # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html *.html.de *.html.en *.html.pl *.texml *.xml.de *.xml.en *.xml.pl reference.xml code_doc *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.html *.html.de *.html.en *.html.fr *.html.pl *.texml *.xml.de *.xml.en *.xml.fr *.xml.pl reference.xml code_doc *.ps *.dvi *.aux *.out *.log *.bbl *.blg *.idx *.thm *.snm *.nav *.toc *.flc *~ Modified: trunk/Toss/www/.cvsignore =================================================================== --- trunk/Toss/www/.cvsignore 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/.cvsignore 2011-03-16 16:04:48 UTC (rev 1364) @@ -5,10 +5,12 @@ *.html *.html.de *.html.en +*.html.fr *.html.pl *.texml *.xml.de *.xml.en +*.xml.fr *.xml.pl reference.xml code_doc Property changes on: trunk/Toss/www/Publications ___________________________________________________________________ Modified: svn:ignore - # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.xml.de *.xml.en *.xml.pl *.html *.html.de *.html.en *.html.pl all.texml all.xml *~ + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.xml.de *.xml.en *.xml.fr *.xml.pl *.html *.html.de *.html.en *.html.fr *.html.pl all.texml all.xml *~ Modified: trunk/Toss/www/Publications/.cvsignore =================================================================== --- trunk/Toss/www/Publications/.cvsignore 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/Publications/.cvsignore 2011-03-16 16:04:48 UTC (rev 1364) @@ -4,10 +4,12 @@ *.xml.de *.xml.en +*.xml.fr *.xml.pl *.html *.html.de *.html.en +*.html.fr *.html.pl all.texml Modified: trunk/Toss/www/Publications/Makefile =================================================================== --- trunk/Toss/www/Publications/Makefile 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/Publications/Makefile 2011-03-16 16:04:48 UTC (rev 1364) @@ -1,6 +1,6 @@ TOPDIR = .. BINDIR = $(TOPDIR)/bin -LANGS = de en pl +LANGS = de en fr pl BIB_FILES = $(wildcard ./*.bib) BIBTEXML_TEX_FILES = $(patsubst %.bib,%.texml,$(BIB_FILES)) Modified: trunk/Toss/www/default.mak =================================================================== --- trunk/Toss/www/default.mak 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/default.mak 2011-03-16 16:04:48 UTC (rev 1364) @@ -1,5 +1,5 @@ BINDIR = $(TOPDIR)/bin -LANGS = de en pl +LANGS = de en fr pl BIB_FILES = $(wildcard ./*.bib) BIBTEXML_TEX_FILES = $(patsubst %.bib,%.texml,$(BIB_FILES)) @@ -83,6 +83,14 @@ chmod 664 $@ ;\ fi +%.html.fr : LANG=fr +%.html.fr : %.xml.fr $(AUXILIARY_FILES) $(XSL_FILES) $(BIBTEXML_FILES) + lang=$(LANG) ; if [ -n "$$lang" ] ; then \ + xsltproc $(XSLTPROC_PARAM) --stringparam "lang" "$(LANG)" --stringparam "uri" "$<" $< \ + | $(BINDIR)/hrefprocess "$(TOPDIR)" "$(LANG)" > $@ ;\ + chmod 664 $@ ;\ + fi + %.html : %.html.en @echo Modified: trunk/Toss/www/index.xml =================================================================== --- trunk/Toss/www/index.xml 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/index.xml 2011-03-16 16:04:48 UTC (rev 1364) @@ -38,7 +38,15 @@ </par> </section> + <section title="À propos de Toss" lang="fr"> + <par><em>Toss</em> jest programem do tworzenia, analizowania + i grania w gry. Dzięki ogólnemu algorytmowi możesz stworzyc grę + i od razu zagrać w nią z komputerem. Na przykład, jak grałoby + się w szachy bez środka planszy? Z Tossem łatwo to sprawdzić! + </par> + </section> + <games-section> <game-div> <game-link game="Breakthrough"/> Modified: trunk/Toss/www/navigation.xml =================================================================== --- trunk/Toss/www/navigation.xml 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/navigation.xml 2011-03-16 16:04:48 UTC (rev 1364) @@ -70,4 +70,27 @@ <item href="/contact.html" id="contact">Kontakt i Linki</item> </menu> + +<menu lang="fr"> + <item href="/" id="Home">Accueil</item> + <item href="/ideas.html" id="ideas">Idées GSoC</item> + <item href="http://tplay.org">Graj Online</item> + <item href="http://sourceforge.net/project/showfiles.php?group_id=115606" + >Télécharger Toss</item> + <menu title="Créerez des Jeux" href="/create.html" id="create"> + <item href="http://vimeo.com/10110495" id="tut">Tutorial Video</item> + <item href="/examples.html" id="examples">Examples</item> + <item href="/gui_interface.html" id="gui_interface">Interface GUI</item> + </menu> + <item href="/play.html" id="play">Regarder Toss Jouer</item> + <menu title="Documentation" href="/docs.html" id="docs"> + <item href="/reference/reference.pdf" id="refpdf">Référence (pdf)</item> + <item href="/reference/" id="refhtml">Référence (html)</item> + <item href="/code_doc/" id="code">Documentation du Code</item> + </menu> + <item href="/Publications/" id="Publications">Papers et Entretiens</item> + <item href="/develop.html" id="develop">Développer Toss</item> + <item href="/contact.html" id="contact">Contact et Liens</item> +</menu> + </navigation> Modified: trunk/Toss/www/styles/common.css =================================================================== --- trunk/Toss/www/styles/common.css 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/styles/common.css 2011-03-16 16:04:48 UTC (rev 1364) @@ -6,8 +6,8 @@ } body { - font-family: "DejaVu Sans", Verdana, sans-serif; - line-height: 140%; + font-family: Ubuntu, "DejaVu Sans", Verdana, sans-serif; + line-height: 130%; } a, a:link, a:active, a:visited { Modified: trunk/Toss/www/xsl/books.xsl =================================================================== --- trunk/Toss/www/xsl/books.xsl 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/xsl/books.xsl 2011-03-16 16:04:48 UTC (rev 1364) @@ -32,6 +32,9 @@ <xsl:if test="$lang='pl'"> <h1 property="dc:title">Ksiazki</h1> </xsl:if> + <xsl:if test="$lang='fr'"> + <h1 property="dc:title">Livres</h1> + </xsl:if> <!-- <xsl:if test="$lang='de'"> <p><em>Der Inhalt dieser Seite ist nur auf Englisch verfügbar.</em></p> Modified: trunk/Toss/www/xsl/include/common.xsl =================================================================== --- trunk/Toss/www/xsl/include/common.xsl 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/xsl/include/common.xsl 2011-03-16 16:04:48 UTC (rev 1364) @@ -78,6 +78,11 @@ <xsl:apply-templates /> <p><a href="http://tplay.org">Więcej gier</a></p> </xsl:when> + <xsl:when test="$lang='fr'"> + <h3><a href="http://tplay.org">Jouez en Ligne contre Toss</a></h3> + <xsl:apply-templates /> + <p><a href="http://tplay.org">Plus de Jeux</a></p> + </xsl:when> <xsl:otherwise> <h3><a href="http://tplay.org">Play Online Against Toss</a></h3> <xsl:apply-templates /> @@ -180,7 +185,7 @@ <a href="http://tplay.org/index_{@game}.html" title="Spiel {@game}" class="game-link" id="game-link-{@game}"> <img class="game-img" src="{$topdir}/img/{@game}.png" - alt="{@game}Brett" id="game-img-{@game}" /> + alt="{@game}-Brett" id="game-img-{@game}" /> </a> </xsl:when> <xsl:when test="$lang='pl'"> @@ -190,11 +195,18 @@ alt="Plansza {@game}" id="game-img-{@game}" /> </a> </xsl:when> + <xsl:when test="$lang='fr'"> + <a href="http://tplay.org/index_{@game}.html" + title="Graj w {@game}" class="game-link" id="game-link-{@game}"> + <img class="game-img" src="{$topdir}/img/{@game}.png" + alt="Bord de {@game}" id="game-img-{@game}" /> + </a> + </xsl:when> <xsl:otherwise> <a href="http://tplay.org/index_{@game}.html" - title="Play {@game}" class="game-link" id="game-link-{@game}"> + title="Jouez au {@game}" class="game-link" id="game-link-{@game}"> <img class="game-img" src="{$topdir}/img/{@game}.png" - alt="{@game} Board Image" id="game-img-{@game}" /> + alt="{@game} Board" id="game-img-{@game}" /> </a> </xsl:otherwise> </xsl:choose> Modified: trunk/Toss/www/xsl/include/layout.xsl =================================================================== --- trunk/Toss/www/xsl/include/layout.xsl 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/xsl/include/layout.xsl 2011-03-16 16:04:48 UTC (rev 1364) @@ -58,6 +58,9 @@ <xsl:if test="$lang='pl'"> <title>Publikacje</title> </xsl:if> + <xsl:if test="$lang='fr'"> + <title>Publications</title> + </xsl:if> </xsl:when> <xsl:when test="$title='Publications' and $author!='all'"> <xsl:variable name="fullname" select="normalize-space(concat(document('../../people.xml')/people/person[@id=$author]/first,' ',document('../../people.xml')/people/person[@id=$author]/last))"/> @@ -70,6 +73,9 @@ <xsl:if test="$lang='pl'"> <title>Publikacje: <xsl:value-of select="$fullname"/></title> </xsl:if> + <xsl:if test="$lang='fr'"> + <title>Publications de <xsl:value-of select="$fullname"/></title> + </xsl:if> </xsl:when> <xsl:otherwise> <title><xsl:value-of select="$title"/></title> @@ -137,6 +143,9 @@ <a href="{concat(substring-before($uri,'.'),'.html.en')}">English</a> </li> <li> + <a href="{concat(substring-before($uri,'.'),'.html.fr')}">Français</a> + </li> + <li> <a href="{concat(substring-before($uri,'.'),'.html.pl')}">Polski</a> </li> </xsl:if> @@ -146,6 +155,9 @@ </li> <li class="selected"><span>English</span></li> <li> + <a href="{concat(substring-before($uri,'.'),'.html.fr')}">Français</a> + </li> + <li> <a href="{concat(substring-before($uri,'.'),'.html.pl')}">Polski</a> </li> </xsl:if> @@ -156,8 +168,23 @@ <li> <a href="{concat(substring-before($uri,'.'),'.html.en')}">English</a> </li> + <li> + <a href="{concat(substring-before($uri,'.'),'.html.fr')}">Français</a> + </li> <li class="selected"><span>Polski</span></li> </xsl:if> + <xsl:if test="$lang='fr'"> + <li> + <a href="{concat(substring-before($uri,'.'),'.html.de')}">Deutsch</a> + </li> + <li> + <a href="{concat(substring-before($uri,'.'),'.html.en')}">English</a> + </li> + <li class="selected"><span>Français</span></li> + <li> + <a href="{concat(substring-before($uri,'.'),'.html.pl')}">Polski</a> + </li> + </xsl:if> </ul> </div> </xsl:template> Modified: trunk/Toss/www/xsl/main.xsl =================================================================== --- trunk/Toss/www/xsl/main.xsl 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/xsl/main.xsl 2011-03-16 16:04:48 UTC (rev 1364) @@ -758,6 +758,9 @@ <xsl:if test="$lang='pl'"> <h3>Wybrane Referaty</h3> </xsl:if> + <xsl:if test="$lang='fr'"> + <h3>Entretiens Sélectionnés</h3> + </xsl:if> <xsl:apply-templates /> </xsl:template> @@ -771,6 +774,9 @@ <xsl:if test="$lang='pl'"> <h3>Badania</h3> </xsl:if> + <xsl:if test="$lang='fr'"> + <h3>Recherche</h3> + </xsl:if> <xsl:apply-templates /> </xsl:template> @@ -802,6 +808,9 @@ <xsl:if test="$lang='pl'"> <h3>Addres</h3> </xsl:if> + <xsl:if test="$lang='fr'"> + <h3>l'Adresse</h3> + </xsl:if> Toss Team<br/> Internet<br/> <xsl:if test="$lang='de'"> @@ -886,6 +895,9 @@ <xsl:if test="$lang='pl'"> <h3>Ostatnie Publikacje</h3> </xsl:if> + <xsl:if test="$lang='fr'"> + <h3>Publications Récentes</h3> + </xsl:if> <xsl:apply-templates select="document('../Publications/all.xml')/*" mode="author"> <xsl:with-param name="author" select="document('../people.xml')/people/person[@id=current()/@author]/last"/> <xsl:with-param name="author_firstname" select="document('../people.xml')/people/person[@id=current()/@author]/first"/> @@ -898,8 +910,11 @@ <p><a href="{$topdir}/Publications/{@author}.html.en">All publications</a></p> </xsl:if> <xsl:if test="$lang='pl'"> - <p><a href="{$topdir}/Publications/{@author}.html.en">Wszystkie publikacje</a></p> + <p><a href="{$topdir}/Publications/{@author}.html.pl">Wszystkie publikacje</a></p> </xsl:if> + <xsl:if test="$lang='fr'"> + <p><a href="{$topdir}/Publications/{@author}.html.fr">Toutes les Publications</a></p> + </xsl:if> </xsl:template> Modified: trunk/Toss/www/xsl/publications.xsl =================================================================== --- trunk/Toss/www/xsl/publications.xsl 2011-03-16 00:05:04 UTC (rev 1363) +++ trunk/Toss/www/xsl/publications.xsl 2011-03-16 16:04:48 UTC (rev 1364) @@ -26,6 +26,9 @@ <xsl:if test="$lang='pl'"> <h1 property="dc:title">Prace i Referaty</h1> </xsl:if> + <xsl:if test="$lang='fr'"> + <h1 property="dc:title">Papers et Entretiens</h1> + </xsl:if> <xsl:if test="document('../people.xml')/people/person[@id=$author]"> <xsl:variable name="fullname" select="normalize-space(concat(document('../people.xml')/people/person[@id=$author]/first,' ',document('../people.xml')/people/person[@id=$author]/last))"/> <h2><xsl:value-of select="$fullname"/></h2> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |