toss-devel-svn Mailing List for Toss (Page 9)
Status: Beta
Brought to you by:
lukaszkaiser
You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(25) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(26) |
Feb
(38) |
Mar
(67) |
Apr
(22) |
May
(41) |
Jun
(30) |
Jul
(24) |
Aug
(32) |
Sep
(29) |
Oct
(34) |
Nov
(18) |
Dec
(2) |
2012 |
Jan
(19) |
Feb
(25) |
Mar
(16) |
Apr
(2) |
May
(18) |
Jun
(21) |
Jul
(11) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <luk...@us...> - 2011-08-29 21:08:26
|
Revision: 1549 http://toss.svn.sourceforge.net/toss/?rev=1549&view=rev Author: lukaszkaiser Date: 2011-08-29 21:08:20 +0000 (Mon, 29 Aug 2011) Log Message: ----------- Starting to add let-in to formulas and real exprs. Modified Paths: -------------- trunk/Toss/Formula/Formula.ml trunk/Toss/Formula/Formula.mli trunk/Toss/Formula/FormulaOps.ml trunk/Toss/Formula/FormulaOpsTest.ml trunk/Toss/Formula/FormulaParser.mly trunk/Toss/Formula/Lexer.mll trunk/Toss/Formula/Tokens.mly Modified: trunk/Toss/Formula/Formula.ml =================================================================== --- trunk/Toss/Formula/Formula.ml 2011-08-28 23:14:56 UTC (rev 1548) +++ trunk/Toss/Formula/Formula.ml 2011-08-29 21:08:20 UTC (rev 1549) @@ -115,6 +115,7 @@ | All of var list * formula | Lfp of [ mso_var | so_var ] * fo_var array * formula | Gfp of [ mso_var | so_var ] * fo_var array * formula + | Let of string * string list * formula * formula and real_expr = | RVar of string @@ -124,6 +125,7 @@ | Fun of string * fo_var | Char of formula | Sum of fo_var list * formula * real_expr + | RLet of string * real_expr * real_expr let is_atom = function @@ -211,6 +213,10 @@ Format.fprintf f "@[<1>gfp %a(%a) = (%a)@]" fprint_var r (Aux.fprint_sep_list "," fprint_var) (Array.to_list vs) (fprint_prec prec) fpphi + | Let (r, args, rphi, inphi) -> + Format.fprintf f "@[<1>let %s(%s) = %a in %a@]" r (String.concat ", " args) + (fprint_prec prec) rphi (fprint_prec prec) inphi + (* Bracket-savvy precedences: 0 +, 2 * *) and fprint_real_prec prec f = function @@ -231,6 +237,9 @@ Format.fprintf f "@[<1>Sum@ (@,%a@ |@ %a@ :@ %a@,)@]" (Aux.fprint_sep_list "," fprint_var) vl (fprint_prec 0) phi (fprint_real_prec 0) r + | RLet (v, lre, inre) -> + Format.fprintf f "@[<1>let %s = %a in %a@]" v + (fprint_real_prec prec) lre (fprint_real_prec prec) inre let fprint f phi = fprint_prec 0 f phi @@ -298,6 +307,7 @@ | RealExpr (re, sgn) -> size_real ~acc:(acc + 1) re | Not phi | Ex (_, phi) | All (_, phi) | Lfp (_,_,phi) | Gfp (_,_,phi) -> size ~acc:(acc + 1) phi + | Let (_, _, def, phi) -> size ~acc:(size ~acc:(acc + 2) def) phi | And flist | Or flist -> List.fold_left (fun i f -> size ~acc:i f) (acc + 1) flist and size_real ?(acc=0) = function @@ -307,6 +317,7 @@ | Char phi -> size ~acc phi | Sum (_, phi, re) -> let sr = size_real ~acc:(acc + 1) re in size ~acc:sr phi + | RLet (_, rdef, re) -> size_real ~acc:(size_real ~acc:(acc + 2) rdef) re let rec rec_compare phi1 phi2 = @@ -359,6 +370,13 @@ rec_compare psi1 psi2 | (Lfp _, _) -> -1 | (_, Lfp _) -> 1 + | (Gfp _, _) -> -1 + | (_, Gfp _) -> 1 + | (Let (r1, a1, def1, phi1), Let (r2, a2, def2, phi2)) -> + let rc = Pervasives.compare r1 r2 in if rc <> 0 then rc else + let ac = Pervasives.compare a1 a2 in if ac <> 0 then ac else + let dc = rec_compare def1 def2 in if dc <> 0 then dc else + rec_compare phi1 phi2 and rec_compare_re re1 re2 = match (re1, re2) with @@ -418,6 +436,8 @@ | Gfp (r, vs, phi) -> (match flatten_f f_or f_and phi with | Or [] -> Or [] | And [] -> And [] | f -> Gfp (r, vs, f)) + | Let (r, a, def, phi) -> + Let (r, a, flatten_f f_or f_and def, flatten_f f_or f_and phi) and flatten_re_f f_or f_and = function | RVar _ | Const _ | Fun _ as re -> re @@ -428,8 +448,9 @@ | Char (phi) -> Char (flatten_f f_or f_and phi) | Sum (vl, phi, r) -> Sum (vl, flatten_f f_or f_and phi, flatten_re_f f_or f_and r) + | RLet (v, def, re) -> + RLet (v, flatten_re_f f_or f_and def, flatten_re_f f_or f_and re) - (* Basic function to flatten formulas. *) let flatten psi = flatten_f (fun x -> x) (fun x -> x) psi let flatten_re psi = flatten_re_f (fun x -> x) (fun x -> x) psi @@ -535,6 +556,8 @@ let sgok = if is_mso (r :> var) then Array.length vs = 1 else ok_sg (var_str r) (Array.length vs) in sgok && (syntax_ok ~sg ~fp:(((var_str r), pos) :: fp) ~pos phi) + | Let (_, _, rphi, inphi) -> (* FIXME!! stupid let-check for now *) + syntax_ok ~sg ~fp ~pos rphi && syntax_ok ~sg ~fp ~pos inphi and syntax_ok_re ?(sg=ref []) ?(fp=[]) ?(pos=true) = function | RVar _ | Const _ | Fun _ -> true @@ -543,3 +566,5 @@ | Char phi -> syntax_ok ~sg ~fp ~pos phi | Sum (_, phi, r) -> syntax_ok ~sg ~fp ~pos phi && syntax_ok_re ~sg ~fp ~pos r + | RLet (_, re, inre) -> (* FIXME!! stupid let-check for now *) + syntax_ok_re ~sg ~fp ~pos re && syntax_ok_re ~sg ~fp ~pos inre Modified: trunk/Toss/Formula/Formula.mli =================================================================== --- trunk/Toss/Formula/Formula.mli 2011-08-28 23:14:56 UTC (rev 1548) +++ trunk/Toss/Formula/Formula.mli 2011-08-29 21:08:20 UTC (rev 1549) @@ -60,6 +60,7 @@ | All of var list * formula | Lfp of [mso_var | so_var] * fo_var array * formula | Gfp of [mso_var | so_var] * fo_var array * formula + | Let of string * string list * formula * formula (** Real-valued terms allow counting, characteristic functions, arithmetic. *) and real_expr = @@ -70,8 +71,8 @@ | Fun of string * fo_var | Char of formula | Sum of fo_var list * formula * real_expr + | RLet of string * real_expr * real_expr - val pow : real_expr -> int -> real_expr val size : ?acc : int -> formula -> int Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-08-28 23:14:56 UTC (rev 1548) +++ trunk/Toss/Formula/FormulaOps.ml 2011-08-29 21:08:20 UTC (rev 1549) @@ -47,8 +47,9 @@ | Gfp (r, vs, phi) when neg -> Lfp (r, vs, nnf ~neg:true ~rev:((var_str r) :: rev) phi) | Gfp (r, vs, phi) -> Gfp (r, vs, nnf ~neg:false ~rev phi) + | Let (r, args, body, phi) -> (* subst_rels [(rel, (args, body))] phi *) + Let (r, args, nnf body, nnf phi) - (* -------------------------- FREE VARIABLES -------------------------------- *) (* Helper function: remove duplicates from sorted list of variables. *) Modified: trunk/Toss/Formula/FormulaOpsTest.ml =================================================================== --- trunk/Toss/Formula/FormulaOpsTest.ml 2011-08-28 23:14:56 UTC (rev 1548) +++ trunk/Toss/Formula/FormulaOpsTest.ml 2011-08-29 21:08:20 UTC (rev 1549) @@ -41,8 +41,8 @@ "all :x, :y (not :x^2 -0.5 < :y^2 -1)"; nnf_eq "ex x :(all y (R (x, y))) > 0" "ex x :(all y (R (x, y))) > 0"; - nnf_eq "set R(x) = ex y C(x, y) in P(x) or R(x)" - "P(x) or ex y C(x, y)"; + nnf_eq "let R(x) = not ex y C(x, y) in not (P(x) or R(x))" + "let R(x) = all y not C(x, y) in not P(x) and not R(x)"; nnf_eq "not lfp T(x) = (P(x) or ex y (E(x, y) and y in T))" "gfp T(x) = (not P(x) and all y (not E(x, y) or y in T))"; nnf_eq "not lfp |R(x, y) = (P(x, y) or ex z (E(x, z) and |R(y, z)))" Modified: trunk/Toss/Formula/FormulaParser.mly =================================================================== --- trunk/Toss/Formula/FormulaParser.mly 2011-08-28 23:14:56 UTC (rev 1548) +++ trunk/Toss/Formula/FormulaParser.mly 2011-08-29 21:08:20 UTC (rev 1549) @@ -15,7 +15,7 @@ %} %start parse_formula parse_real_expr -%type <Formula.formula> parse_formula formula_with_set_expr formula_expr +%type <Formula.formula> parse_formula formula_with_let_expr formula_expr %type <Formula.var list> var_list %type <Formula.fo_var list> fo_var_list %type <Formula.real_expr> parse_real_expr real_expr @@ -116,17 +116,17 @@ { Or [And [Not ($1); Not ($3)]; And [$1; $3]] } | OPEN formula_expr CLOSE { $2 } -formula_with_set_expr: +formula_with_let_expr: | formula_expr { $1 } - | SET_CMD rel = ID - arg = delimited (OPEN, separated_list (COMMA, ID), CLOSE) + | LET_CMD rel = ID + args = delimited (OPEN, separated_list (COMMA, ID), CLOSE) EQ - body = formula_expr IN phi = formula_with_set_expr - { FormulaOps.subst_rels [(rel, (arg, body))] phi } + body = formula_expr IN phi = formula_with_let_expr + { Let (rel, args, body, phi) } parse_formula: - formula_with_set_expr EOF + formula_with_let_expr EOF { if Formula.syntax_ok $1 then $1 else raise (Parsing_error "Wrong formula syntax (arities? fixed-points?)") }; Modified: trunk/Toss/Formula/Lexer.mll =================================================================== --- trunk/Toss/Formula/Lexer.mll 2011-08-28 23:14:56 UTC (rev 1548) +++ trunk/Toss/Formula/Lexer.mll 2011-08-29 21:08:20 UTC (rev 1549) @@ -62,6 +62,7 @@ | DEL_CMD | GET_CMD | SET_CMD + | LET_CMD | EVAL_CMD | ELEM_MOD | REL_MOD @@ -201,6 +202,8 @@ | "GET" { GET_CMD } | "SET" { SET_CMD } | "set" { SET_CMD } + | "LET" { LET_CMD } + | "let" { LET_CMD } | "EVAL" { EVAL_CMD } | "ELEM" { ELEM_MOD } | "REL" { REL_MOD } Modified: trunk/Toss/Formula/Tokens.mly =================================================================== --- trunk/Toss/Formula/Tokens.mly 2011-08-28 23:14:56 UTC (rev 1548) +++ trunk/Toss/Formula/Tokens.mly 2011-08-29 21:08:20 UTC (rev 1549) @@ -9,7 +9,7 @@ %token OPENCUR CLOSECUR OPENSQ CLOSESQ OPEN CLOSE %token IN AND OR XOR NOT EX ALL TC %token WITH EMB PRE INV POST UPDATE DYNAMICS TRUE FALSE ASSOC COND PAYOFF MOVES -%token ADD_CMD DEL_CMD GET_CMD SET_CMD EVAL_CMD +%token ADD_CMD DEL_CMD GET_CMD SET_CMD LET_CMD EVAL_CMD %token ELEM_MOD REL_MOD ALLOF_MOD SIG_MOD FUN_MOD DATA_MOD LOC_MOD TIMEOUT_MOD TIME_MOD PLAYER_MOD PLAYERS_MOD %token MODEL_SPEC RULE_SPEC STATE_SPEC LEFT_SPEC RIGHT_SPEC CLASS LFP GFP EOF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-28 23:15:02
|
Revision: 1548 http://toss.svn.sourceforge.net/toss/?rev=1548&view=rev Author: lukstafi Date: 2011-08-28 23:14:56 +0000 (Sun, 28 Aug 2011) Log Message: ----------- GDL translation: command-line translation minor fix. Modified Paths: -------------- trunk/Toss/GGP/TranslateGame.ml Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-28 22:05:49 UTC (rev 1547) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-28 23:14:56 UTC (rev 1548) @@ -1734,7 +1734,9 @@ let tossrule_preconds = Aux.StrMap.map (fun rdata->rdata.precond) tossrule_data in let playing_as = - Aux.array_argfind (fun x -> x = playing_as) players in + try + Aux.array_argfind (fun x -> x = playing_as) players + with Not_found -> 0 in (match !generate_test_case with | None -> () | Some game_name -> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-28 22:05:58
|
Revision: 1547 http://toss.svn.sourceforge.net/toss/?rev=1547&view=rev Author: lukaszkaiser Date: 2011-08-28 22:05:49 +0000 (Sun, 28 Aug 2011) Log Message: ----------- Translate testing in Makefile, first batch of GGP examples (starting with digits). Modified Paths: -------------- trunk/Toss/GGP/Makefile Added Paths: ----------- trunk/Toss/GGP/examples/2player_normal_form_2010.gdl trunk/Toss/GGP/examples/3pffa.gdl trunk/Toss/GGP/examples/3pttc.gdl trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.0.qdimacs.gdl trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.1.qdimacs.SAT.gdl trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.1.qdimacs.viz.SAT.gdl trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.2.qdimacs.SAT.gdl trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.2.qdimacs.satlike.gdl trunk/Toss/GGP/examples/4pttc.gdl trunk/Toss/GGP/examples/8puzzle.gdl Modified: trunk/Toss/GGP/Makefile =================================================================== --- trunk/Toss/GGP/Makefile 2011-08-28 21:08:34 UTC (rev 1546) +++ trunk/Toss/GGP/Makefile 2011-08-28 22:05:49 UTC (rev 1547) @@ -7,6 +7,8 @@ TranslateTest: GameSimplTest: +GDL_GAMES = $(basename $(notdir $(shell ls examples/*.gdl))) + %.black: examples/%.gdl make -C .. OCAMLRUNPARAM=b; export OCAMLRUNPARAM; ../TossServer -nocache -d 1 & @@ -19,7 +21,6 @@ java -jar gamecontroller-cli.jar play $< 600 10 1 -random 2 -remote 1 toss localhost 8110 1 | grep results killall -v TossServer - tests_all: make -C .. GGPTestsVerbose make tictactoe.white @@ -33,6 +34,16 @@ make connect5.white make connect5.black + +%.translate: examples/%.gdl + @make -C .. GGP/TranslateGameTest.native > /dev/null + @echo Translating $< + @-../TranslateGameTest.native -v -f $< + @echo '' + +translate_all: $(addsuffix .translate, $(GDL_GAMES)) + + .PHONY: clean clean: Added: trunk/Toss/GGP/examples/2player_normal_form_2010.gdl =================================================================== --- trunk/Toss/GGP/examples/2player_normal_form_2010.gdl (rev 0) +++ trunk/Toss/GGP/examples/2player_normal_form_2010.gdl 2011-08-28 22:05:49 UTC (rev 1547) @@ -0,0 +1,36 @@ +(role row) +(role column) + +(init (reward r1 c1 90 90)) +(init (reward r1 c2 40 30)) +(init (reward r1 c3 20 80)) +(init (reward r2 c1 30 40)) +(init (reward r2 c2 0 0)) +(init (reward r2 c3 50 100)) +(init (reward r3 c1 80 20)) +(init (reward r3 c2 100 50)) +(init (reward r3 c3 10 10)) + +(<= (legal row ?m1) + (true (reward ?m1 ?m2 ?r1 ?r2))) +(<= (legal column ?m2) + (true (reward ?m1 ?m2 ?r1 ?r2))) + +(<= (next (did ?p ?m)) + (does ?p ?m)) + +(<= (next (reward ?m1 ?m2 ?r1 ?r2)) + (true (reward ?m1 ?m2 ?r1 ?r2))) + +(<= (goal row ?r1) + (true (did row ?m1)) + (true (did column ?m2)) + (true (reward ?m1 ?m2 ?r1 ?r2))) + +(<= (goal column ?r2) + (true (did row ?m1)) + (true (did column ?m2)) + (true (reward ?m1 ?m2 ?r1 ?r2))) + +(<= terminal + (true (did ?p ?m))) Added: trunk/Toss/GGP/examples/3pffa.gdl =================================================================== --- trunk/Toss/GGP/examples/3pffa.gdl (rev 0) +++ trunk/Toss/GGP/examples/3pffa.gdl 2011-08-28 22:05:49 UTC (rev 1547) @@ -0,0 +1,203 @@ +(role red) +(role yellow) +(role blue) +(init (control red)) +(init (cell 1 4 red)) +(init (cell 4 1 yellow)) +(init (cell 7 4 blue)) +(init (step 1)) +(init (capture red 0)) +(init (capture yellow 0)) +(init (capture blue 0)) +(<= (legal ?player noop) + (role ?player)) +(<= (legal ?player (move ?x1 ?y1 ?x2 ?y2)) + (true (control ?player)) + (true (cell ?x1 ?y1 ?player)) + (orthogonal ?x1 ?y1 ?x2 ?y2) + (onboard ?x2 ?y2) + (true (cell ?x2 ?y2 ?player2)) + (distinct ?player ?player2)) +(<= (legal ?player (move ?x1 ?y1 ?x2 ?y2)) + (true (control ?player)) + (true (cell ?x1 ?y1 ?player)) + (diagonal ?x1 ?y1 ?x2 ?y2) + (onboard ?x2 ?y2) + (true (cell ?x2 ?y2 ?player2)) + (distinct ?player ?player2)) +(<= (legal ?player (move ?x1 ?y1 ?x2 ?y2)) + (true (control ?player)) + (true (cell ?x1 ?y1 ?player)) + (ell ?x1 ?y1 ?x2 ?y2) + (opencell ?x2 ?y2)) +(<= (next (control ?p2)) + (true (control ?p1)) + (rotation ?p1 ?p2)) +(<= (next (cell ?x2 ?y2 ?player)) + (does ?player (move ?x1 ?y1 ?x2 ?y2))) +(<= (next (cell ?x ?y ?piece)) + (true (cell ?x ?y ?piece)) + (not (camefrom ?x ?y)) + (not (wentto ?x ?y))) +(<= (next (cell ?x ?y ?player)) + (spawns ?x ?y ?player)) +(<= (next (capture ?player ?count)) + (true (capture ?player ?count)) + (not (captured ?player))) +(<= (next (capture ?player ?count2)) + (true (capture ?player ?count1)) + (captured ?player) + (captureplus ?count1 ?count2)) +(<= (next (step ?t2)) + (true (step ?t1)) + (stepcount ?t1 ?t2)) +(<= terminal + (true (step 31))) +(<= (goal ?player ?goal) + (true (capture ?player ?count)) + (scoremap ?count ?goal)) +(<= (orthogonal ?x1 ?y ?x2 ?y) + (plus 1 ?x1 ?x2) + (index ?y)) +(<= (orthogonal ?x1 ?y ?x2 ?y) + (plus 1 ?x2 ?x1) + (index ?y)) +(<= (orthogonal ?x ?y1 ?x ?y2) + (index ?x) + (plus 1 ?y1 ?y2)) +(<= (orthogonal ?x ?y1 ?x ?y2) + (index ?x) + (plus 1 ?y2 ?y1)) +(<= (diagonal ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x1 ?x2) + (plus 1 ?y1 ?y2)) +(<= (diagonal ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x1 ?x2) + (plus 1 ?y2 ?y1)) +(<= (diagonal ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x2 ?x1) + (plus 1 ?y1 ?y2)) +(<= (diagonal ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x2 ?x1) + (plus 1 ?y2 ?y1)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 2 ?x1 ?x2) + (plus 1 ?y1 ?y2)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 2 ?x1 ?x2) + (plus 1 ?y2 ?y1)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 2 ?x2 ?x1) + (plus 1 ?y1 ?y2)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 2 ?x2 ?x1) + (plus 1 ?y2 ?y1)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x1 ?x2) + (plus 2 ?y1 ?y2)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x1 ?x2) + (plus 2 ?y2 ?y1)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x2 ?x1) + (plus 2 ?y1 ?y2)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x2 ?x1) + (plus 2 ?y2 ?y1)) +(<= (opencell ?x ?y) + (onboard ?x ?y) + (not (true (cell ?x ?y red))) + (not (true (cell ?x ?y yellow))) + (not (true (cell ?x ?y blue)))) +(<= (onboard ?x ?y) + (index ?x) + (index ?y) + (distinct ?x 1) + (distinct ?x 7) + (distinct ?y 1) + (distinct ?y 7)) +(<= (camefrom ?x1 ?y1) + (does ?player (move ?x1 ?y1 ?x2 ?y2))) +(<= (wentto ?x2 ?y2) + (does ?player (move ?x1 ?y1 ?x2 ?y2))) +(<= (captured ?player) + (true (control ?player)) + (wentto ?x ?y) + (true (cell ?x ?y ?any))) +(index 1) +(index 2) +(index 3) +(index 4) +(index 5) +(index 6) +(index 7) +(plus 1 1 2) +(plus 1 2 3) +(plus 1 3 4) +(plus 1 4 5) +(plus 1 5 6) +(plus 1 6 7) +(plus 2 1 3) +(plus 2 2 4) +(plus 2 3 5) +(plus 2 4 6) +(plus 2 5 7) +(rotation red yellow) +(rotation yellow blue) +(rotation blue red) +(spawns 1 4 red) +(spawns 4 1 yellow) +(spawns 7 4 blue) +(stepcount 1 2) +(stepcount 2 3) +(stepcount 3 4) +(stepcount 4 5) +(stepcount 5 6) +(stepcount 6 7) +(stepcount 7 8) +(stepcount 8 9) +(stepcount 9 10) +(stepcount 10 11) +(stepcount 11 12) +(stepcount 12 13) +(stepcount 13 14) +(stepcount 14 15) +(stepcount 15 16) +(stepcount 16 17) +(stepcount 17 18) +(stepcount 18 19) +(stepcount 19 20) +(stepcount 20 21) +(stepcount 21 22) +(stepcount 22 23) +(stepcount 23 24) +(stepcount 24 25) +(stepcount 25 26) +(stepcount 26 27) +(stepcount 27 28) +(stepcount 28 29) +(stepcount 29 30) +(stepcount 30 31) +(captureplus 0 1) +(captureplus 1 2) +(captureplus 2 3) +(captureplus 3 4) +(captureplus 4 5) +(captureplus 5 6) +(captureplus 6 7) +(captureplus 7 8) +(captureplus 8 9) +(captureplus 9 10) +(scoremap 0 0) +(scoremap 1 10) +(scoremap 2 20) +(scoremap 3 30) +(scoremap 4 40) +(scoremap 5 50) +(scoremap 6 60) +(scoremap 7 70) +(scoremap 8 80) +(scoremap 9 90) +(scoremap 10 100) + + Added: trunk/Toss/GGP/examples/3pttc.gdl =================================================================== --- trunk/Toss/GGP/examples/3pttc.gdl (rev 0) +++ trunk/Toss/GGP/examples/3pttc.gdl 2011-08-28 22:05:49 UTC (rev 1547) @@ -0,0 +1,213 @@ +(role red) +(role yellow) +(role blue) +(init (control red)) +(init (cell 1 4 red)) +(init (cell 4 1 yellow)) +(init (cell 7 4 blue)) +(init (step 1)) +(<= (legal ?player noop) + (role ?player)) +(<= (legal ?player (move ?x1 ?y1 ?x2 ?y2)) + (true (control ?player)) + (true (cell ?x1 ?y1 ?player)) + (orthogonal ?x1 ?y1 ?x2 ?y2) + (onboard ?x2 ?y2) + (true (cell ?x2 ?y2 ?player2)) + (distinct ?player ?player2)) +(<= (legal ?player (move ?x1 ?y1 ?x2 ?y2)) + (true (control ?player)) + (true (cell ?x1 ?y1 ?player)) + (diagonal ?x1 ?y1 ?x2 ?y2) + (onboard ?x2 ?y2) + (true (cell ?x2 ?y2 ?player2)) + (distinct ?player ?player2)) +(<= (legal ?player (move ?x1 ?y1 ?x2 ?y2)) + (true (control ?player)) + (true (cell ?x1 ?y1 ?player)) + (ell ?x1 ?y1 ?x2 ?y2) + (opencell ?x2 ?y2)) +(<= (next (control ?p2)) + (true (control ?p1)) + (rotation ?p1 ?p2)) +(<= (next (cell ?x2 ?y2 ?player)) + (does ?player (move ?x1 ?y1 ?x2 ?y2))) +(<= (next (cell ?x ?y ?piece)) + (true (cell ?x ?y ?piece)) + (not (camefrom ?x ?y)) + (not (wentto ?x ?y))) +(<= (next (cell ?x ?y ?player)) + (spawns ?x ?y ?player)) +(<= (next (step ?t2)) + (true (step ?t1)) + (stepcount ?t1 ?t2)) +(<= terminal + (role ?player) + (line ?player)) +(<= terminal + (true (step 31))) +(<= (goal ?player 0) + (role ?player) + (not (line ?player))) +(<= (goal ?player 100) + (role ?player) + (line ?player)) +(<= (orthogonal ?x1 ?y ?x2 ?y) + (plus 1 ?x1 ?x2) + (index ?y)) +(<= (orthogonal ?x1 ?y ?x2 ?y) + (plus 1 ?x2 ?x1) + (index ?y)) +(<= (orthogonal ?x ?y1 ?x ?y2) + (index ?x) + (plus 1 ?y1 ?y2)) +(<= (orthogonal ?x ?y1 ?x ?y2) + (index ?x) + (plus 1 ?y2 ?y1)) +(<= (diagonal ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x1 ?x2) + (plus 1 ?y1 ?y2)) +(<= (diagonal ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x1 ?x2) + (plus 1 ?y2 ?y1)) +(<= (diagonal ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x2 ?x1) + (plus 1 ?y1 ?y2)) +(<= (diagonal ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x2 ?x1) + (plus 1 ?y2 ?y1)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 2 ?x1 ?x2) + (plus 1 ?y1 ?y2)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 2 ?x1 ?x2) + (plus 1 ?y2 ?y1)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 2 ?x2 ?x1) + (plus 1 ?y1 ?y2)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 2 ?x2 ?x1) + (plus 1 ?y2 ?y1)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x1 ?x2) + (plus 2 ?y1 ?y2)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x1 ?x2) + (plus 2 ?y2 ?y1)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x2 ?x1) + (plus 2 ?y1 ?y2)) +(<= (ell ?x1 ?y1 ?x2 ?y2) + (plus 1 ?x2 ?x1) + (plus 2 ?y2 ?y1)) +(<= (opencell ?x ?y) + (onboard ?x ?y) + (not (true (cell ?x ?y red))) + (not (true (cell ?x ?y yellow))) + (not (true (cell ?x ?y blue)))) +(<= (onboard ?x ?y) + (index ?x) + (index ?y) + (distinct ?x 1) + (distinct ?x 7) + (distinct ?y 1) + (distinct ?y 7)) +(<= (camefrom ?x1 ?y1) + (does ?player (move ?x1 ?y1 ?x2 ?y2))) +(<= (wentto ?x2 ?y2) + (does ?player (move ?x1 ?y1 ?x2 ?y2))) +(<= (line ?player) + (row ?player)) +(<= (line ?player) + (column ?player)) +(<= (line ?player) + (diag ?player)) +(<= (row ?player) + (true (cell 3 3 ?player)) + (true (cell 4 3 ?player)) + (true (cell 5 3 ?player))) +(<= (row ?player) + (true (cell 3 4 ?player)) + (true (cell 4 4 ?player)) + (true (cell 5 4 ?player))) +(<= (row ?player) + (true (cell 3 5 ?player)) + (true (cell 4 5 ?player)) + (true (cell 5 5 ?player))) +(<= (column ?player) + (true (cell 3 3 ?player)) + (true (cell 3 4 ?player)) + (true (cell 3 5 ?player))) +(<= (column ?player) + (true (cell 4 3 ?player)) + (true (cell 4 4 ?player)) + (true (cell 4 5 ?player))) +(<= (column ?player) + (true (cell 5 3 ?player)) + (true (cell 5 4 ?player)) + (true (cell 5 5 ?player))) +(<= (diag ?player) + (true (cell 3 3 ?player)) + (true (cell 4 4 ?player)) + (true (cell 5 5 ?player))) +(<= (diag ?player) + (true (cell 3 5 ?player)) + (true (cell 4 4 ?player)) + (true (cell 5 3 ?player))) +(index 1) +(index 2) +(index 3) +(index 4) +(index 5) +(index 6) +(index 7) +(plus 1 1 2) +(plus 1 2 3) +(plus 1 3 4) +(plus 1 4 5) +(plus 1 5 6) +(plus 1 6 7) +(plus 2 1 3) +(plus 2 2 4) +(plus 2 3 5) +(plus 2 4 6) +(plus 2 5 7) +(rotation red yellow) +(rotation yellow blue) +(rotation blue red) +(spawns 1 4 red) +(spawns 4 1 yellow) +(spawns 7 4 blue) +(stepcount 1 2) +(stepcount 2 3) +(stepcount 3 4) +(stepcount 4 5) +(stepcount 5 6) +(stepcount 6 7) +(stepcount 7 8) +(stepcount 8 9) +(stepcount 9 10) +(stepcount 10 11) +(stepcount 11 12) +(stepcount 12 13) +(stepcount 13 14) +(stepcount 14 15) +(stepcount 15 16) +(stepcount 16 17) +(stepcount 17 18) +(stepcount 18 19) +(stepcount 19 20) +(stepcount 20 21) +(stepcount 21 22) +(stepcount 22 23) +(stepcount 23 24) +(stepcount 24 25) +(stepcount 25 26) +(stepcount 26 27) +(stepcount 27 28) +(stepcount 28 29) +(stepcount 29 30) +(stepcount 30 31) + + + Added: trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.0.qdimacs.gdl =================================================================== --- trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.0.qdimacs.gdl (rev 0) +++ trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.0.qdimacs.gdl 2011-08-28 22:05:49 UTC (rev 1547) @@ -0,0 +1,378 @@ +(prop_var 1) +(prop_var 2) +(prop_var 3) +(prop_var 4) +(prop_var 5) +(prop_var 6) +(prop_var 7) +(prop_var 8) +(prop_var 9) +(prop_var 10) +(prop_var 11) +(prop_var 12) +(prop_var 13) +(prop_var 14) +(prop_var 15) +(prop_var 16) +(prop_var 17) +(prop_var 18) +(prop_var 19) +(prop_var 20) +(prop_var 21) +(prop_var 22) +(prop_var 23) +(prop_var 24) +(prop_var 25) +(prop_var 26) +(prop_var 27) +(prop_var 28) +(prop_var 29) +(prop_var 30) +(prop_var 31) +(prop_var 32) +(prop_var 33) +(prop_var 34) +(prop_var 35) +(prop_var 36) +(prop_var 37) +(prop_var 38) +(prop_var 39) +(prop_var 40) +(prop_var 41) +(prop_var 42) +(prop_var 43) +(prop_var 44) +(prop_var 45) +(prop_var 46) +(prop_var 47) +(prop_var 48) +(prop_var 49) +(prop_var 50) +(prop_var 51) +(prop_var 52) +(prop_var 53) +(prop_var 54) +(prop_var 55) +(prop_var 56) +(prop_var 57) +(prop_var 58) +(prop_var 59) +(prop_var 60) +(clause 1) +(clause 2) +(clause 3) +(clause 4) +(clause 5) +(clause 6) +(clause 7) +(clause 8) +(clause 9) +(clause 10) +(clause 11) +(clause 12) +(clause 13) +(clause 14) +(clause 15) +(clause 16) +(clause 17) +(clause 18) +(clause 19) +(clause 20) +(clause 21) +(clause 22) +(clause 23) +(clause 24) +(clause 25) +(clause 26) +(clause 27) +(clause 28) +(clause 29) +(clause 30) +(clause 31) +(clause 32) +(clause 33) +(clause 34) +(clause 35) +(clause 36) +(clause 37) +(clause 38) +(clause 39) +(clause 40) +(role exists) +(role forall) +(truth_value t) +(truth_value f) +(init (control exists 1)) +(<= (legal ?v488920 (assign ?v488930 ?v488931)) (true (control ?v488920 ?v488930)) (role ?v488920) (prop_var ?v488930) (truth_value ?v488931)) +(<= (legal exists noop) (true (control forall ?v488966)) (prop_var ?v488966)) +(<= (legal forall noop) (true (control exists ?v488966)) (prop_var ?v488966)) +(<= (next (sat ?v488990)) (true (sat ?v488990)) (clause ?v488990)) +(<= (next (control exists 2)) (true (control exists 1))) +(<= (next (control exists 3)) (true (control exists 2))) +(<= (next (control exists 4)) (true (control exists 3))) +(<= (next (control exists 5)) (true (control exists 4))) +(<= (next (control exists 6)) (true (control exists 5))) +(<= (next (control exists 7)) (true (control exists 6))) +(<= (next (control exists 8)) (true (control exists 7))) +(<= (next (control exists 9)) (true (control exists 8))) +(<= (next (control exists 10)) (true (control exists 9))) +(<= (next (control exists 11)) (true (control exists 10))) +(<= (next (control exists 12)) (true (control exists 11))) +(<= (next (control exists 13)) (true (control exists 12))) +(<= (next (control exists 14)) (true (control exists 13))) +(<= (next (control exists 15)) (true (control exists 14))) +(<= (next (control exists 16)) (true (control exists 15))) +(<= (next (control exists 17)) (true (control exists 16))) +(<= (next (control exists 18)) (true (control exists 17))) +(<= (next (control exists 19)) (true (control exists 18))) +(<= (next (control exists 20)) (true (control exists 19))) +(<= (next (control forall 21)) (true (control exists 20))) +(<= (next (control forall 22)) (true (control forall 21))) +(<= (next (control forall 23)) (true (control forall 22))) +(<= (next (control forall 24)) (true (control forall 23))) +(<= (next (control forall 25)) (true (control forall 24))) +(<= (next (control forall 26)) (true (control forall 25))) +(<= (next (control forall 27)) (true (control forall 26))) +(<= (next (control forall 28)) (true (control forall 27))) +(<= (next (control forall 29)) (true (control forall 28))) +(<= (next (control forall 30)) (true (control forall 29))) +(<= (next (control forall 31)) (true (control forall 30))) +(<= (next (control forall 32)) (true (control forall 31))) +(<= (next (control forall 33)) (true (control forall 32))) +(<= (next (control forall 34)) (true (control forall 33))) +(<= (next (control forall 35)) (true (control forall 34))) +(<= (next (control forall 36)) (true (control forall 35))) +(<= (next (control forall 37)) (true (control forall 36))) +(<= (next (control forall 38)) (true (control forall 37))) +(<= (next (control forall 39)) (true (control forall 38))) +(<= (next (control forall 40)) (true (control forall 39))) +(<= (next (control exists 41)) (true (control forall 40))) +(<= (next (control exists 42)) (true (control exists 41))) +(<= (next (control exists 43)) (true (control exists 42))) +(<= (next (control exists 44)) (true (control exists 43))) +(<= (next (control exists 45)) (true (control exists 44))) +(<= (next (control exists 46)) (true (control exists 45))) +(<= (next (control exists 47)) (true (control exists 46))) +(<= (next (control exists 48)) (true (control exists 47))) +(<= (next (control exists 49)) (true (control exists 48))) +(<= (next (control exists 50)) (true (control exists 49))) +(<= (next (control exists 51)) (true (control exists 50))) +(<= (next (control exists 52)) (true (control exists 51))) +(<= (next (control exists 53)) (true (control exists 52))) +(<= (next (control exists 54)) (true (control exists 53))) +(<= (next (control exists 55)) (true (control exists 54))) +(<= (next (control exists 56)) (true (control exists 55))) +(<= (next (control exists 57)) (true (control exists 56))) +(<= (next (control exists 58)) (true (control exists 57))) +(<= (next (control exists 59)) (true (control exists 58))) +(<= (next (control exists 60)) (true (control exists 59))) +(<= (next (control the end)) (true (control exists 60))) +(<= (next (sat 1)) (does ?v493768 (assign 56 f)) (role ?v493768)) +(<= (next (sat 1)) (does ?v493789 (assign 52 f)) (role ?v493789)) +(<= (next (sat 1)) (does ?v493810 (assign 55 f)) (role ?v493810)) +(<= (next (sat 1)) (does ?v493831 (assign 27 f)) (role ?v493831)) +(<= (next (sat 1)) (does ?v493852 (assign 18 t)) (role ?v493852)) +(<= (next (sat 2)) (does ?v493875 (assign 4 f)) (role ?v493875)) +(<= (next (sat 2)) (does ?v493896 (assign 29 t)) (role ?v493896)) +(<= (next (sat 2)) (does ?v493917 (assign 23 f)) (role ?v493917)) +(<= (next (sat 2)) (does ?v493938 (assign 58 f)) (role ?v493938)) +(<= (next (sat 2)) (does ?v493959 (assign 5 t)) (role ?v493959)) +(<= (next (sat 3)) (does ?v493982 (assign 29 t)) (role ?v493982)) +(<= (next (sat 3)) (does ?v494003 (assign 8 t)) (role ?v494003)) +(<= (next (sat 3)) (does ?v494024 (assign 7 f)) (role ?v494024)) +(<= (next (sat 3)) (does ?v494045 (assign 25 t)) (role ?v494045)) +(<= (next (sat 3)) (does ?v494066 (assign 24 t)) (role ?v494066)) +(<= (next (sat 4)) (does ?v494089 (assign 15 f)) (role ?v494089)) +(<= (next (sat 4)) (does ?v494110 (assign 11 t)) (role ?v494110)) +(<= (next (sat 4)) (does ?v494131 (assign 58 t)) (role ?v494131)) +(<= (next (sat 4)) (does ?v494152 (assign 19 t)) (role ?v494152)) +(<= (next (sat 4)) (does ?v494173 (assign 9 t)) (role ?v494173)) +(<= (next (sat 5)) (does ?v494196 (assign 1 f)) (role ?v494196)) +(<= (next (sat 5)) (does ?v494217 (assign 42 f)) (role ?v494217)) +(<= (next (sat 5)) (does ?v494238 (assign 30 f)) (role ?v494238)) +(<= (next (sat 5)) (does ?v494259 (assign 58 t)) (role ?v494259)) +(<= (next (sat 5)) (does ?v494280 (assign 21 t)) (role ?v494280)) +(<= (next (sat 6)) (does ?v494303 (assign 33 f)) (role ?v494303)) +(<= (next (sat 6)) (does ?v494324 (assign 39 t)) (role ?v494324)) +(<= (next (sat 6)) (does ?v494345 (assign 59 t)) (role ?v494345)) +(<= (next (sat 6)) (does ?v494366 (assign 60 t)) (role ?v494366)) +(<= (next (sat 6)) (does ?v494387 (assign 29 f)) (role ?v494387)) +(<= (next (sat 7)) (does ?v494410 (assign 9 f)) (role ?v494410)) +(<= (next (sat 7)) (does ?v494431 (assign 20 t)) (role ?v494431)) +(<= (next (sat 7)) (does ?v494452 (assign 34 f)) (role ?v494452)) +(<= (next (sat 7)) (does ?v494473 (assign 29 t)) (role ?v494473)) +(<= (next (sat 7)) (does ?v494494 (assign 3 t)) (role ?v494494)) +(<= (next (sat 8)) (does ?v494517 (assign 56 f)) (role ?v494517)) +(<= (next (sat 8)) (does ?v494538 (assign 28 f)) (role ?v494538)) +(<= (next (sat 8)) (does ?v494559 (assign 17 t)) (role ?v494559)) +(<= (next (sat 8)) (does ?v494580 (assign 1 t)) (role ?v494580)) +(<= (next (sat 8)) (does ?v494601 (assign 51 f)) (role ?v494601)) +(<= (next (sat 9)) (does ?v494624 (assign 17 t)) (role ?v494624)) +(<= (next (sat 9)) (does ?v494645 (assign 49 f)) (role ?v494645)) +(<= (next (sat 9)) (does ?v494666 (assign 27 t)) (role ?v494666)) +(<= (next (sat 9)) (does ?v494687 (assign 24 f)) (role ?v494687)) +(<= (next (sat 9)) (does ?v494708 (assign 56 t)) (role ?v494708)) +(<= (next (sat 10)) (does ?v494731 (assign 47 f)) (role ?v494731)) +(<= (next (sat 10)) (does ?v494752 (assign 34 f)) (role ?v494752)) +(<= (next (sat 10)) (does ?v494773 (assign 26 f)) (role ?v494773)) +(<= (next (sat 10)) (does ?v494794 (assign 20 f)) (role ?v494794)) +(<= (next (sat 10)) (does ?v494815 (assign 39 t)) (role ?v494815)) +(<= (next (sat 11)) (does ?v494838 (assign 17 f)) (role ?v494838)) +(<= (next (sat 11)) (does ?v494859 (assign 20 f)) (role ?v494859)) +(<= (next (sat 11)) (does ?v494880 (assign 48 t)) (role ?v494880)) +(<= (next (sat 11)) (does ?v494901 (assign 10 f)) (role ?v494901)) +(<= (next (sat 11)) (does ?v494922 (assign 8 t)) (role ?v494922)) +(<= (next (sat 12)) (does ?v494945 (assign 24 f)) (role ?v494945)) +(<= (next (sat 12)) (does ?v494966 (assign 52 f)) (role ?v494966)) +(<= (next (sat 12)) (does ?v494987 (assign 13 t)) (role ?v494987)) +(<= (next (sat 12)) (does ?v495008 (assign 20 t)) (role ?v495008)) +(<= (next (sat 12)) (does ?v495029 (assign 26 f)) (role ?v495029)) +(<= (next (sat 13)) (does ?v495052 (assign 57 f)) (role ?v495052)) +(<= (next (sat 13)) (does ?v495073 (assign 30 t)) (role ?v495073)) +(<= (next (sat 13)) (does ?v495094 (assign 36 t)) (role ?v495094)) +(<= (next (sat 13)) (does ?v495115 (assign 46 f)) (role ?v495115)) +(<= (next (sat 13)) (does ?v495136 (assign 43 t)) (role ?v495136)) +(<= (next (sat 14)) (does ?v495159 (assign 1 t)) (role ?v495159)) +(<= (next (sat 14)) (does ?v495180 (assign 28 t)) (role ?v495180)) +(<= (next (sat 14)) (does ?v495201 (assign 21 f)) (role ?v495201)) +(<= (next (sat 14)) (does ?v495222 (assign 2 t)) (role ?v495222)) +(<= (next (sat 14)) (does ?v495243 (assign 23 f)) (role ?v495243)) +(<= (next (sat 15)) (does ?v495266 (assign 33 f)) (role ?v495266)) +(<= (next (sat 15)) (does ?v495287 (assign 30 f)) (role ?v495287)) +(<= (next (sat 15)) (does ?v495308 (assign 3 f)) (role ?v495308)) +(<= (next (sat 15)) (does ?v495329 (assign 41 t)) (role ?v495329)) +(<= (next (sat 15)) (does ?v495350 (assign 32 f)) (role ?v495350)) +(<= (next (sat 16)) (does ?v495373 (assign 52 t)) (role ?v495373)) +(<= (next (sat 16)) (does ?v495394 (assign 41 f)) (role ?v495394)) +(<= (next (sat 16)) (does ?v495415 (assign 49 t)) (role ?v495415)) +(<= (next (sat 16)) (does ?v495436 (assign 60 t)) (role ?v495436)) +(<= (next (sat 16)) (does ?v495457 (assign 34 t)) (role ?v495457)) +(<= (next (sat 17)) (does ?v495480 (assign 57 f)) (role ?v495480)) +(<= (next (sat 17)) (does ?v495501 (assign 28 t)) (role ?v495501)) +(<= (next (sat 17)) (does ?v495522 (assign 23 t)) (role ?v495522)) +(<= (next (sat 17)) (does ?v495543 (assign 50 f)) (role ?v495543)) +(<= (next (sat 17)) (does ?v495564 (assign 59 t)) (role ?v495564)) +(<= (next (sat 18)) (does ?v495587 (assign 41 t)) (role ?v495587)) +(<= (next (sat 18)) (does ?v495608 (assign 38 f)) (role ?v495608)) +(<= (next (sat 18)) (does ?v495629 (assign 5 t)) (role ?v495629)) +(<= (next (sat 18)) (does ?v495650 (assign 35 f)) (role ?v495650)) +(<= (next (sat 18)) (does ?v495671 (assign 11 t)) (role ?v495671)) +(<= (next (sat 19)) (does ?v495694 (assign 45 f)) (role ?v495694)) +(<= (next (sat 19)) (does ?v495715 (assign 53 t)) (role ?v495715)) +(<= (next (sat 19)) (does ?v495736 (assign 33 t)) (role ?v495736)) +(<= (next (sat 19)) (does ?v495757 (assign 52 t)) (role ?v495757)) +(<= (next (sat 19)) (does ?v495778 (assign 8 t)) (role ?v495778)) +(<= (next (sat 20)) (does ?v495801 (assign 19 f)) (role ?v495801)) +(<= (next (sat 20)) (does ?v495822 (assign 3 f)) (role ?v495822)) +(<= (next (sat 20)) (does ?v495843 (assign 49 f)) (role ?v495843)) +(<= (next (sat 20)) (does ?v495864 (assign 23 f)) (role ?v495864)) +(<= (next (sat 20)) (does ?v495885 (assign 40 t)) (role ?v495885)) +(<= (next (sat 21)) (does ?v495908 (assign 29 t)) (role ?v495908)) +(<= (next (sat 21)) (does ?v495929 (assign 9 f)) (role ?v495929)) +(<= (next (sat 21)) (does ?v495950 (assign 25 t)) (role ?v495950)) +(<= (next (sat 21)) (does ?v495971 (assign 45 t)) (role ?v495971)) +(<= (next (sat 21)) (does ?v495992 (assign 24 f)) (role ?v495992)) +(<= (next (sat 22)) (does ?v496015 (assign 33 f)) (role ?v496015)) +(<= (next (sat 22)) (does ?v496036 (assign 36 t)) (role ?v496036)) +(<= (next (sat 22)) (does ?v496057 (assign 51 f)) (role ?v496057)) +(<= (next (sat 22)) (does ?v496078 (assign 34 t)) (role ?v496078)) +(<= (next (sat 22)) (does ?v496099 (assign 46 t)) (role ?v496099)) +(<= (next (sat 23)) (does ?v496122 (assign 22 t)) (role ?v496122)) +(<= (next (sat 23)) (does ?v496143 (assign 55 t)) (role ?v496143)) +(<= (next (sat 23)) (does ?v496164 (assign 51 t)) (role ?v496164)) +(<= (next (sat 23)) (does ?v496185 (assign 20 f)) (role ?v496185)) +(<= (next (sat 23)) (does ?v496206 (assign 47 f)) (role ?v496206)) +(<= (next (sat 24)) (does ?v496229 (assign 6 f)) (role ?v496229)) +(<= (next (sat 24)) (does ?v496250 (assign 58 f)) (role ?v496250)) +(<= (next (sat 24)) (does ?v496271 (assign 26 f)) (role ?v496271)) +(<= (next (sat 24)) (does ?v496292 (assign 38 f)) (role ?v496292)) +(<= (next (sat 24)) (does ?v496313 (assign 31 f)) (role ?v496313)) +(<= (next (sat 25)) (does ?v496336 (assign 5 f)) (role ?v496336)) +(<= (next (sat 25)) (does ?v496357 (assign 29 t)) (role ?v496357)) +(<= (next (sat 25)) (does ?v496378 (assign 59 f)) (role ?v496378)) +(<= (next (sat 25)) (does ?v496399 (assign 53 t)) (role ?v496399)) +(<= (next (sat 25)) (does ?v496420 (assign 25 t)) (role ?v496420)) +(<= (next (sat 26)) (does ?v496443 (assign 19 f)) (role ?v496443)) +(<= (next (sat 26)) (does ?v496464 (assign 2 f)) (role ?v496464)) +(<= (next (sat 26)) (does ?v496485 (assign 42 t)) (role ?v496485)) +(<= (next (sat 26)) (does ?v496506 (assign 23 f)) (role ?v496506)) +(<= (next (sat 26)) (does ?v496527 (assign 22 f)) (role ?v496527)) +(<= (next (sat 27)) (does ?v496550 (assign 41 t)) (role ?v496550)) +(<= (next (sat 27)) (does ?v496571 (assign 29 f)) (role ?v496571)) +(<= (next (sat 27)) (does ?v496592 (assign 56 f)) (role ?v496592)) +(<= (next (sat 27)) (does ?v496613 (assign 11 t)) (role ?v496613)) +(<= (next (sat 27)) (does ?v496634 (assign 52 f)) (role ?v496634)) +(<= (next (sat 28)) (does ?v496657 (assign 41 f)) (role ?v496657)) +(<= (next (sat 28)) (does ?v496678 (assign 13 t)) (role ?v496678)) +(<= (next (sat 28)) (does ?v496699 (assign 51 f)) (role ?v496699)) +(<= (next (sat 28)) (does ?v496720 (assign 47 f)) (role ?v496720)) +(<= (next (sat 28)) (does ?v496741 (assign 14 f)) (role ?v496741)) +(<= (next (sat 29)) (does ?v496764 (assign 51 f)) (role ?v496764)) +(<= (next (sat 29)) (does ?v496785 (assign 24 f)) (role ?v496785)) +(<= (next (sat 29)) (does ?v496806 (assign 60 f)) (role ?v496806)) +(<= (next (sat 29)) (does ?v496827 (assign 53 f)) (role ?v496827)) +(<= (next (sat 29)) (does ?v496848 (assign 25 t)) (role ?v496848)) +(<= (next (sat 30)) (does ?v496871 (assign 16 f)) (role ?v496871)) +(<= (next (sat 30)) (does ?v496892 (assign 39 f)) (role ?v496892)) +(<= (next (sat 30)) (does ?v496913 (assign 49 f)) (role ?v496913)) +(<= (next (sat 30)) (does ?v496934 (assign 51 t)) (role ?v496934)) +(<= (next (sat 30)) (does ?v496955 (assign 40 f)) (role ?v496955)) +(<= (next (sat 31)) (does ?v496978 (assign 33 f)) (role ?v496978)) +(<= (next (sat 31)) (does ?v496999 (assign 15 t)) (role ?v496999)) +(<= (next (sat 31)) (does ?v497020 (assign 36 t)) (role ?v497020)) +(<= (next (sat 31)) (does ?v497041 (assign 44 t)) (role ?v497041)) +(<= (next (sat 31)) (does ?v497062 (assign 60 t)) (role ?v497062)) +(<= (next (sat 32)) (does ?v497085 (assign 60 f)) (role ?v497085)) +(<= (next (sat 32)) (does ?v497106 (assign 25 f)) (role ?v497106)) +(<= (next (sat 32)) (does ?v497127 (assign 57 t)) (role ?v497127)) +(<= (next (sat 32)) (does ?v497148 (assign 24 t)) (role ?v497148)) +(<= (next (sat 32)) (does ?v497169 (assign 14 t)) (role ?v497169)) +(<= (next (sat 33)) (does ?v497192 (assign 26 t)) (role ?v497192)) +(<= (next (sat 33)) (does ?v497213 (assign 49 f)) (role ?v497213)) +(<= (next (sat 33)) (does ?v497234 (assign 55 t)) (role ?v497234)) +(<= (next (sat 33)) (does ?v497255 (assign 52 t)) (role ?v497255)) +(<= (next (sat 33)) (does ?v497276 (assign 42 t)) (role ?v497276)) +(<= (next (sat 34)) (does ?v497299 (assign 36 t)) (role ?v497299)) +(<= (next (sat 34)) (does ?v497320 (assign 6 f)) (role ?v497320)) +(<= (next (sat 34)) (does ?v497341 (assign 51 t)) (role ?v497341)) +(<= (next (sat 34)) (does ?v497362 (assign 56 t)) (role ?v497362)) +(<= (next (sat 34)) (does ?v497383 (assign 24 t)) (role ?v497383)) +(<= (next (sat 35)) (does ?v497406 (assign 6 f)) (role ?v497406)) +(<= (next (sat 35)) (does ?v497427 (assign 31 t)) (role ?v497427)) +(<= (next (sat 35)) (does ?v497448 (assign 18 t)) (role ?v497448)) +(<= (next (sat 35)) (does ?v497469 (assign 36 f)) (role ?v497469)) +(<= (next (sat 35)) (does ?v497490 (assign 37 t)) (role ?v497490)) +(<= (next (sat 36)) (does ?v497513 (assign 33 t)) (role ?v497513)) +(<= (next (sat 36)) (does ?v497534 (assign 46 f)) (role ?v497534)) +(<= (next (sat 36)) (does ?v497555 (assign 5 t)) (role ?v497555)) +(<= (next (sat 36)) (does ?v497576 (assign 20 f)) (role ?v497576)) +(<= (next (sat 36)) (does ?v497597 (assign 22 f)) (role ?v497597)) +(<= (next (sat 37)) (does ?v497620 (assign 47 f)) (role ?v497620)) +(<= (next (sat 37)) (does ?v497641 (assign 27 t)) (role ?v497641)) +(<= (next (sat 37)) (does ?v497662 (assign 32 t)) (role ?v497662)) +(<= (next (sat 37)) (does ?v497683 (assign 14 f)) (role ?v497683)) +(<= (next (sat 37)) (does ?v497704 (assign 52 t)) (role ?v497704)) +(<= (next (sat 38)) (does ?v497727 (assign 53 t)) (role ?v497727)) +(<= (next (sat 38)) (does ?v497748 (assign 43 t)) (role ?v497748)) +(<= (next (sat 38)) (does ?v497769 (assign 58 f)) (role ?v497769)) +(<= (next (sat 38)) (does ?v497790 (assign 50 t)) (role ?v497790)) +(<= (next (sat 38)) (does ?v497811 (assign 42 f)) (role ?v497811)) +(<= (next (sat 39)) (does ?v497834 (assign 6 f)) (role ?v497834)) +(<= (next (sat 39)) (does ?v497855 (assign 13 t)) (role ?v497855)) +(<= (next (sat 39)) (does ?v497876 (assign 43 t)) (role ?v497876)) +(<= (next (sat 39)) (does ?v497897 (assign 31 t)) (role ?v497897)) +(<= (next (sat 39)) (does ?v497918 (assign 22 f)) (role ?v497918)) +(<= (next (sat 40)) (does ?v497941 (assign 38 t)) (role ?v497941)) +(<= (next (sat 40)) (does ?v497962 (assign 2 t)) (role ?v497962)) +(<= (next (sat 40)) (does ?v497983 (assign 16 t)) (role ?v497983)) +(<= (next (sat 40)) (does ?v498004 (assign 51 t)) (role ?v498004)) +(<= (next (sat 40)) (does ?v498025 (assign 26 f)) (role ?v498025)) +(<= all_sat (true (sat 1)) (true (sat 2)) (true (sat 3)) (true (sat 4)) (true (sat 5)) (true (sat 6)) (true (sat 7)) (true (sat 8)) (true (sat 9)) (true (sat 10)) (true (sat 11)) (true (sat 12)) (true (sat 13)) (true (sat 14)) (true (sat 15)) (true (sat 16)) (true (sat 17)) (true (sat 18)) (true (sat 19)) (true (sat 20)) (true (sat 21)) (true (sat 22)) (true (sat 23)) (true (sat 24)) (true (sat 25)) (true (sat 26)) (true (sat 27)) (true (sat 28)) (true (sat 29)) (true (sat 30)) (true (sat 31)) (true (sat 32)) (true (sat 33)) (true (sat 34)) (true (sat 35)) (true (sat 36)) (true (sat 37)) (true (sat 38)) (true (sat 39)) (true (sat 40))) +(<= terminal all_sat) +(<= terminal (true (control the end))) +(<= (goal exists 100) all_sat) +(<= (goal exists 0) (not all_sat)) +(<= (goal forall 100) (not all_sat)) +(<= (goal forall 0) all_sat) + + Added: trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.1.qdimacs.SAT.gdl =================================================================== --- trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.1.qdimacs.SAT.gdl (rev 0) +++ trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.1.qdimacs.SAT.gdl 2011-08-28 22:05:49 UTC (rev 1547) @@ -0,0 +1,578 @@ +(contains 1 (not 1)) +(contains 1 52) +(contains 1 16) +(contains 1 4) +(contains 1 (not 27)) +(contains 2 (not 27)) +(contains 2 (not 51)) +(contains 2 19) +(contains 2 1) +(contains 2 30) +(contains 3 35) +(contains 3 52) +(contains 3 (not 41)) +(contains 3 (not 18)) +(contains 3 (not 59)) +(contains 4 24) +(contains 4 30) +(contains 4 20) +(contains 4 (not 7)) +(contains 4 (not 23)) +(contains 5 (not 34)) +(contains 5 (not 4)) +(contains 5 13) +(contains 5 (not 49)) +(contains 5 (not 17)) +(contains 6 51) +(contains 6 (not 37)) +(contains 6 1) +(contains 6 5) +(contains 6 (not 29)) +(contains 7 (not 2)) +(contains 7 (not 7)) +(contains 7 (not 53)) +(contains 7 (not 12)) +(contains 7 (not 35)) +(contains 8 (not 39)) +(contains 8 (not 44)) +(contains 8 28) +(contains 8 (not 2)) +(contains 8 51) +(contains 9 (not 21)) +(contains 9 (not 11)) +(contains 9 8) +(contains 9 (not 20)) +(contains 9 2) +(contains 10 (not 37)) +(contains 10 (not 21)) +(contains 10 58) +(contains 10 (not 59)) +(contains 10 7) +(contains 11 33) +(contains 11 59) +(contains 11 (not 41)) +(contains 11 52) +(contains 11 21) +(contains 12 43) +(contains 12 35) +(contains 12 (not 7)) +(contains 12 33) +(contains 12 50) +(contains 13 29) +(contains 13 45) +(contains 13 (not 14)) +(contains 13 25) +(contains 13 24) +(contains 14 (not 21)) +(contains 14 54) +(contains 14 49) +(contains 14 2) +(contains 14 42) +(contains 15 (not 25)) +(contains 15 7) +(contains 15 (not 43)) +(contains 15 (not 39)) +(contains 15 59) +(contains 16 32) +(contains 16 (not 30)) +(contains 16 14) +(contains 16 17) +(contains 16 51) +(contains 17 (not 9)) +(contains 17 44) +(contains 17 (not 3)) +(contains 17 4) +(contains 17 (not 54)) +(contains 18 (not 46)) +(contains 18 48) +(contains 18 55) +(contains 18 (not 6)) +(contains 18 59) +(contains 19 51) +(contains 19 (not 12)) +(contains 19 1) +(contains 19 52) +(contains 19 58) +(contains 20 (not 8)) +(contains 20 47) +(contains 20 19) +(contains 20 (not 42)) +(contains 20 (not 12)) +(contains 21 (not 39)) +(contains 21 11) +(contains 21 1) +(contains 21 (not 41)) +(contains 21 (not 31)) +(contains 22 (not 26)) +(contains 22 34) +(contains 22 9) +(contains 22 (not 35)) +(contains 22 41) +(contains 23 54) +(contains 23 26) +(contains 23 (not 47)) +(contains 23 31) +(contains 23 (not 36)) +(contains 24 (not 15)) +(contains 24 (not 60)) +(contains 24 (not 13)) +(contains 24 6) +(contains 24 47) +(contains 25 (not 21)) +(contains 25 (not 10)) +(contains 25 26) +(contains 25 33) +(contains 25 15) +(contains 26 (not 20)) +(contains 26 11) +(contains 26 49) +(contains 26 12) +(contains 26 (not 41)) +(contains 27 (not 3)) +(contains 27 53) +(contains 27 15) +(contains 27 (not 23)) +(contains 27 58) +(contains 28 (not 3)) +(contains 28 (not 48)) +(contains 28 (not 21)) +(contains 28 59) +(contains 28 46) +(contains 29 28) +(contains 29 25) +(contains 29 (not 10)) +(contains 29 18) +(contains 29 4) +(contains 30 (not 55)) +(contains 30 7) +(contains 30 (not 44)) +(contains 30 22) +(contains 30 (not 32)) +(contains 31 (not 12)) +(contains 31 (not 35)) +(contains 31 (not 48)) +(contains 31 (not 14)) +(contains 31 (not 39)) +(contains 32 13) +(contains 32 (not 45)) +(contains 32 49) +(contains 32 (not 35)) +(contains 32 60) +(contains 33 (not 60)) +(contains 33 27) +(contains 33 (not 19)) +(contains 33 (not 25)) +(contains 33 29) +(contains 34 (not 12)) +(contains 34 43) +(contains 34 3) +(contains 34 (not 5)) +(contains 34 30) +(contains 35 (not 9)) +(contains 35 50) +(contains 35 (not 19)) +(contains 35 (not 59)) +(contains 35 (not 2)) +(contains 36 (not 20)) +(contains 36 14) +(contains 36 (not 58)) +(contains 36 (not 12)) +(contains 36 (not 34)) +(contains 37 22) +(contains 37 (not 16)) +(contains 37 (not 4)) +(contains 37 (not 14)) +(contains 37 52) +(contains 38 (not 45)) +(contains 38 (not 13)) +(contains 38 47) +(contains 38 (not 12)) +(contains 38 15) +(contains 39 (not 50)) +(contains 39 60) +(contains 39 9) +(contains 39 (not 4)) +(contains 39 18) +(contains 40 (not 10)) +(contains 40 (not 54)) +(contains 40 (not 15)) +(contains 40 47) +(contains 40 (not 22)) +(prop_var 1) +(prop_var 2) +(prop_var 3) +(prop_var 4) +(prop_var 5) +(prop_var 6) +(prop_var 7) +(prop_var 8) +(prop_var 9) +(prop_var 10) +(prop_var 11) +(prop_var 12) +(prop_var 13) +(prop_var 14) +(prop_var 15) +(prop_var 16) +(prop_var 17) +(prop_var 18) +(prop_var 19) +(prop_var 20) +(prop_var 21) +(prop_var 22) +(prop_var 23) +(prop_var 24) +(prop_var 25) +(prop_var 26) +(prop_var 27) +(prop_var 28) +(prop_var 29) +(prop_var 30) +(prop_var 31) +(prop_var 32) +(prop_var 33) +(prop_var 34) +(prop_var 35) +(prop_var 36) +(prop_var 37) +(prop_var 38) +(prop_var 39) +(prop_var 40) +(prop_var 41) +(prop_var 42) +(prop_var 43) +(prop_var 44) +(prop_var 45) +(prop_var 46) +(prop_var 47) +(prop_var 48) +(prop_var 49) +(prop_var 50) +(prop_var 51) +(prop_var 52) +(prop_var 53) +(prop_var 54) +(prop_var 55) +(prop_var 56) +(prop_var 57) +(prop_var 58) +(prop_var 59) +(prop_var 60) +(clause 1) +(clause 2) +(clause 3) +(clause 4) +(clause 5) +(clause 6) +(clause 7) +(clause 8) +(clause 9) +(clause 10) +(clause 11) +(clause 12) +(clause 13) +(clause 14) +(clause 15) +(clause 16) +(clause 17) +(clause 18) +(clause 19) +(clause 20) +(clause 21) +(clause 22) +(clause 23) +(clause 24) +(clause 25) +(clause 26) +(clause 27) +(clause 28) +(clause 29) +(clause 30) +(clause 31) +(clause 32) +(clause 33) +(clause 34) +(clause 35) +(clause 36) +(clause 37) +(clause 38) +(clause 39) +(clause 40) +(role exists) +(role forall) +(truth_value t) +(truth_value f) +(init (control exists 1)) +(<= (legal ?v5689 (assign ?v5699 ?v5700)) (true (control ?v5689 ?v5699)) (role ?v5689) (prop_var ?v5699) (truth_value ?v5700)) +(<= (legal exists noop) (true (control forall ?v5735)) (prop_var ?v5735)) +(<= (legal forall noop) (true (control exists ?v5735)) (prop_var ?v5735)) +(<= (next (sat ?v5759)) (true (sat ?v5759)) (clause ?v5759)) +(<= (next (control exists 2)) (true (control exists 1))) +(<= (next (control exists 3)) (true (control exists 2))) +(<= (next (control exists 4)) (true (control exists 3))) +(<= (next (control exists 5)) (true (control exists 4))) +(<= (next (control exists 6)) (true (control exists 5))) +(<= (next (control exists 7)) (true (control exists 6))) +(<= (next (control exists 8)) (true (control exists 7))) +(<= (next (control exists 9)) (true (control exists 8))) +(<= (next (control exists 10)) (true (control exists 9))) +(<= (next (control exists 11)) (true (control exists 10))) +(<= (next (control exists 12)) (true (control exists 11))) +(<= (next (control exists 13)) (true (control exists 12))) +(<= (next (control exists 14)) (true (control exists 13))) +(<= (next (control exists 15)) (true (control exists 14))) +(<= (next (control exists 16)) (true (control exists 15))) +(<= (next (control exists 17)) (true (control exists 16))) +(<= (next (control exists 18)) (true (control exists 17))) +(<= (next (control exists 19)) (true (control exists 18))) +(<= (next (control exists 20)) (true (control exists 19))) +(<= (next (control forall 21)) (true (control exists 20))) +(<= (next (control forall 22)) (true (control forall 21))) +(<= (next (control forall 23)) (true (control forall 22))) +(<= (next (control forall 24)) (true (control forall 23))) +(<= (next (control forall 25)) (true (control forall 24))) +(<= (next (control forall 26)) (true (control forall 25))) +(<= (next (control forall 27)) (true (control forall 26))) +(<= (next (control forall 28)) (true (control forall 27))) +(<= (next (control forall 29)) (true (control forall 28))) +(<= (next (control forall 30)) (true (control forall 29))) +(<= (next (control forall 31)) (true (control forall 30))) +(<= (next (control forall 32)) (true (control forall 31))) +(<= (next (control forall 33)) (true (control forall 32))) +(<= (next (control forall 34)) (true (control forall 33))) +(<= (next (control forall 35)) (true (control forall 34))) +(<= (next (control forall 36)) (true (control forall 35))) +(<= (next (control forall 37)) (true (control forall 36))) +(<= (next (control forall 38)) (true (control forall 37))) +(<= (next (control forall 39)) (true (control forall 38))) +(<= (next (control forall 40)) (true (control forall 39))) +(<= (next (control exists 41)) (true (control forall 40))) +(<= (next (control exists 42)) (true (control exists 41))) +(<= (next (control exists 43)) (true (control exists 42))) +(<= (next (control exists 44)) (true (control exists 43))) +(<= (next (control exists 45)) (true (control exists 44))) +(<= (next (control exists 46)) (true (control exists 45))) +(<= (next (control exists 47)) (true (control exists 46))) +(<= (next (control exists 48)) (true (control exists 47))) +(<= (next (control exists 49)) (true (control exists 48))) +(<= (next (control exists 50)) (true (control exists 49))) +(<= (next (control exists 51)) (true (control exists 50))) +(<= (next (control exists 52)) (true (control exists 51))) +(<= (next (control exists 53)) (true (control exists 52))) +(<= (next (control exists 54)) (true (control exists 53))) +(<= (next (control exists 55)) (true (control exists 54))) +(<= (next (control exists 56)) (true (control exists 55))) +(<= (next (control exists 57)) (true (control exists 56))) +(<= (next (control exists 58)) (true (control exists 57))) +(<= (next (control exists 59)) (true (control exists 58))) +(<= (next (control exists 60)) (true (control exists 59))) +(<= (next (control the end)) (true (control exists 60))) +(<= (next (sat 1)) (does ?v9608 (assign 1 f)) (role ?v9608)) +(<= (next (sat 1)) (does ?v9629 (assign 52 t)) (role ?v9629)) +(<= (next (sat 1)) (does ?v9650 (assign 16 t)) (role ?v9650)) +(<= (next (sat 1)) (does ?v9671 (assign 4 t)) (role ?v9671)) +(<= (next (sat 1)) (does ?v9692 (assign 27 f)) (role ?v9692)) +(<= (next (sat 2)) (does ?v9715 (assign 27 f)) (role ?v9715)) +(<= (next (sat 2)) (does ?v9736 (assign 51 f)) (role ?v9736)) +(<= (next (sat 2)) (does ?v9757 (assign 19 t)) (role ?v9757)) +(<= (next (sat 2)) (does ?v9778 (assign 1 t)) (role ?v9778)) +(<= (next (sat 2)) (does ?v9799 (assign 30 t)) (role ?v9799)) +(<= (next (sat 3)) (does ?v9822 (assign 35 t)) (role ?v9822)) +(<= (next (sat 3)) (does ?v9843 (assign 52 t)) (role ?v9843)) +(<= (next (sat 3)) (does ?v9864 (assign 41 f)) (role ?v9864)) +(<= (next (sat 3)) (does ?v9885 (assign 18 f)) (role ?v9885)) +(<= (next (sat 3)) (does ?v9906 (assign 59 f)) (role ?v9906)) +(<= (next (sat 4)) (does ?v9929 (assign 24 t)) (role ?v9929)) +(<= (next (sat 4)) (does ?v9950 (assign 30 t)) (role ?v9950)) +(<= (next (sat 4)) (does ?v9971 (assign 20 t)) (role ?v9971)) +(<= (next (sat 4)) (does ?v9992 (assign 7 f)) (role ?v9992)) +(<= (next (sat 4)) (does ?v10013 (assign 23 f)) (role ?v10013)) +(<= (next (sat 5)) (does ?v10036 (assign 34 f)) (role ?v10036)) +(<= (next (sat 5)) (does ?v10057 (assign 4 f)) (role ?v10057)) +(<= (next (sat 5)) (does ?v10078 (assign 13 t)) (role ?v10078)) +(<= (next (sat 5)) (does ?v10099 (assign 49 f)) (role ?v10099)) +(<= (next (sat 5)) (does ?v10120 (assign 17 f)) (role ?v10120)) +(<= (next (sat 6)) (does ?v10143 (assign 51 t)) (role ?v10143)) +(<= (next (sat 6)) (does ?v10164 (assign 37 f)) (role ?v10164)) +(<= (next (sat 6)) (does ?v10185 (assign 1 t)) (role ?v10185)) +(<= (next (sat 6)) (does ?v10206 (assign 5 t)) (role ?v10206)) +(<= (next (sat 6)) (does ?v10227 (assign 29 f)) (role ?v10227)) +(<= (next (sat 7)) (does ?v10250 (assign 2 f)) (role ?v10250)) +(<= (next (sat 7)) (does ?v10271 (assign 7 f)) (role ?v10271)) +(<= (next (sat 7)) (does ?v10292 (assign 53 f)) (role ?v10292)) +(<= (next (sat 7)) (does ?v10313 (assign 12 f)) (role ?v10313)) +(<= (next (sat 7)) (does ?v10334 (assign 35 f)) (role ?v10334)) +(<= (next (sat 8)) (does ?v10357 (assign 39 f)) (role ?v10357)) +(<= (next (sat 8)) (does ?v10378 (assign 44 f)) (role ?v10378)) +(<= (next (sat 8)) (does ?v10399 (assign 28 t)) (role ?v10399)) +(<= (next (sat 8)) (does ?v10420 (assign 2 f)) (role ?v10420)) +(<= (next (sat 8)) (does ?v10441 (assign 51 t)) (role ?v10441)) +(<= (next (sat 9)) (does ?v10464 (assign 21 f)) (role ?v10464)) +(<= (next (sat 9)) (does ?v10485 (assign 11 f)) (role ?v10485)) +(<= (next (sat 9)) (does ?v10506 (assign 8 t)) (role ?v10506)) +(<= (next (sat 9)) (does ?v10527 (assign 20 f)) (role ?v10527)) +(<= (next (sat 9)) (does ?v10548 (assign 2 t)) (role ?v10548)) +(<= (next (sat 10)) (does ?v10571 (assign 37 f)) (role ?v10571)) +(<= (next (sat 10)) (does ?v10592 (assign 21 f)) (role ?v10592)) +(<= (next (sat 10)) (does ?v10613 (assign 58 t)) (role ?v10613)) +(<= (next (sat 10)) (does ?v10634 (assign 59 f)) (role ?v10634)) +(<= (next (sat 10)) (does ?v10655 (assign 7 t)) (role ?v10655)) +(<= (next (sat 11)) (does ?v10678 (assign 33 t)) (role ?v10678)) +(<= (next (sat 11)) (does ?v10699 (assign 59 t)) (role ?v10699)) +(<= (next (sat 11)) (does ?v10720 (assign 41 f)) (role ?v10720)) +(<= (next (sat 11)) (does ?v10741 (assign 52 t)) (role ?v10741)) +(<= (next (sat 11)) (does ?v10762 (assign 21 t)) (role ?v10762)) +(<= (next (sat 12)) (does ?v10785 (assign 43 t)) (role ?v10785)) +(<= (next (sat 12)) (does ?v10806 (assign 35 t)) (role ?v10806)) +(<= (next (sat 12)) (does ?v10827 (assign 7 f)) (role ?v10827)) +(<= (next (sat 12)) (does ?v10848 (assign 33 t)) (role ?v10848)) +(<= (next (sat 12)) (does ?v10869 (assign 50 t)) (role ?v10869)) +(<= (next (sat 13)) (does ?v10892 (assign 29 t)) (role ?v10892)) +(<= (next (sat 13)) (does ?v10913 (assign 45 t)) (role ?v10913)) +(<= (next (sat 13)) (does ?v10934 (assign 14 f)) (role ?v10934)) +(<= (next (sat 13)) (does ?v10955 (assign 25 t)) (role ?v10955)) +(<= (next (sat 13)) (does ?v10976 (assign 24 t)) (role ?v10976)) +(<= (next (sat 14)) (does ?v10999 (assign 21 f)) (role ?v10999)) +(<= (next (sat 14)) (does ?v11020 (assign 54 t)) (role ?v11020)) +(<= (next (sat 14)) (does ?v11041 (assign 49 t)) (role ?v11041)) +(<= (next (sat 14)) (does ?v11062 (assign 2 t)) (role ?v11062)) +(<= (next (sat 14)) (does ?v11083 (assign 42 t)) (role ?v11083)) +(<= (next (sat 15)) (does ?v11106 (assign 25 f)) (role ?v11106)) +(<= (next (sat 15)) (does ?v11127 (assign 7 t)) (role ?v11127)) +(<= (next (sat 15)) (does ?v11148 (assign 43 f)) (role ?v11148)) +(<= (next (sat 15)) (does ?v11169 (assign 39 f)) (role ?v11169)) +(<= (next (sat 15)) (does ?v11190 (assign 59 t)) (role ?v11190)) +(<= (next (sat 16)) (does ?v11213 (assign 32 t)) (role ?v11213)) +(<= (next (sat 16)) (does ?v11234 (assign 30 f)) (role ?v11234)) +(<= (next (sat 16)) (does ?v11255 (assign 14 t)) (role ?v11255)) +(<= (next (sat 16)) (does ?v11276 (assign 17 t)) (role ?v11276)) +(<= (next (sat 16)) (does ?v11297 (assign 51 t)) (role ?v11297)) +(<= (next (sat 17)) (does ?v11320 (assign 9 f)) (role ?v11320)) +(<= (next (sat 17)) (does ?v11341 (assign 44 t)) (role ?v11341)) +(<= (next (sat 17)) (does ?v11362 (assign 3 f)) (role ?v11362)) +(<= (next (sat 17)) (does ?v11383 (assign 4 t)) (role ?v11383)) +(<= (next (sat 17)) (does ?v11404 (assign 54 f)) (role ?v11404)) +(<= (next (sat 18)) (does ?v11427 (assign 46 f)) (role ?v11427)) +(<= (next (sat 18)) (does ?v11448 (assign 48 t)) (role ?v11448)) +(<= (next (sat 18)) (does ?v11469 (assign 55 t)) (role ?v11469)) +(<= (next (sat 18)) (does ?v11490 (assign 6 f)) (role ?v11490)) +(<= (next (sat 18)) (does ?v11511 (assign 59 t)) (role ?v11511)) +(<= (next (sat 19)) (does ?v11534 (assign 51 t)) (role ?v11534)) +(<= (next (sat 19)) (does ?v11555 (assign 12 f)) (role ?v11555)) +(<= (next (sat 19)) (does ?v11576 (assign 1 t)) (role ?v11576)) +(<= (next (sat 19)) (does ?v11597 (assign 52 t)) (role ?v11597)) +(<= (next (sat 19)) (does ?v11618 (assign 58 t)) (role ?v11618)) +(<= (next (sat 20)) (does ?v11641 (assign 8 f)) (role ?v11641)) +(<= (next (sat 20)) (does ?v11662 (assign 47 t)) (role ?v11662)) +(<= (next (sat 20)) (does ?v11683 (assign 19 t)) (role ?v11683)) +(<= (next (sat 20)) (does ?v11704 (assign 42 f)) (role ?v11704)) +(<= (next (sat 20)) (does ?v11725 (assign 12 f)) (role ?v11725)) +(<= (next (sat 21)) (does ?v11748 (assign 39 f)) (role ?v11748)) +(<= (next (sat 21)) (does ?v11769 (assign 11 t)) (role ?v11769)) +(<= (next (sat 21)) (does ?v11790 (assign 1 t)) (role ?v11790)) +(<= (next (sat 21)) (does ?v11811 (assign 41 f)) (role ?v11811)) +(<= (next (sat 21)) (does ?v11832 (assign 31 f)) (role ?v11832)) +(<= (next (sat 22)) (does ?v11855 (assign 26 f)) (role ?v11855)) +(<= (next (sat 22)) (does ?v11876 (assign 34 t)) (role ?v11876)) +(<= (next (sat 22)) (does ?v11897 (assign 9 t)) (role ?v11897)) +(<= (next (sat 22)) (does ?v11918 (assign 35 f)) (role ?v11918)) +(<= (next (sat 22)) (does ?v11939 (assign 41 t)) (role ?v11939)) +(<= (next (sat 23)) (does ?v11962 (assign 54 t)) (role ?v11962)) +(<= (next (sat 23)) (does ?v11983 (assign 26 t)) (role ?v11983)) +(<= (next (sat 23)) (does ?v12004 (assign 47 f)) (role ?v12004)) +(<= (next (sat 23)) (does ?v12025 (assign 31 t)) (role ?v12025)) +(<= (next (sat 23)) (does ?v12046 (assign 36 f)) (role ?v12046)) +(<= (next (sat 24)) (does ?v12069 (assign 15 f)) (role ?v12069)) +(<= (next (sat 24)) (does ?v12090 (assign 60 f)) (role ?v12090)) +(<= (next (sat 24)) (does ?v12111 (assign 13 f)) (role ?v12111)) +(<= (next (sat 24)) (does ?v12132 (assign 6 t)) (role ?v12132)) +(<= (next (sat 24)) (does ?v12153 (assign 47 t)) (role ?v12153)) +(<= (next (sat 25)) (does ?v12176 (assign 21 f)) (role ?v12176)) +(<= (next (sat 25)) (does ?v12197 (assign 10 f)) (role ?v12197)) +(<= (next (sat 25)) (does ?v12218 (assign 26 t)) (role ?v12218)) +(<= (next (sat 25)) (does ?v12239 (assign 33 t)) (role ?v12239)) +(<= (next (sat 25)) (does ?v12260 (assign 15 t)) (role ?v12260)) +(<= (next (sat 26)) (does ?v12283 (assign 20 f)) (role ?v12283)) +(<= (next (sat 26)) (does ?v12304 (assign 11 t)) (role ?v12304)) +(<= (next (sat 26)) (does ?v12325 (assign 49 t)) (role ?v12325)) +(<= (next (sat 26)) (does ?v12346 (assign 12 t)) (role ?v12346)) +(<= (next (sat 26)) (does ?v12367 (assign 41 f)) (role ?v12367)) +(<= (next (sat 27)) (does ?v12390 (assign 3 f)) (role ?v12390)) +(<= (next (sat 27)) (does ?v12411 (assign 53 t)) (role ?v12411)) +(<= (next (sat 27)) (does ?v12432 (assign 15 t)) (role ?v12432)) +(<= (next (sat 27)) (does ?v12453 (assign 23 f)) (role ?v12453)) +(<= (next (sat 27)) (does ?v12474 (assign 58 t)) (role ?v12474)) +(<= (next (sat 28)) (does ?v12497 (assign 3 f)) (role ?v12497)) +(<= (next (sat 28)) (does ?v12518 (assign 48 f)) (role ?v12518)) +(<= (next (sat 28)) (does ?v12539 (assign 21 f)) (role ?v12539)) +(<= (next (sat 28)) (does ?v12560 (assign 59 t)) (role ?v12560)) +(<= (next (sat 28)) (does ?v12581 (assign 46 t)) (role ?v12581)) +(<= (next (sat 29)) (does ?v12604 (assign 28 t)) (role ?v12604)) +(<= (next (sat 29)) (does ?v12625 (assign 25 t)) (role ?v12625)) +(<= (next (sat 29)) (does ?v12646 (assign 10 f)) (role ?v12646)) +(<= (next (sat 29)) (does ?v12667 (assign 18 t)) (role ?v12667)) +(<= (next (sat 29)) (does ?v12688 (assign 4 t)) (role ?v12688)) +(<= (next (sat 30)) (does ?v12711 (assign 55 f)) (role ?v12711)) +(<= (next (sat 30)) (does ?v12732 (assign 7 t)) (role ?v12732)) +(<= (next (sat 30)) (does ?v12753 (assign 44 f)) (role ?v12753)) +(<= (next (sat 30)) (does ?v12774 (assign 22 t)) (role ?v12774)) +(<= (next (sat 30)) (does ?v12795 (assign 32 f)) (role ?v12795)) +(<= (next (sat 31)) (does ?v12818 (assign 12 f)) (role ?v12818)) +(<= (next (sat 31)) (does ?v12839 (assign 35 f)) (role ?v12839)) +(<= (next (sat 31)) (does ?v12860 (assign 48 f)) (role ?v12860)) +(<= (next (sat 31)) (does ?v12881 (assign 14 f)) (role ?v12881)) +(<= (next (sat 31)) (does ?v12902 (assign 39 f)) (role ?v12902)) +(<= (next (sat 32)) (does ?v12925 (assign 13 t)) (role ?v12925)) +(<= (next (sat 32)) (does ?v12946 (assign 45 f)) (role ?v12946)) +(<= (next (sat 32)) (does ?v12967 (assign 49 t)) (role ?v12967)) +(<= (next (sat 32)) (does ?v12988 (assign 35 f)) (role ?v12988)) +(<= (next (sat 32)) (does ?v13009 (assign 60 t)) (role ?v13009)) +(<= (next (sat 33)) (does ?v13032 (assign 60 f)) (role ?v13032)) +(<= (next (sat 33)) (does ?v13053 (assign 27 t)) (role ?v13053)) +(<= (next (sat 33)) (does ?v13074 (assign 19 f)) (role ?v13074)) +(<= (next (sat 33)) (does ?v13095 (assign 25 f)) (role ?v13095)) +(<= (next (sat 33)) (does ?v13116 (assign 29 t)) (role ?v13116)) +(<= (next (sat 34)) (does ?v13139 (assign 12 f)) (role ?v13139)) +(<= (next (sat 34)) (does ?v13160 (assign 43 t)) (role ?v13160)) +(<= (next (sat 34)) (does ?v13181 (assign 3 t)) (role ?v13181)) +(<= (next (sat 34)) (does ?v13202 (assign 5 f)) (role ?v13202)) +(<= (next (sat 34)) (does ?v13223 (assign 30 t)) (role ?v13223)) +(<= (next (sat 35)) (does ?v13246 (assign 9 f)) (role ?v13246)) +(<= (next (sat 35)) (does ?v13267 (assign 50 t)) (role ?v13267)) +(<= (next (sat 35)) (does ?v13288 (assign 19 f)) (role ?v13288)) +(<= (next (sat 35)) (does ?v13309 (assign 59 f)) (role ?v13309)) +(<= (next (sat 35)) (does ?v13330 (assign 2 f)) (role ?v13330)) +(<= (next (sat 36)) (does ?v13353 (assign 20 f)) (role ?v13353)) +(<= (next (sat 36)) (does ?v13374 (assign 14 t)) (role ?v13374)) +(<= (next (sat 36)) (does ?v13395 (assign 58 f)) (role ?v13395)) +(<= (next (sat 36)) (does ?v13416 (assign 12 f)) (role ?v13416)) +(<= (next (sat 36)) (does ?v13437 (assign 34 f)) (role ?v13437)) +(<= (next (sat 37)) (does ?v13460 (assign 22 t)) (role ?v13460)) +(<= (next (sat 37)) (does ?v13481 (assign 16 f)) (role ?v13481)) +(<= (next (sat 37)) (does ?v13502 (assign 4 f)) (role ?v13502)) +(<= (next (sat 37)) (does ?v13523 (assign 14 f)) (role ?v13523)) +(<= (next (sat 37)) (does ?v13544 (assign 52 t)) (role ?v13544)) +(<= (next (sat 38)) (does ?v13567 (assign 45 f)) (role ?v13567)) +(<= (next (sat 38)) (does ?v13588 (assign 13 f)) (role ?v13588)) +(<= (next (sat 38)) (does ?v13609 (assign 47 t)) (role ?v13609)) +(<= (next (sat 38)) (does ?v13630 (assign 12 f)) (role ?v13630)) +(<= (next (sat 38)) (does ?v13651 (assign 15 t)) (role ?v13651)) +(<= (next (sat 39)) (does ?v13674 (assign 50 f)) (role ?v13674)) +(<= (next (sat 39)) (does ?v13695 (assign 60 t)) (role ?v13695)) +(<= (next (sat 39)) (does ?v13716 (assign 9 t)) (role ?v13716)) +(<= (next (sat 39)) (does ?v13737 (assign 4 f)) (role ?v13737)) +(<= (next (sat 39)) (does ?v13758 (assign 18 t)) (role ?v13758)) +(<= (next (sat 40)) (does ?v13781 (assign 10 f)) (role ?v13781)) +(<= (next (sat 40)) (does ?v13802 (assign 54 f)) (role ?v13802)) +(<= (next (sat 40)) (does ?v13823 (assign 15 f)) (role ?v13823)) +(<= (next (sat 40)) (does ?v13844 (assign 47 t)) (role ?v13844)) +(<= (next (sat 40)) (does ?v13865 (assign 22 f)) (role ?v13865)) +(<= all_sat (true (sat 1)) (true (sat 2)) (true (sat 3)) (true (sat 4)) (true (sat 5)) (true (sat 6)) (true (sat 7)) (true (sat 8)) (true (sat 9)) (true (sat 10)) (true (sat 11)) (true (sat 12)) (true (sat 13)) (true (sat 14)) (true (sat 15)) (true (sat 16)) (true (sat 17)) (true (sat 18)) (true (sat 19)) (true (sat 20)) (true (sat 21)) (true (sat 22)) (true (sat 23)) (true (sat 24)) (true (sat 25)) (true (sat 26)) (true (sat 27)) (true (sat 28)) (true (sat 29)) (true (sat 30)) (true (sat 31)) (true (sat 32)) (true (sat 33)) (true (sat 34)) (true (sat 35)) (true (sat 36)) (true (sat 37)) (true (sat 38)) (true (sat 39)) (true (sat 40))) +(<= terminal all_sat) +(<= terminal (true (control the end))) +(<= (goal exists 100) all_sat) +(<= (goal exists 0) (not all_sat)) +(<= (goal forall 100) (not all_sat)) +(<= (goal forall 0) all_sat) + + Added: trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.1.qdimacs.viz.SAT.gdl =================================================================== --- trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.1.qdimacs.viz.SAT.gdl (rev 0) +++ trunk/Toss/GGP/examples/3qbf-5cnf-20var-40cl.1.qdimacs.viz.SAT.gdl 2011-08-28 22:05:49 UTC (rev 1547) @@ -0,0 +1,578 @@ +(contains 1 (not 1)) +(contains 1 52) +(contains 1 16) +(contains 1 4) +(contains 1 (not 27)) +(contains 2 (not 27)) +(contains 2 (not 51)) +(contains 2 19) +(contains 2 1) +(contains 2 30) +(contains 3 35) +(contains 3 52) +(contains 3 (not 41)) +(contains 3 (not 18)) +(contains 3 (not 59)) +(contains 4 24) +(contains 4 30) +(contains 4 20) +(contains 4 (not 7)) +(contains 4 (not 23)) +(contains 5 (not 34)) +(contains 5 (not 4)) +(contains 5 13) +(contains 5 (not 49)) +(contains 5 (not 17)) +(contains 6 51) +(contains 6 (not 37)) +(contains 6 1) +(contains 6 5) +(contains 6 (not 29)) +(contains 7 (not 2)) +(contains 7 (not 7)) +(contains 7 (not 53)) +(contains 7 (not 12)) +(contains 7 (not 35)) +(contains 8 (not 39)) +(contains 8 (not 44)) +(contains 8 28) +(contains 8 (not 2)) +(contains 8 51) +(contains 9 (not 21)) +(contains 9 (not 11)) +(contains 9 8) +(contains 9 (not 20)) +(contains 9 2) +(contains 10 (not 37)) +(contains 10 (not 21)) +(contains 10 58) +(contains 10 (not 59)) +(contains 10 7) +(contains 11 33) +(contains 11 59) +(contains 11 (not 41)) +(contains 11 52) +(contains 11 21) +(contains 12 43) +(contains 12 35) +(contains 12 (not 7)) +(contains 12 33) +(contains 12 50) +(contains 13 29) +(contains 13 45) +(contains 13 (not 14)) +(contains 13 25) +(contains 13 24) +(contains 14 (not 21)) +(contains 14 54) +(contains 14 49) +(contains 14 2) +(contains 14 42) +(contains 15 (not 25)) +(contains 15 7) +(contains 15 (not 43)) +(contains 15 (not 39)) +(contains 15 59) +(contains 16 32) +(contains 16 (not 30)) +(contains 16 14) +(contains 16 17) +(contains 16 51) +(contains 17 (not 9)) +(contains 17 44) +(contains 17 (not 3)) +(contains 17 4) +(contains 17 (not 54)) +(contains 18 (not 46)) +(contains 18 48) +(contains 18 55) +(contains 18 (not 6)) +(contains 18 59) +(contains 19 51) +(contains 19 (not 12)) +(contains 19 1) +(contains 19 52) +(contains 19 58) +(contains 20 (not 8)) +(contains 20 47) +(contains 20 19) +(contains 20 (not 42)) +(contains 20 (not 12)) +(contains 21 (not 39)) +(contains 21 11) +(contains 21 1) +(contains 21 (not 41)) +(contains 21 (not 31)) +(contains 22 (not 26)) +(contains 22 34) +(contains 22 9) +(contains 22 (not 35)) +(contains 22 41) +(contains 23 54) +(contains 23 26) +(contains 23 (not 47)) +(contains 23 31) +(contains 23 (not 36)) +(contains 24 (not 15)) +(contains 24 (not 60)) +(contains 24 (not 13)) +(contains 24 6) +(contains 24 47) +(contains 25 (not 21)) +(contains 25 (not 10)) +(contains 25 26) +(contains 25 33) +(contains 25 15) +(contains 26 (not 20)) +(contains 26 11) +(contains 26 49) +(contains 26 12) +(contains 26 (not 41)) +(contains 27 (not 3)) +(contains 27 53) +(contains 27 15) +(contains 27 (not 23)) +(contains 27 58) +(contains 28 (not 3)) +(contains 28 (not 48)) +(contains 28 (not 21)) +(contains 28 59) +(contains 28 46) +(contains 29 28) +(contains 29 25) +(contains 29 (not 10)) +(contains 29 18) +(contains 29 4) +(contains 30 (not 55)) +(contains 30 7) +(contains 30 (not 44)) +(contains 30 22) +(contains 30 (not 32)) +(contains 31 (not 12)) +(contains 31 (not 35)) +(contains 31 (not 48)) +(con... [truncated message content] |
From: <luk...@us...> - 2011-08-28 21:08:40
|
Revision: 1546 http://toss.svn.sourceforge.net/toss/?rev=1546&view=rev Author: lukstafi Date: 2011-08-28 21:08:34 +0000 (Sun, 28 Aug 2011) Log Message: ----------- GDL translation: translate definition from command-line provided file; semantic definition of fluent paths and frame clauses, approximated on random playout states, refining the syntactic definition whenever sensible. Modified Paths: -------------- trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGame.mli trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-08-27 09:44:45 UTC (rev 1545) +++ trunk/Toss/Formula/Aux.ml 2011-08-28 21:08:34 UTC (rev 1546) @@ -288,11 +288,12 @@ aux [] l -let maximal cmp l = +let maximal leq l = + let less x y = leq x y && not (leq y x) in let rec aux acc = function | hd::tl when - not (List.exists (fun x-> cmp hd x) acc) && - not (List.exists (fun x-> cmp hd x) tl) -> + not (List.exists (fun x-> less hd x) acc) && + not (List.exists (fun x-> less hd x) tl) -> aux (hd::acc) tl | hd::tl -> aux acc tl | [] -> acc in Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-08-27 09:44:45 UTC (rev 1545) +++ trunk/Toss/Formula/Aux.mli 2011-08-28 21:08:34 UTC (rev 1546) @@ -176,9 +176,8 @@ (** Find an element satisfying the predicate and separate it from the list. *) val pop_find : ('a -> bool) -> 'a list -> 'a * 'a list -(** Return the list of maximal elements, under the given less-or-equal - comparison (the input does not need to be sorted). (Currently, of - equal elements only the last one is preserved.) *) +(** Return the list of all maximal elements, under the given less-or-equal + comparison. (Maximal elements can be equivalent or incomparable.) *) val maximal : ('a -> 'a -> bool) -> 'a list -> 'a list (** Assuming that [l2] already has only maximal elements, Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-27 09:44:45 UTC (rev 1545) +++ trunk/Toss/GGP/GDL.ml 2011-08-28 21:08:34 UTC (rev 1546) @@ -1445,6 +1445,29 @@ in aux (p, ps) +let paths_intersect ps1 ps2 = + let rec aux = function + | Empty, p | p, Empty -> Empty + | Here, Here + | Here, Here_and_below _ + | Here_and_below _, Here -> Here + | Here, Below _ | Below _, Here -> Empty + | Below ps1, Here_and_below ps2 + | Here_and_below ps2, Below ps1 + | Below ps1, Below ps2 -> Below (join (ps1, ps2)) + | Here_and_below ps1, Here_and_below ps2 + -> Here_and_below (join (ps1, ps2)) + and join = function + | [], _ | _, [] -> [] + | ((rel1, args1)::ps1), ((rel2, args2)::ps2) when rel1 = rel2 -> + let args = Aux.array_map2 (fun x y->aux (x,y)) args1 args2 in + (rel1, args)::join (ps1, ps2) + | ((rel1, _)::ps1), ((rel2, _)::_ as ps2) when rel1 < rel2 -> + join (ps1, ps2) + | ((rel1, _)::_ as ps1), ((rel2, _)::ps2) -> + join (ps1, ps2) in + aux (ps1, ps2) + (** Find a path in a term and substitute, raise [Not_found] if path not present. [subst_at_path p s t] is $t[p \ot s]$. *) let subst_at_path p s t = Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-27 09:44:45 UTC (rev 1545) +++ trunk/Toss/GGP/GDL.mli 2011-08-28 21:08:34 UTC (rev 1546) @@ -235,6 +235,7 @@ (** Add path to a set. First argument gives term arities. *) val add_path : (string -> int) -> path -> path_set -> path_set val paths_union : path_set -> path_set -> path_set +val paths_intersect : path_set -> path_set -> path_set (** List the paths in a set. *) val paths_to_list : path_set -> path list Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-27 09:44:45 UTC (rev 1545) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-28 21:08:34 UTC (rev 1546) @@ -26,13 +26,6 @@ let debug_level = ref 0 let generate_test_case = ref None -(** Treat "next" clauses which introduce a fluent position for a - variable-variable mismatch, as non-erasing frame clauses (to be - ignored). ("Wave" refers to the process of "propagating the frame - condition" that these clauses are assumed to do, if - [nonerasing_frame_wave] is set to [true].) *) -let nonerasing_frame_wave = ref true - (** two heuristics for selecting defined relations: select relations with arity smaller than three; or, select relations that have ground defining clauses (i.e. defining clauses with empty bodies). *) @@ -119,36 +112,99 @@ the set of paths that merges the found term and [c]; as in the definition of $s_\calC$ and $t_\calC$ for a clause $\calC \in \mathrm{Next}_{e}$. Among the most similar terms finds one that is - not a "frame wave", if not possible and if {!nonerasing_frame_wave} - is [true] -- raises [Not_found]. *) + not a "wave", if possible; returns the list of best candidates. *) let most_similar c ts = let gens = List.map (fun t -> t, merge_terms c t) ts in (* worse-or-equal as "leq" *) let cmp (_, (_, pn1, siz1)) (_, (_, pn2, siz2)) = - not (siz1 > siz2) && pn2 >= pn1 in + siz1 < siz2 || siz1 = siz2 && pn1 >= pn2 in let best = Aux.maximal cmp gens in - (* avoid "frame wave" if possible *) - (* FIXME: TODO: handle frame waves as in updated reference spec *) - let t, (ps, _, _) = - if !nonerasing_frame_wave - then - List.find (fun (t, (ps, _, _)) -> - c = t || - List.for_all - (fun fluent -> Aux.Strings.is_empty (term_vars fluent)) - (at_paths ps t)) best - else List.hd best in - t, ps + (* avoid "wave" if possible *) + let nonwave_best, wave_best = Aux.partition_map + (fun (t, (ps, _, _)) -> + if List.for_all + (fun fluent -> Aux.Strings.is_empty (term_vars fluent)) + (at_paths ps t) + then Aux.Left (ps, t) + else Aux.Right (ps, t)) + best in + if nonwave_best = [] then true, wave_best + else false, nonwave_best - +(* Find semantically the fluent paths of a clause -- works only for + clauses that are not "negative true". Find paths that merge with + nearest terms in prior state, better are paths that have less of + different subterms (at them) among prior state terms. Return fluent + paths, an empty path set if the clause is a frame clause. Return + [None] when the clause does not generate any state terms for any + provided playout state. *) +let semantic_fluent_paths program playout_states cl = + let head, body = match cl with + | ("next", [|head|]), body -> head, body + | _ -> assert false in + let old_run_aggregate = !run_prolog_aggregate in + run_prolog_aggregate := true; + let state_fpaths state = + let new_sterms = + run_prolog_goal body + (replace_rel_in_program "true" (state_cls state) program) in + if new_sterms = [] + then None + else + let new_sterms = List.map (fun sb->subst sb head) new_sterms in + let term_paths s = + if List.mem s state then empty_path_set + else + let _, best = most_similar s state in + let best = List.map + (fun (ps,_) -> ps, + List.length (Aux.unique_sorted + (Aux.concat_map (at_paths ps) state))) + best in + let ps, _ = List.hd + (List.sort (fun (_,nts1) (_,nts2) -> nts1 - nts2) best) in + (* {{{ log entry *) + if !debug_level > 4 then ( + Printf.printf "semantic_fluent_paths: for %s paths = %s\n%!" + (term_str s) + (String.concat ", " (List.map path_str (paths_to_list ps))); + if List.length (paths_to_list ps) > 1 then + Printf.printf "state: %s\n\n%!" + (String.concat ", " (List.map term_str state)) + ); + (* }}} *) + ps in + Some (List.fold_left paths_union empty_path_set + (List.map term_paths new_sterms)) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "semantic_fluent_paths: computing for body=%s...\n%!" + (String.concat " " (List.map literal_str body)) + ); + (* }}} *) + let fpaths_if_matched = Aux.map_some state_fpaths playout_states in + if fpaths_if_matched = [] then None + else + let res = + List.fold_left paths_union empty_path_set + fpaths_if_matched in + run_prolog_aggregate := old_run_aggregate; + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "semantic_fluent_paths: f_paths=%s\n%!" + (String.concat "; "(List.map path_str (paths_to_list res))) + ); + (* }}} *) + Some res (* Find $s_\calC$ and $t_\calC$ for a clause $\calC \in \mathrm{Next}_{e}$, i.e. in expanded "next" clauses. Determine which original clauses are frame clauses, and which have to be dropped (under assumption of being "frame waves"). Return the proper frame clauses, the non-frame clauses, and the fluent paths - (as in definition of $\calP_f$). *) -let fluent_paths_and_frames clauses = + (as in definition of $\calP_f$). Augment the syntactic check with + semantic exploration whenever sensible. *) +let fluent_paths_and_frames program playout_states clauses = let defs = defs_of_rules (Aux.concat_map rules_of_clause clauses) in let static, nonstatic = static_rels defs in @@ -164,10 +220,8 @@ let inline_defs = ("does", List.assoc "legal" defs)::inline_defs in (* To determine whether a clause is a frame, we need to know its - expansion, so we expand clauses separately. A proper frame clause - must have *all* expansions being proper frame clauses. But a - clause is dropped as "frame wave" if any of its expansions is - regarded as "frame wave". *) + expansion, so we expand clauses separately. A frame clause + must have *all* expansions being frame clauses. *) let next_clauses = List.filter (fun ((rel,_),_) -> rel="next") clauses in (* {{{ log entry *) @@ -200,33 +254,52 @@ (Aux.assoc_all "true" body) in let p_ts = true_args body in let n_ts = true_args neg_body in - let t_C, ps = most_similar s_C (p_ts @ n_ts) in + let wave, best = most_similar s_C (p_ts @ n_ts) in + let ps, t_C = + try List.find (fun (_,t) -> not (List.mem t n_ts)) best + with Not_found -> List.hd best in (* "negative true" check *) - t_C, ps, List.mem t_C n_ts in - let is_frame s_C (t_C, _, neg_true) = + wave, t_C, ps, List.mem t_C n_ts in + let is_frame s_C (_, t_C, _, neg_true) = not neg_true && s_C = t_C in let find_fluents (c, c_e) = let s_C = (snd (fst c)).(0) in - (* discarding frame waves *) - (* FIXME: TODO: handle frame waves as in updated reference spec *) - let res = Aux.map_try (find_br_fluents s_C) c_e in + let res = List.map (find_br_fluents s_C) c_e in (* {{{ log entry *) if !debug_level > 3 then ( Printf.printf "find_fluents: most_similar for s_C=%s expansions t_C=%s\n" (term_str s_C) (String.concat ", " - (List.map (fun (t,_,_)->term_str t) res)) + (List.map (fun (_,t,_,_)->term_str t) res)) ); (* }}} *) if List.for_all (is_frame s_C) res then Aux.Left c + else if List.for_all + (fun (wave,_,_,neg_true)-> not wave && not neg_true) res + then + let f_paths = + List.map (fun (_, _, ps, _) -> ps) res in + Aux.Right (c, List.fold_left paths_union empty_path_set f_paths) else + let sem_f_paths = + semantic_fluent_paths program playout_states c in + if sem_f_paths = Some empty_path_set (* frame clause *) + then Aux.Left c + else let f_paths = - List.map (fun (t_C, ps, neg_true) -> - if neg_true - then - term_paths (function Const _ -> true | _ -> false) t_C - else ps) res in + List.map (fun (wave, t_C, ps, neg_true) -> + let ps = + if neg_true + then + term_paths (function Const _ -> true | _ -> false) t_C + else ps in + if wave || neg_true then + match sem_f_paths with + | Some sem_ps -> paths_intersect sem_ps ps + | None -> ps + else ps + ) res in Aux.Right (c, List.fold_left paths_union empty_path_set f_paths) in let res = List.map find_fluents next_e in let frames, fluents = Aux.partition_choice res in @@ -244,7 +317,7 @@ (* Expand role variables, find fluent and mask paths, generate the initial structure. Encode frame clauses by using the unique relation name "frame next". *) -let create_init_struc clauses = +let create_init_struc program ~playout_states clauses = let players = Aux.map_some (function | ("role", [|player|]), _ -> Some player @@ -275,7 +348,7 @@ ); (* }}} *) let frame_clauses, move_clauses, f_paths = - fluent_paths_and_frames clauses in + fluent_paths_and_frames program playout_states clauses in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf @@ -435,7 +508,7 @@ let frame_clauses = List.map (fun ((_,args),body) -> ("frame next", args), body) frame_clauses in - players, rules, + rules, frame_clauses @ move_clauses @ clauses, f_paths, m_paths, mask_reps, defined_rels, Aux.Strings.elements !stable_rels, Aux.Strings.elements !fluents, @@ -740,10 +813,6 @@ TODO: unrequired clauses with disjunctions may avoid being excluded. If this poses problems we might need to expand disjunctions containing potentially case-split atoms. - - TODO: (important) filter-out case-split atoms based on conjoining - them with deterministic literals of required clauses (and checking - on the suite of random playout states). *) let rule_cases program playout_states rule_cls = let required_cls = Aux.map_some @@ -1538,11 +1607,19 @@ let translate_game ~playing_as clauses = let clauses = expand_players clauses in let used_vars, clauses = rename_clauses clauses in - let players, rules, + let players = + Aux.map_some (function + | ("role", [|player|]), _ -> Some player + | _ -> None + ) clauses in + let players = Array.of_list players in + let program = preprocess_program clauses in + let playout_states = generate_playout_states program players in + let rules, clauses, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, (*static_base,*) init_state, struc, ground_state_terms, elem_term_map = - create_init_struc clauses in + create_init_struc program ~playout_states clauses in let ground_at paths = List.map (fun p -> p, Aux.unique_sorted @@ -1572,7 +1649,6 @@ (List.map (fun ((rel,args),body as cl)-> if rel = "frame next" then ("next", args), body else cl) clauses) in - let playout_states = generate_playout_states program players in let turn_data = try Some (check_turn_based players program) with Not_turn_based -> None in Modified: trunk/Toss/GGP/TranslateGame.mli =================================================================== --- trunk/Toss/GGP/TranslateGame.mli 2011-08-27 09:44:45 UTC (rev 1545) +++ trunk/Toss/GGP/TranslateGame.mli 2011-08-28 21:08:34 UTC (rev 1546) @@ -64,17 +64,18 @@ purposes. Encode frame clauses by using the unique relation name "frame next". - [players, rules, frame_cls, move_cls, f_paths, m_paths, mask_reps, - defined_rels, stable_rels, fluents, init_state, - struc, ground_state_terms, elem_term_map = create_init_struc clauses] *) + [rules, clauses, f_paths, m_paths, mask_reps, + defined_rels, stable_rels, fluents, + init_state, struc, ground_state_terms, elem_term_map = + create_init_struc program ~playout_states clauses] *) val create_init_struc : + GDL.prolog_program -> + playout_states:GDL.term list list -> GDL.clause list -> - GDL.term array * GDL.gdl_rule list * - GDL.clause list * GDL.path_set * - GDL.path_set * GDL.term list * string list * string list * - string list * GDL.term list * - Structure.structure * GDL.term list * - GDL.term Aux.IntMap.t + GDL.gdl_rule list * GDL.clause list * + GDL.path_set * GDL.path_set * GDL.term list * string list * + string list * string list * GDL.term list * Structure.structure * + GDL.term list * GDL.term Aux.IntMap.t (* [playing_as] is only used for building move translation data, the Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-27 09:44:45 UTC (rev 1545) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-28 21:08:34 UTC (rev 1546) @@ -116,11 +116,12 @@ (fun () -> let descr = load_rules ("./GGP/examples/connect5.gdl") in let clauses = GDL.expand_players descr in - let players, rules, + let program = preprocess_program clauses in + let rules, clauses, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, init_state, struc, ground_state_terms, elem_term_map = - TranslateGame.create_init_struc clauses in + TranslateGame.create_init_struc program ~playout_states:[] clauses in assert_equal ~msg:"f_paths" ~printer:(fun x->x) "cell_2; control_0" @@ -209,16 +210,17 @@ ] -let a () = - (* GDL.debug_level := 4; *) - TranslateGame.debug_level := 4; - TranslateFormula.debug_level := 4; - GameSimpl.debug_level := 4; - DiscreteRule.debug_level := 4; +let set_debug_level i = + (* GDL.debug_level := i; *) + TranslateGame.debug_level := i; + TranslateFormula.debug_level := i; + GameSimpl.debug_level := i; + DiscreteRule.debug_level := i; () let a () = + set_debug_level 4; game_test_case ~game_name:"connect4" ~player:"white" ~own_plnum:0 ~opponent_plnum:1 ~loc0_rule_name:"drop_c11_noop" @@ -278,3 +280,20 @@ Aux.run_test_if_target "TranslateGameTest" ("TranslateGame" >::: [tests; bigtests]) + +let main () = + Aux.set_optimized_gc (); + let (file) = (ref "") in + let opts = [ + ("-v", Arg.Unit (fun () -> set_debug_level 1), "be verbose"); + ("-d", Arg.Int (fun i -> set_debug_level i), "set debug level"); + ("-f", Arg.String (fun s -> file := s), "process file"); + ] in + Arg.parse opts (fun _ -> ()) "Try -help for help or one of the following."; + if !file = "" then exec () else + let descr = load_rules !file in + let gdl_data, result = + TranslateGame.translate_game ~playing_as:(GDL.Const "") descr in + print_endline (Arena.state_str result) + +let _ = Aux.run_if_target "TranslateGameTest" main Modified: trunk/Toss/www/reference/reference.tex =================================================================== --- trunk/Toss/www/reference/reference.tex 2011-08-27 09:44:45 UTC (rev 1545) +++ trunk/Toss/www/reference/reference.tex 2011-08-28 21:08:34 UTC (rev 1546) @@ -1335,7 +1335,7 @@ To construct the elements of the structure from state terms, and to make that structure a good representation of the game in Toss, -we first determine which state terms always have common subtrees. +we first determine which state terms have common subtrees. \begin{definition} \label{def-merge} For two terms $s$ and $t$ we say that a set of paths $P$ \emph{merges} @@ -1361,10 +1361,10 @@ $s_\calC$)}. The term $t_\calC$ is the argument of \texttt{true} in the body of $\calC$ which is most similar to $s$ in the sense of Definition~\ref{def-merge}, and of equally similar has smallest -$d\calP(s,t)$ (if there are several, we pick one arbitrarily). +$d\calP(s,t)$. -\paragraph{Wave Clauses} +\paragraph{Wave Clauses and Fluent Paths} Let \emph{wave clauses} $\mathrm{Next}_{W}$ be defined as follows: $\calC \in \mathrm{Next}_{W}$ if there is $\calC' \in @@ -1375,19 +1375,32 @@ \emptyset \}$. Wave clauses propagate information across terms rather than describing a change of a term. -\paragraph{Fluent Paths and Structure Elements} +We often use the word \emph{fluent} for changing objects, and so we +define the set of \emph{fluent paths}, $\calP_f$, based on two +intuitions. Semantically, the intuition is that fluent paths are all +the $d\calP(s,t)$ paths where $s$ is any new state term and $t$ is its +closest state term from the prior state, for any reachable prior +state. Let us represent such paths, summed over $s$ generated by a +clause $\calC$, as $d\calP(s^{sem}_\calC,t^{sem}_\calC)$. The other +intuition applies to some games that start with a small set of state +terms, and we do not want to consider the whole gradually introduced +state terms as fluent, rather we determine syntactically which +subterms would change no matter what state terms were already +introduced. We approximate the sets +$d\calP(s^{sem}_\calC,t^{sem}_\calC)$ from below by computing them on +states from a small number of random playouts. -We often use the word \emph{fluent} for changing objects, and so we -define the set of \emph{fluent paths}, $\calP_f$, in the following way. -We say that a term $t$ is a \emph{negative true} in a clause $\calC$ if -it is the argument of a negative occurrence of \texttt{true} in $\calC$. -We write $\calL(t)$ for the set of paths to all constant leaves in $t$. -The set -\[ \calP_f \ = \ - \bigcup_{\calC \in \mathrm{Next}_{f}} d\calP(s_\calC, t_\calC) \ \cup \ - \bigcup_{\calC \in \mathrm{Next}_{f},\ - t_\calC \text{ negative true in } \calC} \calL(t_\calC). - \] +We say that a term $t$ is a \emph{negative true} in a +clause $\calC$ if it is the argument of a negative occurrence of +\texttt{true} in $\calC$. We write $\calL(t)$ for the set of paths to +all constant leaves in $t$. The set +\begin{align*} + \calP_f \ = \ & + \bigcup_{\calC \in \mathrm{Next}_{W}} d\calP(s^{sem}_\calC,t^{sem}_\calC) \ \cup \\ + & \bigcup_{\calC \in \mathrm{Next}_{f}} d\calP(s_\calC, t_\calC) \ \cup \\ + & \bigcup_{\calC \in \mathrm{Next}_{f},\ + t_\calC \text{ negative true in } \calC} \calL(t_\calC) \cap d\calP(s^{sem}_\calC,t^{sem}_\calC). + \end{align*} Note that $\calP_f$ contains all merge sets for the selected terms in $\mathrm{Next}_e$ clauses, and additionally, when $t_\calC$ is a negative true, we add the paths to all constant leaves in $t_\calC$. @@ -1434,6 +1447,8 @@ $\calP_f = \{(\mathtt{cell},3), (\mathtt{control},1)\}$. \end{example} +\paragraph{Structure Elements} + The fluent paths define the partition of GDL state terms into elements of the Toss structures in the following way. @@ -1796,32 +1811,22 @@ So far, we have not accounted for the fact that rewrite rules of Toss only affect the matched part of the structure, while the GDL game definition explicitly describes the construction of the whole -successive structure. We will say that a \texttt{next} clause is a -\emph{frame clause} if and only if it contains a \texttt{true} -relation applied to a term equal to the \texttt{next} argument. (TODO: -a clause is a frame clause if it does not add a state term not -present in the current state -- we will check empirically). Negating -the frame clauses from the tuple $\ol{\calN}$ and transforming them -into \emph{erasure clauses} will keep track of the elements that -possibly lose fluents and ensure correct translation. +successive structure. We say that a \texttt{next} clause $\calC$ is a +\emph{frame clause} when $d\calP(s^{sem}_\calC,t^{sem}_\calC) = +\setempty$ (if possible, \ie when the clause is not a wave clause, +approximated by checking whether it contains a \texttt{true} relation +applied to a term equal to the \texttt{next} argument). Negating the +frame clauses from the tuple $\ol{\calN}$ and transforming them into +\emph{erasure clauses} will keep track of the elements that possibly +lose fluents and ensure correct translation. We determine which clauses are frame clauses prior to partitioning into the rule clauses and computing the substitution $\sigma_{\ol{\calC},\ol{\calN}}$ -- at the point where fluent paths -are computed. It is difficult to establish which wave clauses should -be considered frame clauses. In the current implementation, we -optimistically assume that all wave clauses not depending on player -actions (\ie not containing \texttt{does}) are frame clauses (and -currently we ignore frame-wave clauses as they do not provide useful -erasure clauses). In the future, we might perform deeper checking as -to which wave clauses are frame clauses. (TODO: redo this whole -paragraph -- there will be no ``wave clauses'', we'll just detect -frame clauses from random playouts.) +are computed. We transform frame clauses by expanding relations that +would otherwise be translated as defined relations: so as to eliminate +local variables whenever possible. -We transform frame clauses by expanding relations that would otherwise -be translated as defined relations: so as to eliminate local variables -whenever possible. - From the frame clauses in $\sigma_{\ol{\calC}, \ol{\calN}}(\calN_1), \dots, \sigma_{\ol{\calC}, \ol{\calN}}(\calN_m)$, we select subsets $J$ such that, clauses in $J$ having the form $\mathtt{(<= (next\ s_i)\ b_i)}$, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-27 09:44:54
|
Revision: 1545 http://toss.svn.sourceforge.net/toss/?rev=1545&view=rev Author: lukstafi Date: 2011-08-27 09:44:45 +0000 (Sat, 27 Aug 2011) Log Message: ----------- GDL translation fixing: also simplify precondition stored in data for move translation. GameSimpl: remove undefined relations (replace with Or []), process additional formulas (assuming they do not introduce additional simplification data). Connect4: preconditions have redundant parts but too difficult to simplify. Modified Paths: -------------- trunk/Toss/GGP/GameSimpl.ml trunk/Toss/GGP/GameSimpl.mli trunk/Toss/GGP/GameSimplTest.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGameTest.ml Added Paths: ----------- trunk/Toss/GGP/tests/connect4-raw.toss trunk/Toss/GGP/tests/connect4-simpl.toss Modified: trunk/Toss/GGP/GameSimpl.ml =================================================================== --- trunk/Toss/GGP/GameSimpl.ml 2011-08-26 14:33:35 UTC (rev 1544) +++ trunk/Toss/GGP/GameSimpl.ml 2011-08-27 09:44:45 UTC (rev 1545) @@ -14,6 +14,11 @@ instead of [DiscreteRule.special_rel_of rel <> None]? (To protect against GDL using identifiers starting with underscore.) + (0) Cleanup. + + (0a) Replace relations missing from the structure and defined + relations list, with "false", i.e. [Or []]. + (1) Reduce equivalent or complement relations. (1a) If [introduce_complement] is on, for each (unary) predicate @@ -145,7 +150,11 @@ module Tups = Structure.Tuples -let simplify ?(keep_nonempty_predicates=true) (game, state) = +let map_all_formulas f more_formulas game = + Aux.StrMap.map f more_formulas, + Arena.map_to_formulas f game + +let simplify ?(keep_nonempty_predicates=true) ~more_formulas (game, state) = (* {{{ log entry *) if !debug_level > 0 then ( Printf.printf "GameSimpl: defined_rels = %s\n%!" @@ -165,13 +174,24 @@ (String.concat ", " (Aux.Strings.elements fluents)) ); (* }}} *) + (* 0 *) + let present_rel rel = + List.mem_assoc rel signat || + List.mem_assoc rel game.Arena.defined_rels in + let remove_absent = FormulaOps.map_formula + {FormulaOps.identity_map with FormulaOps.map_Rel = + fun rel args -> + if present_rel rel then Formula.Rel (rel, args) + else Formula.Or []} in + let more_formulas, game = + map_all_formulas remove_absent more_formulas game in (* 1 *) 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 + Arena.fold_over_formulas ~include_defined_rels:false (* FIXME: why? *) (FormulaOps.fold_over_atoms add_rel) game Aux.Strings.empty in let complemented = ref [] in @@ -314,8 +334,9 @@ if neg then Not (Rel (orig, args)) else Rel (orig, args) else phi | phi -> phi in - let game = - Arena.map_to_formulas (FormulaOps.map_to_atoms repl_equiv) game in + let more_formulas, game = + map_all_formulas (FormulaOps.map_to_atoms repl_equiv) + more_formulas game in let state = {state with Arena.struc = Structure.clear_rels struc removable} in (* Also have to apply to LHS structures... Don't use @@ -448,8 +469,9 @@ List.mem_assoc rel2 game.Arena.defined_rels) && included_in rel1 rel2 | _ -> false in - let game = - Arena.map_to_formulas (FormulaOps.remove_redundant ~implies) game in + let more_formulas, game = + map_all_formulas (FormulaOps.remove_redundant ~implies) + more_formulas game in (* 3 *) let intersect_rels struc grel rels = @@ -647,8 +669,8 @@ let res = glue_phi (Formula.flatten_sort phi) in if old_used_rels == !used_rels then res else glue_fixpoint res in - let game = - Arena.map_to_formulas glue_fixpoint game in + let more_formulas, game = + map_all_formulas glue_fixpoint more_formulas game in (* 3e *) let more_data = Aux.map_some (fun (crel, orig_rel) -> @@ -885,4 +907,4 @@ Structure.add_rel_name rel arity struc) struc signat in Structure.clear_rels struc clear_rel) (game, state) in - game, state + more_formulas, (game, state) Modified: trunk/Toss/GGP/GameSimpl.mli =================================================================== --- trunk/Toss/GGP/GameSimpl.mli 2011-08-26 14:33:35 UTC (rev 1544) +++ trunk/Toss/GGP/GameSimpl.mli 2011-08-27 09:44:45 UTC (rev 1545) @@ -12,4 +12,6 @@ val simplify : ?keep_nonempty_predicates:bool -> - Arena.game * Arena.game_state -> Arena.game * Arena.game_state + more_formulas:Formula.formula Aux.StrMap.t -> + Arena.game * Arena.game_state -> + Formula.formula Aux.StrMap.t * (Arena.game * Arena.game_state) Modified: trunk/Toss/GGP/GameSimplTest.ml =================================================================== --- trunk/Toss/GGP/GameSimplTest.ml 2011-08-26 14:33:35 UTC (rev 1544) +++ trunk/Toss/GGP/GameSimplTest.ml 2011-08-27 09:44:45 UTC (rev 1545) @@ -13,7 +13,8 @@ "connect5" >:: (fun () -> let connect5 = state_of_file "./GGP/tests/connect5-raw.toss" in - let res = GameSimpl.simplify connect5 in + let _, res = + GameSimpl.simplify ~more_formulas:Aux.StrMap.empty connect5 in let goal = state_of_file "./GGP/tests/connect5-simpl.toss" in let resf = open_out "./GGP/tests/connect5-temp.toss" in let res_str = Arena.state_str res in @@ -30,7 +31,8 @@ "breakthrough" >:: (fun () -> let breakthrough = state_of_file "./GGP/tests/breakthrough-raw.toss" in - let res = GameSimpl.simplify breakthrough in + let _, res = + GameSimpl.simplify ~more_formulas:Aux.StrMap.empty breakthrough in let goal = state_of_file "./GGP/tests/breakthrough-simpl.toss" in let resf = open_out "./GGP/tests/breakthrough-temp.toss" in let res_str = Arena.state_str res in @@ -67,7 +69,8 @@ let game = state_of_file ("./GGP/tests/"^game_name^"-raw.toss") in Printf.printf "\nINPUT:\n%s\n%!" (Arena.state_str game); (* GameSimpl.debug_level := 5; *) - let res = GameSimpl.simplify game in + let _, res = + GameSimpl.simplify ~more_formulas:Aux.StrMap.empty game in let resf = open_out ("./GGP/tests/"^game_name^"-simpl.toss") in let res_str = Arena.state_str res in output_string resf res_str; @@ -78,7 +81,8 @@ let a () = GameSimpl.debug_level := 5; let connect5 = state_of_file "./GGP/tests/connect5-raw.toss" in - let res = GameSimpl.simplify connect5 in + let _, res = + GameSimpl.simplify ~more_formulas:Aux.StrMap.empty connect5 in let goal = state_of_file "./GGP/tests/connect5-simpl.toss" in let resf = open_out "./GGP/tests/connect5-temp.toss" in let res_str = Arena.state_str res in Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-26 14:33:35 UTC (rev 1544) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-27 09:44:45 UTC (rev 1545) @@ -1655,8 +1655,22 @@ ); (* }}} *) let tossrule_data = Aux.strmap_of_assoc tossrule_data in + let tossrule_preconds = + Aux.StrMap.map (fun rdata->rdata.precond) tossrule_data in let playing_as = Aux.array_argfind (fun x -> x = playing_as) players in + (match !generate_test_case with + | None -> () + | Some game_name -> + let file = open_out ("./GGP/tests/"^game_name^"-raw.toss") in + output_string file (Arena.state_str result); + flush file; close_out file); + let tossrule_preconds, result = + GameSimpl.simplify ~more_formulas:tossrule_preconds result in + let tossrule_data = Aux.StrMap.mapi + (fun rname rdata-> + {rdata with precond = Aux.StrMap.find rname tossrule_preconds}) + tossrule_data in let gdl_translation = { (* map between structure elements and their term representations; the reverse direction is by using element names *) @@ -1674,13 +1688,6 @@ (match !generate_test_case with | None -> () | Some game_name -> - let file = open_out ("./GGP/tests/"^game_name^"-raw.toss") in - output_string file (Arena.state_str result); - flush file; close_out file); - let result = GameSimpl.simplify result in - (match !generate_test_case with - | None -> () - | Some game_name -> let file = open_out ("./GGP/tests/"^game_name^"-simpl.toss") in output_string file (Arena.state_str result); flush file; close_out file); Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-26 14:33:35 UTC (rev 1544) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-27 09:44:45 UTC (rev 1545) @@ -193,23 +193,18 @@ "connect4" >:: (fun () -> - (* Although the translation works, its quality is not good - enough to warrant testing. *) - todo "implement handling defined relations first"; - (* TODO: finish adapting the test after game is - cleanly translated. *) game_test_case ~game_name:"connect4" ~player:"white" ~own_plnum:0 ~opponent_plnum:1 - ~loc0_rule_name:"drop_???_0" + ~loc0_rule_name:"drop_c11_noop" ~loc0_emb:[ - "cell_x_y__blank_", "cell_2_1_MV1"; - "control__blank_", "control_MV1"] + "cell_c11_h4__BLANK_", "cell_2_1__BLANK_"; + "control__BLANK_", "control__BLANK_"] ~loc0_move:"(drop 2)" ~loc0_noop:"noop" - ~loc1:1 ~loc1_rule_name:"drop_???_1" + ~loc1:1 ~loc1_rule_name:"noop_drop_c12" ~loc1_emb:[ - "cell_x_y__blank_", "cell_f_g_MV1"; - "control__blank_", "control_MV1"] - ~loc1_noop:"noop" ~loc1_move:"(mark f g)" + "cell_c12_h6__BLANK_", "cell_2_1__BLANK_"; + "control__BLANK_", "control__BLANK_"] + ~loc1_noop:"noop" ~loc1_move:"(drop 2)" ); ] @@ -224,20 +219,18 @@ let a () = - game_test_case ~game_name:"breakthrough" ~player:"white" + game_test_case ~game_name:"connect4" ~player:"white" ~own_plnum:0 ~opponent_plnum:1 - ~loc0_rule_name:"move_x2_y3_x3_y4_noop" + ~loc0_rule_name:"drop_c11_noop" ~loc0_emb:[ - "cellholds_x2_y3__BLANK_", "cellholds_2_2__BLANK_"; - "cellholds_x3_y4__BLANK_", "cellholds_1_3__BLANK_"; + "cell_c11_h4__BLANK_", "cell_2_1__BLANK_"; "control__BLANK_", "control__BLANK_"] - ~loc0_move:"(move 2 2 1 3)" ~loc0_noop:"noop" ~loc1:1 - ~loc1_rule_name:"noop_move_x7_y9_x8_y10" + ~loc0_move:"(drop 2)" ~loc0_noop:"noop" + ~loc1:1 ~loc1_rule_name:"noop_drop_c12" ~loc1_emb:[ - "cellholds_x7_y9__blank_", "cellholds_7_7__BLANK_"; - "cellholds_x8_y10__blank_", "cellholds_6_6__BLANK_"; + "cell_c12_h6__BLANK_", "cell_2_1__BLANK_"; "control__BLANK_", "control__BLANK_"] - ~loc1_noop:"noop" ~loc1_move:"(move 7 7 6 6)" + ~loc1_noop:"noop" ~loc1_move:"(drop 2)" let a () = @@ -275,9 +268,9 @@ let a () = (* regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; *) (* regenerate ~debug:false ~game_name:"connect5" ~player:"x"; *) - regenerate ~debug:false ~game_name:"breakthrough" ~player:"white"; + (* regenerate ~debug:false ~game_name:"breakthrough" ~player:"white"; *) (* regenerate ~debug:true ~game_name:"pawn_whopping" ~player:"x"; *) - (* regen_with_debug ~game_name:"connect4" ~player:"white"; *) + regenerate ~debug:false ~game_name:"connect4" ~player:"white"; (* failwith "generated"; *) () Added: trunk/Toss/GGP/tests/connect4-raw.toss =================================================================== --- trunk/Toss/GGP/tests/connect4-raw.toss (rev 0) +++ trunk/Toss/GGP/tests/connect4-raw.toss 2011-08-27 09:44:45 UTC (rev 1545) @@ -0,0 +1,3116 @@ +REL row__w() = + ex cell_x0_y4__BLANK_, cell_x1_y4__BLANK_, cell_x2_y4__BLANK_, + cell_x3_y4__BLANK_ + (succ__cell_0__cell_0(cell_x0_y4__BLANK_, cell_x1_y4__BLANK_) and + succ__cell_0__cell_0(cell_x1_y4__BLANK_, cell_x2_y4__BLANK_) and + succ__cell_0__cell_0(cell_x2_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x2_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x2_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x2_y4__BLANK_) and + cell_2w(cell_x0_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x0_y4__BLANK_) and + cell_2w(cell_x1_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x1_y4__BLANK_) and + cell_2w(cell_x2_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x2_y4__BLANK_) and + cell_2w(cell_x3_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x3_y4__BLANK_)) +REL row__r() = + ex cell_x0_y4__BLANK_, cell_x1_y4__BLANK_, cell_x2_y4__BLANK_, + cell_x3_y4__BLANK_ + (succ__cell_0__cell_0(cell_x0_y4__BLANK_, cell_x1_y4__BLANK_) and + succ__cell_0__cell_0(cell_x1_y4__BLANK_, cell_x2_y4__BLANK_) and + succ__cell_0__cell_0(cell_x2_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x2_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x2_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x2_y4__BLANK_) and + cell_2r(cell_x0_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x0_y4__BLANK_) and + cell_2r(cell_x1_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x1_y4__BLANK_) and + cell_2r(cell_x2_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x2_y4__BLANK_) and + cell_2r(cell_x3_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x3_y4__BLANK_)) +REL row__dirt() = + ex cell_x0_y4__BLANK_, cell_x1_y4__BLANK_, cell_x2_y4__BLANK_, + cell_x3_y4__BLANK_ + (succ__cell_0__cell_0(cell_x0_y4__BLANK_, cell_x1_y4__BLANK_) and + succ__cell_0__cell_0(cell_x1_y4__BLANK_, cell_x2_y4__BLANK_) and + succ__cell_0__cell_0(cell_x2_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x2_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x2_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x2_y4__BLANK_) and + cell_2dirt(cell_x0_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x0_y4__BLANK_) and + cell_2dirt(cell_x1_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x1_y4__BLANK_) and + cell_2dirt(cell_x2_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x2_y4__BLANK_) and + cell_2dirt(cell_x3_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x3_y4__BLANK_)) +REL row__b() = + ex cell_x0_y4__BLANK_, cell_x1_y4__BLANK_, cell_x2_y4__BLANK_, + cell_x3_y4__BLANK_ + (succ__cell_0__cell_0(cell_x0_y4__BLANK_, cell_x1_y4__BLANK_) and + succ__cell_0__cell_0(cell_x1_y4__BLANK_, cell_x2_y4__BLANK_) and + succ__cell_0__cell_0(cell_x2_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x2_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x0_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x2_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x1_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x2_y4__BLANK_, cell_x3_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x0_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x1_y4__BLANK_) and + EQ___cell_1__cell_1(cell_x3_y4__BLANK_, cell_x2_y4__BLANK_) and + cell_2b(cell_x0_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x0_y4__BLANK_) and + cell_2b(cell_x1_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x1_y4__BLANK_) and + cell_2b(cell_x2_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x2_y4__BLANK_) and + cell_2b(cell_x3_y4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x3_y4__BLANK_)) +REL filled(v0) = + ex cell_c0_h0__BLANK_ + (v0 = cell_c0_h0__BLANK_ and + true and + cell_2dirt(cell_c0_h0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c0_h0__BLANK_)) or + ex cell_c1_h1__BLANK_ + (v0 = cell_c1_h1__BLANK_ and + true and + cell_2w(cell_c1_h1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c1_h1__BLANK_)) or + ex cell_c2_h2__BLANK_ + (v0 = cell_c2_h2__BLANK_ and + true and + cell_2r(cell_c2_h2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c2_h2__BLANK_)) +REL empty(v0) = + ex cell_c_h__BLANK_ + (v0 = cell_c_h__BLANK_ and + true and + cell_2b(cell_c_h__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c_h__BLANK_)) +REL diag__w() = + ex cell_x5_y9__BLANK_, cell_x6_y10__BLANK_, cell_x7_y11__BLANK_, + cell_x8_y12__BLANK_ + (succ__cell_0__cell_0(cell_x5_y9__BLANK_, cell_x6_y10__BLANK_) and + succ__cell_1__cell_1(cell_x5_y9__BLANK_, cell_x6_y10__BLANK_) and + succ__cell_0__cell_0(cell_x6_y10__BLANK_, cell_x7_y11__BLANK_) and + succ__cell_1__cell_1(cell_x6_y10__BLANK_, cell_x7_y11__BLANK_) and + succ__cell_0__cell_0(cell_x7_y11__BLANK_, cell_x8_y12__BLANK_) and + succ__cell_1__cell_1(cell_x7_y11__BLANK_, cell_x8_y12__BLANK_) and + cell_2w(cell_x5_y9__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x5_y9__BLANK_) and + cell_2w(cell_x6_y10__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x6_y10__BLANK_) and + cell_2w(cell_x7_y11__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x7_y11__BLANK_) and + cell_2w(cell_x8_y12__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_y12__BLANK_)) or + ex cell_x9_y13__BLANK_, cell_x10_y14__BLANK_, cell_x11_y15__BLANK_, + cell_x12_y16__BLANK_ + (succ__cell_0__cell_0(cell_x9_y13__BLANK_, cell_x10_y14__BLANK_) and + succ__cell_1__cell_1(cell_x10_y14__BLANK_, cell_x9_y13__BLANK_) and + succ__cell_0__cell_0(cell_x10_y14__BLANK_, cell_x11_y15__BLANK_) and + succ__cell_1__cell_1(cell_x11_y15__BLANK_, cell_x10_y14__BLANK_) and + succ__cell_0__cell_0(cell_x11_y15__BLANK_, cell_x12_y16__BLANK_) and + succ__cell_1__cell_1(cell_x12_y16__BLANK_, cell_x11_y15__BLANK_) and + cell_2w(cell_x9_y13__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x9_y13__BLANK_) and + cell_2w(cell_x10_y14__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x10_y14__BLANK_) and + cell_2w(cell_x11_y15__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x11_y15__BLANK_) and + cell_2w(cell_x12_y16__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x12_y16__BLANK_)) +REL diag__r() = + ex cell_x5_y9__BLANK_, cell_x6_y10__BLANK_, cell_x7_y11__BLANK_, + cell_x8_y12__BLANK_ + (succ__cell_0__cell_0(cell_x5_y9__BLANK_, cell_x6_y10__BLANK_) and + succ__cell_1__cell_1(cell_x5_y9__BLANK_, cell_x6_y10__BLANK_) and + succ__cell_0__cell_0(cell_x6_y10__BLANK_, cell_x7_y11__BLANK_) and + succ__cell_1__cell_1(cell_x6_y10__BLANK_, cell_x7_y11__BLANK_) and + succ__cell_0__cell_0(cell_x7_y11__BLANK_, cell_x8_y12__BLANK_) and + succ__cell_1__cell_1(cell_x7_y11__BLANK_, cell_x8_y12__BLANK_) and + cell_2r(cell_x5_y9__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x5_y9__BLANK_) and + cell_2r(cell_x6_y10__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x6_y10__BLANK_) and + cell_2r(cell_x7_y11__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x7_y11__BLANK_) and + cell_2r(cell_x8_y12__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_y12__BLANK_)) or + ex cell_x9_y13__BLANK_, cell_x10_y14__BLANK_, cell_x11_y15__BLANK_, + cell_x12_y16__BLANK_ + (succ__cell_0__cell_0(cell_x9_y13__BLANK_, cell_x10_y14__BLANK_) and + succ__cell_1__cell_1(cell_x10_y14__BLANK_, cell_x9_y13__BLANK_) and + succ__cell_0__cell_0(cell_x10_y14__BLANK_, cell_x11_y15__BLANK_) and + succ__cell_1__cell_1(cell_x11_y15__BLANK_, cell_x10_y14__BLANK_) and + succ__cell_0__cell_0(cell_x11_y15__BLANK_, cell_x12_y16__BLANK_) and + succ__cell_1__cell_1(cell_x12_y16__BLANK_, cell_x11_y15__BLANK_) and + cell_2r(cell_x9_y13__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x9_y13__BLANK_) and + cell_2r(cell_x10_y14__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x10_y14__BLANK_) and + cell_2r(cell_x11_y15__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x11_y15__BLANK_) and + cell_2r(cell_x12_y16__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x12_y16__BLANK_)) +REL diag__dirt() = + ex cell_x5_y9__BLANK_, cell_x6_y10__BLANK_, cell_x7_y11__BLANK_, + cell_x8_y12__BLANK_ + (succ__cell_0__cell_0(cell_x5_y9__BLANK_, cell_x6_y10__BLANK_) and + succ__cell_1__cell_1(cell_x5_y9__BLANK_, cell_x6_y10__BLANK_) and + succ__cell_0__cell_0(cell_x6_y10__BLANK_, cell_x7_y11__BLANK_) and + succ__cell_1__cell_1(cell_x6_y10__BLANK_, cell_x7_y11__BLANK_) and + succ__cell_0__cell_0(cell_x7_y11__BLANK_, cell_x8_y12__BLANK_) and + succ__cell_1__cell_1(cell_x7_y11__BLANK_, cell_x8_y12__BLANK_) and + cell_2dirt(cell_x5_y9__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x5_y9__BLANK_) and + cell_2dirt(cell_x6_y10__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x6_y10__BLANK_) and + cell_2dirt(cell_x7_y11__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x7_y11__BLANK_) and + cell_2dirt(cell_x8_y12__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_y12__BLANK_)) or + ex cell_x9_y13__BLANK_, cell_x10_y14__BLANK_, cell_x11_y15__BLANK_, + cell_x12_y16__BLANK_ + (succ__cell_0__cell_0(cell_x9_y13__BLANK_, cell_x10_y14__BLANK_) and + succ__cell_1__cell_1(cell_x10_y14__BLANK_, cell_x9_y13__BLANK_) and + succ__cell_0__cell_0(cell_x10_y14__BLANK_, cell_x11_y15__BLANK_) and + succ__cell_1__cell_1(cell_x11_y15__BLANK_, cell_x10_y14__BLANK_) and + succ__cell_0__cell_0(cell_x11_y15__BLANK_, cell_x12_y16__BLANK_) and + succ__cell_1__cell_1(cell_x12_y16__BLANK_, cell_x11_y15__BLANK_) and + cell_2dirt(cell_x9_y13__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x9_y13__BLANK_) and + cell_2dirt(cell_x10_y14__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x10_y14__BLANK_) and + cell_2dirt(cell_x11_y15__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x11_y15__BLANK_) and + cell_2dirt(cell_x12_y16__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x12_y16__BLANK_)) +REL diag__b() = + ex cell_x5_y9__BLANK_, cell_x6_y10__BLANK_, cell_x7_y11__BLANK_, + cell_x8_y12__BLANK_ + (succ__cell_0__cell_0(cell_x5_y9__BLANK_, cell_x6_y10__BLANK_) and + succ__cell_1__cell_1(cell_x5_y9__BLANK_, cell_x6_y10__BLANK_) and + succ__cell_0__cell_0(cell_x6_y10__BLANK_, cell_x7_y11__BLANK_) and + succ__cell_1__cell_1(cell_x6_y10__BLANK_, cell_x7_y11__BLANK_) and + succ__cell_0__cell_0(cell_x7_y11__BLANK_, cell_x8_y12__BLANK_) and + succ__cell_1__cell_1(cell_x7_y11__BLANK_, cell_x8_y12__BLANK_) and + cell_2b(cell_x5_y9__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x5_y9__BLANK_) and + cell_2b(cell_x6_y10__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x6_y10__BLANK_) and + cell_2b(cell_x7_y11__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x7_y11__BLANK_) and + cell_2b(cell_x8_y12__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_y12__BLANK_)) or + ex cell_x9_y13__BLANK_, cell_x10_y14__BLANK_, cell_x11_y15__BLANK_, + cell_x12_y16__BLANK_ + (succ__cell_0__cell_0(cell_x9_y13__BLANK_, cell_x10_y14__BLANK_) and + succ__cell_1__cell_1(cell_x10_y14__BLANK_, cell_x9_y13__BLANK_) and + succ__cell_0__cell_0(cell_x10_y14__BLANK_, cell_x11_y15__BLANK_) and + succ__cell_1__cell_1(cell_x11_y15__BLANK_, cell_x10_y14__BLANK_) and + succ__cell_0__cell_0(cell_x11_y15__BLANK_, cell_x12_y16__BLANK_) and + succ__cell_1__cell_1(cell_x12_y16__BLANK_, cell_x11_y15__BLANK_) and + cell_2b(cell_x9_y13__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x9_y13__BLANK_) and + cell_2b(cell_x10_y14__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x10_y14__BLANK_) and + cell_2b(cell_x11_y15__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x11_y15__BLANK_) and + cell_2b(cell_x12_y16__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x12_y16__BLANK_)) +REL column__w() = + ex cell_x4_y5__BLANK_, cell_x4_y6__BLANK_, cell_x4_y7__BLANK_, + cell_x4_y8__BLANK_ + (succ__cell_1__cell_1(cell_x4_y5__BLANK_, cell_x4_y6__BLANK_) and + succ__cell_1__cell_1(cell_x4_y6__BLANK_, cell_x4_y7__BLANK_) and + succ__cell_1__cell_1(cell_x4_y7__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y7__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y7__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y7__BLANK_) and + cell_2w(cell_x4_y5__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y5__BLANK_) and + cell_2w(cell_x4_y6__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y6__BLANK_) and + cell_2w(cell_x4_y7__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y7__BLANK_) and + cell_2w(cell_x4_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y8__BLANK_)) +REL column__r() = + ex cell_x4_y5__BLANK_, cell_x4_y6__BLANK_, cell_x4_y7__BLANK_, + cell_x4_y8__BLANK_ + (succ__cell_1__cell_1(cell_x4_y5__BLANK_, cell_x4_y6__BLANK_) and + succ__cell_1__cell_1(cell_x4_y6__BLANK_, cell_x4_y7__BLANK_) and + succ__cell_1__cell_1(cell_x4_y7__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y7__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y7__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y7__BLANK_) and + cell_2r(cell_x4_y5__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y5__BLANK_) and + cell_2r(cell_x4_y6__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y6__BLANK_) and + cell_2r(cell_x4_y7__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y7__BLANK_) and + cell_2r(cell_x4_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y8__BLANK_)) +REL column__dirt() = + ex cell_x4_y5__BLANK_, cell_x4_y6__BLANK_, cell_x4_y7__BLANK_, + cell_x4_y8__BLANK_ + (succ__cell_1__cell_1(cell_x4_y5__BLANK_, cell_x4_y6__BLANK_) and + succ__cell_1__cell_1(cell_x4_y6__BLANK_, cell_x4_y7__BLANK_) and + succ__cell_1__cell_1(cell_x4_y7__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y7__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y7__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y7__BLANK_) and + cell_2dirt(cell_x4_y5__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y5__BLANK_) and + cell_2dirt(cell_x4_y6__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y6__BLANK_) and + cell_2dirt(cell_x4_y7__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y7__BLANK_) and + cell_2dirt(cell_x4_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y8__BLANK_)) +REL column__b() = + ex cell_x4_y5__BLANK_, cell_x4_y6__BLANK_, cell_x4_y7__BLANK_, + cell_x4_y8__BLANK_ + (succ__cell_1__cell_1(cell_x4_y5__BLANK_, cell_x4_y6__BLANK_) and + succ__cell_1__cell_1(cell_x4_y6__BLANK_, cell_x4_y7__BLANK_) and + succ__cell_1__cell_1(cell_x4_y7__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y7__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y5__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y7__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y6__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y7__BLANK_, cell_x4_y8__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y5__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y6__BLANK_) and + EQ___cell_0__cell_0(cell_x4_y8__BLANK_, cell_x4_y7__BLANK_) and + cell_2b(cell_x4_y5__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y5__BLANK_) and + cell_2b(cell_x4_y6__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y6__BLANK_) and + cell_2b(cell_x4_y7__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y7__BLANK_) and + cell_2b(cell_x4_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x4_y8__BLANK_)) +REL open() = + ex cell_c10_h7__BLANK_ + (empty(cell_c10_h7__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c10_h7__BLANK_)) +REL line__w() = + (row__w() and true) or (column__w() and true) or (diag__w() and true) +REL line__r() = + (row__r() and true) or (column__r() and true) or (diag__r() and true) +REL line__dirt() = + (row__dirt() and true) or (column__dirt() and true) or + (diag__dirt() and true) +REL line__b() = + (row__b() and true) or (column__b() and true) or (diag__b() and true) +REL terminal() = + (line__r() and true) or (line__w() and true) or (not open() and true) +REL lte(v0, v1) = + ex cell_0__BLANK___BLANK_, cell_x16__BLANK___BLANK_ + (v0 = cell_0__BLANK___BLANK_ and v1 = cell_x16__BLANK___BLANK_ and + number__cell_0(cell_x16__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x16__BLANK___BLANK_) and + cell_00(cell_0__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_0__BLANK___BLANK_)) or + ex cell_x17__BLANK___BLANK_, cell_x17__BLANK___BLANK_ + (v0 = cell_x17__BLANK___BLANK_ and v1 = cell_x17__BLANK___BLANK_ and + number__cell_0(cell_x17__BLANK___BLANK_) and + number__cell_0(cell_x17__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x17__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x17__BLANK___BLANK_)) or + ex cell_x18__BLANK___BLANK_, cell_z4__BLANK___BLANK_ + (v0 = cell_x18__BLANK___BLANK_ and v1 = cell_z4__BLANK___BLANK_ and + ex cell_y21__BLANK___BLANK_ + (succ__cell_0__cell_0(cell_y21__BLANK___BLANK_, + cell_z4__BLANK___BLANK_) and lte(cell_x18__BLANK___BLANK_, + cell_y21__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y21__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x18__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_z4__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x18__BLANK___BLANK_))) or + ex cell_x19__BLANK___BLANK_, cell_y22__BLANK___BLANK_ + (v0 = cell_x19__BLANK___BLANK_ and v1 = cell_y22__BLANK___BLANK_ and + succ__cell_0__cell_0(cell_x19__BLANK___BLANK_, + cell_y22__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y22__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x19__BLANK___BLANK_)) +PLAYERS white, red +RULE drop_c11_noop: + [cell_c11_h4__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2dirt {cell_c11_h4__BLANK_; control__BLANK_}; + _opt_cell_2r {cell_c11_h4__BLANK_; control__BLANK_}; + _opt_cell_2w {cell_c11_h4__BLANK_; control__BLANK_}; + _opt_control_0red {cell_c11_h4__BLANK_; control__BLANK_}; + _opt_control_0white (cell_c11_h4__BLANK_); cell_2b (cell_c11_h4__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_c11_h4__BLANK_); + control_0white (control__BLANK_); control__BLANK_ (control__BLANK_) + | + ] -> + [cell_c11_h4__BLANK_, control__BLANK_ | + cell_2w (cell_c11_h4__BLANK_); control_0red (control__BLANK_) | + ] emb cell_2b, cell_2dirt, cell_2r, cell_2w, control_0red, control_0white + pre + (not terminal() and + ex cell_c11_y17__BLANK_, cell_c11_h3__BLANK_, cell_c11_y18__BLANK_ + (cell__BLANK___BLANK___BLANK_(cell_c11_h3__BLANK_) and + filled(cell_c11_h3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c11_y17__BLANK_) and + filled(cell_c11_y17__BLANK_) and cell_2b(cell_c11_y18__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c11_y18__BLANK_) and + EQ___cell_0__cell_0(cell_c11_h3__BLANK_, cell_c11_h4__BLANK_) and + succ__cell_1__cell_1(cell_c11_h3__BLANK_, cell_c11_h4__BLANK_) and + EQ___cell_0__cell_0(cell_c11_h3__BLANK_, cell_c11_y17__BLANK_) and + EQ___cell_0__cell_0(cell_c11_h3__BLANK_, cell_c11_y18__BLANK_) and + EQ___cell_0__cell_0(cell_c11_h4__BLANK_, cell_c11_h3__BLANK_) and + EQ___cell_0__cell_0(cell_c11_h4__BLANK_, cell_c11_y17__BLANK_) and + EQ___cell_0__cell_0(cell_c11_h4__BLANK_, cell_c11_y18__BLANK_) and + EQ___cell_0__cell_0(cell_c11_y17__BLANK_, cell_c11_h3__BLANK_) and + EQ___cell_0__cell_0(cell_c11_y17__BLANK_, cell_c11_h4__BLANK_) and + EQ___cell_0__cell_0(cell_c11_y17__BLANK_, cell_c11_y18__BLANK_) and + succ__cell_1__cell_1(cell_c11_y17__BLANK_, cell_c11_y18__BLANK_) and + EQ___cell_0__cell_0(cell_c11_y18__BLANK_, cell_c11_h3__BLANK_) and + EQ___cell_0__cell_0(cell_c11_y18__BLANK_, cell_c11_h4__BLANK_) and + EQ___cell_0__cell_0(cell_c11_y18__BLANK_, cell_c11_y17__BLANK_))) +RULE noop_drop_c12: + [cell_c12_h6__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2dirt {cell_c12_h6__BLANK_; control__BLANK_}; + _opt_cell_2r {cell_c12_h6__BLANK_; control__BLANK_}; + _opt_cell_2w {cell_c12_h6__BLANK_; control__BLANK_}; + _opt_control_0red (cell_c12_h6__BLANK_); + _opt_control_0white {cell_c12_h6__BLANK_; control__BLANK_}; + cell_2b (cell_c12_h6__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_c12_h6__BLANK_); + control_0red (control__BLANK_); control__BLANK_ (control__BLANK_) + | + ] -> + [cell_c12_h6__BLANK_, control__BLANK_ | + cell_2r (cell_c12_h6__BLANK_); control_0white (control__BLANK_) | + ] + emb cell_2b, cell_2dirt, cell_2r, cell_2w, control_0red, control_0white + pre + (not terminal() and + ex cell_c12_y19__BLANK_, cell_c12_h5__BLANK_, cell_c12_y20__BLANK_ + (cell__BLANK___BLANK___BLANK_(cell_c12_h5__BLANK_) and + filled(cell_c12_h5__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c12_y19__BLANK_) and + filled(cell_c12_y19__BLANK_) and cell_2b(cell_c12_y20__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c12_y20__BLANK_) and + EQ___cell_0__cell_0(cell_c12_h5__BLANK_, cell_c12_h6__BLANK_) and + succ__cell_1__cell_1(cell_c12_h5__BLANK_, cell_c12_h6__BLANK_) and + EQ___cell_0__cell_0(cell_c12_h5__BLANK_, cell_c12_y19__BLANK_) and + EQ___cell_0__cell_0(cell_c12_h5__BLANK_, cell_c12_y20__BLANK_) and + EQ___cell_0__cell_0(cell_c12_h6__BLANK_, cell_c12_h5__BLANK_) and + EQ___cell_0__cell_0(cell_c12_h6__BLANK_, cell_c12_y19__BLANK_) and + EQ___cell_0__cell_0(cell_c12_h6__BLANK_, cell_c12_y20__BLANK_) and + EQ___cell_0__cell_0(cell_c12_y19__BLANK_, cell_c12_h5__BLANK_) and + EQ___cell_0__cell_0(cell_c12_y19__BLANK_, cell_c12_h6__BLANK_) and + EQ___cell_0__cell_0(cell_c12_y19__BLANK_, cell_c12_y20__BLANK_) and + succ__cell_1__cell_1(cell_c12_y19__BLANK_, cell_c12_y20__BLANK_) and + EQ___cell_0__cell_0(cell_c12_y20__BLANK_, cell_c12_h5__BLANK_) and + EQ___cell_0__cell_0(cell_c12_y20__BLANK_, cell_c12_h6__BLANK_) and + EQ___cell_0__cell_0(cell_c12_y20__BLANK_, cell_c12_y19__BLANK_))) +LOC 0 { + + PLAYER white { + PAYOFF + 100. * :((line__w() and true)) + + 50. * :((not line__r() and not line__w() and not open() and true)) + + 70. * :((not line__r() and not line__w() and open() and true)) + MOVES [drop_c11_noop -> 1] } + PLAYER red { + PAYOFF + 100. * :((line__r() and true)) + + 50. * :((not line__r() and not line__w() and not open() and true)) + + 70. * :((not line__r() and not line__w() and open() and true)) + } +} +LOC 1 { + + PLAYER white { + PAYOFF + 100. * :((line__w() and true)) + + 50. * :((not line__r() and not line__w() and not open() and true)) + + 70. * :((not line__r() and not line__w() and open() and true)) + } + PLAYER red { + PAYOFF + 100. * :((line__r() and true)) + + 50. * :((not line__r() and not line__w() and not open() and true)) + + 70. * :((not line__r() and not line__w() and open() and true)) + MOVES [noop_drop_c12 -> 0] } +} +MODEL + [cell_1_0__BLANK_, cell_1_1__BLANK_, cell_1_2__BLANK_, cell_1_3__BLANK_, + cell_1_4__BLANK_, cell_1_5__BLANK_, cell_1_6__BLANK_, cell_2_0__BLANK_, + cell_2_1__BLANK_, cell_2_2__BLANK_, cell_2_3__BLANK_, cell_2_4__BLANK_, + cell_2_5__BLANK_, cell_2_6__BLANK_, cell_3_0__BLANK_, cell_3_1__BLANK_, + cell_3_2__BLANK_, cell_3_3__BLANK_, cell_3_4__BLANK_, cell_3_5__BLANK_, + cell_3_6__BLANK_, cell_4_0__BLANK_, cell_4_1__BLANK_, cell_4_2__BLANK_, + cell_4_3__BLANK_, cell_4_4__BLANK_, cell_4_5__BLANK_, cell_4_6__BLANK_, + cell_5_0__BLANK_, cell_5_1__BLANK_, cell_5_2__BLANK_, cell_5_3__BLANK_, + cell_5_4__BLANK_, cell_5_5__BLANK_, cell_5_6__BLANK_, cell_6_0__BLANK_, + cell_6_1__BLANK_, cell_6_2__BLANK_, cell_6_3__BLANK_, cell_6_4__BLANK_, + cell_6_5__BLANK_, cell_6_6__BLANK_, cell_7_0__BLANK_, cell_7_1__BLANK_, + cell_7_2__BLANK_, cell_7_3__BLANK_, cell_7_4__BLANK_, cell_7_5__BLANK_, + cell_7_6__BLANK_, control__BLANK_ | + EQ___cell_0__cell_0 { + (cell_1_0__BLANK_, cell_1_0__BLANK_); + (cell_1_0__BLANK_, cell_1_1__BLANK_); + (cell_1_0__BLANK_, cell_1_2__BLANK_); + (cell_1_0__BLANK_, cell_1_3__BLANK_); + (cell_1_0__BLANK_, cell_1_4__BLANK_); + (cell_1_0__BLANK_, cell_1_5__BLANK_); + (cell_1_0__BLANK_, cell_1_6__BLANK_); + (cell_1_1__BLANK_, cell_1_0__BLANK_); + (cell_1_1__BLANK_, cell_1_1__BLANK_); + (cell_1_1__BLANK_, cell_1_2__BLANK_); + (cell_1_1__BLANK_, cell_1_3__BLANK_); + (cell_1_1__BLANK_, cell_1_4__BLANK_); + (cell_1_1__BLANK_, cell_1_5__BLANK_); + (cell_1_1__BLANK_, cell_1_6__BLANK_); + (cell_1_2__BLANK_, cell_1_0__BLANK_); + (cell_1_2__BLANK_, cell_1_1__BLANK_); + (cell_1_2__BLANK_, cell_1_2__BLANK_); + (cell_1_2__BLANK_, cell_1_3__BLANK_); + (cell_1_2__BLANK_, cell_1_4__BLANK_); + (cell_1_2__BLANK_, cell_1_5__BLANK_); + (cell_1_2__BLANK_, cell_1_6__BLANK_); + (cell_1_3__BLANK_, cell_1_0__BLANK_); + (cell_1_3__BLANK_, cell_1_1__BLANK_); + (cell_1_3__BLANK_, cell_1_2__BLANK_); + (cell_1_3__BLANK_, cell_1_3__BLANK_); + (cell_1_3__BLANK_, cell_1_4__BLANK_); + (cell_1_3__BLANK_, cell_1_5__BLANK_); + (cell_1_3__BLANK_, cell_1_6__BLANK_); + (cell_1_4__BLANK_, cell_1_0__BLANK_); + (cell_1_4__BLANK_, cell_1_1__BLANK_); + (cell_1_4__BLANK_, cell_1_2__BLANK_); + (cell_1_4__BLANK_, cell_1_3__BLANK_); + (cell_1_4__BLANK_, cell_1_4__BLANK_); + (cell_1_4__BLANK_, cell_1_5__BLANK_); + (cell_1_4__BLANK_, cell_1_6__BLANK_); + (cell_1_5__BLANK_, cell_1_0__BLANK_); + (cell_1_5__BLANK_, cell_1_1__BLANK_); + (cell_1_5__BLANK_, cell_1_2__BLANK_); + (cell_1_5__BLANK_, cell_1_3__BLANK_); + (cell_1_5__BLANK_, cell_1_4__BLANK_); + (cell_1_5__BLANK_, cell_1_5__BLANK_); + (cell_1_5__BLANK_, cell_1_6__BLANK_); + (cell_1_6__BLANK_, cell_1_0__BLANK_); + (cell_1_6__BLANK_, cell_1_1__BLANK_); + (cell_1_6__BLANK_, cell_1_2__BLANK_); + (cell_1_6__BLANK_, cell_1_3__BLANK_); + (cell_1_6__BLANK_, cell_1_4__BLANK_); + (cell_1_6__BLANK_, cell_1_5__BLANK_); + (cell_1_6__BLANK_, cell_1_6__BLANK_); + (cell_2_0__BLANK_, cell_2_0__BLANK_); + (cell_2_0__BLANK_, cell_2_1__BLANK_); + (cell_2_0__BLANK_, cell_2_2__BLANK_); + (cell_2_0__BLANK_, cell_2_3__BLANK_); + (cell_2_0__BLANK_, cell_2_4__BLANK_); + (cell_2_0__BLANK_, cell_2_5__BLANK_); + (cell_2_0__BLANK_, cell_2_6__BLANK_); + (cell_2_1__BLANK_, cell_2_0__BLANK_); + (cell_2_1__BLANK_, cell_2_1__BLANK_); + (cell_2_1__BLANK_, cell_2_2__BLANK_); + (cell_2_1__BLANK_, cell_2_3__BLANK_); + (cell_2_1__BLANK_, cell_2_4__BLANK_); + (cell_2_1__BLANK_, cell_2_5__BLANK_); + (cell_2_1__BLANK_, cell_2_6__BLANK_); + (cell_2_2__BLANK_, cell_2_0__BLANK_); + (cell_2_2__BLANK_, cell_2_1__BLANK_); + (cell_2_2__BLANK_, cell_2_2__BLANK_); + (cell_2_2__BLANK_, cell_2_3__BLANK_); + (cell_2_2__BLANK_, cell_2_4__BLANK_); + (cell_2_2__BLANK_, cell_2_5__BLANK_); + (cell_2_2__BLANK_, cell_2_6__BLANK_); + (cell_2_3__BLANK_, cell_2_0__BLANK_); + (cell_2_3__BLANK_, cell_2_1__BLANK_); + (cell_2_3__BLANK_, cell_2_2__BLANK_); + (cell_2_3__BLANK_, cell_2_3__BLANK_); + (cell_2_3__BLANK_, cell_2_4__BLANK_); + (cell_2_3__BLANK_, cell_2_5__BLANK_); + (cell_2_3__BLANK_, cell_2_6__BLANK_); + (cell_2_4__BLANK_, cell_2_0__BLANK_); + (cell_2_4__BLANK_, cell_2_1__BLANK_); + (cell_2_4__BLANK_, cell_2_2__BLANK_); + (cell_2_4__BLANK_, cell_2_3__BLANK_); + (cell_2_4__BLANK_, cell_2_4__BLANK_); + (cell_2_4__BLANK_, cell_2_5__BLANK_); + (cell_2_4__BLANK_, cell_2_6__BLANK_); + (cell_2_5__BLANK_, cell_2_0__BLANK_); + (cell_2_5__BLANK_, cell_2_1__BLANK_); + (cell_2_5__BLANK_, cell_2_2__BLANK_); + (cell_2_5__BLANK_, cell_2_3__BLANK_); + (cell_2_5__BLANK_, cell_2_4__BLANK_); + (cell_2_5__BLANK_, cell_2_5__BLANK_); + (cell_2_5__BLANK_, cell_2_6__BLANK_); + (cell_2_6__BLANK_, cell_2_0__BLANK_); + (cell_2_6__BLANK_, cell_2_1__BLANK_); + (cell_2_6__BLANK_, cell_2_2__BLANK_); + (cell_2_6__BLANK_, cell_2_3__BLANK_); + (cell_2_6__BLANK_, cell_2_4__BLANK_); + (cell_2_6__BLANK_, cell_2_5__BLANK_); + (cell_2_6__BLANK_, cell_2_6__BLANK_); + (cell_3_0__BLANK_, cell_3_0__BLANK_); + (cell_3_0__BLANK_, cell_3_1__BLANK_); + (cell_3_0__BLANK_, cell_3_2__BLANK_); + (cell_3_0__BLANK_, cell_3_3__BLANK_); + (cell_3_0__BLANK_, cell_3_4__BLANK_); + (cell_3_0__BLANK_, cell_3_5__BLANK_); + (cell_3_0__BLANK_, cell_3_6__BLANK_); + (cell_3_1__BLANK_, cell_3_0__BLANK_); + (cell_3_1__BLANK_, cell_3_1__BLANK_); + (cell_3_1__BLANK_, cell_3_2__BLANK_); + (cell_3_1__BLANK_, cell_3_3__BLANK_); + (cell_3_1__BLANK_, cell_3_4__BLANK_); + (cell_3_1__BLANK_, cell_3_5__BLANK_); + (cell_3_1__BLANK_, cell_3_6__BLANK_); + (cell_3_2__BLANK_, cell_3_0__BLANK_); + (cell_3_2__BLANK_, cell_3_1__BLANK_); + (cell_3_2__BLANK_, cell_3_2__BLANK_); + (cell_3_2__BLANK_, cell_3_3__BLANK_); + (cell_3_2__BLANK_, cell_3_4__BLANK_); + (cell_3_2__BLANK_, cell_3_5__BLANK_); + (cell_3_2__BLANK_, cell_3_6__BLANK_); + (cell_3_3__BLANK_, cell_3_0__BLANK_); + (cell_3_3__BLANK_, cell_3_1__BLANK_); + (cell_3_3__BLANK_, cell_3_2__BLANK_); + (cell_3_3__BLANK_, cell_3_3__BLANK_); + (cell_3_3__BLANK_, cell_3_4__BLANK_); + (cell_3_3__BLANK_, cell_3_5__BLANK_); + (cell_3_3__BLANK_, cell_3_6__BLANK_); + (cell_3_4__BLANK_, cell_3_0__BLANK_); + (cell_3_4__BLANK_, cell_3_1__BLANK_); + (cell_3_4__BLANK_, cell_3_2__BLANK_); + (cell_3_4__BLANK_, cell_3_3__BLANK_); + (cell_3_4__BLANK_, cell_3_4__BLANK_); + (cell_3_4__BLANK_, cell_3_5__BLANK_); + (cell_3_4__BLANK_, cell_3_6__BLANK_); + (cell_3_5__BLANK_, cell_3_0__BLANK_); + (cell_3_5__BLANK_, cell_3_1__BLANK_); + (cell_3_5__BLANK_, cell_3_2__BLANK_); + (cell_3_5__BLANK_, cell_3_3__BLANK_); + (cell_3_5__BLANK_, cell_3_4__BLANK_); + (cell_3_5__BLANK_, cell_3_5__BLANK_); + (cell_3_5__BLANK_, cell_3_6__BLANK_); + (cell_3_6__BLANK_, cell_3_0__BLANK_); + (cell_3_6__BLANK_, cell_3_1__BLANK_); + (cell_3_6__BLANK_, cell_3_2__BLANK_); + (cell_3_6__BLANK_, cell_3_3__BLANK_); + (cell_3_6__BLANK_, cell_3_4__BLANK_); + (cell_3_6__BLANK_, cell_3_5__BLANK_); + (cell_3_6__BLANK_, cell_3_6__BLANK_); + (cell_4_0__BLANK_, cell_4_0__BLANK_); + (cell_4_0__BLANK_, cell_4_1__BLANK_); + (cell_4_0__BLANK_, cell_4_2__BLANK_); + (cell_4_0__BLANK_, cell_4_3__BLANK_); + (cell_4_0__BLANK_, cell_4_4__BLANK_); + (cell_4_0__BLANK_, cell_4_5__BLANK_); + (cell_4_0__BLANK_, cell_4_6__BLANK_); + (cell_4_1__BLANK_, cell_4_0__BLANK_); + (cell_4_1__BLANK_, cell_4_1__BLANK_); + (cell_4_1__BLANK_, cell_4_2__BLANK_); + (cell_4_1__BLANK_, cell_4_3__BLANK_); + (cell_4_1__BLANK_, cell_4_4__BLANK_); + (cell_4_1__BLANK_, cell_4_5__BLANK_); + (cell_4_1__BLANK_, cell_4_6__BLANK_); + (cell_4_2__BLANK_, cell_4_0__BLANK_); + (cell_4_2__BLANK_, cell_4_1__BLANK_); + (cell_4_2__BLANK_, cell_4_2__BLANK_); + (cell_4_2__BLANK_, cell_4_3__BLANK_); + (cell_4_2__BLANK_, cell_4_4__BLANK_); + (cell_4_2__BLANK_, cell_4_5__BLANK_); + (cell_4_2__BLANK_, cell_4_6__BLANK_); + (cell_4_3__BLANK_, cell_4_0__BLANK_); + (cell_4_3__BLANK_, cell_4_1__BLANK_); + (cell_4_3__BLANK_, cell_4_2__BLANK_); + (cell_4_3__BLANK_, cell_4_3__BLANK_); + (cell_4_3__BLANK_, cell_4_4__BLANK_); + (cell_4_3__BLANK_, cell_4_5__BLANK_); + (cell_4_3__BLANK_, cell_4_6__BLANK_); + (cell_4_4__BLANK_, cell_4_0__BLANK_); + (cell_4_4__BLANK_, cell_4_1__BLANK_); + (cell_4_4__BLANK_, cell_4_2__BLANK_); + (cell_4_4__BLANK_, cell_4_3__BLANK_); + (cell_4_4__BLANK_, cell_4_4__BLANK_); + (cell_4_4__BLANK_, cell_4_5__BLANK_); + (cell_4_4__BLANK_, cell_4_6__BLANK_); + (cell_4_5__BLANK_, cell_4_0__BLANK_); + (cell_4_5__BLANK_, cell_4_1__BLANK_); + (cell_4_5__BLANK_, cell_4_2__BLANK_); + (cell_4_5__BLANK_, cell_4_3__BLANK_); + (cell_4_5__BLANK_, cell_4_4__BLANK_); + (cell_4_5__BLANK_, cell_4_5__BLANK_); + (cell_4_5__BLANK_, cell_4_6__BLANK_); + (cell_4_6__BLANK_, cell_4_0__BLANK_); + (cell_4_6__BLANK_, cell_4_1__BLANK_); + (cell_4_6__BLANK_, cell_4_2__BLANK_); + (cell_4_6__BLANK_, cell_4_3__BLANK_); + (cell_4_6__BLANK_, cell_4_4__BLANK_); + (cell_4_6__BLANK_, cell_4_5__BLANK_); + (cell_4_6__BLANK_, cell_4_6__BLANK_); + (cell_5_0__BLANK_, cell_5_0__BLANK_); + (cell_5_0__BLANK_, cell_5_1__BLANK_); + (cell_5_0__BLANK_, cell_5_2__BLANK_); + (cell_5_0__BLANK_, cell_5_3__BLANK_); + (cell_5_0__BLANK_, cell_5_4__BLANK_); + (cell_5_0__BLANK_, cell_5_5__BLANK_); + (cell_5_0__BLANK_, cell_5_6__BLANK_); + (cell_5_1__BLANK_, cell_5_0__BLANK_); + (cell_5_1__BLANK_, cell_5_1__BLANK_); + (cell_5_1__BLANK_, cell_5_2__BLANK_); + (cell_5_1__BLANK_, cell_5_3__BLANK_); + (cell_5_1__BLANK_, cell_5_4__BLANK_); + (cell_5_1__BLANK_, cell_5_5__BLANK_); + (cell_5_1__BLANK_, cell_5_6__BLANK_); + (cell_5_2__BLANK_, cell_5_0__BLANK_); + (cell_5_2__BLANK_, cell_5_1__BLANK_); + (cell_5_2__BLANK_, cell_5_2__BLANK_); + (cell_5_2__BLANK_, cell_5_3__BLANK_); + (cell_5_2__BLANK_, cell_5_4__BLANK_); + (cell_5_2__BLANK_, cell_5_5__BLANK_); + (cell_5_2__BLANK_, cell_5_6__BLANK_); + (cell_5_3__BLANK_, cell_5_0__BLANK_); + (cell_5_3__BLANK_, cell_5_1__BLANK_); + (cell_5_3__BLANK_, cell_5_2__BLANK_); + (cell_5_3__BLANK_, cell_5_3__BLANK_); + (cell_5_3__BLANK_, cell_5_4__BLANK_); + (cell_5_3__BLANK_, cell_5_5__BLANK_); + (cell_5_3__BLANK_, cell_5_6__BLANK_); + (cell_5_4__BLANK_, cell_5_0__BLANK_); + (cell_5_4__BLANK_, cell_5_1__BLANK_); + (cell_5_4__BLANK_, cell_5_2__BLANK_); + (cell_5_4__BLANK_, cell_5_3__BLANK_); + (cell_5_4__BLANK_, cell_5_4__BLANK_); + (cell_5_4__BLANK_, cell_5_5__BLANK_); + (cell_5_4__BLANK_, cell_5_6__BLANK_); + (cell_5_5__BLANK_, cell_5_0__BLANK_); + (cell_5_5__BLANK_, cell_5_1__BLANK_); + (cell_5_5__BLANK_, cell_5_2__BLANK_); + (cell_5_5__BLANK_, cell_5_3__BLANK_); + (cell_5_5__BLANK_, cell_5_4__BLANK_); + (cell_5_5__BLANK_, cell_5_5__BLANK_); + (cell_5_5__BLANK_, cell_5_6__BLANK_); + (cell_5_6__BLANK_, cell_5_0__BLANK_); + (cell_5_6__BLANK_, cell_5_1__BLANK_); + (cell_5_6__BLANK_, cell_5_2__BLANK_); + (cell_5_6__BLANK_, cell_5_3__BLANK_); + (cell_5_6__BLANK_, cell_5_4__BLANK_); + (cell_5_6__BLANK_, cell_5_5__BLANK_); + (cell_5_6__BLANK_, cell_5_6__BLANK_); + (cell_6_0__BLANK_, cell_6_0__BLANK_); + (cell_6_0__BLANK_, cell_6_1__BLANK_); + (cell_6_0__BLANK_, cell_6_2__BLANK_); + (cell_6_0__BLANK_, cell_6_3__BLANK_); + (cell_6_0__BLANK_, cell_6_4__BLANK_); + (cell_6_0__BLANK_, cell_6_5__BLANK_); + (cell_6_0__BLANK_, cell_6_6__BLANK_); + (cell_6_1__BLANK_, cell_6_0__BLANK_); + (cell_6_1__BLANK_, cell_6_1__BLANK_); + (cell_6_1__BLANK_, cell_6_2__BLANK_); + (cell_6_1__BLANK_, cell_6_3__BLANK_); + (cell_6_1__BLANK_, cell_6_4__BLANK_); + (cell_6_1__BLANK_, cell_6_5__BLANK_); + (cell_6_1__BLANK_, cell_6_6__BLANK_); + (cell_6_2__BLANK_, cell_6_0__BLANK_); + (cell_6_2__BLANK_, cell_6_1__BLANK_); + (cell_6_2__BLANK_, cell_6_2__BLANK_); + (cell_6_2__BLANK_, cell_6_3__BLANK_); + (cell_6_2__BLANK_, cell_6_4__BLANK_); + (cell_6_2__BLANK_, cell_6_5__BLANK_); + (cell_6_2__BLANK_, cell_6_6__BLANK_); + (cell_6_3__BLANK_, cell_6_0__BLANK_); + (cell_6_3__BLANK_, cell_6_1__BLANK_); + (cell_6_3__BLANK_, cell_6_2__BLANK_); + (cell_6_3__BLANK_, cell_6_3__BLANK_); + (cell_6_3__BLANK_, cell_6_4__BLANK_); + (cell_6_3__BLANK_, cell_6_5__BLANK_); + (cell_6_3__BLANK_, cell_6_6__BLANK_); + (cell_6_4__BLANK_, cell_6_0__BLANK_); + (cell_6_4__BLANK_, cell_6_1__BLANK_); + (cell_6_4__BLANK_, cell_6_2__BLANK_); + (cell_6_4__BLANK_, cell_6_3__BLANK_); + (cell_6_4__BLANK_, cell_6_4__BLANK_); + (cell_6_4__BLANK_, cell_6_5__BLANK_); + (cell_6_4__BLANK_, cell_6_6__BLANK_); + (cell_6_5__BLANK_, cell_6_0__BLANK_); + (cell_6_5__BLANK_, cell_6_1__BLANK_); + (cell_6_5__BLANK_, cell_6_2__BLANK_); + (cell_6_5__BLANK_, cell_6_3__BLANK_); + (cell_6_5__BLANK_, cell_6_4__BLANK_); + (cell_6_5__BLANK_, cell_6_5__BLANK_); + (cell_6_5__BLANK_, cell_6_6__BLANK_); + (cell_6_6__BLANK_, cell_6_0__BLANK_); + (cell_6_6__BLANK_, cell_6_1__BLANK_); + (cell_6_6__BLANK_, cell_6_2__BLANK_); + (cell_6_6__BLANK_, cell_6_3__BLANK_); + (cell_6_6__BLANK_, cell_6_4__BLANK_); + (cell_6_6__BLANK_, cell_6_5__BLANK_); + (cell_6_6__BLANK_, cell_6_6__BLANK_); + (cell_7_0__BLANK_, cell_7_0__BLANK_); + (cell_7_0__BLANK_, cell_7_1__BLANK_); + (cell_7_0__BLANK_, cell_7_2__BLANK_); + (cell_7_0__BLANK_, cell_7_3__BLANK_); + (cell_7_0__BLANK_, cell_7_4__BLANK_); + (cell_7_0__BLANK_, cell_7_5__BLANK_); + (cell_7_0__BLANK_, cell_7_6__BLANK_); + (cell_7_1__BLANK_, cell_7_0__BLANK_); + (cell_7_1__BLANK_, cell_7_1__BLANK_); + (cell_7_1__BLANK_, cell_7_2__BLANK_); + (cell_7_1__BLANK_, cell_7_3__BLANK_); + (cell_7_1__BLANK_, cell_7_4__BLANK_); + (cell_7_1__BLANK_, cell_7_5__BLANK_); + (cell_7_1__BLANK_, cell_7_6__BLANK_); + (cell_7_2__BLANK_, cell_7_0__BLANK_); + (cell_7_2__BLANK_, cell_7_1__BLANK_); + (cell_7_2__BLANK_, cell_7_2__BLANK_); + (cell_7_2__BLANK_, cell_7_3__BLANK_); + (cell_7_2__BLANK_, cell_7_4__BLANK_); + (cell_7_2__BLANK_, cell_7_5__BLANK_); + (cell_7_2__BLANK_, cell_7_6__BLANK_); + (cell_7_3__BLANK_, cell_7_0__BLANK_); + (cell_7_3__BLANK_, cell_7_1__BLANK_); + (cell_7_3__BLANK_, cell_7_2__BLANK_); + (cell_7_3__BLANK_, cell_7_3__BLANK_); + (cell_7_3__BLANK_, cell_7_4__BLANK_); + (cell_7_3__BLANK_, cell_7_5__BLANK_); + (cell_7_3__BLANK_, cell_7_6__BLANK_); + (cell_7_4__BLANK_, cell_7_0__BLANK_); + (cell_7_4__BLANK_, cell_7_1__BLANK_); + (cell_7_4__BLANK_, cell_7_2__BLANK_); + (cell_7_4__BLANK_, cell_7_3__BLANK_); + (cell_7_4__BLANK_, cell_7_4__BLANK_); + (cell_7_4__BLANK_, cell_7_5__BLANK_); + (cell_7_4__BLANK_, cell_7_6__BLANK_); + (cell_7_5__BLANK_, cell_7_0__BLANK_); + (cell_7_5__BLANK_, cell_7_1__BLANK_); + (cell_7_5__BLANK_, cell_7_2__BLANK_); + (cell_7_5__BLANK_, cell_7_3__BLANK_); + (cell_7_5__BLANK_, cell_7_4__BLANK_); + (cell_7_5__BLANK_, cell_7_5__BLANK_); + (cell_7_5__BLANK_, cell_7_6__BLANK_); + (cell_7_6__BLANK_, cell_7_0__BLANK_); + (cell_7_6__BLANK_, cell_7_1__BLANK_); + (cell_7_6__BLANK_, cell_7_2__BLANK_); + (cell_7_6__BLANK_, cell_7_3__BLANK_); + (cell_7_6__BLANK_, cell_7_4__BLANK_); + (cell_7_6__BLANK_, cell_7_5__BLANK_); + (cell_7_6__BLANK_, cell_7_6__BLANK_) + }; + EQ___cell_0__cell_1 { + (cell_1_0__BLANK_, cell_1_1__BLANK_); + (cell_1_0__BLANK_, cell_2_1__BLANK_); + (cell_1_0__BLANK_, cell_3_1__BLANK_); + (cell_1_0__BLANK_, cell_4_1__BLANK_); + (cell_1_0__BLANK_, cell_5_1__BLANK_); + (cell_1_0__BLANK_, cell_6_1__BLANK_); + (cell_1_0__BLANK_, cell_7_1__BLANK_); + (cell_1_1__BLANK_, cell_1_1__BLANK_); + (cell_1_1__BLANK_, cell_2_1__BLANK_); + (cell_1_1__BLANK_, cell_3_1__BLANK_); + (cell_1_1__BLANK_, cell_4_1__BLANK_); + (cell_1_1__BLANK_, cell_5_1__BLANK_); + (cell_1_1__BLANK_, cell_6_1__BLANK_); + (cell_1_1__BLANK_, cell_7_1__BLANK_); + (cell_1_2__BLANK_, cell_1_1__BLANK_); + (cell_1_2__BLANK_, cell_2_1__BLANK_); + (cell_1_2__BLANK_, cell_3_1__BLANK_); + (cell_1_2__BLANK_, cell_4_1__BLANK_); + (cell_1_2__BLANK_, cell_5_1__BLANK_); + (cell_1_2__BLANK_, cell_6_1__BLANK_); + (cell_1_2__BLANK_, cell_7_1__BLANK_); + (cell_1_3__BLANK_, cell_1_1__BLANK_); + (cell_1_3__BLANK_, cell_2_1__BLANK_); + (cell_1_3__BLANK_, cell_3_1__BLANK_); + (cell_1_3__BLANK_, cell_4_1__BLANK_); + (cell_1_3__BLANK_, cell_5_1__BLANK_); + (cell_1_3__BLANK_, cell_6_1__BLANK_); + (cell_1_3__BLANK_, cell_7_1__BLANK_); + (cell_1_4__BLANK_, cell_1_1__BLANK_); + (cell_1_4__BLANK_, cell_2_1__BLANK_); + (cell_1_4__BLANK_, cell_3_1__BLANK_); + (cell_1_4__BLANK_, cell_4_1__BLANK_); + (cell_1_4__BLANK_, cell_5_1__BLANK_); + (cell_1_4__BLANK_, cell_6_1__BLANK_); + (cell_1_4__BLANK_, cell_7_1__BLANK_); + (cell_1_5__BLANK_, cell_1_1__BLANK_); + (cell_1_5__BLANK_, cell_2_1__BLANK_); + (cell_1_5__BLANK_, cell_3_1__BLANK_); + (cell_1_5__BLANK_, cell_4_1__BLANK_); + (cell_1_5__BLANK_, cell_5_1__BLANK_); + (cell_1_5__BLANK_, cell_6_1__BLANK_); + (cell_1_5__BLANK_, cell_7_1__BLANK_); + (cell_1_6__BLANK_, cell_1_1__BLANK_); + (cell_1_6__BLANK_, cell_2_1__BLANK_); + (cell_1_6__BLANK_, cell_3_1__BLANK_); + (cell_1_6__BLANK_, cell_4_1__BLANK_); + (cell_1_6__BLANK_, cell_5_1__BLANK_); + (cell_1_6__BLANK_, cell_6_1__BLANK_); + (cell_1_6__BLANK_, cell_7_1__BLANK_); + (cell_2_0__BLANK_, cell_1_2__BLANK_); + (cell_2_0__BLANK_, cell_2_2__BLANK_); + (cell_2_0__BLANK_, cell_3_2__BLANK_); + (cell_2_0__BLANK_, cell_4_2__BLANK_); + (cell_2_0__BLANK_, cell_5_2__BLANK_); + (cell_2_0__BLANK_, cell_6_2__BLANK_); + (cell_2_0__BLANK_, cell_7_2__BLANK_); + (cell_2_1__BLANK_, cell_1_2__BLANK_); + (cell_2_1__BLANK_, cell_2_2__BLANK_); + (cell_2_1__BLANK_, cell_3_2__BLANK_); + (cell_2_1__BLANK_, cell_4_2__BLANK_); + (cell_2_1__BLANK_, cell_5_2__BLANK_); + (cell_2_1__BLANK_, cell_6_2__BLANK_); + (cell_2_1__BLANK_, cell_7_2__BLANK_); + (cell_2_2__BLANK_, cell_1_2__BLANK_); + (cell_2_2__BLANK_, cell_2_2__BLANK_); + (cell_2_2__BLANK_, cell_3_2__BLANK_); + (cell_2_2__BLANK_, cell_4_2__BLANK_); + (cell_2_2__BLANK_, cell_5_2__BLANK_); + (cell_2_2__BLANK_, cell_6_2__BLANK_); + (cell_2_2__BLANK_, cell_7_2__BLANK_); + (cell_2_3__BLANK_, cell_1_2__BLANK_); + (cell_2_3__BLANK_, cell_2_2__BLANK_); + (cell_2_3__BLANK_, cell_3_2__BLANK_); + (cell_2_3__BLANK_, cell_4_2__BLANK_); + (cell_2_3__BLANK_, cell_5_2__BLANK_); + (cell_2_3__BLANK_, cell_6_2__BLANK_); + (cell_2_3__BLANK_, cell_7_2__BLANK_); + (cell_2_4__BLANK_, cell_1_2__BLANK_); + (cell_2_4__BLANK_, cell_2_2__BLANK_); + (cell_2_4__BLANK_, cell_3_2__BLANK_); + (cell_2_4__BLANK_, cell_4_2__BLANK_); + (cell_2_4__BLANK_, cell_5_2__BLANK_); + (cell_2_4__BLANK_, cell_6_2__BLANK_); + (cell_2_4__BLANK_, cell_7_2__BLANK_); + (cell_2_5__BLANK_, cell_1_2__BLANK_); + (cell_2_5__BLANK_, cell_2_2__BLANK_); + (cell_2_5__BLANK_, cell_3_2__BLANK_); + (cell_2_5__BLANK_, cell_4_2__BLANK_); + (cell_2_5__BLANK_, cell_5_2__BLANK_); + (cell_2_5__BLANK_, cell_6_2__BLANK_); + (cell_2_5__BLANK_, cell_7_2__BLANK_); + (cell_2_6__BLANK_, cell_1_2__BLANK_); + (cell_2_6__BLANK_, cell_2_2__BLANK_); + (cell_2_6__BLANK_, cell_3_2__BLANK_); + (cell_2_6__BLANK_, cell_4_2__BLANK_); + (cell_2_6__BLANK_... [truncated message content] |
From: <luk...@us...> - 2011-08-26 14:33:43
|
Revision: 1544 http://toss.svn.sourceforge.net/toss/?rev=1544&view=rev Author: lukstafi Date: 2011-08-26 14:33:35 +0000 (Fri, 26 Aug 2011) Log Message: ----------- GDL translation: (fix) expand frame clasues for generating erasure clauses; (optimization) filter unrequired (mostly erasure) rule clauses before splitting rule candidates; various bug fixes (e.g. sign of Distinct atoms); specification-level fix for handling <negative true> literals during formula translation; related, adding blanked out <true> atoms of RHS terms to rewrite rule conditions just prior to translation. GameSimpl: minor bug fix; removing unused defined relations. Modified Paths: -------------- 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/GDL.mli trunk/Toss/GGP/GameSimpl.ml trunk/Toss/GGP/TranslateFormula.ml trunk/Toss/GGP/TranslateFormula.mli trunk/Toss/GGP/TranslateFormulaTest.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/GGP/tests/breakthrough-raw.toss trunk/Toss/GGP/tests/breakthrough-simpl.toss trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/Formula/Aux.ml 2011-08-26 14:33:35 UTC (rev 1544) @@ -458,6 +458,17 @@ done; !r +let list_find_all_max cmp l = + match l with + | [] -> [] + | a::l -> List.fold_left + (fun all_max cand -> + let res = cmp cand (List.hd all_max) in + if res > 0 then [cand] + else if res = 0 then cand::all_max + else all_max) + [a] l + let array_find_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-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/Formula/Aux.mli 2011-08-26 14:33:35 UTC (rev 1544) @@ -249,6 +249,8 @@ arrays are of different lengths. *) val array_for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool +(** Find all maximal elements in a list. *) +val list_find_all_max : ('a -> 'a -> int) -> 'a list -> 'a list (** 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. *) Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/Formula/FormulaOps.ml 2011-08-26 14:33:35 UTC (rev 1544) @@ -1052,6 +1052,9 @@ let as_conjuncts phi = let rec conjuncts = function | And fl -> Aux.concat_map conjuncts fl + | Not (And [f]) -> conjuncts (Not f) + | Not (Or fl) -> + Aux.concat_map conjuncts (List.map (fun f->Not f) fl) | All (vs, f) -> List.map (fun f -> All (vs, f)) (conjuncts f) | Ex (vs, phi) -> (match conjuncts phi with Modified: trunk/Toss/Formula/FormulaOps.mli =================================================================== --- trunk/Toss/Formula/FormulaOps.mli 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/Formula/FormulaOps.mli 2011-08-26 14:33:35 UTC (rev 1544) @@ -43,7 +43,7 @@ map_Sum : fo_var list -> formula -> real_expr -> real_expr } -(** Identity map to be refined using the [with] clause. *) +(** Identity map to be refined using the [with] syntax. *) val identity_map : formula_and_expr_map (** Map through the structure adjusting subformulas/subexpressions. *) Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/GGP/GDL.ml 2011-08-26 14:33:35 UTC (rev 1544) @@ -95,6 +95,8 @@ | True arg -> "true", [|arg|] | Does (arg1, arg2) -> "does", [|arg1; arg2|] +(** Remember that [rel_of_atom] inverts polarity of "distinct" -- + invert back after using [atom_of_rel] if needed. *) let atom_of_rel = function | "distinct", args -> Distinct args (* not a proper relation -- avoid *) @@ -106,7 +108,7 @@ let rec bodies_of_literal = function | Pos (Distinct args) -> [Aux.Right ("distinct", args)] (* not negated actually! *) - | Neg (Distinct _) -> assert false + | Neg (Distinct args) -> [Aux.Left ("distinct",args)] | Pos atom -> [Aux.Left (rel_of_atom atom)] | Neg atom -> [Aux.Right (rel_of_atom atom)] | Disj disjs -> @@ -201,8 +203,36 @@ not (List.mem_assoc rel1 rules)) body) branches) stratum in stratify (stratum::strata) (more_rules @ rules) - +(* Topological-like sort w.r.t. the call-graph. *) +let topsort_callgraph clauses for_rels = + let defs = defs_of_rules (Aux.concat_map rules_of_clause clauses) in + (* building incidence list *) + let defs = List.map + (fun (rel, brs) -> + rel, + Aux.concat_map (fun (_,body,neg_body) -> + List.map fst body @ List.map fst neg_body) brs) + defs in + let defs = List.map + (fun (rel, drels) -> + rel, Aux.strings_of_list (Aux.list_inter drels for_rels)) defs in + let rec aux strata defs = + if defs = [] then List.flatten (List.rev strata) + else + (* like in topological sort, but don't restrict to empty call set *) + let stratum = Aux.list_find_all_max + (fun (_,a) (_,b) -> + Aux.Strings.cardinal b - Aux.Strings.cardinal a) defs in + let stratum = List.map fst stratum in + let visited = Aux.strings_of_list stratum in + let defs = List.filter + (fun (r,_) -> not (Aux.Strings.mem r visited)) defs in + let defs = List.map + (fun (r,calls) -> r, Aux.Strings.diff calls visited) defs in + aux (stratum::strata) defs in + aux [] (List.filter (fun (r,_) -> List.mem r for_rels) defs) + let rec subst_one (x, term as sb) = function | Var y when x=y -> term | (Const _ | Var _ as t) -> t @@ -236,7 +266,7 @@ | _ -> raise Not_found -(** A "blank" term. *) +(** A "blank", or "wild-card", term. *) let blank = Const "_BLANK_" (* Match terms on the left to ground terms on the right, ignoring @@ -714,6 +744,7 @@ used_vars := Aux.StrMap.fold (fun _ cls acc -> Aux.Strings.union (clauses_vars cls) acc) p Aux.Strings.empty; used_vars := Aux.Strings.union !used_vars (clause_vars (("",[||]),g)); + let g = preprocess_cl_body g in let sc_init fc sb = fun m -> fc () (sb::m) in let fc_init () = fun m -> m in let extract res = res [] in @@ -731,6 +762,7 @@ used_vars := Aux.StrMap.fold (fun _ cls acc -> Aux.Strings.union (clauses_vars cls) acc) p Aux.Strings.empty; used_vars := Aux.Strings.union !used_vars (clause_vars (("",[||]),g)); + let g = preprocess_cl_body g in let sc_init fc _ = true in let fc_init () = false in run_goal g p sc_init fc_init [] @@ -740,10 +772,10 @@ (* ************************************************************ *) (** {3 Transformations of GDL clauses: inlining, negation.} *) -(** Expand branches of a definition inlining the provided definitions, - only expand positive literals. Iterate expansion to support - nesting of definitions. *) -let expand_positive_lits defs brs = +(** Expand branches of a definition inlining the provided + definitions. Iterate expansion to support nesting of + definitions. *) +let expand_definitions defs brs = let used_vars = ref (gdl_defs_vars (("",brs)::defs)) in let freshen_brs brs = let br_vars = gdl_defs_vars ["",brs] in @@ -755,7 +787,7 @@ (Aux.Strings.elements br_vars) in let sb = List.map (fun (v,t) -> v, Var t) sb in List.map (subst_br sb) brs in - let expand_atom (rel, args as atom) + let expand_pos_atom (rel, args as atom) (sb, (head, r_body, r_neg_body)) = (let try def_brs = freshen_brs (List.assoc rel defs) in let args = Array.map (subst sb) args in @@ -766,10 +798,39 @@ sb, subst_br sb r_br ) def_brs with Not_found -> - [sb, (head, atom::r_body, r_neg_body)]) in + [sb, (head, (subst_rel sb atom)::r_body, r_neg_body)]) in + let pack_lits body neg_body = + List.map (fun a->Aux.Left a) body @ + List.map (fun a->Aux.Right a) neg_body in + let expand_neg_atom (rel, args as atom) + (sb, (head, r_body, r_neg_body)) = + (let try def_brs = freshen_brs (List.assoc rel defs) in + let args = Array.map (subst sb) args in + let def_brs = Aux.map_try + (fun (params,body,neg_body) -> + let sb = unify_args ~sb params args in + let body = List.map (subst_rel sb) body + and neg_body = List.map (subst_rel sb) neg_body in + (* do not propagate the substitution further *) + pack_lits body neg_body) + def_brs in + if def_brs = [] then + [sb, (head, r_body, r_neg_body)] + else + (* DNF of the negation of [def_brs] disjunction -- + [Left]/[Right] switch meaning *) + let dnf_of_neg = Aux.product def_brs in + List.map (fun dnf_br -> + let d_neg_body, d_body = Aux.partition_choice dnf_br in + sb, (head, d_body @ r_body, d_neg_body @ r_neg_body) + ) dnf_of_neg + with Not_found -> + [sb, (head, r_body, (subst_rel sb atom)::r_neg_body)]) in + let expand_br (head, body, neg_body) = - let init = [[], (head, [], neg_body)] in - Aux.concat_foldr expand_atom body init in + let init = [[], (head, [], [])] in + Aux.concat_foldr expand_neg_atom neg_body + (Aux.concat_foldr expand_pos_atom body init) in let rec fix n_brs brs i = let brs = Aux.concat_map expand_br brs in let new_n_brs = List.length brs in @@ -787,15 +848,18 @@ let placeholder = "", [] in let clauses = List.map (fun body -> placeholder, body) conjs in let clauses = Aux.concat_map rules_of_clause clauses in + let pos = function Distinct _ as a -> Neg a | a -> Pos a in + let neg = function Distinct _ as a -> Pos a | a -> Neg a in let clauses = List.map (fun (_,body,neg_body) -> - List.map (fun a -> Pos (atom_of_rel a)) body @ - List.map (fun a -> Neg (atom_of_rel a)) neg_body) clauses in + List.map (fun a -> pos (atom_of_rel a)) body @ + List.map (fun a -> neg (atom_of_rel a)) neg_body) clauses in let negated = Aux.product clauses in (* can raise [Not_found] in case of unsatisfiable "not distinct" *) let nclause body = let uniterms, lits = Aux.partition_map (function - | Neg (Distinct terms) -> Aux.Left (Array.to_list terms) + (* we negate! so not (Pos Distinct) here *) + | Pos (Distinct terms) -> Aux.Left (Array.to_list terms) | Neg atom -> Aux.Right (Pos atom) | Pos atom -> Aux.Right (Neg atom) | Disj _ -> assert false) body in @@ -1543,3 +1607,36 @@ List.fold_left (fun clauses (p, ts) -> expand_path_vars_by prepare_lits p ts clauses ) clauses ps_sterms + + +let blank_outside_subterm arities path subterm = + List.fold_right + (fun (rel, pos) acc -> + let subterms = Array.make (List.assoc rel arities) blank in + subterms.(pos) <- acc; + Func (rel, subterms)) + path subterm + +(** Find a path in a term and substitute, raise [Not_found] if path + not present. Push past blank subterms. [subst_at_path a p s blank] + is the same as [blank_outside_subterm a p s]. *) +let subst_past_blank arities p s t = + let rec aux = function + | [], _ -> s + | (rel1, pos)::p, Func (rel2, args) when rel1 = rel2 -> + let args = Array.copy args in + args.(pos) <- aux (p, args.(pos)); + Func (rel1, args) + | (rel, pos)::p, t when t = blank -> + let subterms = Array.make (List.assoc rel arities) blank in + subterms.(pos) <- aux (p, blank); + Func (rel, subterms) + | _ -> raise Not_found in + aux (p, t) + +let blank_outside_subterms arities path_subts = + try + List.fold_left (fun acc (p, s) -> subst_past_blank arities p s acc) + blank path_subts + with Not_found -> + invalid_arg "blank_outside_subterms: conflicting paths" Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/GGP/GDL.mli 2011-08-26 14:33:35 UTC (rev 1544) @@ -112,11 +112,15 @@ (** {3 Transformations of GDL clauses: inlining, negation.} *) -(** Expand branches of a definition inlining the provided definitions, - only expand positive literals. Iterate expansion to support - nesting of definitions. *) -val expand_positive_lits : gdl_defs -> def_branch list -> def_branch list +(** Expand branches of a definition inlining the provided + definitions. Iterate expansion to support nesting of + definitions. *) +val expand_definitions : gdl_defs -> def_branch list -> def_branch list +(** Remember that [rel_of_atom] inverts polarity of "distinct" -- + invert back after using [atom_of_rel] if needed. *) +val atom_of_rel : rel_atom -> atom + (** Form clause bodies whose disjunction is equivalent to the negation of disjunction of given clause bodies. Keep the substitution so that the heads of corresponding clauses can be @@ -154,6 +158,8 @@ val literal_str : literal -> string val clause_str : clause -> string +val topsort_callgraph : clause list -> string list -> string list + (** {3 GDL whole-game operations.} Aggregate and random playout, player-denoting variable elimination. *) @@ -235,10 +241,17 @@ val path_str : path -> string -(* [ground_vars_at_paths prepare_lits ps_sterms clauses] expands - variables that have occurrences at paths in [ps_sterms] in some - state term of a clause (from which pre-processed literals are - extracted by [prepare_lits]), by terms provided in [ps_sterms]. *) +(** [ground_vars_at_paths prepare_lits ps_sterms clauses] expands + variables that have occurrences at paths in [ps_sterms] in some + state term of a clause (from which pre-processed literals are + extracted by [prepare_lits]), by terms provided in [ps_sterms]. *) val ground_vars_at_paths : (clause -> literal list) -> (path * term list) list -> clause list -> clause list + + +val blank_outside_subterm : + (string * int) list -> path -> term -> term + +val blank_outside_subterms : + (string * int) list -> (path * term) list -> term Modified: trunk/Toss/GGP/GameSimpl.ml =================================================================== --- trunk/Toss/GGP/GameSimpl.ml 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/GGP/GameSimpl.ml 2011-08-26 14:33:35 UTC (rev 1544) @@ -99,10 +99,13 @@ used; if [keep_nonempty_predicates] is true, do not remove predicates. + Remove unused defined relations. Note that recursion loops are not + handled (i.e. mutually recursive relations are not removed). + FIXME: why some unused (non-empty) predicates end up being empty? TODO: require an explicit set of relations to keep instead of - [keep_nonempty_predicates]. + [keep_nonempty_predicates]. ??? (5) TODO: Glue redundant rules (equal and having the same roles in the game graph). @@ -479,13 +482,14 @@ Structure.add_rels struc grel tuples in (* preparing (3a-d) *) - let add_rel rel acc = + let add_rel excl rel acc = match rel with - | Rel (rel,_) -> Aux.Strings.add rel acc + | Rel (rel,_) when rel <> excl -> Aux.Strings.add rel acc | _ -> acc in + let add_rels excl = FormulaOps.fold_over_atoms (add_rel excl) in let used_rels = Arena.fold_over_formulas ~include_defined_rels:false - (FormulaOps.fold_over_atoms add_rel) + (add_rels "") game Aux.Strings.empty in let used_rels = ref used_rels in let struc = ref state.Arena.struc in @@ -829,22 +833,39 @@ (* 4 *) (* since relations relevant for LHS structures occur in the "embedding formula", we can freely remove from all structures - static relations that do not occur in any formula *) + the relations that do not occur in any formula *) let used_rels = Arena.fold_over_formulas ~include_defined_rels:false - (FormulaOps.fold_over_atoms add_rel) + (FormulaOps.fold_over_atoms (add_rels "")) game Aux.Strings.empty in + let used_in_def = + List.fold_right (fun (drel, (_, def)) -> add_rels drel def) + game.Arena.defined_rels Aux.Strings.empty in + let used_in_def, defined_rels = + let rec aux (used_in_def, defined_rels) = + let defined_rels = List.filter + (fun (r, _) -> Aux.Strings.mem r used_rels || + Aux.Strings.mem r used_in_def) + defined_rels in + let now_used_in_def = + List.fold_right (fun (drel, (_, def)) -> add_rels drel def) + defined_rels Aux.Strings.empty in + if Aux.Strings.subset used_in_def now_used_in_def + then now_used_in_def, defined_rels + else aux (now_used_in_def, defined_rels) in + aux (used_in_def, game.Arena.defined_rels) in + let used_rels = Aux.Strings.union used_in_def used_rels in + let game = {game with Arena.defined_rels = defined_rels} 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 keep_nonempty_predicates || - List.assoc rel signat > 1 || + (try List.assoc rel signat > 1 with Not_found -> false) || Structure.rel_size !struc rel = 0 ) && not (Aux.Strings.mem rel fluents) && - 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 ( Modified: trunk/Toss/GGP/TranslateFormula.ml =================================================================== --- trunk/Toss/GGP/TranslateFormula.ml 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/GGP/TranslateFormula.ml 2011-08-26 14:33:35 UTC (rev 1544) @@ -56,9 +56,7 @@ ) state_terms in other, pos_terms, neg_terms) disj -(* Whether $i$th argument is a $\mathrm{DefSide}$ or a - $\mathrm{CallSide}$, and the $p_{R,i}$ path for a relation $R$. *) -type defrel_arg_mode = (bool * path) array +type defrel_argpaths = (GDL.path * int) list list type transl_data = { f_paths : path_set; (* fluent paths *) @@ -66,7 +64,7 @@ all_paths : path_set; (* sum of f_paths and m_paths *) mask_reps : term list; (* mask terms *) defined_rels : string list; - defrel_arg_mode : (string * defrel_arg_mode) list ref; + mutable defrel_argpaths : (string * defrel_argpaths) list; (* late binding to store $ArgMode# data *) term_arities : (string * int) list; rel_default_path : (string * path option array) list; @@ -78,7 +76,7 @@ all_paths = empty_path_set; mask_reps = []; defined_rels = []; - defrel_arg_mode = ref []; + defrel_argpaths = []; term_arities = []; rel_default_path = []; } @@ -89,25 +87,34 @@ let var_of_term data t = Formula.fo_var_of_string (term_to_name (blank_out data t)) -let blank_outside_subterm data path subterm = - let arities = data.term_arities in - List.fold_right - (fun (rel, pos) acc -> - let subterms = Array.make (List.assoc rel arities) blank in - subterms.(pos) <- acc; - Func (rel, subterms)) - path subterm - let var_of_subterm data path subt = Formula.fo_var_of_string - (term_to_name (blank_outside_subterm data path subt)) + (term_to_name (blank_outside_subterm data.term_arities path subt)) -(* placeholder *) -let translate_defrel = - ref (fun data sterms_all sterms_in s_subterms sign rel args -> - assert false) +let var_of_subterms data path_subts = + Formula.fo_var_of_string + (term_to_name (blank_outside_subterms data.term_arities path_subts)) -let transl_rels data rels_phi sterms_all sterms_in = + +let find_defrel_arg sterms args apset = + List.find + (fun s -> List.for_all (fun (p,i) -> at_path s p = args.(i)) apset) + sterms + +let translate_defrel data sterms sign rel args = + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "translate_defrel: phi=%s, sign=%b\n" + (rel_atom_str (rel, args)) sign + ); + (* }}} *) + let partition = List.assoc rel data.defrel_argpaths in + let s_l = List.map (find_defrel_arg sterms args) partition in + let vtup = Array.of_list (List.map (var_of_term data) s_l) in + let defrel_phi = Formula.Rel (rel, vtup) in + if sign then defrel_phi else Formula.Not defrel_phi + +let transl_rels data rels_phi sterms_all vterms_in = (* within-mask subterms to locate paths on which to generate relations *) let s_subterms = Aux.concat_map (fun sterm -> @@ -132,7 +139,8 @@ let stuples = Aux.product stuples in let stuples = List.filter (fun stup -> - List.exists (fun (sterm,_) -> List.mem sterm sterms_in) stup) + List.exists (fun (sterm,_) -> + List.mem (var_of_term data sterm) vterms_in) stup) stuples in let atoms = Aux.map_some (fun stup -> @@ -151,8 +159,7 @@ let transl_posdefrel sign rel args = if List.mem rel data.defined_rels then - [!translate_defrel data sterms_all sterms_in - s_subterms sign rel args] + [translate_defrel data sterms_all sign rel args] else transl_rel sign rel args in let rec aux = function | Pos (Rel (rel, args)) -> transl_posdefrel true rel args @@ -263,7 +270,7 @@ neg_ext @ [ (* positive because they form a "premise" *) - transl_rels data rels_eqs all_terms neg_terms; + transl_rels data rels_eqs all_terms neg_vars; (* the universal "conclusion" *) negated_neg_state_transl]) in let universal_part = @@ -275,7 +282,7 @@ let base_part = Formula.And ( pos_ext @ - [ transl_rels data rels_eqs pos_terms pos_terms; + [ transl_rels data rels_eqs pos_terms pos_vars; transl_state data pos_state_phi] @ universal_part) in if pos_vars = [] then base_part @@ -294,187 +301,173 @@ (* **************************************** *) (* {3 Build and use defined relations.} *) -let select_defrel_argpaths data all_branches = - (* TODO: code-review this and [build_defrel] functions *) - let select_for_defrel rel = - (* searching for ArgMode = DefSide,S,p *) - let branches = Aux.assoc_all rel all_branches in - (* {{{ log entry *) - if !debug_level > 2 then ( - Printf.printf "select_defrel_argpaths: rel=%s, no of brs=%d\n%!" - rel (List.length branches) - ); - (* }}} *) - (* first find the common paths, we will find the state terms later *) - let branch_paths = - List.map (fun (args, (_, sterms_pos, sterms_neg)) -> - let sterms = state_terms (sterms_pos @ sterms_neg) in - Array.map (fun arg -> - Aux.concat_map (fun sterm -> - Aux.map_some (fun x->x) - (map_paths (fun p subt -> - if subt = arg then Some p else None) data.m_paths sterm) - ) sterms) args - ) branches in - let p_defside = List.fold_left - (Aux.array_map2 Aux.list_inter) - (List.hd branch_paths) (List.tl branch_paths) in - let p_defside = Array.map - (function path::_ -> Some path | [] -> None) p_defside in - (* now find the mapping $\calS_i$ for the DefSide result *) - let branch_sterms (args, (_, sterms_pos, sterms_neg)) = - let sterms = state_terms (sterms_pos @ sterms_neg) in - Aux.array_map2 - (fun arg -> function None -> None - | Some path -> - Some (List.find (fun sterm -> - List.mem (Some path) - (map_paths (fun p subt -> - if subt = arg then Some p else None) data.m_paths sterm) - ) sterms)) - args p_defside in - let s_defside = List.map branch_sterms branches in - (* now computing the ArgMode(R,i) = CallSide,p variant *) - let call_branches = Aux.concat_map - (fun (_,(_, (phi, _, _ as body))) -> - let calls = Aux.assoc_all rel (rel_atoms phi) in - List.map (fun args -> args, body) calls - ) all_branches in - let callside_for_arg i = - let call_paths = Aux.concat_map - (fun (args, (_, sterms_pos, sterms_neg)) -> - let sterms = state_terms (sterms_pos @ sterms_neg) - and arg = args.(i) in - let paths = Aux.concat_map (fun sterm -> - Aux.map_some (fun x->x) - (map_paths (fun p subt -> - if subt = arg then Some p else None) data.m_paths sterm) - ) sterms in - List.map (fun p -> p, ()) paths - ) call_branches in - let call_paths = List.map - (fun (p, ns) -> List.length ns, p) - (Aux.collect call_paths) in - (* decreasing order *) - match List.sort (fun (x,_) (y,_) -> y-x) call_paths with - | [] -> None - | (_,p)::_ -> Some p in - let p_callside = Array.mapi - (fun i -> - function Some _ -> None | None -> callside_for_arg i) - p_defside in - let arg_paths = Array.mapi - (fun i defside -> - let callside = p_callside.(i) in - match defside, callside with - | Some p, _ | None, Some p -> p - | None, None -> - (* the ArgMode(R,i) = NoSide,p variant is precomputed *) - try - match (List.assoc rel data.rel_default_path).(i) with - | Some p -> p - | None -> raise Not_found - with Not_found -> - failwith - (Printf.sprintf - "TranslateFormula.build_defrels: could not \ - determine path for relation %s argument %d" rel i) - ) p_defside in - let defrel_arg_mode = Aux.array_map2 - (fun defside path -> defside <> None, path) - p_defside arg_paths in - data.defrel_arg_mode := - (rel, defrel_arg_mode) :: !(data.defrel_arg_mode); - rel, (p_defside, s_defside, arg_paths) in - List.map select_for_defrel data.defined_rels - - -let build_defrels data clauses = - let all_branches = Aux.concat_map - (fun ((rel,args),body) -> - List.map (fun phi -> rel, (args, phi)) (separate_disj [body])) +let select_defrel_argpaths drel data clauses = + let atoms_sterms = List.map + (fun ((rel,args), body) -> + let r_atoms = if rel = drel then [args] else [] in + let r_atoms = r_atoms @ Aux.map_some + (function Rel (rel, args) when rel = drel -> Some args + | _ -> None) + (atoms_of_body body) in + r_atoms, state_terms body + (* we take all state terms to have more compact partition *) + (*Aux.map_some + (function Pos (True s) -> Some s | _ -> None) body*)) clauses in - let sel_argpaths = select_defrel_argpaths data all_branches in - let build_defrel rel = - (* now building the translation *) - let (p_defside, s_defside, arg_paths) = - List.assoc rel sel_argpaths in - let defvars = - Array.mapi (fun i _ -> "v"^string_of_int i) arg_paths in - let defbody (args,(rels_phi,pos_state,neg_state)) s_defside = - let arg_eqs = Array.mapi (* $E_{j,l}$ *) - (fun i v -> - let v = Formula.fo_var_of_string v in - let in_I = p_defside.(i) <> None in - if in_I - then - let s_i = match s_defside.(i) with - | Some s -> var_of_term data s - | None -> assert false in - Formula.Eq (v, s_i) - else Formula.Eq (v, var_of_subterm data arg_paths.(i) args.(i))) - defvars in - let arg_eqs = Array.to_list arg_eqs in - let callside_sterms = (* $S_{j,l}$ *) - Aux.array_mapi_some - (fun i path -> - if p_defside.(i) <> None then None (* only for not in I *) - else Some (blank_outside_subterm data path args.(i))) - arg_paths in - (* packing sterms back as a formula *) - let callside_sterms = Array.to_list - (Array.map (fun sterm -> Pos (True sterm)) callside_sterms) in - transl_disjunct data rels_phi - (callside_sterms @ pos_state) neg_state arg_eqs in - let branches = Aux.assoc_all rel all_branches in - let def_disjuncts = List.map2 defbody branches s_defside in - rel, (Array.to_list defvars, Formula.Or def_disjuncts) in - List.map build_defrel data.defined_rels + let check_path args p s_p = + let inds = Aux.array_argfind_all (fun r -> r=s_p) args in + List.map (fun i->p,i) inds in + let sterm_path_sets args s = + let ptups = Aux.product + (map_paths (check_path args) data.m_paths s) in + (* distinct [p] in a tuple is already ensured *) + List.filter (fun tup -> + not (Aux.not_unique (List.map snd tup))) ptups in + let argpath_sets = Aux.concat_map + (fun (atoms, sterms) -> Aux.concat_map + (fun args -> Aux.concat_map (sterm_path_sets args) sterms) + atoms) + atoms_sterms in + let argpath_sets = + Aux.map_reduce (fun pset -> pset, 1) (+) 0 argpath_sets in + let argpath_sets = List.sort Pervasives.compare + (List.map (* lexicographic comparison *) + (fun (pset,count) -> List.length pset, count, pset) + argpath_sets) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "select_defrel_argpaths: drel=%s; argpath_sets=\n%!" drel; + List.iter (fun (len, count, pset) -> + Printf.printf "len=%d; count=%d; pset=%s\n%!" len count + (String.concat ", " + (List.map (fun (p,i)->path_str p^": "^string_of_int i) pset))) + argpath_sets + ); + (* }}} *) + let argpath_sets = List.map Aux.trd3 (List.rev argpath_sets) in + (* now greedily -- by traversing the ordering -- select covering *) + let apsets_cover = List.fold_left + (fun cover apset -> + if List.exists + (fun (_,i) -> not (List.exists (fun cov_apset -> + List.exists (fun (_,j)->i=j) cov_apset) cover)) apset + then apset::cover else cover) + [] argpath_sets in + (* eliminating multiple points -- starting with best apsets so + they're unchanged *) + let partition = List.fold_left + (fun partition apset -> + let apset = List.filter (fun (_,i) -> + not (List.exists (fun cov_apset -> + List.exists (fun (_,j)->i=j) cov_apset) partition)) apset in + if apset = [] then partition else apset::partition) + [] apsets_cover in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "select_defrel_argpaths: drel=%s; partition=\n%!" drel; + List.iter (fun pset -> + Printf.printf "pset=%s\n%!" + (String.concat ", " + (List.map (fun (p,i)->path_str p^": "^string_of_int i) pset))) + partition + ); + (* }}} *) + (* filling-in missing paths from precomputed defaults *) + let arity = Array.length + (List.hd (fst (List.find (fun (atoms,_) -> atoms<>[]) + atoms_sterms))) in + let argpaths = Array.init arity + (fun i -> + try List.find (List.exists (fun (_,j)->i=j)) partition + with Not_found -> + try + match (List.assoc drel data.rel_default_path).(i) with + | Some p -> [p, i] + | None -> raise Not_found + with Not_found -> + failwith + (Printf.sprintf + "TranslateFormula.build_defrels: could not \ + determine path for relation %s argument %d" drel i) + ) in + let res = Aux.unique (=) (Array.to_list argpaths) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "select_defrel_argpaths: drel=%s; result=\n%!" drel; + List.iter (fun pset -> + Printf.printf "pset=%s\n%!" + (String.concat ", " + (List.map (fun (p,i)->path_str p^": "^string_of_int i) pset))) + res + ); + (* }}} *) + res -let transl_defrel data sterms_all sterms_in s_subterms sign rel args = +let defrel_transform drel partition data ((h_rel,h_args as h),body as cl) = + (* adding "true" atoms to clauses for missing argpath state terms *) + let r_atoms = if h_rel = drel then [h_args] else [] in + let r_atoms = r_atoms @ Aux.map_some + (function Rel (rel, args) when rel = drel -> Some args + | _ -> None) + (atoms_of_body body) in + let sterms = Aux.map_some + (function Pos (True s) -> Some s | _ -> None) body in + let sterm_arg_for_atom args apset = + try ignore (find_defrel_arg sterms args apset); None + with Not_found -> + let path_subts = List.map (fun (p,i)->p, args.(i)) apset in + Some (blank_outside_subterms data.term_arities path_subts) in + let add_sterms = Aux.concat_map + (fun args -> Aux.map_some (sterm_arg_for_atom args) partition) + r_atoms in (* {{{ log entry *) - if !debug_level > 2 then ( - Printf.printf "transl_defrel: phi=%s, sign=%b\n" - (rel_atom_str (rel, args)) sign + if !debug_level > 2 && add_sterms <> [] then ( + Printf.printf + "defrel_transform: add_sterms=%s; clause=\n%s\n\n%!" + (String.concat ", " (List.map term_str add_sterms)) + (clause_str cl) ); (* }}} *) - let arg_mode = List.assoc rel !(data.defrel_arg_mode) in - (* the $s \tpos_{p_{R,i}} = t_i$ state terms *) - let arg_sterms = Array.mapi - (fun i (defside, path) -> if defside then None else - try Some ( - List.find (fun s -> at_path s path = args.(i)) sterms_all) - with Not_found -> None) - arg_mode in - let var_args = Array.mapi - (fun i (_, path) -> - match arg_sterms.(i) with - | None -> var_of_subterm data path args.(i) (* in J *) - | Some sterm -> var_of_term data sterm) - arg_mode in - let defrel_phi = Formula.Rel (rel, var_args) in - let defrel_phi = - if sign then defrel_phi else Formula.Not defrel_phi in - let ex_vars = Array.to_list - (Aux.array_mapi_some (fun i (_,path) -> - if arg_sterms.(i) = None - then Some (var_of_subterm data path args.(i)) - else None) arg_mode) in - let in_J_eq_transl i (_,path) = - if arg_sterms.(i) = None - then - let eq_phi = [Pos (Rel ("EQ_", [|args.(i); args.(i)|]))] in - let v = blank_outside_subterm data path args.(i) in - Some (transl_rels data eq_phi (v::sterms_all) [v]) - else None in - let eqs_phi = Array.to_list - (Aux.array_mapi_some in_J_eq_transl arg_mode) in - let base = - if eqs_phi = [] then defrel_phi - else Formula.And (defrel_phi::eqs_phi) in - if ex_vars = [] then base - else Formula.Ex ((ex_vars :> Formula.var list), base) + h, Aux.map_rev_prepend body (fun s -> Pos (True s)) add_sterms -let _ = translate_defrel := transl_defrel +let build_defrels data clauses = + let defined_rels_ord = + topsort_callgraph clauses data.defined_rels in + let process_drel clauses drel = + let partition = + select_defrel_argpaths drel data clauses in + data.defrel_argpaths <- (drel, partition)::data.defrel_argpaths; + List.map (defrel_transform drel partition data) clauses in + (* first arguments processed first -- fold_left *) + let clauses = List.fold_left process_drel clauses defined_rels_ord in + let build_defrel drel = + (* now building the translation *) + let partition = List.assoc drel data.defrel_argpaths in + let r_clauses = Aux.map_some + (fun ((rel,args),body) -> + if rel=drel then Some (args,body) else None) clauses in + let d_arity = List.length partition in + let defvars = + Array.init d_arity (fun i -> "v"^string_of_int i) in + let tr_def_r (args, body) = + let sterms = Aux.map_some + (function Pos (True s) -> Some s | _ -> None) body in + let s_l = List.map (find_defrel_arg sterms args) partition in + let v_l = List.map (var_of_term data) s_l in + let eqs = List.map2 + (fun v sv -> Formula.Eq (`FO v, sv)) + (Array.to_list defvars) v_l in + let def_phi = FormulaOps.del_vars_quant (v_l :> Formula.var list) + (translate data [body]) in + if v_l = [] then Formula.And (eqs @ [def_phi]) + else Formula.Ex ((v_l :> Formula.var list), + Formula.And (eqs @ [def_phi])) in + drel, (Array.to_list defvars, + Formula.Or (List.map tr_def_r r_clauses)) in + clauses, List.map build_defrel defined_rels_ord + Modified: trunk/Toss/GGP/TranslateFormula.mli =================================================================== --- trunk/Toss/GGP/TranslateFormula.mli 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/GGP/TranslateFormula.mli 2011-08-26 14:33:35 UTC (rev 1544) @@ -1,8 +1,6 @@ val debug_level : int ref -(* Whether $i$th argument is a $\mathrm{DefSide}$ or a - $\mathrm{CallSide}$, and the $p_{R,i}$ path for a relation $R$. *) -type defrel_arg_mode = (bool * GDL.path) array +type defrel_argpaths = (GDL.path * int) list list type transl_data = { f_paths : GDL.path_set; (** fluent paths *) @@ -10,8 +8,8 @@ all_paths : GDL.path_set; (** sum of f_paths and m_paths *) mask_reps : GDL.term list; (** mask terms *) defined_rels : string list; - defrel_arg_mode : (string * defrel_arg_mode) list ref; - (** late binding to store $ArgMode$ data *) + mutable defrel_argpaths : (string * defrel_argpaths) list; + (** late binding to store argument paths data *) term_arities : (string * int) list; rel_default_path : (string * GDL.path option array) list; } @@ -31,4 +29,4 @@ val build_defrels : transl_data -> GDL.clause list -> - (string * (string list * Formula.formula)) list + GDL.clause list * (string * (string list * Formula.formula)) list Modified: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-26 14:33:35 UTC (rev 1544) @@ -66,7 +66,7 @@ all_paths = all_paths; mask_reps = mask_reps; defined_rels = defined_rels; - defrel_arg_mode = ref []; + defrel_argpaths = []; term_arities = term_arities; rel_default_path = rel_default_path; } @@ -153,15 +153,16 @@ GDL.ground_vars_at_paths prepare_lits ground_at_f_paths clauses in let defined_rels, clauses = GDL.elim_ground_args transl_data.defined_rels clauses in + let transl_data = {transl_data with defined_rels = defined_rels} in + let clauses, defined_rels = + TranslateFormula.build_defrels transl_data clauses in (* {{{ log entry *) if !TranslateFormula.debug_level > 2 then ( - Printf.printf "defined relations connect5: clauses =\n%s\n%!" + Printf.printf + "defined relations connect5: transformed clauses =\n%s\n%!" (String.concat "\n" (List.map GDL.clause_str clauses)) ); (* }}} *) - let transl_data = {transl_data with defined_rels = defined_rels} in - let defined_rels = - TranslateFormula.build_defrels transl_data clauses in let result drel = let args, body = List.assoc drel defined_rels in drel^"("^String.concat ", " args^ @@ -169,38 +170,7 @@ assert_equal ~msg:"adjacent_cell defined relation translation" ~printer:(fun x->x) - "adjacent_cell(v0, v1, v2, v3) = ex cell_x__BLANK___BLANK_, cell_y__BLANK___BLANK_, cell_x1__BLANK___BLANK_, - cell_y1__BLANK___BLANK_ - (cell__BLANK___BLANK___BLANK_(cell_x__BLANK___BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_y__BLANK___BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_x1__BLANK___BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_y1__BLANK___BLANK_) and - adjacent__cell_0__cell_0(cell_x__BLANK___BLANK_, - cell_x1__BLANK___BLANK_) and - adjacent__cell_0__cell_0(cell_y__BLANK___BLANK_, - cell_y1__BLANK___BLANK_) and v0 = cell_x__BLANK___BLANK_ and - v1 = cell_y__BLANK___BLANK_ and v2 = cell_x1__BLANK___BLANK_ and - v3 = cell_y1__BLANK___BLANK_) or - ex cell_x__BLANK___BLANK_, cell_y__BLANK___BLANK_, cell_x1__BLANK___BLANK_, - cell_y__BLANK___BLANK_ - (cell__BLANK___BLANK___BLANK_(cell_x__BLANK___BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_x1__BLANK___BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_y__BLANK___BLANK_) and - adjacent__cell_0__cell_0(cell_x__BLANK___BLANK_, - cell_x1__BLANK___BLANK_) and - coordinate__cell_0(cell_y__BLANK___BLANK_) and - v0 = cell_x__BLANK___BLANK_ and v1 = cell_y__BLANK___BLANK_ and - v2 = cell_x1__BLANK___BLANK_ and v3 = cell_y__BLANK___BLANK_) or - ex cell_x__BLANK___BLANK_, cell_y__BLANK___BLANK_, cell_x__BLANK___BLANK_, - cell_y1__BLANK___BLANK_ - (cell__BLANK___BLANK___BLANK_(cell_y__BLANK___BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_x__BLANK___BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_y1__BLANK___BLANK_) and - adjacent__cell_0__cell_0(cell_y__BLANK___BLANK_, - cell_y1__BLANK___BLANK_) and - coordinate__cell_0(cell_x__BLANK___BLANK_) and - v0 = cell_x__BLANK___BLANK_ and v1 = cell_y__BLANK___BLANK_ and - v2 = cell_x__BLANK___BLANK_ and v3 = cell_y1__BLANK___BLANK_)" + "adjacent_cell(v0, v1) =" (result "adjacent_cell"); assert_equal ~msg:"conn5__o defined relation translation" ~printer:(fun x->x) Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-26 14:33:35 UTC (rev 1544) @@ -185,7 +185,7 @@ (* it should actually be a single element association *) let brs_c = List.assoc "next" (defs_of_rules (rules_of_clause c)) in - c, expand_positive_lits inline_defs brs_c) next_clauses in + c, expand_definitions inline_defs brs_c) next_clauses in (* {{{ log entry *) if !debug_level > 2 then ( let next_exp = Aux.concat_map snd next_e in @@ -302,7 +302,6 @@ (String.concat ", " (List.map term_str element_reps)) ); (* }}} *) - let m_paths = List.map (term_paths ~prefix_only:true (Aux.neg contains_blank)) element_reps in let m_paths = @@ -340,6 +339,20 @@ static_rels in let struc_rels = "EQ_"::struc_rels in let defined_rels = defined_rels @ nonstatic_rels in + let defs = List.filter + (fun ((rel,_),_) -> List.mem rel defined_rels) clauses in + let defs = defs_of_rules (Aux.concat_map rules_of_clause defs) in + let frame_defs = List.assoc "next" + (defs_of_rules (Aux.concat_map rules_of_clause frame_clauses)) in + let frame_defs = expand_definitions defs frame_defs in + let pos = function Distinct _ as a -> Neg a | a -> Pos a in + let neg = function Distinct _ as a -> Pos a | a -> Neg a in + let frame_clauses = List.map + (fun (args, body, neg_body) -> + ("next", args), + List.map (fun a->pos (atom_of_rel a)) body @ + List.map (fun a->neg (atom_of_rel a)) neg_body) + frame_defs in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf @@ -421,6 +434,7 @@ List.filter (fun ((rel,_),_) -> rel <> "next") clauses in let frame_clauses = List.map (fun ((_,args),body) -> ("frame next", args), body) frame_clauses in + players, rules, frame_clauses @ move_clauses @ clauses, f_paths, m_paths, mask_reps, defined_rels, @@ -672,13 +686,25 @@ List.map (fun ((_,h),body) -> h.(0),false,body) erasure_cls in (* {{{ log entry *) if !debug_level > 2 then ( - Printf.printf "add_erasure_clauses: erasure clauses --\n%!"; + Printf.printf "add_erasure_clauses: all erasure clauses --\n%!"; let print_erasure (s, _, body) = Printf.printf "ERASURE: %s <== %s\n%!" (term_str s) (String.concat " " (List.map literal_str body)) in List.iter print_erasure erasure_cls; flush stdout; ); (* }}} *) + let erasure_cls = Aux.maximal + (fun (h1,_,b1) (h2,_,b2) -> h1=h2 && Aux.list_diff b2 b1 = []) + erasure_cls in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "add_erasure_clauses: minimal erasure clauses --\n%!"; + let print_erasure (s, _, body) = + Printf.printf "ERASURE: %s <== %s\n%!" (term_str s) + (String.concat " " (List.map literal_str body)) in + List.iter print_erasure erasure_cls; flush stdout; + ); + (* }}} *) let next_cls = Aux.map_some (fun (s, (frame, required), body) -> if not frame then Some (s, required, body) else None) next_cls in @@ -715,19 +741,32 @@ excluded. If this poses problems we might need to expand disjunctions containing potentially case-split atoms. + TODO: (important) filter-out case-split atoms based on conjoining + them with deterministic literals of required clauses (and checking + on the suite of random playout states). *) -let rule_cases rule_cls = +let rule_cases program playout_states rule_cls = let required_cls = Aux.map_some (fun (h, required, body) -> if required then Some (h, body) else None) rule_cls in + let required_body = Aux.concat_map snd required_cls in let unrequired_cls = Aux.map_some (fun (h, required, body) -> if not required then Some (h, body) else None) rule_cls in + let unrequired_cls = List.filter + (fun (_, unreq_body) -> + List.exists + (fun state -> + run_prolog_check_goal (required_body @ unreq_body) + (replace_rel_in_program "true" (state_cls state) program)) + playout_states) + unrequired_cls in let forbidden_lits = Aux.unique_sorted (Aux.concat_map (fun (_, body) -> Aux.map_some (function - | Pos (Rel _ as a) | Pos (True _ as a) -> Some (Neg a) - | Neg (Rel _ as a) | Neg (True _ as a) -> Some (Pos a) + | Pos (Does _) | Neg (Does _) -> None + | Pos a -> Some (Neg a) + | Neg a -> Some (Pos a) | _ -> None) body) required_cls) in let unrequired_cls = List.filter (fun (_, body) -> @@ -740,8 +779,8 @@ let unreq_atoms = Aux.unique_sorted (Aux.concat_map (fun (_, body) -> Aux.map_some (function - | Pos (Rel _ as a) | Pos (True _ as a) - | Neg (Rel _ as a) | Neg (True _ as a) -> Some a + | Pos (Does _) | Neg (Does _) -> None + | Pos a | Neg a -> Some a | _ -> None) body) unrequired_cls) in let split_atoms = Aux.list_diff unreq_atoms req_atoms in if split_atoms = [] then (* single partition *) @@ -777,7 +816,14 @@ Printf.printf "%a: %s\n%!" (Aux.array_fprint (fun ch -> Printf.fprintf ch "%+d")) pattern (String.concat " " (List.map atom_str atoms)) in - List.iter print_pat patterns + List.iter print_pat patterns; + let print_cl i (h, body) = + Printf.printf "%d: %s <== %s\n%!" i (term_str h) + (String.concat " " (List.map literal_str body)) in + Printf.printf "rule_cases: required cls --\n%!"; + Array.iteri print_cl (Array.of_list required_cls); + Printf.printf "rule_cases: split on cls --\n%!"; + Array.iteri print_cl (Array.of_list unrequired_cls) ); (* }}} *) let choices = Aux.power split_atoms [false; true] in @@ -795,11 +841,22 @@ ) unrequired_cls in let case_cls = case_cls @ required_cls in let case_rhs, case_conds = List.split case_cls in - let case_rhs = Aux.list_remove ignore_rhs case_rhs in - Aux.unique_sorted case_rhs, - Aux.unique_sorted (separation_cond @ List.concat case_conds) in + let case_rhs = + Aux.list_remove ignore_rhs (Aux.unique_sorted case_rhs) in + let case_conds = + Aux.unique_sorted (List.concat case_conds) in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "\nRCAND:\nsep_cond: %s\nRHS: %s\ncase_conds: %s\n\n%!" + (String.concat " " (List.map literal_str separation_cond)) + (String.concat " " (List.map term_str case_rhs)) + (String.concat " " (List.map literal_str case_conds)) + ); + (* }}} *) + case_rhs, + Aux.unique_sorted (separation_cond @ case_conds) in let res = List.map rule_case choices in - (* {{{ log entry *) + (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "rule_cases: next clauses partitioned into rules\n%!"; let print_case i (case_rhs, case_cond) = @@ -808,7 +865,7 @@ (String.concat " " (List.map literal_str case_cond)) in Array.iteri print_case (Array.of_list res) ); - (* }}} *) + (* }}} *) res @@ -838,16 +895,17 @@ List.map (add_erasure_clauses f_paths) move_tups -let add_legal_cond (legal_tup, next_cls) = +let add_legal_cond program playout_states (legal_tup, next_cls) = let legal_tup, legal_conds = List.split legal_tup in let legal_cls = List.map (* required clauses *) (fun body -> ignore_rhs, true, body) legal_conds in List.map (fun (case_rhs, case_cond) -> legal_tup, case_rhs, case_cond) - (rule_cases (legal_cls @ next_cls)) + (rule_cases program playout_states (legal_cls @ next_cls)) -let turnbased_rule_cases loc_noops used_vars f_paths next_cls +let turnbased_rule_cases loc_noops used_vars f_paths + program playout_states next_cls players legal_by_player = let legal_tuples = Aux.product legal_by_player in (* remove tuples with multiple players making moves @@ -874,14 +932,16 @@ let move_tups = process_rule_cands used_vars f_paths next_cls `General players legal_tuples in - let rules = Aux.concat_map add_legal_cond move_tups in + let rules = Aux.concat_map + (add_legal_cond program playout_states) move_tups in (* we do not look for the players -- for turn-based case, it's done while building game graph *) Aux.Left rules (* If "Concurrent Moves" case, divide rule clauses among players. *) -let concurrent_rule_cases used_vars f_paths next_cls players legal_by_player = +let concurrent_rule_cases used_vars f_paths program playout_states + next_cls players legal_by_player = let env_pl_tups = env_player, process_rule_cands used_vars f_paths next_cls `Environment [] [[]] in @@ -896,11 +956,12 @@ ) players legal_by_player in let player_rules = List.map (fun (player, move_tups) -> - player, Aux.concat_map add_legal_cond move_tups) + player, Aux.concat_map (add_legal_cond program playout_states) move_tups) (player_rules @ [env_pl_tups]) in Aux.Right player_rules -let general_int_rule_cases used_vars f_paths next_cls players legal_by_player = +let general_int_rule_cases used_vars f_paths program playout_states + next_cls players legal_by_player = failwith "General Interaction Games not implemented yet" @@ -914,7 +975,8 @@ are built. The rules are partitioned among players. The last player is the environment, [env_player] (this way, the numbering of players can be the same as in turn-based case). *) -let create_rule_cands is_turn_based used_vars f_paths next_cls clauses = +let create_rule_cands is_turn_based used_vars f_paths + program playout_states next_cls clauses = let players = (* Array.of_list *) Aux.map_some (function | ("role", [|player|]), _ -> Some player @@ -945,14 +1007,17 @@ ) players in let result = if is_concurrent then - concurrent_rule_cases used_vars f_paths next_cls players legal_by_player + concurrent_rule_cases used_vars f_paths program playout_states + next_cls players legal_by_player else match is_turn_based with | Some (_, loc_noops) -> - turnbased_rule_cases loc_noops used_vars f_paths next_cls + turnbased_rule_cases loc_noops used_vars f_paths + program playout_states next_cls players legal_by_player | None -> - general_int_rule_cases used_vars f_paths next_cls + general_int_rule_cases used_vars f_paths + program playout_states next_cls players legal_by_player in (* {{{ log entry *) @@ -975,34 +1040,17 @@ (* We use a bunch of possible game states, generated by random playouts, to approximate which rule candidates are satisfiable in - some reachable state. *) -let filter_rule_cands players program rule_cands = - (* {{{ log entry *) - if !debug_level > 1 then ( - Printf.printf "filter_rule_cands: generating states...\n%!"; - (* GDL.debug_level := 4; *) - ); - (* }}} *) - let states = Aux.fold_n - (fun acc -> - let _, states = - playout_prolog ~aggregate:false players !playout_horizon - program in - states @ acc) [] !playouts_for_rule_filtering in - (* {{{ log entry *) - if !debug_level > 1 then ( - (* GDL.debug_level := 0; *) - Printf.printf "filter_rule_cands: generated %d states.\n%!" - (List.length states) - ); - (* }}} *) + some reachable state. After filtering, we add blanked-out RHS + terms as "true" atoms (so they are properly constrained and treated + existentially). *) +let filter_rule_cands players f_paths program playout_states rule_cands = let check_cands cands = List.filter (fun (_, _, case_conds) -> let res = List.exists (fun state -> run_prolog_check_goal case_conds (replace_rel_in_program "true" (state_cls state) program)) - states in + playout_states in (* {{{ log entry *) if !debug_level > 1 then ( Printf.printf "check_cands: cond %s -- %b\n%!" @@ -1011,10 +1059,15 @@ (* }}} *) res ) cands in + let add_rhs_as_lhs (legal_tup, case_rhs, case_cond) = + let case_blanks = List.map + (fun s -> Pos (True (simult_subst f_paths blank s))) case_rhs in + legal_tup, case_rhs, Aux.unique_sorted (case_blanks @ case_cond) in + let process cands = List.map add_rhs_as_lhs (check_cands cands) in match rule_cands with - | Aux.Left cands -> Aux.Left (check_cands cands) + | Aux.Left cands -> Aux.Left (process cands) | Aux.Right cands -> - Aux.Right (List.map (fun (p,cands) -> p, check_cands cands) cands) + Aux.Right (List.map (fun (p,cands) -> p, process cands) cands) exception Not_turn_based @@ -1422,7 +1475,64 @@ intersects ) defined_rels +(* Representing rule candidates as (rule) clauses. *) +let encode_rule_cands_in_clauses rule_cands clauses = + let rule_cl_i = ref 0 in + let more_cls = ref [] in + let proc_cand (legal_tup, rhs_tup, cond) = + let i = !rule_cl_i in + incr rule_cl_i; + more_cls := (("rule clause", [|Const (string_of_int i)|]), cond):: + !more_cls; + legal_tup, rhs_tup, i in + let rule_cands = + match rule_cands with + | Aux.Left cands -> Aux.Left (List.map proc_cand cands) + | Aux.Right cands -> Aux.Right + (List.map (fun (p,cands) -> p, List.map proc_cand cands) + cands) in + rule_cands, !more_cls @ clauses + +let decode_rule_cands_of_clauses rule_cands clauses = + let rule_cls, clauses = Aux.partition_map + (function + | ("rule clause", [|Const i|]), cond -> + Aux.Left (int_of_string i, cond) + | cl -> Aux.Right cl) + clauses in + let proc_cand (legal_tup, rhs_tup, cond_i) = + legal_tup, rhs_tup, List.assoc cond_i rule_cls in + let rule_cands = + match rule_cands with + | Aux.Left cands -> Aux.Left (List.map proc_cand cands) + | Aux.Right cands -> Aux.Right + (List.map (fun (p,cands) -> p, List.map proc_cand cands) + cands) in + rule_cands, clauses + +let generate_playout_states program players = + (* {{{ log entry *) + if !debug_level > 1 then ( + Printf.printf "translate_game: generating states...\n%!"; + (* GDL.debug_level := 4; *) + ); + (* }}} *) + let states = Aux.fold_n + (fun acc -> + let _, states = + playout_prolog ~aggregate:false players !playout_horizon + program in + states @ acc) [] !playouts_for_rule_filtering in + (* {{{ log entry *) + if !debug_level > 1 then ( + (* GDL.debug_level := 0; *) + Printf.printf "translate_game: generated %d states.\n%!" + (List.length states) + ); + (* }}} *) + states + (* [playing_as] is only used for building move translation data, the translation is independent of the selected player. *) let translate_game ~playing_as clauses = @@ -1462,13 +1572,16 @@ (List.map (fun ((rel,args),body as cl)-> if rel = "frame next" then ("next", args), body else cl) clauses) in + let playout_states = generate_playout_states program players in let turn_data = try Some (check_turn_based players program) with Not_turn_based -> None in let rule_cands, is_concurrent = - create_rule_cands turn_data used_vars f_paths next_cls clauses in + create_rule_cands turn_data used_vars f_paths + program playout_states next_cls clauses in let rule_cands = - filter_rule_cands players program rule_cands in + filter_rule_cands players f_paths program playout_states rule_cands in + let term_arities = Aux.unique_sorted (Aux.concat_map term_arities ground_state_terms) in let defined_rel_arities = List.map @@ -1482,13 +1595,24 @@ all_paths = paths_union f_paths m_paths; mask_reps = mask_reps; defined_rels = defined_rels; - defrel_arg_mode = ref []; (* built in TranslateFormula *) + defrel_argpaths = []; (* built in TranslateFormula *) term_arities = term_arities; rel_default_path = transl_arg_type_no_side defined_rel_arities init_state program (ground_at m_paths); } in - let defined_rels = TranslateFormula.build_defrels transl_data clauses in + (* Building defined rels needs to happen between creating rule + candidates and rule translation, so that transformed clauses don't + affect the GDL-side of construction, but are ready for + precondition formula translation. *) + (* Transform the rule conditions as well so they can be translated. *) + let rule_cands, clauses = + encode_rule_cands_in_clauses rule_cands clauses in + let clauses, defined_rels = + TranslateFormula.build_defrels transl_data clauses in + let rule_cands, clauses = + decode_rule_cands_of_clauses rule_cands clauses in + let player_names = Array.to_list (Array.mapi (fun i p -> term_to_name p, i) players) in (* possibly update the structure with a control element and predicate *) Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-21 10:27:37 UTC (rev 1543) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-26 14:33:35 UTC (rev 1544) @@ -177,17 +177,17 @@ (fun () -> game_test_case ~game_name:"breakthrough" ~player:"white" ~own_plnum:0 ~opponent_plnum:1 - ~loc0_rule_name:"move_x239_y257_x238_y256_0" + ~loc0_rule_name:"move_x2_y3_x3_y4_noop" ~loc0_emb:[ - "cellholds_x239_y257__blank_", "cellholds_2_2_MV1"; - "cellholds_x238_y256__blank_", "cellholds_1_3_MV1"; - "control__blank_", "control_MV1"] + "cellholds_x2_y3__BLANK_", "cellholds_2_2__BLANK_"; + "cellholds_x3_y4__BLANK_", "cellholds_1_3__BLANK_"; + "control__BLANK_", "control__BLANK_"] ~loc0_move:"(move 2 2 1 3)" ~loc0_noop:"noop" ~loc1:1 - ~loc1_rule_name:"move_x467_y497_x466_y496_1" + ~loc1_rule_name:"noop_move_x7_y9_x8_y10" ~loc1_emb:[ - "cellholds_x467_y497__blank_", "cellholds_7_7_MV1"; - "cellholds_x466_y496__blank_", "cellholds_6_6_MV1"; - "control__blank_", "control_MV1"] + "cellholds_x7_y9__blank_", "cellholds_7_7__BLANK_"; + "cellholds_x8_y10__blank_", "cellholds_6_6__BLANK_"; + "control__BLANK_", "control__BLANK_"] ~loc1_noop:"noop" ~loc1_move:"(move 7 7 6 6)" ); @@ -226,17 +226,17 @@ let a () = game_test_case ~game_name:"breakthrough" ~player:"white" ~own_plnum:0 ~opponent_plnum:1 - ~loc0_rule_name:"move_x239_y257_x238_y256_0" + ~loc0_rule_name:"move_x2_y3_x3_y4_noop" ~loc0_emb:[ - "cellholds_x239_y257__blank_", "cellholds_2_2_MV1"; - "cellholds_x238_y256__blank_", "cellholds_1_3_MV1"; - "control__blank_", "control_MV1"] + "cellholds_x2_y3__BLANK_", "cellholds_2_2__BLANK_"; + "cellholds_x3_y4__BLANK_", "cellholds_1_3__BLANK_"; + ... [truncated message content] |
From: <luk...@us...> - 2011-08-21 10:27:44
|
Revision: 1543 http://toss.svn.sourceforge.net/toss/?rev=1543&view=rev Author: lukstafi Date: 2011-08-21 10:27:37 +0000 (Sun, 21 Aug 2011) Log Message: ----------- GDL translation: revised specification of translating as defined relations; fix in GDL.ml related to finding fluents; literal translation handling Distinct. Modified Paths: -------------- trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/TranslateFormula.ml trunk/Toss/GGP/TranslateFormula.mli trunk/Toss/GGP/TranslateFormulaTest.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGame.mli trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-18 09:30:20 UTC (rev 1542) +++ trunk/Toss/GGP/GDL.ml 2011-08-21 10:27:37 UTC (rev 1543) @@ -749,9 +749,10 @@ let br_vars = gdl_defs_vars ["",brs] in let sb = List.map (fun v -> - v, Aux.not_conflicting_name ~truncate:true !used_vars v) + let nv = Aux.not_conflicting_name ~truncate:true !used_vars v in + used_vars := Aux.Strings.add nv !used_vars; + v, nv) (Aux.Strings.elements br_vars) in - used_vars := Aux.add_strings (List.map snd sb) !used_vars; let sb = List.map (fun (v,t) -> v, Var t) sb in List.map (subst_br sb) brs in let expand_atom (rel, args as atom) Modified: trunk/Toss/GGP/TranslateFormula.ml =================================================================== --- trunk/Toss/GGP/TranslateFormula.ml 2011-08-18 09:30:20 UTC (rev 1542) +++ trunk/Toss/GGP/TranslateFormula.ml 2011-08-21 10:27:37 UTC (rev 1543) @@ -58,7 +58,7 @@ (* Whether $i$th argument is a $\mathrm{DefSide}$ or a $\mathrm{CallSide}$, and the $p_{R,i}$ path for a relation $R$. *) -type defrel_arg_type = (bool * path) array +type defrel_arg_mode = (bool * path) array type transl_data = { f_paths : path_set; (* fluent paths *) @@ -66,8 +66,8 @@ all_paths : path_set; (* sum of f_paths and m_paths *) mask_reps : term list; (* mask terms *) defined_rels : string list; - defrel_arg_type : (string * defrel_arg_type) list ref; - (* late binding to store $ArgType# data *) + defrel_arg_mode : (string * defrel_arg_mode) list ref; + (* late binding to store $ArgMode# data *) term_arities : (string * int) list; rel_default_path : (string * path option array) list; } @@ -78,7 +78,7 @@ all_paths = empty_path_set; mask_reps = []; defined_rels = []; - defrel_arg_type = ref []; + defrel_arg_mode = ref []; term_arities = []; rel_default_path = []; } @@ -159,9 +159,30 @@ | Neg (Rel (rel, args)) -> transl_posdefrel false rel args | Pos (Does _ | Role _) | Neg (Does _ | Role _) -> [] + | Pos (Distinct ts) -> + let res = + Array.mapi (fun i t_i -> + if i = 0 then [] + else aux (Neg (Rel ("EQ_", [|ts.(0); t_i|])))) ts in + List.concat (Array.to_list res) + | Neg (Distinct ts) -> + (* they shouldn't do it but since they did... *) + let res = + Array.mapi (fun i t_i -> + if i = 0 then [] + else aux (Pos (Rel ("EQ_", [|ts.(0); t_i|])))) ts in + List.concat (Array.to_list res) | Disj lits -> - [Formula.Or (Aux.concat_map (fun l -> aux l) lits)] - | _ -> assert false in (* FIXME: what about Distinct? *) + [Formula.Or (Aux.concat_map aux lits)] + | lit -> + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "transl_rels: Unhandled literal %s\n%!" + (literal_str lit) + ); + (* }}} *) + [] (* assert false *) + in Formula.And (Aux.concat_map aux rels_phi) let transl_state data phi = @@ -211,6 +232,11 @@ let neg_terms = state_terms neg_state_phi in let neg_vars = Aux.list_diff (List.map (var_of_term data) neg_terms) pos_vars in + let neg_ext, pos_ext = List.partition + (fun conj -> + List.exists (fun v->List.mem v (neg_vars :> Formula.var list)) + (FormulaOps.free_vars conj)) + ext_phi in let all_terms = pos_terms @ neg_terms in let phi_vars = clause_vars (("", [| |]), @@ -225,7 +251,7 @@ (clause_str (("rels_phi", [||]),rels_phi)) (clause_str (("pos_state_phi", [||]),pos_state_phi)) (clause_str (("neg_state_phi", [||]),neg_state_phi)) - ("ext_phi="^Formula.str ext_phi) + ("ext_phi="^Formula.str (Formula.And ext_phi)) ); (* }}} *) let negated_neg_state_transl = @@ -233,21 +259,23 @@ Formula.Or ( List.map (transl_state data) (nnf_dnf neg_state_phi)) in let negated_part = - Formula.And [ - (* positive because they form a "premise" *) - transl_rels data rels_eqs all_terms neg_terms; - (* the universal "conclusion" *) - negated_neg_state_transl] in + Formula.And ( + neg_ext @ + [ + (* positive because they form a "premise" *) + transl_rels data rels_eqs all_terms neg_terms; + (* the universal "conclusion" *) + negated_neg_state_transl]) in let universal_part = - if neg_terms = [] then [] + if neg_terms = [] && neg_ext = [] then [] else if neg_vars = [] then [Formula.Not negated_part] else [Formula.Not ( Formula.Ex ((neg_vars :> Formula.var list), negated_part))] in let base_part = Formula.And ( - [ ext_phi; - transl_rels data rels_eqs pos_terms pos_terms; + pos_ext @ + [ transl_rels data rels_eqs pos_terms pos_terms; transl_state data pos_state_phi] @ universal_part) in if pos_vars = [] then base_part @@ -259,7 +287,7 @@ let translate data disj = let disj = separate_disj disj in Formula.Or (List.map (fun (rels_phi, pos_state, neg_state) -> - transl_disjunct data rels_phi pos_state neg_state (Formula.And []) + transl_disjunct data rels_phi pos_state neg_state [] ) disj) @@ -269,7 +297,7 @@ let select_defrel_argpaths data all_branches = (* TODO: code-review this and [build_defrel] functions *) let select_for_defrel rel = - (* searching for ArgType = DefSide,S,p *) + (* searching for ArgMode = DefSide,S,p *) let branches = Aux.assoc_all rel all_branches in (* {{{ log entry *) if !debug_level > 2 then ( @@ -306,7 +334,7 @@ ) sterms)) args p_defside in let s_defside = List.map branch_sterms branches in - (* now computing the ArgType(R,i) = CallSide,p variant *) + (* now computing the ArgMode(R,i) = CallSide,p variant *) let call_branches = Aux.concat_map (fun (_,(_, (phi, _, _ as body))) -> let calls = Aux.assoc_all rel (rel_atoms phi) in @@ -341,7 +369,7 @@ match defside, callside with | Some p, _ | None, Some p -> p | None, None -> - (* the ArgType(R,i) = NoSide,p variant is precomputed *) + (* the ArgMode(R,i) = NoSide,p variant is precomputed *) try match (List.assoc rel data.rel_default_path).(i) with | Some p -> p @@ -352,11 +380,11 @@ "TranslateFormula.build_defrels: could not \ determine path for relation %s argument %d" rel i) ) p_defside in - let defrel_arg_type = Aux.array_map2 + let defrel_arg_mode = Aux.array_map2 (fun defside path -> defside <> None, path) p_defside arg_paths in - data.defrel_arg_type := - (rel, defrel_arg_type) :: !(data.defrel_arg_type); + data.defrel_arg_mode := + (rel, defrel_arg_mode) :: !(data.defrel_arg_mode); rel, (p_defside, s_defside, arg_paths) in List.map select_for_defrel data.defined_rels @@ -386,7 +414,7 @@ Formula.Eq (v, s_i) else Formula.Eq (v, var_of_subterm data arg_paths.(i) args.(i))) defvars in - let arg_eqs = Formula.And (Array.to_list arg_eqs) in + let arg_eqs = Array.to_list arg_eqs in let callside_sterms = (* $S_{j,l}$ *) Aux.array_mapi_some (fun i path -> @@ -411,20 +439,20 @@ (rel_atom_str (rel, args)) sign ); (* }}} *) - let arg_type = List.assoc rel !(data.defrel_arg_type) in + let arg_mode = List.assoc rel !(data.defrel_arg_mode) in (* the $s \tpos_{p_{R,i}} = t_i$ state terms *) let arg_sterms = Array.mapi (fun i (defside, path) -> if defside then None else try Some ( List.find (fun s -> at_path s path = args.(i)) sterms_all) with Not_found -> None) - arg_type in + arg_mode in let var_args = Array.mapi (fun i (_, path) -> match arg_sterms.(i) with | None -> var_of_subterm data path args.(i) (* in J *) | Some sterm -> var_of_term data sterm) - arg_type in + arg_mode in let defrel_phi = Formula.Rel (rel, var_args) in let defrel_phi = if sign then defrel_phi else Formula.Not defrel_phi in @@ -432,7 +460,7 @@ (Aux.array_mapi_some (fun i (_,path) -> if arg_sterms.(i) = None then Some (var_of_subterm data path args.(i)) - else None) arg_type) in + else None) arg_mode) in let in_J_eq_transl i (_,path) = if arg_sterms.(i) = None then @@ -441,7 +469,7 @@ Some (transl_rels data eq_phi (v::sterms_all) [v]) else None in let eqs_phi = Array.to_list - (Aux.array_mapi_some in_J_eq_transl arg_type) in + (Aux.array_mapi_some in_J_eq_transl arg_mode) in let base = if eqs_phi = [] then defrel_phi else Formula.And (defrel_phi::eqs_phi) in Modified: trunk/Toss/GGP/TranslateFormula.mli =================================================================== --- trunk/Toss/GGP/TranslateFormula.mli 2011-08-18 09:30:20 UTC (rev 1542) +++ trunk/Toss/GGP/TranslateFormula.mli 2011-08-21 10:27:37 UTC (rev 1543) @@ -2,7 +2,7 @@ (* Whether $i$th argument is a $\mathrm{DefSide}$ or a $\mathrm{CallSide}$, and the $p_{R,i}$ path for a relation $R$. *) -type defrel_arg_type = (bool * GDL.path) array +type defrel_arg_mode = (bool * GDL.path) array type transl_data = { f_paths : GDL.path_set; (** fluent paths *) @@ -10,8 +10,8 @@ all_paths : GDL.path_set; (** sum of f_paths and m_paths *) mask_reps : GDL.term list; (** mask terms *) defined_rels : string list; - defrel_arg_type : (string * defrel_arg_type) list ref; - (** late binding to store $ArgType$ data *) + defrel_arg_mode : (string * defrel_arg_mode) list ref; + (** late binding to store $ArgMode$ data *) term_arities : (string * int) list; rel_default_path : (string * GDL.path option array) list; } Modified: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-18 09:30:20 UTC (rev 1542) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-21 10:27:37 UTC (rev 1543) @@ -66,7 +66,7 @@ all_paths = all_paths; mask_reps = mask_reps; defined_rels = defined_rels; - defrel_arg_type = ref []; + defrel_arg_mode = ref []; term_arities = term_arities; rel_default_path = rel_default_path; } Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-18 09:30:20 UTC (rev 1542) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-21 10:27:37 UTC (rev 1543) @@ -26,11 +26,6 @@ let debug_level = ref 0 let generate_test_case = ref None -(** Translate static relations that otherwise would be translated as - structure relations, but have arity above the threshold, as - defined relations. *) -let defined_arity_above = ref 2 - (** Treat "next" clauses which introduce a fluent position for a variable-variable mismatch, as non-erasing frame clauses (to be ignored). ("Wave" refers to the process of "propagating the frame @@ -38,6 +33,13 @@ [nonerasing_frame_wave] is set to [true].) *) let nonerasing_frame_wave = ref true +(** two heuristics for selecting defined relations: select relations + with arity smaller than three; or, select relations that have ground + defining clauses (i.e. defining clauses with empty bodies). *) +type as_defined_rels = + Many_by_arity | Few_by_ground_def | Fewer_by_all_ground +let as_defined_rels = ref Few_by_ground_def + (** When translating as turn-based, filter-out moves composed only of actions such that each is a "noop" action of some player at some location. Assumes that players do not use their "noop" actions @@ -326,9 +328,16 @@ let m_pathl = paths_to_list m_paths in let f_pathl = paths_to_list f_paths in (* adding subterm equality relations and fact relations *) - let struc_rels, defined_rels = - List.partition (fun rel -> - List.assoc rel arities <= !defined_arity_above) static_rels in + let struc_rels, defined_rels = List.partition + (fun rel -> + if !as_defined_rels = Few_by_ground_def + then List.exists + (fun ((rc,args),body) -> rel=rc && body = []) clauses + else if !as_defined_rels = Fewer_by_all_ground + then List.for_all + (fun ((rc,args),body) -> rel=rc && body = []) clauses + else List.assoc rel arities < 3) + static_rels in let struc_rels = "EQ_"::struc_rels in let defined_rels = defined_rels @ nonstatic_rels in (* {{{ log entry *) @@ -1473,7 +1482,7 @@ all_paths = paths_union f_paths m_paths; mask_reps = mask_reps; defined_rels = defined_rels; - defrel_arg_type = ref []; (* built in TranslateFormula *) + defrel_arg_mode = ref []; (* built in TranslateFormula *) term_arities = term_arities; rel_default_path = transl_arg_type_no_side defined_rel_arities init_state program Modified: trunk/Toss/GGP/TranslateGame.mli =================================================================== --- trunk/Toss/GGP/TranslateGame.mli 2011-08-18 09:30:20 UTC (rev 1542) +++ trunk/Toss/GGP/TranslateGame.mli 2011-08-21 10:27:37 UTC (rev 1543) @@ -2,6 +2,13 @@ val debug_level : int ref val generate_test_case : string option ref +(** two heuristics for selecting defined relations: select relations + with arity smaller than three; or, select relations that have ground + defining clauses (i.e. defining clauses with empty bodies). *) +type as_defined_rels = + Many_by_arity | Few_by_ground_def | Fewer_by_all_ground +val as_defined_rels : as_defined_rels ref + (** Limit on plys for both aggregate and random playouts. *) val playout_horizon : int ref Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-18 09:30:20 UTC (rev 1542) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-21 10:27:37 UTC (rev 1543) @@ -215,8 +215,9 @@ ] let a () = - GDL.debug_level := 4; + (* GDL.debug_level := 4; *) TranslateGame.debug_level := 4; + TranslateFormula.debug_level := 4; GameSimpl.debug_level := 4; DiscreteRule.debug_level := 4; () Modified: trunk/Toss/www/reference/reference.tex =================================================================== --- trunk/Toss/www/reference/reference.tex 2011-08-18 09:30:20 UTC (rev 1542) +++ trunk/Toss/www/reference/reference.tex 2011-08-21 10:27:37 UTC (rev 1543) @@ -1330,8 +1330,8 @@ state. Since an approximation is sufficient, we check only the positive part of the legality condition of each move. -In the future, instead of an aggregate playout we -might use a form of type inference to approximate $\calS$. +% In the future, instead of an aggregate playout we +% might use a form of type inference to approximate $\calS$. To construct the elements of the structure from state terms, and to make that structure a good representation of the game in Toss, @@ -1628,11 +1628,11 @@ % formulas. %\end{definition} -\subsection{Expanding the GDL Game Definition} +\subsection{Expanding the GDL Game Definition}\label{expanding-gamedef} Prior to further processing, we modify the wave clauses of the game. Let $\calN \in \mathrm{Next}_{W}$, we add to the body of $\calN$ -a \texttt{true} atom $(\mathtt{true} \ BL(s_\calN)$ (where +a \texttt{true} atom $(\mathtt{true} \ BL(s_\calN))$ (where $\mathtt{BL}(t)=t\big[\calP_f \ot \mathtt{BLANK}\big]$). The added state term will be the corresponding LHS element of the RHS element introduced by the clause. @@ -1669,6 +1669,10 @@ replace the atom by a disjunction of corresponding atoms, or if it is a negative literal, by a conjunction of negated atoms. +For simplicity, we still refer to the transformed definition as $G$, +but it is to be understood as the result of transformation $G'$ +equivalent to the original game definition $G$. + \subsection{Structure Rewriting Rules} To create the structure rewriting rule for the Toss game, @@ -1958,12 +1962,16 @@ \subsection{Translating Formulas} \label{subsec-translate} -First we describe translation in the case all GDL relations other than -\texttt{next} are stable, \ie do not even indirectly depend on -\texttt{true}. A stable GDL relation is translated as multiple stable -Toss relations. Then we approach the GDL relations (other than -\texttt{next}) that depend on \texttt{true} by translating them as -defined relations in Toss. +We translate a GDL relation as either multiple Toss stable relations +(\ie structure relations that do not change during the game), or as +Toss defined relation (\ie a relation given by its defining formula). +All GDL relations that even indirectly depend on \texttt{true} need to +be translated as defined relations. Of the remaining relations, we +select the ones to be translated as structure (stable) relations +heuristically. Currently, a parameter of the translation allows to: +select relations with arity smaller than three; or, select relations +whose (some, or all) defining clauses are ground (\ie with empty +bodies). \subsubsection{Stable Relations and Fluents} @@ -1993,23 +2001,22 @@ is translated as: \begin{align*} - \mathrm{Tr}(\Phi_i,E) := + \mathrm{Tr}(\Phi_i) := \exists \mathtt{BL}(\mathtt{ST}(ST^{+}_i)) \big( & - E \wedge + \wedge \TrRels(eqs_i \wedge G_i, \mathtt{ST}(ST^{+}_i), \mathtt{ST}(ST^{+}_i)) \wedge \TrST(ST^{+}_i) \wedge \\ & - \neg \exists \big( \mathtt{BL}(\mathtt{ST}(ST^{-}_i)) \setminus - \mathtt{BL}(\mathtt{ST}(ST^{+}_i)) \big) \big( \\ & -\ \ \ \ \ \ \ \ -\TrRels(eqs_i \wedge G_i, \mathtt{ST}(ST^{+}_i) \cup + \neg \exists V^{-} \big( + \wedge \TrRels(eqs_i \wedge G_i, \mathtt{ST}(ST^{+}_i) \cup \mathtt{ST}(ST^{-}_i), \mathtt{ST}(ST^{-}_i)) \wedge \\ & \ \ \ \ \ \ \ \ -\TrST(\mathtt{NNF}(\neg ST^{-}_i)) \big) \big) +\TrST(\mathtt{NNF}(\neg ST^{-}_i)) \big) \big) \\ +V^{-} & := \big( \mathtt{BL}(\mathtt{ST}(ST^{-}_i)) \setminus + \mathtt{BL}(\mathtt{ST}(ST^{+}_i)) \big) \end{align*} The result of translation is $\mathrm{Tr}(\Phi) := -\mathrm{Tr}(\Phi_1,T) \vee \ldots \vee \mathrm{Tr}(\Phi_n,T)$ -(argument $E$ is for later use). +\mathrm{Tr}(\Phi_1) \vee \ldots \vee \mathrm{Tr}(\Phi_n)$. We now proceed to define $\TrRels$ and $\TrST$. For an atom $r$, let $\pm r$ mean either $r$ or $\neg r$ when on the left-hand-side, and @@ -2027,7 +2034,7 @@ v_1 = \mathtt{BL}(s_1) \wedge \ldots \wedge v_n = \mathtt{BL}(s_n) \wedge \\ & p_1, \ldots, p_n \in \calP_m \wedge s_1 \tpos_{p_1} = t_1 \wedge \ldots \wedge s_n \tpos_{p_n} = t_n \big\} \\ - & \textit{(when $R$ is a stable relation)} \\ + & \textit{(when $R$ is not translated as defined relation)} \\ \TrST (\phi_1 \wedge \phi_2) = & \TrST (\phi_1) \wedge \TrST(\phi_2) \\ \TrST (\phi_1 \vee \phi_2) = & @@ -2044,109 +2051,113 @@ Mask_m(v) \; \big| \; v = \mathtt{BL}(t) \wedge t \in m \big\} \end{align*} -The case of $\TrRels$ for non-stable relations will be covered in the -next section. +The case of $\TrRels$ for relations intended to be translated as +defined relations will be covered in the next section. \subsubsection{Introducing and Using Defined Relations} +Prior to translating formulas that use the defined relations, we need +to transform the game definition, iteratively for each defined +relation in the partial order of the ``call graph'', \ie whenever +possible doing the transformation for a relation before doing it for +relations used to define it. (We keep the convention from +Section~\ref{expanding-gamedef}, that $G$ is substituted with the +transformed definitions.) + +\paragraph{State Terms to Transfer Arguments} + Consider generating defined relation for relation $R$ with GDL defining clauses -\[ \mathtt{(<= (R \ t^1_1 \ldots t^1_n) \ b_1)}, - \ldots, \mathtt{(<= (R \ t^k_1 \ldots t^k_n) \ b_k)}.\] -For the $i$th argument of $R$ ($i \in \{1,\ldots,n\}$) we will find -$\mathtt{ArgType}(R,i)$ with possible values -$(\mathtt{DefSide},\calS_i,p_i)$, $(\mathtt{CallSide},p_i)$ and $(\mathtt{NoSide},p_i)$, with a mapping $\calS_i$ into state terms -corresponding to the argument in a given context and a path $p_i \in -\calP_m$ corresponding to the subterm position selected to -``transfer'' the argument. +\[ \mathtt{(<= (R \ t^1_1 \ldots t^1_n) \ b_1)}, \ldots, \mathtt{(<= + (R \ t^k_1 \ldots t^k_n) \ b_k)}.\] Let all atoms of $R$ in $G$ +(including both the heads $(R \ t^j_1 \ldots t^j_n)$, and inside of +$b_j$ above) be $\calR=\big\{(R \ r^1_1 \ldots r^1_n),\ldots,(R \ +r^K_1 \ldots r^K_n)\big\}$. Based on $\calR$ we will find a partition +of argument positions and an assignment of mask paths to positions +$(a_1,p_1),\ldots,(a_n,p_n)$ such that $a_1=1$, $a_{i+1}-a_i \in \{0,1\}$, for any partition $\calI = \{i +\ | \ a_i = I\}$, the paths $(p_i \ | \ i \in \calI)$ are distinct and +do not conflict, \ie $(\exists s) (\forall p_i \ | \ i \in \calI) \ +s\tpos_{p_i}$. GDL arguments of a single partition will be passed as a +single defined relation argument. -Let $\mathrm{TrDistr}(b_j) = \Phi^j_1 \vee \ldots \vee \Phi^j_{m_j}$ -where $\Phi^j_l = G^j_l \wedge ST^{j+}_l \wedge ST^{j-}_l$. Let -$\calS_i$ be a mapping from $(j,l)$ to $s^i_{j,l} \in -\mathtt{ST}(ST^{j+}_l)$ and $p_i \in \calP_m$ a path such that -$s^i_{j,l} \tpos_{p_i} = t^j_i$. If such a path and (total for $j,l$) -mapping exist, then $\mathtt{ArgType}(R,i) = -(\mathtt{DefSide},\calS_i,p_i)$. +To find the paths and the partition, consider a clause body +$\mathtt{b}$, any occurrence of relation $R$ atom $(R \ r^j_1 \ldots +r^j_n)$ in $\mathtt{b}$ and positive literal $(\mathtt{true} \ s) \in +\mathtt{b}$ (where the literal is not under disjunction). Let $\{p,i \ +| \ s \tpos_p = r^j_i \}$. We count such sets of paths for all +$\mathtt{b}$ and positive $(\mathtt{true} \ s) \in \mathtt{b}$. We +greedily select sets that together cover all argument positions, with +highest size, and of equally sized with highest count. Of these, we +build the partition by removing from the sets the path-position pairs +where the position is already present in remaining path-position +pairs, in order reverse to the selection criterion. -Otherwise, let $r = R(u_1,\ldots,u_n)$ be an atom of $R$ occurring in -a $\Phi_d = G \wedge ST^{+} \wedge ST^{-}$ disjunct of -$\mathrm{TrDistr}$ result for arbitrary clause of the GDL game -definition. Let $\calS_i(p)$ be a mapping from $\Phi_d$ to -$s^i_{\Phi_d} \in \mathtt{ST}(ST^{+})$ with $p \in \calP_m$ a path -such that $s^i_{\Phi_d} \tpos_p = u_i$, whenever such $s^i_{\Phi_d} -\in \mathtt{ST}(ST^{+})$ exists. Let $p_i$ be such that the size of -the domain of $\calS_i(p_i)$ is maximal. Set $\mathtt{ArgType}(R,i) = -(\mathtt{CallSide},p_i)$. +In case no set of paths contains a path for the $i$th argument, we set +the path $p_i \in \calP_m$ (with a unique $a_i$) so that the +intersection of the projection of the graph of $R$ for the initial +game state $g_{R,i} = \{s | G \vdash R(t_1,\ldots,t_n) \textit{ for + any } \ol{t} \textit{ s.t. } t_i = s\}$, and the set of subterms of +state terms at path $p_i$, $g_{p_i} = \{s \tpos_{p_i} | s \in +\calS\}$, is maximal w.r.t. cardinality ($p_i = \arg \max_{p \in + \calP_m} \left| g_{R,i} \cap g_p \right|$). -In case neither $\mathtt{DefSide}$ nor $\mathtt{CallSide}$ approach is -satisfactory, we set $\mathtt{ArgType}(R,i) = (\mathtt{NoSide},p_i)$, -where the path $p_i \in \calP_m$ is selected so that the intersection -of the projection of the graph of $R$ for the initial game state -$g_{R,i} = \{s | G \vdash R(t_1,\ldots,t_n) \textit{ for any } -\ol{t} \textit{ s.t. } t_i = s\}$, and the set of subterms of state -terms at path $p_i$, $g_{p_i} = \{s \tpos_{p_i} | s \in \calS\}$, is -maximal w.r.t. cardinality ($p_i = \arg \max_{p \in \calP_m} \left| - g_{R,i} \cap g_p \right|$). +Ideally, $p_i \in \calP_m$ should be a path whose domain, \ie the set +$\big\{t \big| s\tpos_{p_i} = t, s \in \calS\big\}$, contains the +domain of the $i$th argument of $R$, \ie the sum of projections of $R$ +on $i$th argument for all possible game states. We do not guarantee +this. -For correctness, $p_i \in \calP_m$ should be a path whose domain, \ie -the set $\big\{t \big| s\tpos_{p_i} = t, s \in \calS\big\}$, contains -the domain of the $i$th argument of $R$, \ie the sum of projections of -$R$ on $i$th argument for all possible game states. The current -definition above does not guarantee this; the exact implementation may -further evolve as $\mathtt{ArgType}$ is relevant for the quality of -translation (\ie both for correctness and how many simplifications can -be applied, see Section~\ref{sec-game-simpl}). +Once the paths for arguments have been selected, we make sure that a +clause in $G$ that has an atom $(R \ r^1_1 \ldots r^1_n)$, has the +positive literals $(\mathtt{true} \ s_\calI)$ such that $\bigwedge_{i + \in \calI} s_\calI \tpos_{p_i} = r^j_i$. For every $\calI$ for which +such a positive literal does not occur in the clause body, we add an +atom $\big(\mathtt{true} \ \mathtt{BL}(\{p_i \ot r^j_i \ | \ i \in +\calI\})\big)$ to the clause. The notation $\mathtt{BL}(\{p_i \ot t_i \ | \ +i \in \calI\})$ for a paths $p_i$ and terms $t_i$ denotes a state term +containing $t_i$ at path $p_i$, and $\mathtt{BLANK}$ as subterms at +all its positions that are not on any path $p_i$ (\ie are not prefixes +of any $p_i$). -We are ready to provide the translated definition $R_{def}$. Let -$v_1,\ldots,v_n$ be fresh Toss variables, let $\calI_R = \big\{i -\big| \mathtt{ArgType}(R,i) = -(\mathtt{DefSide},\calS_i,p_i)\big\}$ and $p_{R,i}$ be such that -$\mathtt{ArgType}(R,i) = -(\mathtt{DefSide},\calS_i,p_{R,i})$ or $\mathtt{ArgType}(R,i) = -(\mathtt{CallSide},p_{R,i})$. Let $\mathtt{BL}(p \ot t)$ for -a path $p$ and term $t$ be a state term containing $t$ at path $p$, -and $\mathtt{BLANK}$ as subterms at all its positions that are not on -path $p$ (\ie are not prefixes of $p$). Using notation introduced -above, let +\paragraph{Translating Defined Relations} +Recall the definitions introduced above to generate state terms to +transfer arguments for translating a relation $R$ as defined +relation. Let $(a_1,p_1),\ldots,(a_n,p_n)$ be the partition of $R$ +arguments and their paths, $a_n = N$, and $\calI_m = \{i \ | \ a_i = m\}$ (for $m \in \{1,\ldots,N\}$). Let +$v_1,\ldots,v_N$ be fresh Toss variables. + +Recall that each $(R \ t^l_1 \ldots t^l_n)$ is also a $(R \ r^{j_l}_1 +\ldots r^{j_l}_n) \in \calR$ for some $j_l$. Therefore, there exist +positive \texttt{true} literals $(\mathtt{true} \ +s^l_1),\ldots,(\mathtt{true} \ s^l_N)$ in the body $b_l$ such that +$(\forall p_i \ | \ i \in \calI_m) \ s^l_m\tpos_{p_i}$. Let $V^l = +\{\mathtt{BL}(s^l_1),\ldots,\mathtt{BL}(s^l_N)\}$. The translated definition +$R_{def}$ is: + \begin{align*} -E_{j,l} = & - \bigwedge \big\{v_i=s^i_{j,l} \big| i \in \calI\big\} \wedge - \bigwedge\big\{v_i=\mathtt{BL}(p_i \ot t^j_i) \big| - i \in \{1,\ldots,n\} \setminus \calI\big\} \\ -S_{j,l} = & -\bigwedge\big\{\mathtt{true}\big(\mathtt{BL}(p_i \ot t^j_i)\big) \big| -i \in \{1,\ldots,n\} \setminus \calI\big\} + R_{def}(v_1,\ldots,v_N) = & + \mathrm{TrDefR}((<= (R \ t^1_1 \ldots t^1_n) \ b_1)) \\ + & \vee \ldots \vee \\ + & \mathrm{TrDefR}((<= (R \ t^k_1 \ldots t^k_n) \ b_k)) \\ + \mathrm{TrDefR}((<= (R \ t_1 \ldots t_n) \ b)) = & (\exists{V^l})\big( + v_1=\mathtt{BL}(s_1) \wedge \ldots \wedge v_N=\mathtt{BL}(s_N) \wedge + \mathtt{Erase}_{V^l} (\mathtt{Tr}(b_l)) \big) \end{align*} +where $\mathtt{Erase}_V(\phi)$ erases all quantification over +variables from $V$ in formula $\phi$. -The translation is: +It remains to define $\TrRels$ for the case of defined relations. Let +$R$ be $N$, $p_1,\ldots,p_n$, $\calI_1,\ldots,\calI_N$ be as +introduced for $R$. Since $(R \ r_1 \ldots r_n) \in \calR$, there +exist $s_1,\ldots,s_N \in \calS_1$ such that $(\forall p_i \ | \ i \in +\calI_m) \ s_m\tpos_{p_i}$. Put \[ -R_{def}(v_1,\ldots,v_n) = -\mathrm{Tr}(S_{1,1} \wedge \Phi^1_1,E_{1,1}) \vee \ldots -\vee \mathrm{Tr}(S_{k,m_k} \wedge \Phi^k_{m_k},E_{k,m_k}) + \TrRels (\pm R(r_1, \ldots, r_n), S_1, S_2) = + \pm R_{def}(\mathtt{BL}(s_1),\ldots,\mathtt{BL}(s_N)). \] -It remains to define $\TrRels$ for the case of non-stable GDL relations: -\begin{align*} - \TrRels (\pm R(t_1, \ldots, t_n), S_1, S_2) = & - \exists \{v_i \ | \ i \in \calJ \} \big( - \pm R_{def}(v_1, \ldots, v_n) \wedge \\ & - \Land \big\{ - \TrRels (\mathtt{EQ}(t_i,t_i), - S_1 \cup \{v_i\}, \{v_i\}) - \ \big| \ i \in \calJ \big\} \big) \\ & - \textit{(when $R$ is not a stable relation)} \\ - \textit{where} \\ - \calJ = & - \big\{i \ \big| \ i \in \calI_R \vee - \neg \exists s \in S_1 (s\tpos_{p_{R,i}} = t_i) \big\} \\ - v_i = \mathtt{BL}(p_{R,i}\ot t_i) & \textit{ if } i \in \calJ \\ - v_i = \mathtt{BL}(s) & \textit{ if } i \not\in \calJ - \textit{ where $s$ such that } s \in S_1 \wedge s\tpos_{p_{R,i}} = t_i -\end{align*} - - \subsection{Concurrent Moves and Toss Locations} \label{subsec-concurrency} In Section~\ref{subsec-rules}, we described the creation of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-18 09:30:32
|
Revision: 1542 http://toss.svn.sourceforge.net/toss/?rev=1542&view=rev Author: lukstafi Date: 2011-08-18 09:30:20 +0000 (Thu, 18 Aug 2011) Log Message: ----------- GDL translation: reverting to saturation-based solver for aggregate playout; optimized saturation (better data structures, matching instead of unification). Modified Paths: -------------- 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/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGameTest.ml Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-08-16 14:49:54 UTC (rev 1541) +++ trunk/Toss/Formula/Aux.ml 2011-08-18 09:30:20 UTC (rev 1542) @@ -81,6 +81,10 @@ [] -> tl | a::l -> let r = f a in r :: map_prepend tl f l +let rec map_rev_prepend tl f = function + [] -> tl + | a::l -> let r = f a in map_rev_prepend (r::tl) f l + let map_some f l = let rec maps_f accu = function | [] -> accu Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-08-16 14:49:54 UTC (rev 1541) +++ trunk/Toss/Formula/Aux.mli 2011-08-18 09:30:20 UTC (rev 1542) @@ -54,7 +54,11 @@ (** Map a second list and prepend the result to the first list, by single traversal. Not tail-recursive. *) val map_prepend : 'a list -> ('b -> 'a) -> 'b list -> 'a list +(** Map a second list and prepend the result to the first list, in + reverse order. Tail-recursive. *) +val map_rev_prepend : 'a list -> ('b -> 'a) -> 'b list -> 'a list + (** Map a list filtering out some elements. *) val map_some : ('a -> 'b option) -> 'a list -> 'b list Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-16 14:49:54 UTC (rev 1541) +++ trunk/Toss/GGP/GDL.ml 2011-08-18 09:30:20 UTC (rev 1542) @@ -258,7 +258,25 @@ (List.map (subst_one sb1) terms2) | _ -> raise Not_found +(* Yet another variant, for fast saturation. *) +let rec match_nonvar sb terms1 terms2 = + match terms1, terms2 with + | [], [] -> sb + | Const a::terms1, Const b::terms2 when a=b -> + match_nonvar sb terms1 terms2 + | Func (f,args1)::terms1, Func (g,args2)::terms2 when f=g -> + match_nonvar sb (Array.to_list args1 @ terms1) + (Array.to_list args2 @ terms2) + | _::terms1, Var _::terms2 -> + match_nonvar sb terms1 terms2 + | Var x::terms1, c::terms2 -> + let sb1 = x, c in + match_nonvar (sb1::List.map (fun (x,t)->x, subst_one sb1 t) sb) + (List.map (subst_one sb1) terms1) + (List.map (subst_one sb1) terms2) + | _ -> raise Not_found + let unify_args ?(sb=[]) args1 args2 = unify sb (Array.to_list args1) (Array.to_list args2) @@ -289,6 +307,10 @@ try ignore (unify [] [term1] [term2]); true with Not_found -> false +let try_match_nonvar terms1 terms2 = + try ignore (match_nonvar [] terms1 terms2); true + with Not_found -> false + let unify_rels ?sb (rel1, args1) (rel2, args2) = if rel1 = rel2 then unify_args ?sb args1 args2 else raise Not_found @@ -387,35 +409,79 @@ rel ^"(" ^ String.concat ", " args ^")" -(* TODO: optimize by using rel-indexing (also in [aggregate_playout]). - TODO: optimize by using constant-time append data structure. *) -(* Variables still left after saturation have universal interpretation! *) -let saturate base rules = +(** {4 Saturation-based solver.} *) - let instantiate_one (tot_base : rel_atom list) - (cur_base : rel_atom list) irules = - Aux.concat_map (function - | head, [], neg_body -> - if List.mem head tot_base then [] - else if List.exists (fun (rel,args as neg_atom) -> +module Tuples = Set.Make(struct + type t = term array + let compare = Pervasives.compare +end) +type graph = Tuples.t Aux.StrMap.t + +let add_tuples nvs vs = + List.fold_left (fun vs nv -> Tuples.add nv vs) vs nvs +let tuples_of_list nvs = + add_tuples nvs Tuples.empty + +let merge_graphs graph1 graph2 = + Aux.StrMap.fold + (fun rel tups1 graph -> + let tups2 = + try Aux.StrMap.find rel graph2 with Not_found -> Tuples.empty in + Aux.StrMap.add rel (Tuples.union tups1 tups2) graph) + graph1 graph2 + +let build_graph atoms = + List.fold_left + (fun graph (rel,tups) -> + Aux.StrMap.add rel (tuples_of_list tups) graph) + Aux.StrMap.empty (Aux.collect atoms) + +let graph_to_atoms graph = + List.rev + (Aux.StrMap.fold (fun rel tups atoms -> + Aux.map_rev_prepend atoms (fun tup -> rel, tup) + (Tuples.elements tups)) graph []) + +let graph_mem rel tup graph = + try + Tuples.mem tup (Aux.StrMap.find rel graph) + with Not_found -> false + +let instantiate_one tot_base cur_base irules = + Aux.concat_map (function + | (hrel, hargs as head), [], neg_body -> + if (try Tuples.mem hargs (Aux.StrMap.find hrel tot_base) + with Not_found -> false) + then [] + else if List.exists (fun (rel,args) -> + let rel_tups = + try Aux.StrMap.find rel tot_base with Not_found -> Tuples.empty in + Tuples.mem args rel_tups || rel = "distinct" && Aux.not_unique (Array.to_list args) || - (* faster option: *) - (* List.mem neg_atom tot_base *) - (* accurate option: *) - List.exists (rels_unify neg_atom) tot_base - ) neg_body then [] - else [Aux.Left head] - | head, cond1::body, neg_body -> - Aux.map_try (fun fact -> + let neg_tup = Array.to_list args in + Tuples.exists + (fun tup -> try_match_nonvar neg_tup (Array.to_list tup)) + rel_tups + ) neg_body then [] + else [Aux.Left head] + | (hrel, hargs as head), (rel,args as pos_atom)::body, neg_body -> + if (try Tuples.mem hargs (Aux.StrMap.find hrel tot_base) + with Not_found -> false) + then [] + else + let pos_tup = Array.to_list args in + let cur_tups = + try Tuples.elements (Aux.StrMap.find rel cur_base) + with Not_found -> [] in + Aux.map_try + (fun rel_tup -> (* {{{ log entry *) - if !debug_level > 5 then ( - Printf.printf "instantiate_one: trying to unify %s and %s\n%!" - (rel_atom_str fact) (rel_atom_str cond1) + Printf.printf "instantiate_one: trying to match %s and %s\n%!" + (rel_atom_str (rel, rel_tup)) (rel_atom_str pos_atom) ); - (* }}} *) - let sb = unify_rels fact cond1 in + let sb = match_nonvar [] pos_tup (Array.to_list rel_tup) in (* {{{ log entry *) if !debug_level > 5 then ( Printf.printf "instantiate_one: succeeded with %s\n%!" @@ -425,21 +491,26 @@ let irule = subst_rel sb head, subst_rels sb body, subst_rels sb neg_body in - Aux.Right irule - ) cur_base) irules in + Aux.Right irule) + cur_tups) + irules +(* TODO: optimize by using rel-indexing (also in [aggregate_playout]). *) +(* Variables still left after saturation have universal interpretation! *) +let saturate base rules = + let rec inst_stratum old_base old_irules cur_base cur_irules = (* {{{ log entry *) if !debug_level > 4 then ( - Printf.printf "inst_stratum: old_base = %s; cur_base = %s\n%!" - (rel_atoms_str old_base) (rel_atoms_str cur_base); + (*Printf.printf "inst_stratum: old_base = %s; cur_base = %s\n%!" + (rel_atoms_str old_base) (rel_atoms_str cur_base);*) Printf.printf "inst_stratum: #old_irules = %d, #cur_irules = %d\n%!" (List.length old_irules) (List.length cur_irules) ); (* }}} *) - let base = Aux.unique_sorted (cur_base @ old_base) - and irules = Aux.unique_sorted (cur_irules @ old_irules) in + let base = merge_graphs cur_base old_base + and irules = Aux.sorted_merge cur_irules old_irules in let new_base1, new_irules1 = Aux.partition_choice (instantiate_one base cur_base cur_irules) in (* {{{ log entry *) @@ -464,24 +535,24 @@ (rel_atoms_str new_base3) ); (* }}} *) - let new_base = Aux.unique_sorted (new_base1 @ new_base2 @ new_base3) + let new_base = build_graph + (new_base1 @ new_base2 @ new_base3) and new_irules = Aux.unique_sorted (new_irules1 @ new_irules2 @ new_irules3) in - let new_base = - List.filter (fun f->not (List.mem f base)) new_base in - let new_irules = - List.filter (fun f->not (List.mem f irules)) new_irules in - if new_base = [] && new_irules = [] + (* [new_base] is already disjoint from [base] *) + let new_irules = Aux.sorted_diff new_irules irules in + if Aux.StrMap.is_empty new_base && new_irules = [] then base else inst_stratum base irules new_base new_irules in let rec instantiate base = function | [] -> base | stratum::strata -> - instantiate (inst_stratum [] [] base stratum) strata in + instantiate (inst_stratum Aux.StrMap.empty [] base stratum) strata in - instantiate base - (List.map rules_of_defs (stratify [] (defs_of_rules rules))) + instantiate (*build_graph*) base + (List.map (Aux.unique_sorted -| rules_of_defs) + (stratify [] (defs_of_rules rules))) @@ -872,35 +943,34 @@ (* [~aggregate:true] performs an aggregate ply, [~aggregate:false] performs a random ply. *) let ply_satur ~aggregate players static current rules = - let base = - Aux.map_prepend static (fun term -> "true", [|term|]) current in - let base = saturate (base @ static) rules in + let base = Aux.StrMap.add "true" current + (*tuples_of_list (List.map (fun term -> [|term|]) current)*) static in + let base = saturate base rules in (* {{{ log entry *) if !debug_level > 4 then ( Printf.printf "GDL.ply: updated base -- %s\n%!" - (rel_atoms_str base) + (rel_atoms_str (graph_to_atoms base)) ); (* }}} *) - let does = Aux.map_some (fun (rel, args) -> - if rel = "legal" then Some ("does", args) else None) base in + let does = Tuples.elements (Aux.StrMap.find "legal" base) in let does = if aggregate then does else List.map (Aux.random_elem -| snd) - (Aux.collect (List.map (fun (_,args as atom) -> - args.(0), atom) does)) in + (Aux.collect (List.map (fun args -> + args.(0), args) does)) in if (* no move *) Aux.array_existsi (fun _ player -> List.for_all (function - |_, [|Var _; _ |] -> false - | _, [|actor; _ |] -> player <> actor | _ -> true) + | [|Var _; _ |] -> false + | [|actor; _ |] -> player <> actor | _ -> true) does) players then ( (* {{{ log entry *) if !debug_level > 0 then ( let players_nomove = Aux.array_find_all (fun player -> - List.for_all (function _, [|actor; _|] -> player <> actor + List.for_all (function [|actor; _|] -> player <> actor | _ -> true) does) players in Printf.printf @@ -910,16 +980,11 @@ (* }}} *) raise Playout_over) else - let step = saturate (does @ base) rules in - let step_state = Aux.map_some - (function ("next", [|arg|]) -> Some arg - | _ -> None) step in + let step = saturate + (Aux.StrMap.add "does" (tuples_of_list does) base) rules in + let step_state = Aux.StrMap.find "next" step in if !playout_fixpoint && (* fixpoint reached *) - List.for_all (function - | Func (_,[|arg|]) when - Aux.array_existsi (fun _ player -> arg=player) players -> true - | term -> List.mem term current - ) step_state + Tuples.subset step_state current then ( (* {{{ log entry *) if !debug_level > 0 then ( @@ -928,7 +993,8 @@ (* }}} *) raise Playout_over) else if not aggregate && (* terminal position reached *) - List.mem_assoc "terminal" step + (try not (Tuples.is_empty (Aux.StrMap.find "terminal" step)) + with Not_found -> false) then ( (* {{{ log entry *) if !debug_level > 0 then ( @@ -937,8 +1003,11 @@ (* }}} *) raise Playout_over) else - List.map snd does, step_state + does, step_state +let state_of_tups ts = + List.map (fun s->s.(0)) (Tuples.elements ts) + (* Besides the playout, also return the separation of rules into static and dynamic. Note that the list of playout states is one longer than that of playout actions. @@ -967,7 +1036,7 @@ ["init"; "does"; "true"; "next"; "terminal"; "goal"] in let static_rules, dynamic_rules = List.partition (fun ((rel,_),_,_) -> List.mem rel static_rels) rules in - let static_base = saturate [] static_rules in + let static_base = saturate Aux.StrMap.empty static_rules in let state_rules = List.map (function | ("legal", [|player; _|] as head), body, neg_body -> @@ -987,30 +1056,33 @@ (* {{{ log entry *) if !debug_level > 0 then ( Printf.printf "playout: state %s\n%!" - (String.concat " " (List.map term_str next)) + (String.concat " " + (List.map term_str (state_of_tups next))) ); (* }}} *) let next = - if aggregate then state @ next else next in + if aggregate then (Tuples.union state next) else next in if step < horizon then loop (actions::actions_accu) (state::state_accu) (step+1) next else + let states = List.rev (next::state::state_accu) in List.rev (actions::actions_accu), - List.rev (next::state::state_accu) + List.map (fun ts->state_of_tups ts) states with Playout_over -> - List.rev actions_accu, List.rev (state::state_accu)) in + List.rev actions_accu, + List.map (fun ts->state_of_tups ts) + (List.rev (state::state_accu))) in (* FIXME: this is identity, right? remove *) let init_base = saturate static_base state_rules in - let init_state = - Aux.map_some (function ("init", [|arg|]) -> Some arg - | _ -> None) init_base in + let init_state = Aux.StrMap.find "init" init_base in (* {{{ log entry *) if !debug_level > 0 then ( Printf.printf "playout: init %s\n%!" - (String.concat " " (List.map term_str init_state)) + (String.concat " " + (List.map term_str (state_of_tups init_state))) ); (* }}} *) - static_rules, dynamic_rules, static_base, init_state, + static_rules, dynamic_rules, static_base, (state_of_tups init_state), loop [] [] 0 init_state Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-16 14:49:54 UTC (rev 1541) +++ trunk/Toss/GGP/GDL.mli 2011-08-18 09:30:20 UTC (rev 1542) @@ -76,9 +76,12 @@ val subst_clause : substitution -> clause -> clause val subst_consts_clause : substitution -> clause -> clause +module Tuples : Set.S with type elt = term array +type graph = Tuples.t Aux.StrMap.t +val graph_mem : string -> term array -> graph -> bool +val graph_to_atoms : graph -> rel_atom list (** Saturation currently exposed for testing purposes. *) -val saturate : - rel_atom list -> gdl_rule list -> rel_atom list +val saturate : graph -> gdl_rule list -> graph (** {3 Continuation-based Prolog interpreter} *) @@ -175,7 +178,7 @@ val playout_satur : aggregate:bool -> term array -> int -> gdl_rule list -> gdl_rule list * gdl_rule list * - rel_atom list * term list * + graph * term list * (term array list list * term list list) val playout_prolog : Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-08-16 14:49:54 UTC (rev 1541) +++ trunk/Toss/GGP/GDLTest.ml 2011-08-18 09:30:20 UTC (rev 1542) @@ -57,24 +57,24 @@ (beta rock) (theta scisors) (gamma scisors)" in (* GDL.debug_level := 3; *) - let res = GDL.saturate [] + let res = GDL.saturate Aux.StrMap.empty (Aux.concat_map GDL.rules_of_clause descr) in assert_equal ~printer:(fun x->x) ~msg:"simple stratified" "(alpha paper) (alpha rock) (beta paper) (beta rock) (beta scisors) (gamma paper) (gamma scisors) (theta scisors) (zeta rock)" (String.concat " " - (List.map GDL.rel_atom_str res)); + (List.map GDL.rel_atom_str (GDL.graph_to_atoms res))); let descr = parse_game_descr " (<= (two-of-three ?X ?Y) (a ?X) (a ?Y) (distinct ?X ?Y)) (a 1) (a 2) (a 3)" in (* GDL.debug_level := 3; *) - let res = GDL.saturate [] + let res = GDL.saturate Aux.StrMap.empty (Aux.concat_map GDL.rules_of_clause descr) in assert_equal ~printer:(fun x->x) ~msg:"simple distinct" "(a 1) (a 2) (a 3) (two-of-three 1 2) (two-of-three 1 3) (two-of-three 2 1) (two-of-three 2 3) (two-of-three 3 1) (two-of-three 3 2)" (String.concat " " - (List.map GDL.rel_atom_str res)); + (List.map GDL.rel_atom_str (graph_to_atoms res))); ); "saturate recursive" >:: @@ -96,12 +96,12 @@ (succ 4 5) (succ 5 6) (succ 6 7) (succ 7 8) " in (* GDL.debug_level := 3; *) - let res = GDL.saturate [] + let res = GDL.saturate Aux.StrMap.empty (Aux.concat_map GDL.rules_of_clause descr) in assert_equal ~printer:(fun x->x) ~msg:"simple stratified" "(lte 0 0) (lte 0 1) (lte 0 2) (lte 0 3) (lte 0 4) (lte 0 5) (lte 0 6) (lte 0 7) (lte 0 8) (lte 1 1) (lte 1 2) (lte 1 3) (lte 1 4) (lte 1 5) (lte 1 6) (lte 1 7) (lte 1 8) (lte 2 2) (lte 2 3) (lte 2 4) (lte 2 5) (lte 2 6) (lte 2 7) (lte 2 8) (lte 3 3) (lte 3 4) (lte 3 5) (lte 3 6) (lte 3 7) (lte 3 8) (lte 4 4) (lte 4 5) (lte 4 6) (lte 4 7) (lte 4 8) (lte 5 5) (lte 5 6) (lte 5 7) (lte 5 8) (lte 6 6) (lte 6 7) (lte 6 8) (lte 7 7) (lte 7 8) (lte 8 8) (number 0) (number 1) (number 2) (number 3) (number 4) (number 5) (number 6) (number 7) (number 8) (succ 0 1) (succ 1 2) (succ 2 3) (succ 3 4) (succ 4 5) (succ 5 6) (succ 6 7) (succ 7 8)" (String.concat " " - (List.map GDL.rel_atom_str res)); + (List.map GDL.rel_atom_str (GDL.graph_to_atoms res))); ); "run_prolog" >:: Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-16 14:49:54 UTC (rev 1541) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-18 09:30:20 UTC (rev 1542) @@ -250,14 +250,18 @@ ) clauses in let players = Array.of_list players in let rules = Aux.concat_map rules_of_clause clauses in - (* + (* Turns out the saturation-based solver is sometimes far better for + performing aggregate playout, which is very much + saturation-like. *) let static_rel_defs, nonstatic_rel_defs, static_base, init_state, (agg_actions, agg_states) = playout_satur ~aggregate:true players !playout_horizon rules in - *) + (* *) + (* let program = preprocess_program clauses in let agg_actions, agg_states = playout_prolog ~aggregate:true players !playout_horizon program in + *) let init_state = List.hd agg_states in let static_rels, nonstatic_rels = static_rels (defs_of_rules rules) in @@ -345,8 +349,8 @@ Aux.fold_left_try (fun struc etup -> let tup = Array.of_list (List.map2 at_path etup ptup) in if rel = "EQ_" && arity = 2 && tup.(0) = tup.(1) || - (* List.mem (rel, tup) static_base *) - rel <> "EQ_" && run_prolog_check_atom (rel, tup) program + rel <> "EQ_" && graph_mem rel tup static_base + (* rel <> "EQ_" && run_prolog_check_atom (rel, tup) program *) then ( stable_rels := Aux.Strings.add fact_rel !stable_rels; Structure.add_rel_named_elems struc fact_rel Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-16 14:49:54 UTC (rev 1541) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-18 09:30:20 UTC (rev 1542) @@ -172,7 +172,7 @@ "control__blank_", "control_MV1"] ~loc1_noop:"noop" ~loc1_move:"(mark f g)" ); -(* + "breakthrough" >:: (fun () -> game_test_case ~game_name:"breakthrough" ~player:"white" @@ -211,11 +211,11 @@ "control__blank_", "control_MV1"] ~loc1_noop:"noop" ~loc1_move:"(mark f g)" ); -*) + ] let a () = - (* GDL.debug_level := 4; *) + GDL.debug_level := 4; TranslateGame.debug_level := 4; GameSimpl.debug_level := 4; DiscreteRule.debug_level := 4; @@ -223,18 +223,20 @@ let a () = - game_test_case ~game_name:"tictactoe" ~player:"xplayer" + game_test_case ~game_name:"breakthrough" ~player:"white" ~own_plnum:0 ~opponent_plnum:1 - ~loc0_rule_name:"mark_x6_y_noop" + ~loc0_rule_name:"move_x239_y257_x238_y256_0" ~loc0_emb:[ - "cell_x6_y__BLANK_", "cell_2_2__BLANK_"; - "control__BLANK_", "control__BLANK_"] - ~loc0_move:"(mark 2 2)" ~loc0_noop:"noop" - ~loc1:1 ~loc1_rule_name:"noop_mark_x7_y0" + "cellholds_x239_y257__blank_", "cellholds_2_2_MV1"; + "cellholds_x238_y256__blank_", "cellholds_1_3_MV1"; + "control__blank_", "control_MV1"] + ~loc0_move:"(move 2 2 1 3)" ~loc0_noop:"noop" ~loc1:1 + ~loc1_rule_name:"move_x467_y497_x466_y496_1" ~loc1_emb:[ - "cell_x7_y0__BLANK_", "cell_1_1__BLANK_"; - "control__BLANK_", "control__BLANK_"] - ~loc1_noop:"noop" ~loc1_move:"(mark 1 1)" + "cellholds_x467_y497__blank_", "cellholds_7_7_MV1"; + "cellholds_x466_y496__blank_", "cellholds_6_6_MV1"; + "control__blank_", "control_MV1"] + ~loc1_noop:"noop" ~loc1_move:"(move 7 7 6 6)" let a () = @@ -270,9 +272,9 @@ TranslateGame.generate_test_case := None let a () = - regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; + (* regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; *) (* regenerate ~debug:false ~game_name:"connect5" ~player:"x"; *) - (* regenerate ~debug:true ~game_name:"breakthrough" ~player:"white"; *) + regenerate ~debug:true ~game_name:"breakthrough" ~player:"white"; (* regenerate ~debug:true ~game_name:"pawn_whopping" ~player:"x"; *) (* regen_with_debug ~game_name:"connect4" ~player:"white"; *) (* failwith "generated"; *) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-16 14:50:00
|
Revision: 1541 http://toss.svn.sourceforge.net/toss/?rev=1541&view=rev Author: lukstafi Date: 2011-08-16 14:49:54 +0000 (Tue, 16 Aug 2011) Log Message: ----------- GDL translation fixing: minor Prolog integration bugs, adding non-terminal-state condition to rules, minor move translation bugs. Modified Paths: -------------- trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/GGP/tests/connect5-raw.toss trunk/Toss/GGP/tests/connect5-simpl.toss trunk/Toss/GGP/tests/tictactoe-raw.toss trunk/Toss/GGP/tests/tictactoe-simpl.toss Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-16 11:29:29 UTC (rev 1540) +++ trunk/Toss/GGP/GDL.ml 2011-08-16 14:49:54 UTC (rev 1541) @@ -235,6 +235,30 @@ (List.map (subst_one sb1) terms2) | _ -> raise Not_found + +(** A "blank" term. *) +let blank = Const "_BLANK_" + +(* Match terms on the left to ground terms on the right, ignoring + [Const "_BLANK_"] on the right. *) +let rec match_nonblank sb terms1 terms2 = + match terms1, terms2 with + | [], [] -> sb + | Const a::terms1, Const b::terms2 when a=b -> + match_nonblank sb terms1 terms2 + | Func (f,args1)::terms1, Func (g,args2)::terms2 when f=g -> + match_nonblank sb (Array.to_list args1 @ terms1) + (Array.to_list args2 @ terms2) + | _::terms1, Const "_BLANK_"::terms2 -> + match_nonblank sb terms1 terms2 + | Var x::terms1, c::terms2 -> + let sb1 = x, c in + match_nonblank (sb1::List.map (fun (x,t)->x, subst_one sb1 t) sb) + (List.map (subst_one sb1) terms1) + (List.map (subst_one sb1) terms2) + | _ -> raise Not_found + + let unify_args ?(sb=[]) args1 args2 = unify sb (Array.to_list args1) (Array.to_list args2) @@ -1422,10 +1446,7 @@ let pred_on_path_subterm path subterm = path_str path ^ term_to_name subterm -(** A "blank" term. *) -let blank = Const "_BLANK_" - (* [expand_path_vars_by prepare_lits p ts clauses] expands variables that have occurrences at path [p] in some state term of a clause (from which pre-processed literals are extracted by Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-16 11:29:29 UTC (rev 1540) +++ trunk/Toss/GGP/GDL.mli 2011-08-16 14:49:54 UTC (rev 1541) @@ -62,6 +62,9 @@ type substitution = (string * term) list val unify : substitution -> term list -> term list -> substitution +(** Match terms on the left to ground terms on the right, ignoring + [Const "_BLANK_"] on the right. *) +val match_nonblank : substitution -> term list -> term list -> substitution val unify_all : substitution -> term list -> substitution val rels_unify : rel_atom -> rel_atom -> bool val subst : substitution -> term -> term Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-16 11:29:29 UTC (rev 1540) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-16 14:49:54 UTC (rev 1541) @@ -346,7 +346,7 @@ let tup = Array.of_list (List.map2 at_path etup ptup) in if rel = "EQ_" && arity = 2 && tup.(0) = tup.(1) || (* List.mem (rel, tup) static_base *) - run_prolog_check_atom (rel, tup) program + rel <> "EQ_" && run_prolog_check_atom (rel, tup) program then ( stable_rels := Aux.Strings.add fact_rel !stable_rels; Structure.add_rel_named_elems struc fact_rel @@ -967,6 +967,7 @@ (* {{{ log entry *) if !debug_level > 1 then ( Printf.printf "filter_rule_cands: generating states...\n%!"; + (* GDL.debug_level := 4; *) ); (* }}} *) let states = Aux.fold_n @@ -977,6 +978,7 @@ states @ acc) [] !playouts_for_rule_filtering in (* {{{ log entry *) if !debug_level > 1 then ( + (* GDL.debug_level := 0; *) Printf.printf "filter_rule_cands: generated %d states.\n%!" (List.length states) ); @@ -1132,7 +1134,10 @@ let case_precond = (* singleton disjunct, i.e. no disjunction *) TranslateFormula.translate transl_data [case_cond] in - let precond = Formula.And (synch_precond @ [case_precond]) in + (* a defined relation for checking game termination *) + let nonterminal = Formula.Not (Formula.Rel ("terminal", [||])) in + let precond = + Formula.And (nonterminal :: synch_precond @ [case_precond]) in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "build_toss_rule: synch precond = %s; main precond = %s\n%!" @@ -1429,7 +1434,7 @@ let clauses = GDL.ground_vars_at_paths prepare_lits ground_at_f_paths clauses in let defined_rels = Aux.list_diff defined_rels - ["goal"; "legal"; "next"; "terminal"] in + ["goal"; "legal"; "next"] in let defined_rels, clauses = elim_ground_args defined_rels clauses in let next_cls = Aux.map_some (function @@ -1439,8 +1444,11 @@ clauses in (* For determining turn-based we could use the original program, but for filtering the rule candidates we need the transformed - clauses. *) - let program = preprocess_program clauses in + clauses. We restore the frame clauses. *) + let program = preprocess_program + (List.map (fun ((rel,args),body as cl)-> + if rel = "frame next" then ("next", args), body + else cl) clauses) in let turn_data = try Some (check_turn_based players program) with Not_turn_based -> None in @@ -1581,7 +1589,6 @@ ) fixed_inst in let precond = Formula.And (anchors @ [rdata.precond]) in (* {{{ log entry *) - if !debug_level > 2 then ( Printf.printf "GDL.translate_incoming_move: rule=%s; trying precond=\n%s\n...%!" @@ -1595,6 +1602,13 @@ ~emb_rels:fluents ~signat ~struc_elems:rdata.struc_elems in let lhs_struc = rule.DiscreteRule.lhs_struc in let rule = DiscreteRule.compile_rule signat [] rule in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf + "GDL.translate_incoming_move: struc=\n%s\n%!" + (Structure.str struc) + ); + (* }}} *) let asgns = DiscreteRule.find_matchings struc rule in (* {{{ log entry *) @@ -1781,10 +1795,18 @@ let sb = try List.fold_left (fun sb (v_term, e_term) -> - unify sb [e_term] [v_term]) [] emb - with Not_found -> failwith - ("GDL.translate_outgoing_move: inconsistent match for rule " - ^rname) in + match_nonblank sb [v_term] [e_term]) [] emb + with Not_found -> + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "translate_outgoing_move: inconsistent sb: %s\n%!" + (String.concat "; "(List.map (fun (vt, et) -> + term_str vt ^"<-"^term_str et) emb)) + ); + (* }}} *) + failwith + ("GDL.translate_outgoing_move: inconsistent match for rule " + ^rname) in let legal_term = if Array.length tossrule.legal_tuple > 1 then tossrule.legal_tuple.(gdl.playing_as) Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-16 11:29:29 UTC (rev 1540) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-16 14:49:54 UTC (rev 1541) @@ -50,18 +50,15 @@ let game = load_rules ("./GGP/examples/"^game_name^".gdl") in let gdl, res = TranslateGame.translate_game ~playing_as:(Const player) game in - let goal_name = - (*if !GDL.prune_rulecands_at = GDL.Never - then game_name^"-simpl-unpruned.toss" - else if !GDL.prune_rulecands_at = GDL.After_simpl - then game_name^"-simpl-pruned.toss" - else *) game_name^"-simpl.toss" in - let goal = state_of_file ("./GGP/tests/"^goal_name) in + let goal_name = game_name^"-simpl.toss" in + (* let goal = state_of_file ("./GGP/tests/"^goal_name) in *) + let goal_str = Aux.input_file (open_in ("./GGP/tests/"^goal_name)) in let resf = open_out ("./GGP/tests/"^game_name^"-temp.toss") in let res_str = Arena.state_str res in output_string resf res_str; close_out resf; - let eq, msg = Arena.compare_diff goal res in + (* let eq, msg = Arena.compare_diff goal res in *) + let eq, msg = goal_str = res_str, "sorry, just comparing as strings" in assert_bool ("GGP/examples/"^game_name^".gdl to GGP/tests/"^goal_name^ ", see GGP/tests/"^game_name^"-temp.toss: "^msg) @@ -99,15 +96,15 @@ (fun () -> game_test_case ~game_name:"tictactoe" ~player:"xplayer" ~own_plnum:0 ~opponent_plnum:1 - ~loc0_rule_name:"mark_x64_y19_0" + ~loc0_rule_name:"mark_x6_y_noop" ~loc0_emb:[ - "cell_x64_y19__blank_", "cell_2_2_MV1"; - "control__blank_", "control_MV1"] + "cell_x6_y__BLANK_", "cell_2_2__BLANK_"; + "control__BLANK_", "control__BLANK_"] ~loc0_move:"(mark 2 2)" ~loc0_noop:"noop" - ~loc1:1 ~loc1_rule_name:"mark_x71_y26_1" + ~loc1:1 ~loc1_rule_name:"noop_mark_x7_y0" ~loc1_emb:[ - "cell_x71_y26__blank_", "cell_1_1_MV1"; - "control__blank_", "control_MV1"] + "cell_x7_y0__BLANK_", "cell_1_1__BLANK_"; + "control__BLANK_", "control__BLANK_"] ~loc1_noop:"noop" ~loc1_move:"(mark 1 1)" ); @@ -175,7 +172,7 @@ "control__blank_", "control_MV1"] ~loc1_noop:"noop" ~loc1_move:"(mark f g)" ); - +(* "breakthrough" >:: (fun () -> game_test_case ~game_name:"breakthrough" ~player:"white" @@ -214,10 +211,11 @@ "control__blank_", "control_MV1"] ~loc1_noop:"noop" ~loc1_move:"(mark f g)" ); +*) ] let a () = - GDL.debug_level := 2; + (* GDL.debug_level := 4; *) TranslateGame.debug_level := 4; GameSimpl.debug_level := 4; DiscreteRule.debug_level := 4; @@ -225,18 +223,18 @@ let a () = - game_test_case ~game_name:"connect5" ~player:"x" + game_test_case ~game_name:"tictactoe" ~player:"xplayer" ~own_plnum:0 ~opponent_plnum:1 - ~loc0_rule_name:"mark_x161_y162_0" + ~loc0_rule_name:"mark_x6_y_noop" ~loc0_emb:[ - "cell_x161_y162__blank_", "cell_e_f_MV1"; - "control__blank_", "control_MV1"] - ~loc0_move:"(mark e f)" ~loc0_noop:"noop" - ~loc1:1 ~loc1_rule_name:"mark_x175_y176_1" + "cell_x6_y__BLANK_", "cell_2_2__BLANK_"; + "control__BLANK_", "control__BLANK_"] + ~loc0_move:"(mark 2 2)" ~loc0_noop:"noop" + ~loc1:1 ~loc1_rule_name:"noop_mark_x7_y0" ~loc1_emb:[ - "cell_x175_y176__blank_", "cell_f_g_MV1"; - "control__blank_", "control_MV1"] - ~loc1_noop:"noop" ~loc1_move:"(mark f g)" + "cell_x7_y0__BLANK_", "cell_1_1__BLANK_"; + "control__BLANK_", "control__BLANK_"] + ~loc1_noop:"noop" ~loc1_move:"(mark 1 1)" let a () = @@ -272,7 +270,7 @@ TranslateGame.generate_test_case := None let a () = - regenerate ~debug:true ~game_name:"tictactoe" ~player:"xplayer"; + regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; (* regenerate ~debug:false ~game_name:"connect5" ~player:"x"; *) (* regenerate ~debug:true ~game_name:"breakthrough" ~player:"white"; *) (* regenerate ~debug:true ~game_name:"pawn_whopping" ~player:"x"; *) Modified: trunk/Toss/GGP/tests/connect5-raw.toss =================================================================== --- trunk/Toss/GGP/tests/connect5-raw.toss 2011-08-16 11:29:29 UTC (rev 1540) +++ trunk/Toss/GGP/tests/connect5-raw.toss 2011-08-16 14:49:54 UTC (rev 1541) @@ -408,6 +408,9 @@ cell__BLANK___BLANK___BLANK_(cell_d_y8__BLANK_) and cell_2x(cell_e_y8__BLANK_) and cell__BLANK___BLANK___BLANK_(cell_e_y8__BLANK_)) +REL terminal() = + (true and not exists_empty_cell() and true) or + (true and exists_line_of_five() and true) PLAYERS x, o RULE mark_x5_y5_noop: [cell_x5_y5__BLANK_, control__BLANK_ | @@ -422,7 +425,7 @@ ] -> [cell_x5_y5__BLANK_, control__BLANK_ | cell_2x (cell_x5_y5__BLANK_); control_0o (control__BLANK_) | - ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x + ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x pre not terminal() RULE noop_mark_x6_y6: [cell_x6_y6__BLANK_, control__BLANK_ | _opt_cell_2b (control__BLANK_); @@ -436,7 +439,7 @@ ] -> [cell_x6_y6__BLANK_, control__BLANK_ | cell_2o (cell_x6_y6__BLANK_); control_0x (control__BLANK_) | - ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x + ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x pre not terminal() LOC 0 { PLAYER x { Modified: trunk/Toss/GGP/tests/connect5-simpl.toss =================================================================== --- trunk/Toss/GGP/tests/connect5-simpl.toss 2011-08-16 11:29:29 UTC (rev 1540) +++ trunk/Toss/GGP/tests/connect5-simpl.toss 2011-08-16 14:49:54 UTC (rev 1541) @@ -204,6 +204,7 @@ not control__BLANK_(cell_c1_y8__BLANK_) and not control__BLANK_(cell_d_y8__BLANK_) and not control__BLANK_(cell_e_y8__BLANK_)) +REL terminal() = exists_line_of_five() or not exists_empty_cell() PLAYERS x, o DATA R2: EQ___cell_1__cell_1__AND__nextcol__cell_0__cell_0, R0: nextcol__cell_0__cell_0__AND__nextcol__cell_1__cell_1, @@ -221,7 +222,7 @@ ] -> [cell_x5_y5__BLANK_, control__BLANK_ | cell_2x (cell_x5_y5__BLANK_); control_0o (control__BLANK_) | - ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x + ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x pre not terminal() RULE noop_mark_x6_y6: [cell_x6_y6__BLANK_, control__BLANK_ | _opt_cell_2b (control__BLANK_); @@ -234,7 +235,7 @@ ] -> [cell_x6_y6__BLANK_, control__BLANK_ | cell_2o (cell_x6_y6__BLANK_); control_0x (control__BLANK_) | - ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x + ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x pre not terminal() LOC 0 { PLAYER x { PAYOFF 100. * :(conn5__x()) + 50. * :(not exists_line_of_five()) Modified: trunk/Toss/GGP/tests/tictactoe-raw.toss =================================================================== --- trunk/Toss/GGP/tests/tictactoe-raw.toss 2011-08-16 11:29:29 UTC (rev 1540) +++ trunk/Toss/GGP/tests/tictactoe-raw.toss 2011-08-16 14:49:54 UTC (rev 1541) @@ -186,6 +186,9 @@ cell__BLANK___BLANK___BLANK_(cell_m4_2__BLANK_) and cell_13(cell_m4_3__BLANK_) and cell_2x(cell_m4_3__BLANK_) and cell__BLANK___BLANK___BLANK_(cell_m4_3__BLANK_)) +REL terminal() = + (true and not open() and true) or (true and line__o() and true) or + (true and line__x() and true) PLAYERS xplayer, oplayer RULE mark_x6_y_noop: [cell_x6_y__BLANK_, control__BLANK_ | @@ -202,23 +205,7 @@ cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer -RULE mark_x6_y_noop0: - [cell_x6_y__BLANK_, control__BLANK_ | - _opt_cell_2b (control__BLANK_); - _opt_cell_2o {cell_x6_y__BLANK_; control__BLANK_}; - _opt_cell_2x {cell_x6_y__BLANK_; control__BLANK_}; - _opt_control_0oplayer (cell_x6_y__BLANK_); - _opt_control_0xplayer (cell_x6_y__BLANK_); cell_2b (cell_x6_y__BLANK_); - cell__BLANK___BLANK___BLANK_ (cell_x6_y__BLANK_); - control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_); - control__BLANK_ (control__BLANK_) - | - ] -> - [cell_x6_y__BLANK_, control__BLANK_ | - cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_); - control_0xplayer (control__BLANK_) - | - ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer + pre not terminal() RULE noop_mark_x7_y0: [cell_x7_y0__BLANK_, control__BLANK_ | _opt_cell_2b (control__BLANK_); @@ -234,23 +221,7 @@ cell_2o (cell_x7_y0__BLANK_); control_0xplayer (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer -RULE noop_mark_x7_y00: - [cell_x7_y0__BLANK_, control__BLANK_ | - _opt_cell_2b (control__BLANK_); - _opt_cell_2o {cell_x7_y0__BLANK_; control__BLANK_}; - _opt_cell_2x {cell_x7_y0__BLANK_; control__BLANK_}; - _opt_control_0oplayer (cell_x7_y0__BLANK_); - _opt_control_0xplayer (cell_x7_y0__BLANK_); cell_2b (cell_x7_y0__BLANK_); - cell__BLANK___BLANK___BLANK_ (cell_x7_y0__BLANK_); - control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_); - control__BLANK_ (control__BLANK_) - | - ] -> - [cell_x7_y0__BLANK_, control__BLANK_ | - cell_2o (cell_x7_y0__BLANK_); control_0oplayer (control__BLANK_); - control_0xplayer (control__BLANK_) - | - ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer + pre not terminal() LOC 0 { PLAYER xplayer { @@ -258,7 +229,7 @@ 100. * :((true and line__x() and true)) + 50. * :((true and not line__x() and not line__o() and not open() and true)) - MOVES [mark_x6_y_noop -> 1]; [mark_x6_y_noop0 -> 1] } + MOVES [mark_x6_y_noop -> 1] } PLAYER oplayer { PAYOFF 100. * :((true and line__o() and true)) + @@ -279,7 +250,7 @@ 100. * :((true and line__o() and true)) + 50. * :((true and not line__x() and not line__o() and not open() and true)) - MOVES [noop_mark_x7_y0 -> 0]; [noop_mark_x7_y00 -> 0] } + MOVES [noop_mark_x7_y0 -> 0] } } MODEL [cell_1_1__BLANK_, cell_1_2__BLANK_, cell_1_3__BLANK_, cell_2_1__BLANK_, Modified: trunk/Toss/GGP/tests/tictactoe-simpl.toss =================================================================== --- trunk/Toss/GGP/tests/tictactoe-simpl.toss 2011-08-16 11:29:29 UTC (rev 1540) +++ trunk/Toss/GGP/tests/tictactoe-simpl.toss 2011-08-16 14:49:54 UTC (rev 1541) @@ -115,6 +115,7 @@ v0 = cell_m4_1__BLANK_ and not control__BLANK_(cell_m4_1__BLANK_) and not control__BLANK_(cell_m4_2__BLANK_) and not control__BLANK_(cell_m4_3__BLANK_)) +REL terminal() = line__o() or line__x() or not open() PLAYERS xplayer, oplayer DATA R3: cell_03__AND__cell_11, R2: cell_01__AND__cell_13, R1: cell_03__AND__cell_13, R0: cell_02__AND__cell_12, @@ -133,22 +134,7 @@ cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer -RULE mark_x6_y_noop0: - [cell_x6_y__BLANK_, control__BLANK_ | - _opt_cell_2b (control__BLANK_); - _opt_cell_2o {cell_x6_y__BLANK_; control__BLANK_}; - _opt_cell_2x {cell_x6_y__BLANK_; control__BLANK_}; - _opt_control_0oplayer (cell_x6_y__BLANK_); - _opt_control_0xplayer (cell_x6_y__BLANK_); cell_2b (cell_x6_y__BLANK_); - control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_); - control__BLANK_ (control__BLANK_) - | - ] -> - [cell_x6_y__BLANK_, control__BLANK_ | - cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_); - control_0xplayer (control__BLANK_) - | - ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer + pre not terminal() RULE noop_mark_x7_y0: [cell_x7_y0__BLANK_, control__BLANK_ | _opt_cell_2b (control__BLANK_); @@ -163,29 +149,14 @@ cell_2o (cell_x7_y0__BLANK_); control_0xplayer (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer -RULE noop_mark_x7_y00: - [cell_x7_y0__BLANK_, control__BLANK_ | - _opt_cell_2b (control__BLANK_); - _opt_cell_2o {cell_x7_y0__BLANK_; control__BLANK_}; - _opt_cell_2x {cell_x7_y0__BLANK_; control__BLANK_}; - _opt_control_0oplayer (cell_x7_y0__BLANK_); - _opt_control_0xplayer (cell_x7_y0__BLANK_); cell_2b (cell_x7_y0__BLANK_); - control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_); - control__BLANK_ (control__BLANK_) - | - ] -> - [cell_x7_y0__BLANK_, control__BLANK_ | - cell_2o (cell_x7_y0__BLANK_); control_0oplayer (control__BLANK_); - control_0xplayer (control__BLANK_) - | - ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer + pre not terminal() LOC 0 { PLAYER xplayer { PAYOFF 100. * :(line__x()) + 50. * :((not line__o() and not line__x() and not open())) - MOVES [mark_x6_y_noop -> 1]; [mark_x6_y_noop0 -> 1] } + MOVES [mark_x6_y_noop -> 1] } PLAYER oplayer { PAYOFF 100. * :(line__o()) + @@ -203,7 +174,7 @@ PAYOFF 100. * :(line__o()) + 50. * :((not line__o() and not line__x() and not open())) - MOVES [noop_mark_x7_y0 -> 0]; [noop_mark_x7_y00 -> 0] } + MOVES [noop_mark_x7_y0 -> 0] } } MODEL [cell_1_1__BLANK_, cell_1_2__BLANK_, cell_1_3__BLANK_, cell_2_1__BLANK_, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-16 11:29:36
|
Revision: 1540 http://toss.svn.sourceforge.net/toss/?rev=1540&view=rev Author: lukstafi Date: 2011-08-16 11:29:29 +0000 (Tue, 16 Aug 2011) Log Message: ----------- GDL translation: Continuation Passing Style Prolog interpreter (saturation based code left for comparisons). Modified Paths: -------------- 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/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGame.mli trunk/Toss/GGP/TranslateGameTest.ml Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-08-13 21:19:21 UTC (rev 1539) +++ trunk/Toss/Formula/Aux.ml 2011-08-16 11:29:29 UTC (rev 1540) @@ -128,8 +128,39 @@ let list_diff a b = List.filter (fun e -> not (List.mem e b)) a +let sorted_diff xs ys = + let rec aux acc = function + | [], _ -> acc + | xs, [] -> List.rev_append xs acc + | (x::xs' as xs), (y::ys' as ys) -> + let c = Pervasives.compare x y in + if c = 0 then aux acc (xs', ys') + else if c < 0 then aux (x::acc) (xs', ys) + else aux acc (xs, ys') in + List.rev (aux [] (xs, ys)) + let list_inter a b = List.filter (fun e -> List.mem e b) a +let sorted_inter xs ys = + let rec aux acc = function + | [], _ | _, [] -> acc + | (x::xs' as xs), (y::ys' as ys) -> + let c = Pervasives.compare x y in + if c = 0 then aux (x::acc) (xs', ys') + else if c < 0 then aux acc (xs', ys) + else aux acc (xs, ys') in + List.rev (aux [] (xs, ys)) + +let sorted_merge xs ys = + let rec aux acc = function + | [], xs | xs, [] -> List.rev_append xs acc + | (x::xs' as xs), (y::ys' as ys) -> + let c = Pervasives.compare x y in + if c = 0 then aux (x::acc) (xs', ys') + else if c < 0 then aux (x::acc) (xs', ys) + else aux (y::acc) (xs, ys') in + List.rev (aux [] (xs, ys)) + let rec rev_assoc l x = match l with [] -> raise Not_found | (a,b)::l -> if b = x then a else rev_assoc l x Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-08-13 21:19:21 UTC (rev 1539) +++ trunk/Toss/Formula/Aux.mli 2011-08-16 11:29:29 UTC (rev 1540) @@ -79,12 +79,24 @@ inequality. *) val list_remove : 'a -> 'a list -> 'a list -(** Difference: [List.filter (fun e -> not (List.mem e b)) a]. *) +(** Set difference: [List.filter (fun e -> not (List.mem e b)) a]. *) val list_diff : 'a list -> 'a list -> 'a list +(** Set difference of lists of unique increasing elements (as returned + by {!Aux.unique_sorted}). *) +val sorted_diff : 'a list -> 'a list -> 'a list + (** Intersection: [list_inter a b = List.filter (fun e -> List.mem e b) a]. *) val list_inter : 'a list -> 'a list -> 'a list +(** Set intersection of lists of unique increasing elements (as returned + by {!Aux.unique_sorted}). *) +val sorted_inter : 'a list -> 'a list -> 'a list + +(** Set union of lists of unique increasing elements (as returned + by {!Aux.unique_sorted}). *) +val sorted_merge : 'a list -> 'a list -> 'a list + (** Return first key with the given value from the key-value pairs, using structural equality. *) val rev_assoc : ('a * 'b) list -> 'b -> 'a Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-13 21:19:21 UTC (rev 1539) +++ trunk/Toss/GGP/GDL.ml 2011-08-16 11:29:29 UTC (rev 1540) @@ -5,12 +5,11 @@ (* ************************************************************ *) (* ************************************************************ *) -(** {3 Datalog programs: Type definitions and saturation.} *) +(** {3 Datalog programs: Type definitions, saturation, Prolog interpreter.} *) open Aux.BasicOperators let debug_level = ref 0 -let aggregate_drop_negative = ref true let playout_fixpoint = ref true type term = @@ -147,6 +146,10 @@ List.fold_left Aux.Strings.union Aux.Strings.empty (List.map gdl_rule_vars (rules_of_clause cl)) +let clauses_vars cls = + List.fold_left Aux.Strings.union Aux.Strings.empty + (List.map clause_vars cls) + let defs_of_rules rules = Aux.map_reduce (fun ((rel, args), body, neg_body) -> rel, (args, body, neg_body)) (fun y x->x::y) [] rules @@ -232,8 +235,8 @@ (List.map (subst_one sb1) terms2) | _ -> raise Not_found -let unify_args args1 args2 = - unify [] (Array.to_list args1) (Array.to_list args2) +let unify_args ?(sb=[]) args1 args2 = + unify sb (Array.to_list args1) (Array.to_list args2) let rec subst sb = function | Var y as t -> @@ -262,8 +265,8 @@ try ignore (unify [] [term1] [term2]); true with Not_found -> false -let unify_rels (rel1, args1) (rel2, args2) = - if rel1 = rel2 then unify_args args1 args2 +let unify_rels ?sb (rel1, args1) (rel2, args2) = + if rel1 = rel2 then unify_args ?sb args1 args2 else raise Not_found let rels_unify atom1 atom2 = @@ -456,8 +459,190 @@ instantiate base (List.map rules_of_defs (stratify [] (defs_of_rules rules))) + + (* ************************************************************ *) (* ************************************************************ *) +(** {3 Continuation-based Prolog interpreter} *) + +(** The interpreter can reinterpret "does" atoms as "legal" atoms for + aggregate playout. For random playout, remember to compute legal + moves, select randomly one for each player and add "does" atoms to + the program. *) +let run_prolog_aggregate = ref false + +(* In the future, [prolog_program] could implement deeper hashing to + be used by [assoc_clauses]. *) +type prolog_program = clause list Aux.StrMap.t + +(** Push negative literals to the right. *) +let preprocess_cl_body body = + let posi, nega = List.partition + (function Neg _ | Pos (Distinct _) -> false | _ -> true) + body in + posi @ nega + +let preprocess_program clauses = + let clauses = List.map + (fun ((rel,args as head), body) -> + rel, (head, preprocess_cl_body body)) clauses in + let clauses = Aux.collect clauses in + Aux.strmap_of_assoc clauses + +let replace_rel_in_program rel clauses p = + Aux.StrMap.add rel clauses p + +let used_vars = ref Aux.Strings.empty + +let assoc_clauses (rel,_ as a) p = + let cls = + try Aux.StrMap.find rel p + with Not_found -> + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "assoc_clauses: %s not found among:" rel; + Aux.StrMap.iter (fun r _ -> print_string (" "^r)) p; + Printf.printf "\n%!"; + ); + (* }}} *) + [] in + let freshen_cl cl = + let cl_vars = clause_vars cl in + let sb = List.map + (fun v -> + let nv = Aux.not_conflicting_name ~truncate:true !used_vars v in + used_vars := Aux.Strings.add nv !used_vars; + v, nv) + (Aux.Strings.elements cl_vars) in + let sb = List.map (fun (v,t) -> v, Var t) sb in + subst_clause sb cl in + let cls = List.map freshen_cl cls in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf + "assoc_clauses: trying %s with:\n%s\n%!" + (rel_atom_str a) + (String.concat "\n"(List.map clause_str cls)) + ); + (* }}} *) + cls + +let rec run_clauses a p sc fc sb = + match a with + | Distinct ts -> + (try + let ts_l = Array.to_list (Array.map (subst sb) ts) in + ignore (unify_all sb ts_l); + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "run_clauses: not distinct %s\n%!" + (String.concat ", " (List.map term_str ts_l)) + ); + (* }}} *) + fc () + with Not_found -> sc fc sb) + | Does (pl, lt) when !run_prolog_aggregate -> + let a = subst_rel sb ("legal", [|pl; lt|]) in + run_clseq (assoc_clauses a p) a p sc fc sb + | a -> + let a = subst_rel sb (rel_of_atom a) in + run_clseq (assoc_clauses a p) a p sc fc sb + +and run_clseq l a p sc fc sb = + match l with + | [] -> fc () + | [cl] -> run_clause cl a p sc fc sb + | cl::l -> + run_clause cl a p sc (fun () -> run_clseq l a p sc fc sb) sb + +and run_clause (h, g) a p sc fc sb = + (* We could use the [let try] construct, but this is more transparent. *) + let sb = (* [assoc_clauses] freshened vars *) + try Some (unify_rels ~sb (subst_rel sb h) a) + with Not_found -> None in + match sb with + | Some sb -> + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "run_clause: succeeded with %s\n%!" + (clause_str (subst_clause sb (h, g))) + ); + (* }}} *) + run_goal g p sc fc sb + | None -> fc () + +and run_goal g p sc fc sb = + match g with [] -> sc fc sb + | lit::g -> run_gseq lit g p sc fc sb + +and run_gseq lit g p sc fc sb = + match g with [] -> run_lit lit p sc fc sb + | lit'::g -> run_lit lit p (run_gseq lit' g p sc) fc sb + +and run_lit lit p sc fc sb = + match lit with + | Pos a -> run_clauses a p sc fc sb + | Neg a -> + run_clauses a p (fun _ _ -> fc ()) (fun () -> sc fc sb) sb + | Disj [] -> fc () + | Disj [lit] -> run_lit lit p sc fc sb + | Disj (lit::lits) -> + run_lit lit p sc (fun () -> run_lit (Disj lits) p sc fc sb) sb + +let run_prolog_atom (rel, args as q : rel_atom) (p : prolog_program) = + used_vars := Aux.StrMap.fold (fun _ cls acc -> + Aux.Strings.union (clauses_vars cls) acc) p Aux.Strings.empty; + used_vars := Aux.Strings.union !used_vars (terms_vars args); + let sc_init fc sb = fun m -> + let ans = subst_rel sb q in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "run_prolog_atom: returning %s\n%!" + (rel_atom_str ans) + ); + (* }}} *) + fc () (ans::m) in + let fc_init () = fun m -> m in + let extract res = res [] in + let res = + Aux.unique_sorted ( + extract (run_clauses (Rel (rel, args)) p sc_init fc_init [])) in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "run_prolog_atom: returned %d distinct results.\n%!" + (List.length res) + ); + (* }}} *) + res + +let run_prolog_goal (g : literal list) (p : prolog_program) = + used_vars := Aux.StrMap.fold (fun _ cls acc -> + Aux.Strings.union (clauses_vars cls) acc) p Aux.Strings.empty; + used_vars := Aux.Strings.union !used_vars (clause_vars (("",[||]),g)); + let sc_init fc sb = fun m -> fc () (sb::m) in + let fc_init () = fun m -> m in + let extract res = res [] in + extract (run_goal g p sc_init fc_init []) + +let run_prolog_check_atom (rel, args) (p : prolog_program) = + used_vars := Aux.StrMap.fold (fun _ cls acc -> + Aux.Strings.union (clauses_vars cls) acc) p Aux.Strings.empty; + used_vars := Aux.Strings.union !used_vars (terms_vars args); + let sc_init fc _ = true in + let fc_init () = false in + run_clauses (Rel (rel, args)) p sc_init fc_init [] + +let run_prolog_check_goal (g : literal list) (p : prolog_program) = + used_vars := Aux.StrMap.fold (fun _ cls acc -> + Aux.Strings.union (clauses_vars cls) acc) p Aux.Strings.empty; + used_vars := Aux.Strings.union !used_vars (clause_vars (("",[||]),g)); + let sc_init fc _ = true in + let fc_init () = false in + run_goal g p sc_init fc_init [] + + +(* ************************************************************ *) +(* ************************************************************ *) (** {3 Transformations of GDL clauses: inlining, negation.} *) (** Expand branches of a definition inlining the provided definitions, @@ -646,8 +831,10 @@ (Aux.unique_sorted !all_rels) in all_rels, clauses in fix clauses - +let state_cls terms = + List.map (fun t -> ("true", [|t|]), []) terms + (* ************************************************************ *) (* ************************************************************ *) (** {3 GDL whole-game operations.} @@ -660,7 +847,7 @@ (* [~aggregate:true] performs an aggregate ply, [~aggregate:false] performs a random ply. *) -let ply ~aggregate players static current rules = +let ply_satur ~aggregate players static current rules = let base = Aux.map_prepend static (fun term -> "true", [|term|]) current in let base = saturate (base @ static) rules in @@ -732,15 +919,15 @@ into static and dynamic. Note that the list of playout states is one longer than that of playout actions. - When [aggregate_drop_negative] is true, to keep monotonicity, - besides removing negative literals from "legal" clauses, we also - add old terms to the state. (Only when [~aggregate:true].) + To keep monotonicity, besides removing negative literals from + "legal" clauses, we also add old terms to the state. (Only when + [~aggregate:true].) [~aggregate:true] performs an aggregate ply, [~aggregate:false] performs a random ply. Aggregate playouts are "deprecated", especially for uses other than generating all possible state terms. *) -let playout ~aggregate players horizon rules = +let playout_satur ~aggregate players horizon rules = (* separate and precompute the static part *) let rec separate static_rels state_rels = let static, more_state = @@ -761,8 +948,7 @@ List.map (function | ("legal", [|player; _|] as head), body, neg_body -> head, ("role", [|player|])::body, - if aggregate && !aggregate_drop_negative - then [] else neg_body + if aggregate then [] else neg_body | ("does", _ (* as head *)), body, _ -> assert false (* head, body, [] *) | rule -> rule) dynamic_rules in @@ -773,7 +959,7 @@ ); (* }}} *) (let try actions, next = - ply ~aggregate players static_base state state_rules in + ply_satur ~aggregate players static_base state state_rules in (* {{{ log entry *) if !debug_level > 0 then ( Printf.printf "playout: state %s\n%!" @@ -781,8 +967,7 @@ ); (* }}} *) let next = - if aggregate && !aggregate_drop_negative then state @ next - else next in + if aggregate then state @ next else next in if step < horizon then loop (actions::actions_accu) (state::state_accu) (step+1) next else @@ -806,6 +991,136 @@ +(* [~aggregate:true] performs an aggregate ply, [~aggregate:false] + performs a random ply. *) +let ply_prolog ~aggregate players current program = + let program = + replace_rel_in_program "true" + (List.map (fun term -> ("true", [|term|]), []) current) program in + let legal_terms = List.map snd + (run_prolog_atom ("legal", [|Var "x"; Var "y"|]) program) in + let program = + if aggregate then (run_prolog_aggregate := true; program) + else ( + run_prolog_aggregate := false; + let legal_by_player = Aux.collect + (List.map + (function [|pl; lterm|] -> pl, lterm | _ -> assert false) + legal_terms) in + let does_cls = List.map + (fun (player, lterms) -> + ("does", [|player; Aux.random_elem lterms|]), []) + legal_by_player in + replace_rel_in_program "does" does_cls program) in + if (* no move *) + Aux.array_existsi (fun _ player -> + not (run_prolog_check_goal + [Pos (Rel ("legal", [|player; Var "y"|]))] program)) + players + then ( + (* {{{ log entry *) + if !debug_level > 1 then ( + let players_nomove = + Aux.array_find_all (fun player -> + List.for_all (function [|actor; _|] -> player <> actor + | _ -> true) + legal_terms) players in + Printf.printf + "GDL.ply_prolog: playout over due to no move for %s\n%!" + (String.concat ", " (List.map term_str players_nomove)) + ); + (* }}} *) + raise Playout_over) + else + let step = run_prolog_atom ("next", [|Var "x"|]) program in + let step_state = Aux.map_some + (function ("next", [|arg|]) -> Some arg + | _ -> None) step in + if !playout_fixpoint && (* fixpoint reached *) + Aux.sorted_diff step_state current = [] && + (aggregate || Aux.sorted_diff current step_state = []) + then ( + (* {{{ log entry *) + if !debug_level > 1 then ( + Printf.printf "GDL.ply: playout over due to fixpoint\n%!"; + ); + (* }}} *) + raise Playout_over) + else if not aggregate && (* terminal position reached *) + run_prolog_check_goal + [Pos (Rel ("terminal", [||]))] program + then ( + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "GDL.ply: playout over due to terminal position\n%!"; + ); + (* }}} *) + raise Playout_over) + else + legal_terms, step_state + +let remove_neg_lits cls = + let rec neg_lit = function + | Neg _ | Pos (Distinct _) -> true + | Disj disj when List.exists neg_lit disj -> true + | _ -> false in + List.map (fun (h, b) -> h, List.filter (Aux.neg neg_lit) b) cls + +(* Note that the list of playout states is + one longer than that of playout actions. + + To keep monotonicity, besides removing negative literals from + "legal" clauses, we also add old terms to the state. (Only when + [~aggregate:true].) + + [~aggregate:true] performs an aggregate ply, [~aggregate:false] + performs a random ply. Aggregate playouts are "deprecated", + especially for uses other than generating all possible state + terms. *) +let playout_prolog ~aggregate players horizon program = + let program = + if aggregate then + let next_cls = assoc_clauses ("next",[|Var "x"|]) program in + let legal_cls = assoc_clauses ("legal",[|Var "x"|]) program in + replace_rel_in_program "next" (remove_neg_lits next_cls) + (replace_rel_in_program "legal" (remove_neg_lits legal_cls) program) + else program in + + let rec loop actions_accu state_accu step state = + (* {{{ log entry *) + if !debug_level > 1 then ( + Printf.printf "playout_prolog: step %d...\n%!" step + ); + (* }}} *) + (let try actions, next = + ply_prolog ~aggregate players state program in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "playout: state %s\n%!" + (String.concat " " (List.map term_str next)) + ); + (* }}} *) + let next = + if aggregate then Aux.sorted_merge state next else next in + if step < horizon then + loop (actions::actions_accu) (state::state_accu) (step+1) next + else + List.rev (actions::actions_accu), + List.rev (next::state::state_accu) + with Playout_over -> + List.rev actions_accu, List.rev (state::state_accu)) in + let init_state = List.map (fun (_,args) -> args.(0)) + (run_prolog_atom ("init", [|Var "x"|]) program) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "playout: init %s\n%!" + (String.concat " " (List.map term_str init_state)) + ); + (* }}} *) + loop [] [] 0 init_state + + + let find_cycle cands = (* {{{ log entry *) if !debug_level > 0 then ( @@ -864,12 +1179,14 @@ (** Partition relations into static (not depending, even indirectly, on "true") and remaining ones. *) let static_rels defs = + let base_dyn = + ["init"; "does"; "true"; "next"; "terminal"; "goal"] in let rec aux nonstatic remaining = let more = Aux.map_some (fun (rel, branches) -> if List.exists (fun (_, body, neg_body) -> let called = List.map fst (body @ neg_body) in - List.exists (fun rel -> rel = "true" || + List.exists (fun rel -> List.mem rel base_dyn || List.mem rel nonstatic) called ) branches then Some rel else None Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-13 21:19:21 UTC (rev 1539) +++ trunk/Toss/GGP/GDL.mli 2011-08-16 11:29:29 UTC (rev 1540) @@ -2,7 +2,6 @@ Type definitions, helper functions. *) val debug_level : int ref -val aggregate_drop_negative : bool ref val playout_fixpoint : bool ref (** {3 Datalog programs: Type definitions and saturation.} *) @@ -53,6 +52,7 @@ val term_vars : term -> Aux.Strings.t val terms_vars : term array -> Aux.Strings.t val clause_vars : clause -> Aux.Strings.t +val clauses_vars : clause list -> Aux.Strings.t val defs_of_rules : gdl_rule list -> gdl_defs val rules_of_clause : clause -> gdl_rule list @@ -77,6 +77,33 @@ val saturate : rel_atom list -> gdl_rule list -> rel_atom list +(** {3 Continuation-based Prolog interpreter} *) + +(** The interpreter can reinterpret "does" atoms as "legal" atoms for + aggregate playout. For random playout, remember to compute legal + moves, select randomly one for each player and add "does" atoms to + the program. *) +val run_prolog_aggregate : bool ref + +type prolog_program +val preprocess_program : clause list -> prolog_program +val replace_rel_in_program : + string -> clause list -> prolog_program -> prolog_program + +(** Compute all implied instantiations of the given atom, return + sorted unique instances. *) +val run_prolog_atom : rel_atom -> prolog_program -> rel_atom list +(** Compute all variable substitutions that satisfy the given + conjunction of literals. The substitutions are not unique (there + is as many of them as there are different proofs of the goal). *) +val run_prolog_goal : literal list -> prolog_program -> substitution list +(** Just check if the atom / conjunction of literals is + satisfiable. Should be faster than checking non-emptiness of + [run_prolog_goal] result. *) +val run_prolog_check_atom : rel_atom -> prolog_program -> bool +val run_prolog_check_goal : literal list -> prolog_program -> bool + + (** {3 Transformations of GDL clauses: inlining, negation.} *) (** Expand branches of a definition inlining the provided definitions, @@ -103,6 +130,8 @@ val elim_ground_args : string list -> clause list -> string list * clause list +val state_cls : term list -> clause list + (** {3 GDL translation helpers.} *) val blank : term @@ -128,9 +157,9 @@ val static_rels : gdl_defs -> string list * string list -(** Besides the aggregate playout, also return the separation of rules - into static and dynamic. Note that the list of playout states is - one longer than that of playout actions. +(** Besides the aggregate or random playout, also return the + separation of rules into static and dynamic. Note that the list of + playout states is one longer than that of playout actions. When [aggregate_drop_negative] is true, to keep monotonicity, besides removing negative literals from "legal" clauses, we also @@ -140,12 +169,16 @@ performs a random ply. Aggregate playouts are "deprecated", especially for uses other than generating all possible state terms. *) -val playout : +val playout_satur : aggregate:bool -> term array -> int -> gdl_rule list -> gdl_rule list * gdl_rule list * rel_atom list * term list * (term array list list * term list list) +val playout_prolog : + aggregate:bool -> term array -> int -> prolog_program -> + term array list list * term list list + val find_cycle : term option list -> term option list val expand_players : clause list -> clause list Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-08-13 21:19:21 UTC (rev 1539) +++ trunk/Toss/GGP/GDLTest.ml 2011-08-16 11:29:29 UTC (rev 1540) @@ -103,11 +103,78 @@ (String.concat " " (List.map GDL.rel_atom_str res)); ); + + "run_prolog" >:: + (fun () -> + let descr = parse_game_descr + " +(<= (alpha ?X) (beta ?X) (not (theta ?X))) +(<= (zeta ?X) (beta ?X) (not (gamma ?X))) +(<= (beta ?X) (gamma ?X)) +(gamma paper) +(beta rock) +(theta scisors) (gamma scisors)" in + (* GDL.debug_level := 3; *) + let program = GDL.preprocess_program descr in + let res = GDL.run_prolog_atom ("alpha", [|Var "X"|]) program in + assert_equal ~printer:(fun x->x) ~msg:"run_prolog alpha" + "(alpha paper) (alpha rock)" + (String.concat " " + (List.map GDL.rel_atom_str res)); + let res = GDL.run_prolog_atom ("zeta", [|Var "X"|]) program in + assert_equal ~printer:(fun x->x) ~msg:"run_prolog alpha" + "(zeta rock)" + (String.concat " " + (List.map GDL.rel_atom_str res)); - "playout simple" >:: + let descr = parse_game_descr + " +(<= (two-of-three ?X ?Y) (a ?X) (a ?Y) (distinct ?X ?Y)) +(a 1) (a 2) (a 3)" in + (* GDL.debug_level := 3; *) + let program = GDL.preprocess_program descr in + let res = + GDL.run_prolog_atom ("two-of-three", [|Var "X"; Var "Y"|]) + program in + assert_equal ~printer:(fun x->x) ~msg:"simple distinct" + "(two-of-three 1 2) (two-of-three 1 3) (two-of-three 2 1) (two-of-three 2 3) (two-of-three 3 1) (two-of-three 3 2)" + (String.concat " " + (List.map GDL.rel_atom_str res)); + ); + + "run_prolog recursive" >:: (fun () -> let descr = parse_game_descr " +(<= (lte 0 ?x) + (number ?x)) +(<= (lte ?x ?x) + (number ?x)) +(<= (lte ?x ?z) + (succ ?y ?z) + (lte ?x ?y)) +(<= (lte ?x ?y) + (succ ?x ?y)) +(number 0) (number 1) (number 2) (number 3) +(number 4) (number 5) (number 6) (number 7) (number 8) +(succ 0 1) (succ 1 2) (succ 2 3) (succ 3 4) +(succ 4 5) (succ 5 6) (succ 6 7) (succ 7 8) +" in + (* GDL.debug_level := 3; *) + let program = GDL.preprocess_program descr in + let res = + GDL.run_prolog_atom ("lte", [|Var "x"; Var "y"|]) + program in + assert_equal ~printer:(fun x->x) ~msg:"simple stratified" + "(lte 0 0) (lte 0 1) (lte 0 2) (lte 0 3) (lte 0 4) (lte 0 5) (lte 0 6) (lte 0 7) (lte 0 8) (lte 1 1) (lte 1 2) (lte 1 3) (lte 1 4) (lte 1 5) (lte 1 6) (lte 1 7) (lte 1 8) (lte 2 2) (lte 2 3) (lte 2 4) (lte 2 5) (lte 2 6) (lte 2 7) (lte 2 8) (lte 3 3) (lte 3 4) (lte 3 5) (lte 3 6) (lte 3 7) (lte 3 8) (lte 4 4) (lte 4 5) (lte 4 6) (lte 4 7) (lte 4 8) (lte 5 5) (lte 5 6) (lte 5 7) (lte 5 8) (lte 6 6) (lte 6 7) (lte 6 8) (lte 7 7) (lte 7 8) (lte 8 8)" + (String.concat " " + (List.map GDL.rel_atom_str res)); + ); + + "playout_satur simple" >:: + (fun () -> + let descr = parse_game_descr + " (role x) (role o) (init (cell a a b)) @@ -132,7 +199,7 @@ " in let _, _, _, _, (agg_actions, _) = - GDL.playout ~aggregate:true [|GDL.Const "x"; GDL.Const "o"|] + GDL.playout_satur ~aggregate:true [|GDL.Const "x"; GDL.Const "o"|] 10 (Aux.concat_map GDL.rules_of_clause descr) in let actions = List.map (List.map (fun a->"does", a)) agg_actions in assert_equal ~printer:(fun x->x) ~msg:"aggregate" @@ -142,7 +209,7 @@ (List.map GDL.rel_atom_str step)) actions)); let _, _, _, _, (rand_actions, _) = - GDL.playout ~aggregate:false [|GDL.Const "x"; GDL.Const "o"|] + GDL.playout_satur ~aggregate:false [|GDL.Const "x"; GDL.Const "o"|] 10 (Aux.concat_map GDL.rules_of_clause descr) in let actions = List.map (List.map (fun a->"does", a)) rand_actions in let res = @@ -156,6 +223,59 @@ (does o (mark b a)) (does x noop)"]) ); + "playout_prolog simple" >:: + (fun () -> + let descr = parse_game_descr + " +(role x) +(role o) +(init (cell a a b)) +(init (cell b a b)) +(init (control x)) +(<= (next (control ?r)) + (does ?r noop)) +(<= (next (cell ?x ?y ?r)) + (does ?r (mark ?x ?y))) +(<= (next (cell ?x ?y ?c)) + (true (cell ?x ?y ?c)) + (does ?r (mark ?x1 ?y1)) + (or (distinct ?x ?x1) + (distinct ?y ?y1))) +(<= (legal ?r (mark ?x ?y)) + (true (control ?r)) + (true (cell ?x ?y b)) + ) +(<= (legal ?r noop) + (role ?r) + (not (true (control ?r)))) +" in + + let program = GDL.preprocess_program descr in + let agg_actions, _ = + GDL.playout_prolog ~aggregate:true [|GDL.Const "x"; GDL.Const "o"|] + 10 program in + let actions = List.map (List.map (fun a->"does", a)) agg_actions in + assert_equal ~printer:(fun x->x) ~msg:"aggregate" + "(does o noop) (does x noop) (does x (mark a a)) (does x (mark b a)); +(does o noop) (does o (mark a a)) (does o (mark b a)) (does x noop) (does x (mark a a)) (does x (mark b a))" + (String.concat ";\n" (List.map (fun step -> String.concat " " + (List.map GDL.rel_atom_str step)) actions)); + + let rand_actions, _ = + GDL.playout_prolog ~aggregate:false [|GDL.Const "x"; GDL.Const "o"|] + 10 program in + let actions = List.map (List.map (fun a->"does", a)) rand_actions in + let res = + String.concat ";\n" (List.map (fun step -> String.concat " " + (List.map GDL.rel_atom_str step)) actions) in + assert_bool ( + "random (see expected result in the test source): got " ^ res) + (List.mem res ["(does o noop) (does x (mark a a)) (does x (mark b a)); +(does o (mark a a)) (does x noop)"; +"(does o noop) (does x (mark a a)) (does x (mark b a)); +(does o (mark b a)) (does x noop)"]) + ); + "expand players connect5" >:: (fun () -> let descr = load_rules ("./GGP/examples/connect5.gdl") in @@ -279,9 +399,14 @@ (fun () -> let descr = load_rules ("./GGP/examples/connect5.gdl") in let clauses = expand_players descr in + (* let _, _, _, _, (rand_actions, _) = - GDL.playout ~aggregate:false [|GDL.Const "x"; GDL.Const "o"|] + GDL.playout_satur ~aggregate:false [|GDL.Const "x"; GDL.Const "o"|] 10 (Aux.concat_map GDL.rules_of_clause clauses) in + *) + let rand_actions, _ = + GDL.playout_prolog ~aggregate:false [|GDL.Const "x"; GDL.Const "o"|] + 10 (GDL.preprocess_program clauses) in let noop_actions = Aux.take_n 9 (List.map (Aux.map_some @@ -301,5 +426,7 @@ let a () = GDL.debug_level := 5 +let a () = + () let exec = Aux.run_test_if_target "GDLTest" tests Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-13 21:19:21 UTC (rev 1539) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-16 11:29:29 UTC (rev 1540) @@ -47,6 +47,10 @@ (** Limit on the number of steps for aggregate and random playouts. *) let playout_horizon = ref 20 +(** How many random playouts to generate states for rule filtering (a + rule needs to match in at least one generated state to be kept). *) +let playouts_for_rule_filtering = ref 4 + let env_player = Const "ENVIRONMENT" type tossrule_data = { @@ -246,13 +250,17 @@ ) clauses in let players = Array.of_list players in let rules = Aux.concat_map rules_of_clause clauses in + (* let static_rel_defs, nonstatic_rel_defs, static_base, init_state, (agg_actions, agg_states) = - playout ~aggregate:true players !playout_horizon rules in - let static_rels = Aux.unique_sorted - (List.map (fun ((rel,_),_,_)->rel) static_rel_defs) in - let nonstatic_rels = Aux.unique_sorted - (List.map (fun ((rel,_),_,_)->rel) nonstatic_rel_defs) in + playout_satur ~aggregate:true players !playout_horizon rules in + *) + let program = preprocess_program clauses in + let agg_actions, agg_states = + playout_prolog ~aggregate:true players !playout_horizon program in + let init_state = List.hd agg_states in + let static_rels, nonstatic_rels = + static_rels (defs_of_rules rules) in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf @@ -336,8 +344,9 @@ let fact_rel = rel_on_paths rel ptup in Aux.fold_left_try (fun struc etup -> let tup = Array.of_list (List.map2 at_path etup ptup) in - if rel = "EQ_" && arity = 2 && tup.(0) = tup.(1) - || List.mem (rel, tup) static_base + if rel = "EQ_" && arity = 2 && tup.(0) = tup.(1) || + (* List.mem (rel, tup) static_base *) + run_prolog_check_atom (rel, tup) program then ( stable_rels := Aux.Strings.add fact_rel !stable_rels; Structure.add_rel_named_elems struc fact_rel @@ -403,7 +412,7 @@ frame_clauses @ move_clauses @ clauses, f_paths, m_paths, mask_reps, defined_rels, Aux.Strings.elements !stable_rels, Aux.Strings.elements !fluents, - static_base, init_state, struc, ground_state_terms, elem_term_map + init_state, struc, ground_state_terms, elem_term_map (* substitute a "next" clause with frame info *) let subst_fnextcl sb (head, frame, body) = @@ -951,25 +960,40 @@ (* }}} *) result, is_concurrent - -let filter_rule_cands static_base defined_rels rule_cands = - let check_atom = function - | Pos (Rel (rel, _ as a)) -> - List.mem rel defined_rels || - List.exists (rels_unify a) static_base - | Neg (Rel (rel, _ as a)) -> - List.mem rel defined_rels || - not (List.exists (rels_unify a) static_base) - | _ -> true in +(* We use a bunch of possible game states, generated by random + playouts, to approximate which rule candidates are satisfiable in + some reachable state. *) +let filter_rule_cands players program rule_cands = + (* {{{ log entry *) + if !debug_level > 1 then ( + Printf.printf "filter_rule_cands: generating states...\n%!"; + ); + (* }}} *) + let states = Aux.fold_n + (fun acc -> + let _, states = + playout_prolog ~aggregate:false players !playout_horizon + program in + states @ acc) [] !playouts_for_rule_filtering in + (* {{{ log entry *) + if !debug_level > 1 then ( + Printf.printf "filter_rule_cands: generated %d states.\n%!" + (List.length states) + ); + (* }}} *) let check_cands cands = List.filter (fun (_, _, case_conds) -> - let res = List.for_all check_atom case_conds in + let res = List.exists + (fun state -> + run_prolog_check_goal case_conds + (replace_rel_in_program "true" (state_cls state) program)) + states in (* {{{ log entry *) - if !debug_level > 2 then ( + if !debug_level > 1 then ( Printf.printf "check_cands: cond %s -- %b\n%!" (String.concat " "(List.map literal_str case_conds)) res ); - (* }}} *) + (* }}} *) res ) cands in match rule_cands with @@ -982,15 +1006,19 @@ (* Check if game is turn based and return the player cycle if it is, otherwise rise [Not_turn_based]. Also return the [noop] actions for players in the locations. *) -let check_turn_based players rules = +let check_turn_based players program = let check_one_playout () = (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "check_turn_based: starting check_one_playout\n" ); (* }}} *) + (* let _, _, _, _, (playout_actions, playout_states) = - playout ~aggregate:false players !playout_horizon rules in + playout_satur ~aggregate:false players !playout_horizon rules in + *) + let playout_actions, playout_states = + playout_prolog ~aggregate:false players !playout_horizon program in (* {{{ log entry *) if !debug_level > 3 then ( let actions = List.map @@ -1345,11 +1373,15 @@ payoffs -let transl_arg_type_no_side defined_rels static_base init_state +let transl_arg_type_no_side defined_rels init_state program ground_at_m_paths = assert (ground_at_m_paths <> []); + let program = + replace_rel_in_program "true" (state_cls init_state) program in List.map (fun (rel, ar) -> - let rel_graph = Aux.assoc_all rel static_base in + let vtup = Array.init ar (fun i -> Var ("v"^string_of_int i)) in + let rel_graph = List.map snd + (run_prolog_atom (rel, vtup) program) in match rel_graph with (* empty graph, take any path *) | [] -> rel, Array.make ar None @@ -1381,7 +1413,7 @@ let players, rules, clauses, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, - static_base, init_state, struc, ground_state_terms, elem_term_map = + (*static_base,*) init_state, struc, ground_state_terms, elem_term_map = create_init_struc clauses in let ground_at paths = List.map (fun p -> @@ -1405,13 +1437,17 @@ | ("next",[|s_C|]),body_C -> Some (s_C, false, body_C) | _ -> None) clauses in + (* For determining turn-based we could use the original program, but + for filtering the rule candidates we need the transformed + clauses. *) + let program = preprocess_program clauses in let turn_data = - try Some (check_turn_based players rules) + try Some (check_turn_based players program) with Not_turn_based -> None in let rule_cands, is_concurrent = create_rule_cands turn_data used_vars f_paths next_cls clauses in let rule_cands = - filter_rule_cands static_base defined_rels rule_cands in + filter_rule_cands players program rule_cands in let term_arities = Aux.unique_sorted (Aux.concat_map term_arities ground_state_terms) in let defined_rel_arities = List.map @@ -1428,7 +1464,7 @@ defrel_arg_type = ref []; (* built in TranslateFormula *) term_arities = term_arities; rel_default_path = - transl_arg_type_no_side defined_rel_arities static_base init_state + transl_arg_type_no_side defined_rel_arities init_state program (ground_at m_paths); } in let defined_rels = TranslateFormula.build_defrels transl_data clauses in Modified: trunk/Toss/GGP/TranslateGame.mli =================================================================== --- trunk/Toss/GGP/TranslateGame.mli 2011-08-13 21:19:21 UTC (rev 1539) +++ trunk/Toss/GGP/TranslateGame.mli 2011-08-16 11:29:29 UTC (rev 1540) @@ -5,6 +5,10 @@ (** Limit on plys for both aggregate and random playouts. *) val playout_horizon : int ref +(** How many random playouts to generate states for rule filtering (a + rule needs to match in at least one generated state to be kept). *) +val playouts_for_rule_filtering : int ref + type tossrule_data = { legal_tuple : GDL.term array; (* the "legal"/"does" term of the player that performs the move @@ -54,14 +58,14 @@ relation name "frame next". [players, rules, frame_cls, move_cls, f_paths, m_paths, mask_reps, - defined_rels, stable_rels, fluents, stable_base, init_state, + defined_rels, stable_rels, fluents, init_state, struc, ground_state_terms, elem_term_map = create_init_struc clauses] *) val create_init_struc : GDL.clause list -> GDL.term array * GDL.gdl_rule list * GDL.clause list * GDL.path_set * GDL.path_set * GDL.term list * string list * string list * - string list * GDL.rel_atom list * GDL.term list * + string list * GDL.term list * Structure.structure * GDL.term list * GDL.term Aux.IntMap.t Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-13 21:19:21 UTC (rev 1539) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-16 11:29:29 UTC (rev 1540) @@ -122,7 +122,7 @@ let players, rules, clauses, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, - stable_base, init_state, struc, ground_state_terms, elem_term_map = + init_state, struc, ground_state_terms, elem_term_map = TranslateGame.create_init_struc clauses in assert_equal ~msg:"f_paths" ~printer:(fun x->x) @@ -217,7 +217,7 @@ ] let a () = - (* GDL.debug_level := 2; *) + GDL.debug_level := 2; TranslateGame.debug_level := 4; GameSimpl.debug_level := 4; DiscreteRule.debug_level := 4; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-13 21:19:29
|
Revision: 1539 http://toss.svn.sourceforge.net/toss/?rev=1539&view=rev Author: lukstafi Date: 2011-08-13 21:19:21 +0000 (Sat, 13 Aug 2011) Log Message: ----------- GDL translation: completely reworked clause partitioning for rule candidate generation (replacing a placeholder in the reimplementation); a couple of bug fixes. Modified Paths: -------------- trunk/Toss/Formula/FormulaOps.ml trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GameSimpl.ml trunk/Toss/GGP/TranslateFormula.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/GGP/tests/tictactoe-raw.toss trunk/Toss/GGP/tests/tictactoe-simpl.toss Modified: trunk/Toss/Formula/FormulaOps.ml =================================================================== --- trunk/Toss/Formula/FormulaOps.ml 2011-08-13 01:47:40 UTC (rev 1538) +++ trunk/Toss/Formula/FormulaOps.ml 2011-08-13 21:19:21 UTC (rev 1539) @@ -124,19 +124,21 @@ let free_vars phi = remove_dup_vars [] (List.sort compare_vars (free_vars_acc [] phi)) -(* Delete top-most ex/all quantification of [vs] in the formula. *) +(* Delete all quantification over [vs] in the formula. *) let rec del_vars_quant vs = function | Eq _ | Rel _ | In _ | SO _ | RealExpr _ as f -> f | Not phi -> Not (del_vars_quant vs phi) | And (flist) -> And (List.map (del_vars_quant vs) flist) | Or (flist) -> Or (List.map (del_vars_quant vs) flist) | Ex ([], phi) | All ([], phi) -> del_vars_quant vs phi - | Ex (v :: vr, phi) when List.mem v vs -> - del_vars_quant (Aux.list_remove v vs) (Ex (vr, phi)) - | Ex (v :: vr, phi) -> Ex ([v], del_vars_quant vs (Ex (vr, phi))) - | All (v :: vr, phi) when List.mem v vs -> - del_vars_quant (Aux.list_remove v vs) (All (vr, phi)) - | All (v :: vr, phi) -> All ([v], del_vars_quant vs (All (vr, phi))) + | Ex (vr, phi) -> + let vr = Aux.list_diff vr vs in + if vr = [] then del_vars_quant vs phi + else Ex (vr, del_vars_quant vs phi) + | All (vr, phi) -> + let vr = Aux.list_diff vr vs in + if vr = [] then del_vars_quant vs phi + else All (vr, del_vars_quant vs phi) | Lfp (r, xs, phi) -> Lfp (r, xs, del_vars_quant vs phi) | Gfp (r, xs, phi) -> Gfp (r, xs, del_vars_quant vs phi) Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-13 01:47:40 UTC (rev 1538) +++ trunk/Toss/GGP/GDL.ml 2011-08-13 21:19:21 UTC (rev 1539) @@ -247,7 +247,7 @@ (try List.assoc y sb with Not_found -> t) | Var _ as t -> t | Func (f, args) -> - Func (f, Array.map (subst sb) args) + Func (f, Array.map (subst_consts sb) args) let rec unify_all sb = function | [] | [_] -> sb Modified: trunk/Toss/GGP/GameSimpl.ml =================================================================== --- trunk/Toss/GGP/GameSimpl.ml 2011-08-13 01:47:40 UTC (rev 1538) +++ trunk/Toss/GGP/GameSimpl.ml 2011-08-13 21:19:21 UTC (rev 1539) @@ -275,13 +275,25 @@ match spec with | None -> rel | Some spec -> DiscreteRule.orig_rel_of rel in - rel <> "" && - not (Aux.Strings.mem rel fluents) && - not (List.mem_assoc rel game.Arena.defined_rels) && - not (List.exists (fun (_,(rel2,_)) -> rel2=rel) equivalent) && - not (Aux.Strings.mem (fst (List.assoc rel equivalent)) fluents || - List.mem_assoc (fst (List.assoc rel equivalent)) - game.Arena.defined_rels) + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "removable: %s...%!" rel + ); + (* }}} *) + let res = + rel <> "" && + not (Aux.Strings.mem rel fluents) && + not (List.mem_assoc rel game.Arena.defined_rels) && + not (List.exists (fun (_,(rel2,_)) -> rel2=rel) equivalent) && + not (Aux.Strings.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 > 3 then ( + Printf.printf "%B\n%!" res; + ); + (* }}} *) + res in (* {{{ log entry *) if !debug_level > 0 then ( Modified: trunk/Toss/GGP/TranslateFormula.ml =================================================================== --- trunk/Toss/GGP/TranslateFormula.ml 2011-08-13 01:47:40 UTC (rev 1538) +++ trunk/Toss/GGP/TranslateFormula.ml 2011-08-13 21:19:21 UTC (rev 1539) @@ -209,7 +209,8 @@ let pos_terms = state_terms pos_state_phi in let pos_vars = List.map (var_of_term data) pos_terms in let neg_terms = state_terms neg_state_phi in - let neg_vars = List.map (var_of_term data) neg_terms in + let neg_vars = + Aux.list_diff (List.map (var_of_term data) neg_terms) pos_vars in let all_terms = pos_terms @ neg_terms in let phi_vars = clause_vars (("", [| |]), @@ -231,15 +232,18 @@ (* negation-normal-form of "not neg_state_phi" *) Formula.Or ( List.map (transl_state data) (nnf_dnf neg_state_phi)) in + let negated_part = + Formula.And [ + (* positive because they form a "premise" *) + transl_rels data rels_eqs all_terms neg_terms; + (* the universal "conclusion" *) + negated_neg_state_transl] in let universal_part = if neg_terms = [] then [] + else if neg_vars = [] + then [Formula.Not negated_part] else [Formula.Not ( - Formula.Ex (((Aux.list_diff neg_vars pos_vars) :> Formula.var list), - Formula.And [ - (* positive because they form a "premise" *) - transl_rels data rels_eqs all_terms neg_terms; - (* the universal "conclusion" *) - negated_neg_state_transl]))] in + Formula.Ex ((neg_vars :> Formula.var list), negated_part))] in let base_part = Formula.And ( [ ext_phi; Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-13 01:47:40 UTC (rev 1538) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-13 21:19:21 UTC (rev 1539) @@ -47,9 +47,6 @@ (** Limit on the number of steps for aggregate and random playouts. *) let playout_horizon = ref 20 -(** Use "true" atoms while computing rule cases. *) -let split_on_state_atoms = ref false - let env_player = Const "ENVIRONMENT" type tossrule_data = { @@ -452,8 +449,8 @@ (* Find the rule clauses $\ol{\calC},\ol{\calN}$. Also handles as special cases: "concurrent" case with selecting clauses for only one player, and "environment" case for selecting clauses not - dependent on any player. Preserve legal clauses into the output - tuples. *) + dependent on any player. Preserve "legal" clauses into the output + tuples. Mark which "next" clauses contained "does" atoms. *) let move_tuples used_vars next_cls mode players legal_tuples = (* computing the $d_i(\calN)$ for each $\calN$ *) let fresh_x_f () = @@ -532,12 +529,19 @@ with Not_found -> cl_tup ) cl_tup next_clauses in let cl_tups = List.map maximality cl_tups in - (* removing "does" atoms from clauses *) + (* Removing "does" atoms from clauses, but leaving a trace: a + clause containing "does" atom is required to participate in + the rewrite rule. *) List.map (fun (sb, _, n_cls) -> let n_cls = List.map (fun (head,frame,body) -> - head, frame, - List.filter - (function Pos (Does _) -> false | _ -> true) body) n_cls in + if List.exists + (function Pos (Does _) -> true | _ -> false) body + then + head, (frame, true), + List.filter + (function Pos (Does _) -> false | _ -> true) body + else + head, (frame, false), body) n_cls in sb, legal_tup, n_cls) cl_tups in Aux.concat_map move_clauses legal_tuples @@ -551,7 +555,7 @@ ); (* }}} *) let frame_cls = - Aux.map_some (fun (s, frame, body) -> + Aux.map_some (fun (s, (frame, _), body) -> if frame then Some (s, body) else None) next_cls in (* two passes to ensure coverage and maximality *) (* Treating fixed-vars as consts, by substituting them with @@ -592,6 +596,13 @@ let frames = List.map (fun (sb, s, bodies) -> s, List.map (subst_literals sb) bodies) frames in + (* removing the framed state terms *) + let frames = + let filter_out s body = + List.filter + (function Pos (True t) when t=s -> false | _ -> true) body in + List.map (fun (s, bodies) -> + s, List.map (filter_out s) bodies) frames in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "add_erasure_clauses: frames --\n%!"; @@ -633,54 +644,112 @@ let erasure_cls = List.map (subst_consts_clause fixed_to_var) (List.map (fun (s,body)->("erasure next",[|s|]),body) erasure_cls) in + (* Erasure clauses are considered as not having "does" atoms, + although of course the frame clauses did have "does" atoms. *) let erasure_cls = - List.map (fun ((_,h),body) -> h.(0),body) erasure_cls in + List.map (fun ((_,h),body) -> h.(0),false,body) erasure_cls in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "add_erasure_clauses: erasure clauses --\n%!"; - let print_erasure (s, body) = + let print_erasure (s, _, body) = Printf.printf "ERASURE: %s <== %s\n%!" (term_str s) (String.concat " " (List.map literal_str body)) in List.iter print_erasure erasure_cls; flush stdout; ); (* }}} *) let next_cls = - Aux.map_some (fun (s, frame, body) -> - if not frame then Some (s, body) else None) next_cls in + Aux.map_some (fun (s, (frame, required), body) -> + if not frame then Some (s, required, body) else None) next_cls in legal_tup, next_cls @ erasure_cls -(* Assign rule clauses to rule cases, i.e. candidates for - Toss rules. Collect the conditions and RHS state terms together. - Frame clauses are already processed into erasure clauses. *) -let rule_cases next_cls = - let atoms = Aux.concat_map - (fun (_, body) -> Aux.map_some (function - | Pos (Rel _ as a) | Neg (Rel _ as a) -> Some a - | (Pos (True _ as a) | Neg (True _ as a)) - when !split_on_state_atoms -> Some a - | _ -> None) body) next_cls in - if atoms = [] then (* single partition *) - let case_rhs, case_conds = List.split next_cls in +let ignore_rhs = Const "__IGNORE_RHS__" + +(* Assign rule clauses to rule cases, i.e. candidates for Toss + rules. Collect the conditions and RHS state terms together. Frame + clauses are already processed into erasure clauses. Rule clauses + should contain the "legal" clauses with heads replaced by + "_IGNORE_RHS_" terms which will be discarded later; "legal" clauses + and "next" clauses that contained "does" atoms should be marked as + required. + + We call atoms or literals "deterministic" if they are not under + disjunction. First we collect deterministic literals of required + clauses, and remove unrequired clauses that have deterministic + literals conflicting with deterministic literals of required clauses. + + The candidates are built by partitioning rule clauses. We select + "case-split atoms": the deterministic atoms of unrequired clauses + that are not deterministic atoms of required clauses. To further + decrease the number of case-split atoms, we build "patterns": + collect atoms that occur in the same clauses with the same sign, + and from each pattern we pick just one arbitrary atom. We generate + all sign assingments to case-split atoms -- each is a potential + rule case. For each sign assignment, we select exactly those + unrequired clauses that have no literals disagreeing with the sign + assignment. + + TODO: unrequired clauses with disjunctions may avoid being + excluded. If this poses problems we might need to expand + disjunctions containing potentially case-split atoms. + +*) +let rule_cases rule_cls = + let required_cls = Aux.map_some + (fun (h, required, body) -> + if required then Some (h, body) else None) rule_cls in + let unrequired_cls = Aux.map_some + (fun (h, required, body) -> + if not required then Some (h, body) else None) rule_cls in + let forbidden_lits = Aux.unique_sorted + (Aux.concat_map + (fun (_, body) -> Aux.map_some (function + | Pos (Rel _ as a) | Pos (True _ as a) -> Some (Neg a) + | Neg (Rel _ as a) | Neg (True _ as a) -> Some (Pos a) + | _ -> None) body) required_cls) in + let unrequired_cls = List.filter + (fun (_, body) -> + not (List.exists (fun flit -> List.mem flit body) + forbidden_lits)) + unrequired_cls in + let req_atoms = List.map + (function Pos a -> a | Neg a -> a | _ -> assert false) + forbidden_lits in + let unreq_atoms = Aux.unique_sorted + (Aux.concat_map + (fun (_, body) -> Aux.map_some (function + | Pos (Rel _ as a) | Pos (True _ as a) + | Neg (Rel _ as a) | Neg (True _ as a) -> Some a + | _ -> None) body) unrequired_cls) in + let split_atoms = Aux.list_diff unreq_atoms req_atoms in + if split_atoms = [] then (* single partition *) + let rule_cls = required_cls @ unrequired_cls in + let case_rhs, case_conds = List.split rule_cls in + let case_rhs = Aux.list_remove ignore_rhs case_rhs in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "rule_cases: single partition\n%!"; ); (* }}} *) - [next_cls, case_rhs, List.concat case_conds] + [Aux.unique_sorted case_rhs, + Aux.unique_sorted (List.concat case_conds)] else let patterns = - let next_cls = Array.of_list next_cls in + let unrequired_cls = Array.of_list unrequired_cls in List.map (fun a -> Array.mapi (fun i (_, body) -> if List.mem (Neg a) body then -1 else if List.mem (Pos a) body then 1 else 0 - ) next_cls, - a) atoms in + ) unrequired_cls, + a) split_atoms in let patterns = Aux.collect patterns in + let split_atoms = List.map + (fun (_,atoms) -> List.hd atoms) patterns in (* {{{ log entry *) if !debug_level > 2 then ( + Printf.printf "rule_cases: case-split atoms = %s\n%!" + (String.concat " " (List.map atom_str split_atoms)); Printf.printf "rule_cases: patterns --\n%!"; let print_pat (pattern, atoms) = Printf.printf "%a: %s\n%!" @@ -689,34 +758,29 @@ List.iter print_pat patterns ); (* }}} *) - let patterns = List.filter (fun (pat, _) -> - Aux.array_existsi (fun _ v-> v < 1) pat && - Aux.array_existsi (fun _ v-> v > -1) pat) patterns in - let pos_choice = List.map (fun _ -> true) patterns in - let neg_choice = List.map (fun _ -> false) patterns in - let choices = Aux.product [pos_choice; neg_choice] in + let choices = Aux.power split_atoms [false; true] in let rule_case choice = let separation_cond = - List.concat - (List.map2 (fun b (_, atoms) -> - if b then List.map (fun a -> Pos a) atoms - else List.map (fun a -> Neg a) atoms) choice patterns) in + List.map (fun (a,b) -> if b then Pos a else Neg a) choice in let case_cls = List.filter (fun (_, body) -> - List.for_all2 (fun b (_, atoms) -> - if b then (* atoms not excluded *) - List.for_all (fun a -> not (List.mem (Neg a) body)) atoms - else (* atoms not included *) - List.for_all (fun a -> not (List.mem (Pos a) body)) atoms - ) choice patterns - ) next_cls in + List.for_all (fun (a,b) -> + if b then (* atom not excluded *) + not (List.mem (Neg a) body) + else (* atom not included *) + not (List.mem (Pos a) body) + ) choice + ) unrequired_cls in + let case_cls = case_cls @ required_cls in let case_rhs, case_conds = List.split case_cls in - case_cls, case_rhs, separation_cond @ List.concat case_conds in + let case_rhs = Aux.list_remove ignore_rhs case_rhs in + Aux.unique_sorted case_rhs, + Aux.unique_sorted (separation_cond @ List.concat case_conds) in let res = List.map rule_case choices in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "rule_cases: next clauses partitioned into rules\n%!"; - let print_case i (_, case_rhs, case_cond) = + let print_case i (case_rhs, case_cond) = Printf.printf "\nRCAND: #%d\nRHS: %s\nLHS: %s\n%!" i (String.concat " " (List.map term_str case_rhs)) (String.concat " " (List.map literal_str case_cond)) in @@ -737,9 +801,9 @@ if !debug_level > 2 then ( Printf.printf "process_rule_cands: move tuples before adding erasure cls--\n%!"; - let nclause_str (rhs, is_frame, body) = + let nclause_str (rhs, (is_frame, required), body) = Printf.printf - "%s <=fr:%b= %s\n%!"(term_str rhs) is_frame + "%s <=fr:%B;req:%B= %s\n%!"(term_str rhs) is_frame required (String.concat " "(List.map literal_str body)) in let print_tup i (legal_tup, n_cls) = Printf.printf "CAND: #%d\nlegal_tup: %s\n%!" i @@ -753,12 +817,12 @@ let add_legal_cond (legal_tup, next_cls) = - let legal_tup, legal_cond = List.split legal_tup in - let legal_cond = List.concat legal_cond in - List.map (fun (case_cls, case_rhs, case_cond) -> - legal_tup, Aux.unique_sorted case_rhs, - Aux.unique_sorted (case_cond @ legal_cond) - ) (rule_cases next_cls) + let legal_tup, legal_conds = List.split legal_tup in + let legal_cls = List.map (* required clauses *) + (fun body -> ignore_rhs, true, body) legal_conds in + List.map + (fun (case_rhs, case_cond) -> legal_tup, case_rhs, case_cond) + (rule_cases (legal_cls @ next_cls)) let turnbased_rule_cases loc_noops used_vars f_paths next_cls @@ -1037,11 +1101,16 @@ rule_names := Aux.Strings.add rname !rule_names; let label = {Arena.lb_rule = rname; time_in = 0.1, 0.1; parameters_in = []} in - let precond = - Formula.And - (synch_precond @ - (* singleton disjunct, i.e. no disjunction *) - [TranslateFormula.translate transl_data [case_cond]]) in + let case_precond = + (* singleton disjunct, i.e. no disjunction *) + TranslateFormula.translate transl_data [case_cond] in + let precond = Formula.And (synch_precond @ [case_precond]) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "build_toss_rule: synch precond = %s; main precond = %s\n%!" + (Formula.str (Formula.And synch_precond)) (Formula.str case_precond) + ); + (* }}} *) let rhs_add = Aux.concat_map (fun sterm -> let s_subterms = Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-13 01:47:40 UTC (rev 1538) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-13 21:19:21 UTC (rev 1539) @@ -272,11 +272,12 @@ TranslateGame.generate_test_case := None let a () = - regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; + regenerate ~debug:true ~game_name:"tictactoe" ~player:"xplayer"; (* regenerate ~debug:false ~game_name:"connect5" ~player:"x"; *) (* regenerate ~debug:true ~game_name:"breakthrough" ~player:"white"; *) (* regenerate ~debug:true ~game_name:"pawn_whopping" ~player:"x"; *) (* regen_with_debug ~game_name:"connect4" ~player:"white"; *) + (* failwith "generated"; *) () let exec () = Modified: trunk/Toss/GGP/tests/tictactoe-raw.toss =================================================================== --- trunk/Toss/GGP/tests/tictactoe-raw.toss 2011-08-13 01:47:40 UTC (rev 1538) +++ trunk/Toss/GGP/tests/tictactoe-raw.toss 2011-08-13 21:19:21 UTC (rev 1539) @@ -192,43 +192,65 @@ _opt_cell_2b (control__BLANK_); _opt_cell_2o {cell_x6_y__BLANK_; control__BLANK_}; _opt_cell_2x {cell_x6_y__BLANK_; control__BLANK_}; - _opt_control_0oplayer {cell_x6_y__BLANK_; control__BLANK_}; - _opt_control_0xplayer {cell_x6_y__BLANK_; control__BLANK_}; - cell_2b (cell_x6_y__BLANK_); - cell__BLANK___BLANK___BLANK_ (cell_x6_y__BLANK_) + _opt_control_0oplayer (cell_x6_y__BLANK_); + _opt_control_0xplayer (cell_x6_y__BLANK_); cell_2b (cell_x6_y__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_x6_y__BLANK_); + control_0xplayer (control__BLANK_); control__BLANK_ (control__BLANK_) | ] -> [cell_x6_y__BLANK_, control__BLANK_ | + cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_) | + ] + emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer +RULE mark_x6_y_noop0: + [cell_x6_y__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2o {cell_x6_y__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x6_y__BLANK_; control__BLANK_}; + _opt_control_0oplayer (cell_x6_y__BLANK_); + _opt_control_0xplayer (cell_x6_y__BLANK_); cell_2b (cell_x6_y__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_x6_y__BLANK_); + control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_); + control__BLANK_ (control__BLANK_) + | + ] -> + [cell_x6_y__BLANK_, control__BLANK_ | cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer - pre - (not (cell_0x6(cell_x6_y__BLANK_) and cell_1y(cell_x6_y__BLANK_)) and - ex control__BLANK_ - (control_0oplayer(control__BLANK_) and - control_0xplayer(control__BLANK_) and control__BLANK_(control__BLANK_))) RULE noop_mark_x7_y0: [cell_x7_y0__BLANK_, control__BLANK_ | _opt_cell_2b (control__BLANK_); _opt_cell_2o {cell_x7_y0__BLANK_; control__BLANK_}; _opt_cell_2x {cell_x7_y0__BLANK_; control__BLANK_}; - _opt_control_0oplayer {cell_x7_y0__BLANK_; control__BLANK_}; - _opt_control_0xplayer {cell_x7_y0__BLANK_; control__BLANK_}; - cell_2b (cell_x7_y0__BLANK_); - cell__BLANK___BLANK___BLANK_ (cell_x7_y0__BLANK_) + _opt_control_0oplayer (cell_x7_y0__BLANK_); + _opt_control_0xplayer (cell_x7_y0__BLANK_); cell_2b (cell_x7_y0__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_x7_y0__BLANK_); + control_0oplayer (control__BLANK_); control__BLANK_ (control__BLANK_) | ] -> [cell_x7_y0__BLANK_, control__BLANK_ | + cell_2o (cell_x7_y0__BLANK_); control_0xplayer (control__BLANK_) | + ] + emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer +RULE noop_mark_x7_y00: + [cell_x7_y0__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2o {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_control_0oplayer (cell_x7_y0__BLANK_); + _opt_control_0xplayer (cell_x7_y0__BLANK_); cell_2b (cell_x7_y0__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_x7_y0__BLANK_); + control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_); + control__BLANK_ (control__BLANK_) + | + ] -> + [cell_x7_y0__BLANK_, control__BLANK_ | cell_2o (cell_x7_y0__BLANK_); control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer - pre - (not (cell_0x7(cell_x7_y0__BLANK_) and cell_1y0(cell_x7_y0__BLANK_)) and - ex control__BLANK_ - (control_0oplayer(control__BLANK_) and - control_0xplayer(control__BLANK_) and control__BLANK_(control__BLANK_))) LOC 0 { PLAYER xplayer { @@ -236,7 +258,7 @@ 100. * :((true and line__x() and true)) + 50. * :((true and not line__x() and not line__o() and not open() and true)) - MOVES [mark_x6_y_noop -> 1] } + MOVES [mark_x6_y_noop -> 1]; [mark_x6_y_noop0 -> 1] } PLAYER oplayer { PAYOFF 100. * :((true and line__o() and true)) + @@ -257,7 +279,7 @@ 100. * :((true and line__o() and true)) + 50. * :((true and not line__x() and not line__o() and not open() and true)) - MOVES [noop_mark_x7_y0 -> 0] } + MOVES [noop_mark_x7_y0 -> 0]; [noop_mark_x7_y00 -> 0] } } MODEL [cell_1_1__BLANK_, cell_1_2__BLANK_, cell_1_3__BLANK_, cell_2_1__BLANK_, Modified: trunk/Toss/GGP/tests/tictactoe-simpl.toss =================================================================== --- trunk/Toss/GGP/tests/tictactoe-simpl.toss 2011-08-13 01:47:40 UTC (rev 1538) +++ trunk/Toss/GGP/tests/tictactoe-simpl.toss 2011-08-13 21:19:21 UTC (rev 1539) @@ -1,427 +1,228 @@ +REL column__b(v0) = + ex cell_1_n4__BLANK_, cell_2_n4__BLANK_, cell_3_n4__BLANK_ + (EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_2_n4__BLANK_) and + cell_03(cell_3_n4__BLANK_) and cell_02(cell_2_n4__BLANK_) and + cell_01(cell_1_n4__BLANK_) and cell_2b(cell_1_n4__BLANK_) and + cell_2b(cell_2_n4__BLANK_) and cell_2b(cell_3_n4__BLANK_) and + v0 = cell_1_n4__BLANK_ and not control__BLANK_(cell_1_n4__BLANK_) and + not control__BLANK_(cell_2_n4__BLANK_) and + not control__BLANK_(cell_3_n4__BLANK_)) +REL column__o(v0) = + ex cell_1_n4__BLANK_, cell_2_n4__BLANK_, cell_3_n4__BLANK_ + (EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_2_n4__BLANK_) and + cell_03(cell_3_n4__BLANK_) and cell_02(cell_2_n4__BLANK_) and + cell_01(cell_1_n4__BLANK_) and cell_2o(cell_1_n4__BLANK_) and + cell_2o(cell_2_n4__BLANK_) and cell_2o(cell_3_n4__BLANK_) and + v0 = cell_1_n4__BLANK_ and not control__BLANK_(cell_1_n4__BLANK_) and + not control__BLANK_(cell_2_n4__BLANK_) and + not control__BLANK_(cell_3_n4__BLANK_)) +REL column__x(v0) = + ex cell_1_n4__BLANK_, cell_2_n4__BLANK_, cell_3_n4__BLANK_ + (EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_2_n4__BLANK_) and + cell_03(cell_3_n4__BLANK_) and cell_02(cell_2_n4__BLANK_) and + cell_01(cell_1_n4__BLANK_) and cell_2x(cell_1_n4__BLANK_) and + cell_2x(cell_2_n4__BLANK_) and cell_2x(cell_3_n4__BLANK_) and + v0 = cell_1_n4__BLANK_ and not control__BLANK_(cell_1_n4__BLANK_) and + not control__BLANK_(cell_2_n4__BLANK_) and + not control__BLANK_(cell_3_n4__BLANK_)) +REL diagonal__b() = + ex cell_1_1__BLANK_, cell_2_2__BLANK_, cell_3_3__BLANK_ + (R(cell_1_1__BLANK_) and R0(cell_2_2__BLANK_) and R1(cell_3_3__BLANK_) and + cell_2b(cell_1_1__BLANK_) and cell_2b(cell_2_2__BLANK_) and + cell_2b(cell_3_3__BLANK_) and not control__BLANK_(cell_1_1__BLANK_) and + not control__BLANK_(cell_2_2__BLANK_) and + not control__BLANK_(cell_3_3__BLANK_)) or + ex cell_1_3__BLANK_, cell_2_2__BLANK_, cell_3_1__BLANK_ + (R2(cell_1_3__BLANK_) and R0(cell_2_2__BLANK_) and + R3(cell_3_1__BLANK_) and cell_2b(cell_1_3__BLANK_) and + cell_2b(cell_2_2__BLANK_) and cell_2b(cell_3_1__BLANK_) and + not control__BLANK_(cell_1_3__BLANK_) and + not control__BLANK_(cell_2_2__BLANK_) and + not control__BLANK_(cell_3_1__BLANK_)) +REL diagonal__o() = + ex cell_1_1__BLANK_, cell_2_2__BLANK_, cell_3_3__BLANK_ + (R(cell_1_1__BLANK_) and R0(cell_2_2__BLANK_) and R1(cell_3_3__BLANK_) and + cell_2o(cell_1_1__BLANK_) and cell_2o(cell_2_2__BLANK_) and + cell_2o(cell_3_3__BLANK_) and not control__BLANK_(cell_1_1__BLANK_) and + not control__BLANK_(cell_2_2__BLANK_) and + not control__BLANK_(cell_3_3__BLANK_)) or + ex cell_1_3__BLANK_, cell_2_2__BLANK_, cell_3_1__BLANK_ + (R2(cell_1_3__BLANK_) and R0(cell_2_2__BLANK_) and + R3(cell_3_1__BLANK_) and cell_2o(cell_1_3__BLANK_) and + cell_2o(cell_2_2__BLANK_) and cell_2o(cell_3_1__BLANK_) and + not control__BLANK_(cell_1_3__BLANK_) and + not control__BLANK_(cell_2_2__BLANK_) and + not control__BLANK_(cell_3_1__BLANK_)) +REL diagonal__x() = + ex cell_1_1__BLANK_, cell_2_2__BLANK_, cell_3_3__BLANK_ + (R(cell_1_1__BLANK_) and R0(cell_2_2__BLANK_) and R1(cell_3_3__BLANK_) and + cell_2x(cell_1_1__BLANK_) and cell_2x(cell_2_2__BLANK_) and + cell_2x(cell_3_3__BLANK_) and not control__BLANK_(cell_1_1__BLANK_) and + not control__BLANK_(cell_2_2__BLANK_) and + not control__BLANK_(cell_3_3__BLANK_)) or + ex cell_1_3__BLANK_, cell_2_2__BLANK_, cell_3_1__BLANK_ + (R2(cell_1_3__BLANK_) and R0(cell_2_2__BLANK_) and + R3(cell_3_1__BLANK_) and cell_2x(cell_1_3__BLANK_) and + cell_2x(cell_2_2__BLANK_) and cell_2x(cell_3_1__BLANK_) and + not control__BLANK_(cell_1_3__BLANK_) and + not control__BLANK_(cell_2_2__BLANK_) and + not control__BLANK_(cell_3_1__BLANK_)) +REL line__b() = + diagonal__b() or + ex cell__BLANK__m6__BLANK_ column__b(cell__BLANK__m6__BLANK_) or + ex cell_m5__BLANK___BLANK_ row__b(cell_m5__BLANK___BLANK_) +REL line__o() = + diagonal__o() or + ex cell__BLANK__m6__BLANK_ column__o(cell__BLANK__m6__BLANK_) or + ex cell_m5__BLANK___BLANK_ row__o(cell_m5__BLANK___BLANK_) +REL line__x() = + diagonal__x() or + ex cell__BLANK__m6__BLANK_ column__x(cell__BLANK__m6__BLANK_) or + ex cell_m5__BLANK___BLANK_ row__x(cell_m5__BLANK___BLANK_) +REL open() = + ex cell_m7_n5__BLANK_ + (cell_2b(cell_m7_n5__BLANK_) and not control__BLANK_(cell_m7_n5__BLANK_)) +REL row__b(v0) = + ex cell_m4_1__BLANK_, cell_m4_2__BLANK_, cell_m4_3__BLANK_ + (EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_2__BLANK_) and + cell_13(cell_m4_3__BLANK_) and cell_12(cell_m4_2__BLANK_) and + cell_11(cell_m4_1__BLANK_) and cell_2b(cell_m4_1__BLANK_) and + cell_2b(cell_m4_2__BLANK_) and cell_2b(cell_m4_3__BLANK_) and + v0 = cell_m4_1__BLANK_ and not control__BLANK_(cell_m4_1__BLANK_) and + not control__BLANK_(cell_m4_2__BLANK_) and + not control__BLANK_(cell_m4_3__BLANK_)) +REL row__o(v0) = + ex cell_m4_1__BLANK_, cell_m4_2__BLANK_, cell_m4_3__BLANK_ + (EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_2__BLANK_) and + cell_13(cell_m4_3__BLANK_) and cell_12(cell_m4_2__BLANK_) and + cell_11(cell_m4_1__BLANK_) and cell_2o(cell_m4_1__BLANK_) and + cell_2o(cell_m4_2__BLANK_) and cell_2o(cell_m4_3__BLANK_) and + v0 = cell_m4_1__BLANK_ and not control__BLANK_(cell_m4_1__BLANK_) and + not control__BLANK_(cell_m4_2__BLANK_) and + not control__BLANK_(cell_m4_3__BLANK_)) +REL row__x(v0) = + ex cell_m4_1__BLANK_, cell_m4_2__BLANK_, cell_m4_3__BLANK_ + (EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_2__BLANK_) and + cell_13(cell_m4_3__BLANK_) and cell_12(cell_m4_2__BLANK_) and + cell_11(cell_m4_1__BLANK_) and cell_2x(cell_m4_1__BLANK_) and + cell_2x(cell_m4_2__BLANK_) and cell_2x(cell_m4_3__BLANK_) and + v0 = cell_m4_1__BLANK_ and not control__BLANK_(cell_m4_1__BLANK_) and + not control__BLANK_(cell_m4_2__BLANK_) and + not control__BLANK_(cell_m4_3__BLANK_)) PLAYERS xplayer, oplayer -DATA R3: cell_3_n_MV1__AND__cell_m_3_MV1, - R2: cell_1_n_MV1__AND__cell_m_1_MV1, R1: cell_3_n_MV1__AND__cell_m_1_MV1, - R0: cell_2_n_MV1__AND__cell_m_2_MV1, R: cell_1_n_MV1__AND__cell_m_3_MV1 -RULE mark_x64_y19_0: - [cell_x64_y19__blank_, control__blank_ | - _opt_cell_m_n_b (control__blank_); - _opt_cell_m_n_o {cell_x64_y19__blank_; control__blank_}; - _opt_cell_m_n_x {cell_x64_y19__blank_; control__blank_}; - _opt_control_oplayer (cell_x64_y19__blank_); - _opt_control_xplayer (cell_x64_y19__blank_); - cell_m_n_b (cell_x64_y19__blank_); control_xplayer (control__blank_) +DATA R3: cell_03__AND__cell_11, R2: cell_01__AND__cell_13, + R1: cell_03__AND__cell_13, R0: cell_02__AND__cell_12, + R: cell_01__AND__cell_11 +RULE mark_x6_y_noop: + [cell_x6_y__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2o {cell_x6_y__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x6_y__BLANK_; control__BLANK_}; + _opt_control_0oplayer (cell_x6_y__BLANK_); + _opt_control_0xplayer (cell_x6_y__BLANK_); cell_2b (cell_x6_y__BLANK_); + control_0xplayer (control__BLANK_); control__BLANK_ (control__BLANK_) | ] -> - [cell_x64_y19__blank_, control__blank_ | - cell_m_n_x (cell_x64_y19__blank_); control_oplayer (control__blank_) | + [cell_x6_y__BLANK_, control__BLANK_ | + cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_) | ] - emb cell_m_n_b, cell_m_n_o, cell_m_n_x, control_oplayer, control_xplayer - pre - not - (not ex cell_m48_n23__blank_ cell_m_n_b(cell_m48_n23__blank_) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_m45__blank_, cell_2_m45__blank_, cell_1_m45__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m45__blank_, cell_3_m45__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m45__blank_, cell_2_m45__blank_) and - cell_3_n_MV1(cell_3_m45__blank_) and - cell_2_n_MV1(cell_2_m45__blank_) and - cell_1_n_MV1(cell_1_m45__blank_) and - cell_m_n_x(cell_1_m45__blank_) and cell_m_n_x(cell_2_m45__blank_) and - cell_m_n_x(cell_3_m45__blank_)) or - ex cell_3_m47__blank_, cell_2_m47__blank_, cell_1_m47__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m47__blank_, cell_3_m47__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m47__blank_, cell_2_m47__blank_) and - cell_3_n_MV1(cell_3_m47__blank_) and - cell_2_n_MV1(cell_2_m47__blank_) and - cell_1_n_MV1(cell_1_m47__blank_) and - cell_m_n_o(cell_1_m47__blank_) and cell_m_n_o(cell_2_m47__blank_) and - cell_m_n_o(cell_3_m47__blank_)) or - ex cell_m44_3__blank_, cell_m44_2__blank_, cell_m44_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m44_1__blank_, cell_m44_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m44_1__blank_, cell_m44_2__blank_) and - cell_m_3_MV1(cell_m44_3__blank_) and - cell_m_2_MV1(cell_m44_2__blank_) and - cell_m_1_MV1(cell_m44_1__blank_) and - cell_m_n_x(cell_m44_1__blank_) and cell_m_n_x(cell_m44_2__blank_) and - cell_m_n_x(cell_m44_3__blank_)) or - ex cell_m46_3__blank_, cell_m46_2__blank_, cell_m46_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m46_1__blank_, cell_m46_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m46_1__blank_, cell_m46_2__blank_) and - cell_m_3_MV1(cell_m46_3__blank_) and - cell_m_2_MV1(cell_m46_2__blank_) and - cell_m_1_MV1(cell_m46_1__blank_) and - cell_m_n_o(cell_m46_1__blank_) and cell_m_n_o(cell_m46_2__blank_) and - cell_m_n_o(cell_m46_3__blank_))) -RULE mark_x71_y26_1: - [cell_x71_y26__blank_, control__blank_ | - _opt_cell_m_n_b (control__blank_); - _opt_cell_m_n_o {cell_x71_y26__blank_; control__blank_}; - _opt_cell_m_n_x {cell_x71_y26__blank_; control__blank_}; - _opt_control_oplayer (cell_x71_y26__blank_); - _opt_control_xplayer (cell_x71_y26__blank_); - cell_m_n_b (cell_x71_y26__blank_); control_oplayer (control__blank_) + emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer +RULE mark_x6_y_noop0: + [cell_x6_y__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2o {cell_x6_y__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x6_y__BLANK_; control__BLANK_}; + _opt_control_0oplayer (cell_x6_y__BLANK_); + _opt_control_0xplayer (cell_x6_y__BLANK_); cell_2b (cell_x6_y__BLANK_); + control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_); + control__BLANK_ (control__BLANK_) | ] -> - [cell_x71_y26__blank_, control__blank_ | - cell_m_n_o (cell_x71_y26__blank_); control_xplayer (control__blank_) | + [cell_x6_y__BLANK_, control__BLANK_ | + cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_); + control_0xplayer (control__BLANK_) + | + ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer +RULE noop_mark_x7_y0: + [cell_x7_y0__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2o {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_control_0oplayer (cell_x7_y0__BLANK_); + _opt_control_0xplayer (cell_x7_y0__BLANK_); cell_2b (cell_x7_y0__BLANK_); + control_0oplayer (control__BLANK_); control__BLANK_ (control__BLANK_) + | + ] -> + [cell_x7_y0__BLANK_, control__BLANK_ | + cell_2o (cell_x7_y0__BLANK_); control_0xplayer (control__BLANK_) | ] - emb cell_m_n_b, cell_m_n_o, cell_m_n_x, control_oplayer, control_xplayer - pre - not - (not ex cell_m48_n23__blank_ cell_m_n_b(cell_m48_n23__blank_) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_m45__blank_, cell_2_m45__blank_, cell_1_m45__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m45__blank_, cell_3_m45__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m45__blank_, cell_2_m45__blank_) and - cell_3_n_MV1(cell_3_m45__blank_) and - cell_2_n_MV1(cell_2_m45__blank_) and - cell_1_n_MV1(cell_1_m45__blank_) and - cell_m_n_x(cell_1_m45__blank_) and cell_m_n_x(cell_2_m45__blank_) and - cell_m_n_x(cell_3_m45__blank_)) or - ex cell_3_m47__blank_, cell_2_m47__blank_, cell_1_m47__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m47__blank_, cell_3_m47__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m47__blank_, cell_2_m47__blank_) and - cell_3_n_MV1(cell_3_m47__blank_) and - cell_2_n_MV1(cell_2_m47__blank_) and - cell_1_n_MV1(cell_1_m47__blank_) and - cell_m_n_o(cell_1_m47__blank_) and cell_m_n_o(cell_2_m47__blank_) and - cell_m_n_o(cell_3_m47__blank_)) or - ex cell_m44_3__blank_, cell_m44_2__blank_, cell_m44_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m44_1__blank_, cell_m44_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m44_1__blank_, cell_m44_2__blank_) and - cell_m_3_MV1(cell_m44_3__blank_) and - cell_m_2_MV1(cell_m44_2__blank_) and - cell_m_1_MV1(cell_m44_1__blank_) and - cell_m_n_x(cell_m44_1__blank_) and cell_m_n_x(cell_m44_2__blank_) and - cell_m_n_x(cell_m44_3__blank_)) or - ex cell_m46_3__blank_, cell_m46_2__blank_, cell_m46_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m46_1__blank_, cell_m46_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m46_1__blank_, cell_m46_2__blank_) and - cell_m_3_MV1(cell_m46_3__blank_) and - cell_m_2_MV1(cell_m46_2__blank_) and - cell_m_1_MV1(cell_m46_1__blank_) and - cell_m_n_o(cell_m46_1__blank_) and cell_m_n_o(cell_m46_2__blank_) and - cell_m_n_o(cell_m46_3__blank_))) + emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer +RULE noop_mark_x7_y00: + [cell_x7_y0__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2o {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_control_0oplayer (cell_x7_y0__BLANK_); + _opt_control_0xplayer (cell_x7_y0__BLANK_); cell_2b (cell_x7_y0__BLANK_); + control_0oplayer (control__BLANK_); control_0xplayer (control__BLANK_); + control__BLANK_ (control__BLANK_) + | + ] -> + [cell_x7_y0__BLANK_, control__BLANK_ | + cell_2o (cell_x7_y0__BLANK_); control_0oplayer (control__BLANK_); + control_0xplayer (control__BLANK_) + | + ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer LOC 0 { PLAYER xplayer { PAYOFF - 50. + - -50. * - :( - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_m9__blank_, cell_2_m9__blank_, cell_1_m9__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m9__blank_, cell_3_m9__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m9__blank_, cell_2_m9__blank_) and - cell_3_n_MV1(cell_3_m9__blank_) and - cell_2_n_MV1(cell_2_m9__blank_) and - cell_1_n_MV1(cell_1_m9__blank_) and - cell_m_n_o(cell_1_m9__blank_) and cell_m_n_o(cell_2_m9__blank_) and - cell_m_n_o(cell_3_m9__blank_)) or - ex cell_m8_3__blank_, cell_m8_2__blank_, cell_m8_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m8_1__blank_, cell_m8_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m8_1__blank_, cell_m8_2__blank_) and - cell_m_3_MV1(cell_m8_3__blank_) and - cell_m_2_MV1(cell_m8_2__blank_) and - cell_m_1_MV1(cell_m8_1__blank_) and - cell_m_n_o(cell_m8_1__blank_) and cell_m_n_o(cell_m8_2__blank_) and - cell_m_n_o(cell_m8_3__blank_)) - ) - + - 50. * - :( - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_m2__blank_, cell_2_m2__blank_, cell_1_m2__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m2__blank_, cell_3_m2__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m2__blank_, cell_2_m2__blank_) and - cell_3_n_MV1(cell_3_m2__blank_) and - cell_2_n_MV1(cell_2_m2__blank_) and - cell_1_n_MV1(cell_1_m2__blank_) and - cell_m_n_x(cell_1_m2__blank_) and cell_m_n_x(cell_2_m2__blank_) and - cell_m_n_x(cell_3_m2__blank_)) or - ex cell_m1_3__blank_, cell_m1_2__blank_, cell_m1_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m1_1__blank_, cell_m1_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m1_1__blank_, cell_m1_2__blank_) and - cell_m_3_MV1(cell_m1_3__blank_) and - cell_m_2_MV1(cell_m1_2__blank_) and - cell_m_1_MV1(cell_m1_1__blank_) and - cell_m_n_x(cell_m1_1__blank_) and cell_m_n_x(cell_m1_2__blank_) and - cell_m_n_x(cell_m1_3__blank_)) - ) - MOVES [mark_x64_y19_0 -> 1] } + 100. * :(line__x()) + + 50. * :((not line__o() and not line__x() and not open())) + MOVES [mark_x6_y_noop -> 1]; [mark_x6_y_noop0 -> 1] } PLAYER oplayer { PAYOFF - 50. + - -50. * - :( - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_m18__blank_, cell_2_m18__blank_, cell_1_m18__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m18__blank_, cell_3_m18__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m18__blank_, cell_2_m18__blank_) and - cell_3_n_MV1(cell_3_m18__blank_) and - cell_2_n_MV1(cell_2_m18__blank_) and - cell_1_n_MV1(cell_1_m18__blank_) and - cell_m_n_x(cell_1_m18__blank_) and - cell_m_n_x(cell_2_m18__blank_) and cell_m_n_x(cell_3_m18__blank_)) or - ex cell_m17_3__blank_, cell_m17_2__blank_, cell_m17_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m17_1__blank_, cell_m17_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m17_1__blank_, cell_m17_2__blank_) and - cell_m_3_MV1(cell_m17_3__blank_) and - cell_m_2_MV1(cell_m17_2__blank_) and - cell_m_1_MV1(cell_m17_1__blank_) and - cell_m_n_x(cell_m17_1__blank_) and - cell_m_n_x(cell_m17_2__blank_) and cell_m_n_x(cell_m17_3__blank_)) - ) - + - 50. * - :( - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_m11__blank_, cell_2_m11__blank_, cell_1_m11__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m11__blank_, cell_3_m11__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m11__blank_, cell_2_m11__blank_) and - cell_3_n_MV1(cell_3_m11__blank_) and - cell_2_n_MV1(cell_2_m11__blank_) and - cell_1_n_MV1(cell_1_m11__blank_) and - cell_m_n_o(cell_1_m11__blank_) and - cell_m_n_o(cell_2_m11__blank_) and cell_m_n_o(cell_3_m11__blank_)) or - ex cell_m10_3__blank_, cell_m10_2__blank_, cell_m10_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m10_1__blank_, cell_m10_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m10_1__blank_, cell_m10_2__blank_) and - cell_m_3_MV1(cell_m10_3__blank_) and - cell_m_2_MV1(cell_m10_2__blank_) and - cell_m_1_MV1(cell_m10_1__blank_) and - cell_m_n_o(cell_m10_1__blank_) and - cell_m_n_o(cell_m10_2__blank_) and cell_m_n_o(cell_m10_3__blank_)) - ) + 100. * :(line__o()) + + 50. * :((not line__o() and not line__x() and not open())) } } LOC 1 { PLAYER xplayer { PAYOFF - 50. + - -50. * - :( - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_m9__blank_, cell_2_m9__blank_, cell_1_m9__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m9__blank_, cell_3_m9__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m9__blank_, cell_2_m9__blank_) and - cell_3_n_MV1(cell_3_m9__blank_) and - cell_2_n_MV1(cell_2_m9__blank_) and - cell_1_n_MV1(cell_1_m9__blank_) and - cell_m_n_o(cell_1_m9__blank_) and cell_m_n_o(cell_2_m9__blank_) and - cell_m_n_o(cell_3_m9__blank_)) or - ex cell_m8_3__blank_, cell_m8_2__blank_, cell_m8_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m8_1__blank_, cell_m8_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m8_1__blank_, cell_m8_2__blank_) and - cell_m_3_MV1(cell_m8_3__blank_) and - cell_m_2_MV1(cell_m8_2__blank_) and - cell_m_1_MV1(cell_m8_1__blank_) and - cell_m_n_o(cell_m8_1__blank_) and cell_m_n_o(cell_m8_2__blank_) and - cell_m_n_o(cell_m8_3__blank_)) - ) - + - 50. * - :( - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_m2__blank_, cell_2_m2__blank_, cell_1_m2__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m2__blank_, cell_3_m2__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m2__blank_, cell_2_m2__blank_) and - cell_3_n_MV1(cell_3_m2__blank_) and - cell_2_n_MV1(cell_2_m2__blank_) and - cell_1_n_MV1(cell_1_m2__blank_) and - cell_m_n_x(cell_1_m2__blank_) and cell_m_n_x(cell_2_m2__blank_) and - cell_m_n_x(cell_3_m2__blank_)) or - ex cell_m1_3__blank_, cell_m1_2__blank_, cell_m1_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m1_1__blank_, cell_m1_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m1_1__blank_, cell_m1_2__blank_) and - cell_m_3_MV1(cell_m1_3__blank_) and - cell_m_2_MV1(cell_m1_2__blank_) and - cell_m_1_MV1(cell_m1_1__blank_) and - cell_m_n_x(cell_m1_1__blank_) and cell_m_n_x(cell_m1_2__blank_) and - cell_m_n_x(cell_m1_3__blank_)) - ) + 100. * :(line__x()) + + 50. * :((not line__o() and not line__x() and not open())) } PLAYER oplayer { PAYOFF - 50. + - -50. * - :( - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_m18__blank_, cell_2_m18__blank_, cell_1_m18__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m18__blank_, cell_3_m18__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m18__blank_, cell_2_m18__blank_) and - cell_3_n_MV1(cell_3_m18__blank_) and - cell_2_n_MV1(cell_2_m18__blank_) and - cell_1_n_MV1(cell_1_m18__blank_) and - cell_m_n_x(cell_1_m18__blank_) and - cell_m_n_x(cell_2_m18__blank_) and cell_m_n_x(cell_3_m18__blank_)) or - ex cell_m17_3__blank_, cell_m17_2__blank_, cell_m17_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m17_1__blank_, cell_m17_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m17_1__blank_, cell_m17_2__blank_) and - cell_m_3_MV1(cell_m17_3__blank_) and - cell_m_2_MV1(cell_m17_2__blank_) and - cell_m_1_MV1(cell_m17_1__blank_) and - cell_m_n_x(cell_m17_1__blank_) and - cell_m_n_x(cell_m17_2__blank_) and cell_m_n_x(cell_m17_3__blank_)) - ) - + - 50. * - :( - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (R(cell_1_3__blank_) and R0(cell_2_2__blank_) and - R1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (R2(cell_1_1__blank_) and R0(cell_2_2__blank_) and - R3(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_m11__blank_, cell_2_m11__blank_, cell_1_m11__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m11__blank_, cell_3_m11__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m11__blank_, cell_2_m11__blank_) and - cell_3_n_MV1(cell_3_m11__blank_) and - cell_2_n_MV1(cell_2_m11__blank_) and - cell_1_n_MV1(cell_1_m11__blank_) and - cell_m_n_o(cell_1_m11__blank_) and - cell_m_n_o(cell_2_m11__blank_) and cell_m_n_o(cell_3_m11__blank_)) or - ex cell_m10_3__blank_, cell_m10_2__blank_, cell_m10_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m10_1__blank_, cell_m10_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m10_1__blank_, cell_m10_2__blank_) and - cell_m_3_MV1(cell_m10_3__blank_) and - cell_m_2_MV1(cell_m10_2__blank_) and - cell_m_1_MV1(cell_m10_1__blank_) and - cell_m_n_o(cell_m10_1__blank_) and - cell_m_n_o(cell_m10_2__blank_) and cell_m_n_o(cell_m10_3__blank_)) - ) - MOVES [mark_x71_y26_1 -> 0] } + 100. * :(line__o()) + + 50. * :((not line__o() and not line__x() and not open())) + MOVES [noop_mark_x7_y0 -> 0]; [noop_mark_x7_y00 -> 0] } } MODEL - [control_MV1, cell_3_3_MV1, cell_3_2_MV1, cell_3_1_MV1, cell_2_3_MV1, - cell_2_2_MV1, cell_2_1_MV1, cell_1_3_MV1, cell_1_2_MV1, cell_1_1_MV1 | - EQ___cell_m_n_MV1_m { - (cell_3_3_MV1, cell_3_3_MV1); (cell_3_3_MV1, cell_3_2_MV1); - (cell_3_3_MV1, cell_3_1_MV1); (cell_3_2_MV1, cell_3_3_MV1); - (cell_3_2_MV1, cell_3_2_MV1); (cell_3_2_MV1, cell_3_1_MV1); - (cell_3_1_MV1, cell_3_3_MV1); (cell_3_1_MV1, cell_3_2_MV1); - (cell_3_1_MV1, cell_3_1_MV1); (cell_2_3_MV1, cell_2_3_MV1); - (cell_2_3_MV1, cell_2_2_MV1); (cell_2_3_MV1, cell_2_1_MV1); - (cell_2_2_MV1, cell_2_3_MV1); (cell_2_2_MV1, cell_2_2_MV1); - (cell_2_2_MV1, cell_2_1_MV1); (cell_2_1_MV1, cell_2_3_MV1); - (cell_2_1_MV1, cell_2_2_MV1); (cell_2_1_MV1, cell_2_1_MV1); - (cell_1_3_MV1, cell_1_3_MV1); (cell_1_3_MV1, cell_1_2_MV1); - (cell_1_3_MV1, cell_1_1_MV1); (cell_1_2_MV1, cell_1_3_MV1); - (cell_1_2_MV1, cell_1_2_MV1); (cell_1_2_MV1, cell_1_1_MV1); - (cell_1_1_MV1, cell_1_3_MV1); (cell_1_1_MV1, cell_1_2_MV1); - (cell_1_1_MV1, cell_1_1_MV1) + [cell_1_1__BLANK_, cell_1_2__BLANK_, cell_1_3__BLANK_, cell_2_1__BLANK_, + cell_2_2__BLANK_, cell_2_3__BLANK_, cell_3_1__BLANK_, cell_3_2__BLANK_, + cell_3_3__BLANK_, control__BLANK_ | + R (cell_1_1__BLANK_); R0 (cell_2_2__BLANK_); R1 (cell_3_3__BLANK_); + R2 (cell_1_3__BLANK_); R3 (cell_3_1__BLANK_); + cell_01 {cell_1_1__BLANK_; cell_1_2__BLANK_; cell_1_3__BLANK_}; + cell_02 {cell_2_1__BLANK_; cell_2_2__BLANK_; cell_2_3__BLANK_}; + cell_03 {cell_3_1__BLANK_; cell_3_2__BLANK_; cell_3_3__BLANK_}; + cell_11 {cell_1_1__BLANK_; cell_2_1__BLANK_; cell_3_1__BLANK_}; + cell_12 {cell_1_2__BLANK_; cell_2_2__BLANK_; cell_3_2__BLANK_}; + cell_13 {cell_1_3__BLANK_; cell_2_3__BLANK_; cell_3_3__BLANK_}; + cell_2b { + cell_1_1__BLANK_; cell_1_2__BLANK_; cell_1_3__BLANK_; cell_2_1__BLANK_; + cell_2_2__BLANK_; cell_2_3__BLANK_; cell_3_1__BLANK_; cell_3_2__BLANK_; + cell_3_3__BLANK_ }; - EQ___cell_m_n_MV1_n { - (cell_3_3_MV1, cell_3_3_MV1); (cell_3_3_MV1, cell_2_3_MV1); - (cell_3_3_MV1, cell_1_3_MV1); (cell_3_2_MV1, cell_3_2_MV1); - (cell_3_2_MV1, cell_2_2_MV1); (cell_3_2_MV1, cell_1_2_MV1); - (cell_3_1_MV1, cell_3_1_MV1); (cell_3_1_MV1, cell_2_1_MV1); - (cell_3_1_MV1, cell_1_1_MV1); (cell_2_3_MV1, cell_3_3_MV1); - (cell_2_3_MV1, cell_2_3_MV1); (cell_2_3_MV1, cell_1_3_MV1); - (cell_2_2_MV1, cell_3_2_MV1); (cell_2_2_MV1, cell_2_2_MV1); - (cell_2_2_MV1, cell_1_2_MV1); (cell_2_1_MV1, cell_3_1_MV1); - (cell_2_1_MV1, cell_2_1_MV1); (cell_2_1_MV1, cell_1_1_MV1); - (cell_1_3_MV1, cell_3_3_MV1); (cell_1_3_MV1, cell_2_3_MV1); - (cell_1_3_MV1, cell_1_3_MV1); (cell_1_2_MV1, cell_3_2_MV1); - (cell_1_2_MV1, cell_2_2_MV1); (cell_1_2_MV1, cell_1_2_MV1); - (cell_1_1_MV1, cell_3_1_MV1); (cell_1_1_MV1, cell_2_1_MV1); - (cell_1_1_MV1, cell_1_1_MV1) - }; - R (cell_1_3_MV1); R0 (cell_2_2_MV1); R1 (cell_3_1_MV1); - R2 (cell_1_1_MV1); R3 (cell_3_3_MV1); - cell_1_n_MV1 {cell_1_3_MV1; cell_1_2_MV1; cell_1_1_MV1}; - cell_2_n_MV1 {cell_2_3_MV1; cell_2_2_MV1; cell_2_1_MV1}; - cell_3_n_MV1 {cell_3_3_MV1; cell_3_2_MV1; cell_3_1_MV1}; - cell_m_1_MV1 {cell_3_1_MV1; cell_2_1_MV1; cell_1_1_MV1}; - cell_m_2_MV1 {cell_3_2_MV1; cell_2_2_MV1; cell_1_2_MV1}; - cell_m_3_MV1 {cell_3_3_MV1; cell_2_3_MV1; cell_1_3_MV1}; - cell_m_n_b { - cell_3_3_MV1; cell_3_2_MV1; cell_3_1_MV1; cell_2_3_MV1; cell_2_2_MV1; - cell_2_1_MV1; cell_1_3_MV1; cell_1_2_MV1; cell_1_1_MV1 - }; - cell_m_n_o:1 {}; cell_m_n_x:1 {}; control_MV1 (control_MV1); - control_oplayer:1 {}; control_xplayer (control_MV1) + cell_2o:1 {}; cell_2x:1 {}; control_0oplayer:1 {}; + control_0xplayer (control__BLANK_); control__BLANK_ (control__BLANK_) | ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-13 01:47:46
|
Revision: 1538 http://toss.svn.sourceforge.net/toss/?rev=1538&view=rev Author: lukstafi Date: 2011-08-13 01:47:40 +0000 (Sat, 13 Aug 2011) Log Message: ----------- Scratch test call in last commit. Modified Paths: -------------- trunk/Toss/GGP/TranslateGameTest.ml Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-13 01:39:33 UTC (rev 1537) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-13 01:47:40 UTC (rev 1538) @@ -271,7 +271,7 @@ DiscreteRule.debug_level := discreterule_dl); TranslateGame.generate_test_case := None -let a = +let a () = regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; (* regenerate ~debug:false ~game_name:"connect5" ~player:"x"; *) (* regenerate ~debug:true ~game_name:"breakthrough" ~player:"white"; *) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-13 01:39:42
|
Revision: 1537 http://toss.svn.sourceforge.net/toss/?rev=1537&view=rev Author: lukstafi Date: 2011-08-13 01:39:33 +0000 (Sat, 13 Aug 2011) Log Message: ----------- GDL translation fixing: small specification fix regarding same variables from both positive and negated state terms; Structure corrected to discard adding new elements with existing names; fixes in preparing precondition and other data for rule generation; for turn-based translation, consider only legal clause tuples with single player having non-noop move. Modified Paths: -------------- trunk/Toss/Arena/DiscreteRule.ml trunk/Toss/GGP/TranslateFormula.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/GGP/tests/connect5-raw.toss trunk/Toss/GGP/tests/connect5-simpl.toss trunk/Toss/GGP/tests/tictactoe-raw.toss trunk/Toss/Solver/Structure.ml trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/Arena/DiscreteRule.ml =================================================================== --- trunk/Toss/Arena/DiscreteRule.ml 2011-08-12 14:07:42 UTC (rev 1536) +++ trunk/Toss/Arena/DiscreteRule.ml 2011-08-13 01:39:33 UTC (rev 1537) @@ -719,12 +719,12 @@ 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 *) + (* {{{ 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 @@ -836,6 +836,24 @@ embedding formula, but we need to avoid negating their support *) let lhs_opt_rels, lhs_pos_tups, lhs_pos_expanded = compile_opt_rels lhs_rels in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "compile_rule: lhs_pos_tups=%s\n%!" + (String.concat "; "(List.map (fun (rel,tups)-> + rel^"{"^String.concat ";"(List.map (fun tup -> + "("^String.concat ", " + (Array.to_list (Array.map ( + Structure.elem_name rule_src.lhs_struc) tup))^")") tups)^"}") + lhs_pos_tups)); + Printf.printf "compile_rule: lhs_pos_expanded=%s\n%!" + (String.concat "; "(List.map (fun (rel,tups)-> + rel^"{"^String.concat ";"(List.map (fun tup -> + "("^String.concat ", " + (Array.to_list (Array.map ( + Structure.elem_name rule_src.lhs_struc) tup))^")") tups)^"}") + lhs_pos_expanded)); + ); + (* }}} *) let lhs_all_tups n = List.map Array.of_list (Aux.product ( Aux.fold_n (fun acc -> lhs_elems::acc) [] n)) in @@ -862,6 +880,17 @@ with Not_found -> failwith ("not in signature: " ^ rel)))) base_emb_rels in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "compile_rule: lhs_neg_tups=%s\n%!" + (String.concat "; "(List.map (fun (rel,tups)-> + rel^"{"^String.concat ";"(List.map (fun tup -> + "("^String.concat ", " + (Array.to_list (Array.map ( + Structure.elem_name rule_src.lhs_struc) tup))^")") tups)^"}") + lhs_neg_tups)); + ); + (* }}} *) (* injectivity checking *) let lhs_alldif_tups = triang_product 2 lhs_elem_vars in @@ -872,11 +901,11 @@ 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) + 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 @ + List.map (function [x;y] -> Not (Eq (`FO x, `FO y)) + | _ -> assert false) lhs_alldif_tups @ (FormulaOps.as_conjuncts precond) ) in Modified: trunk/Toss/GGP/TranslateFormula.ml =================================================================== --- trunk/Toss/GGP/TranslateFormula.ml 2011-08-12 14:07:42 UTC (rev 1536) +++ trunk/Toss/GGP/TranslateFormula.ml 2011-08-13 01:39:33 UTC (rev 1537) @@ -234,7 +234,7 @@ let universal_part = if neg_terms = [] then [] else [Formula.Not ( - Formula.Ex ((neg_vars :> Formula.var list), + Formula.Ex (((Aux.list_diff neg_vars pos_vars) :> Formula.var list), Formula.And [ (* positive because they form a "premise" *) transl_rels data rels_eqs all_terms neg_terms; Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-12 14:07:42 UTC (rev 1536) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-13 01:39:33 UTC (rev 1537) @@ -38,8 +38,14 @@ [nonerasing_frame_wave] is set to [true].) *) let nonerasing_frame_wave = ref true +(** When translating as turn-based, filter-out moves composed only of + actions such that each is a "noop" action of some player at some + location. Assumes that players do not use their "noop" actions + for purposes other than waiting for their turn. *) +let noops_not_moves = ref true + (** Limit on the number of steps for aggregate and random playouts. *) -let playout_horizon = ref 30 +let playout_horizon = ref 20 (** Use "true" atoms while computing rule cases. *) let split_on_state_atoms = ref false @@ -443,11 +449,11 @@ *) -(* Find the rule clauses $\ol{\calC},\ol{\calN}$. Do not remove the - "does" atoms from clauses. Also handles as special cases: - "concurrent" case with selecting clauses for only one player, and - "environment" case for selecting clauses not dependent on any - player. Preserve legal clauses into the output tuples. *) +(* Find the rule clauses $\ol{\calC},\ol{\calN}$. Also handles as + special cases: "concurrent" case with selecting clauses for only + one player, and "environment" case for selecting clauses not + dependent on any player. Preserve legal clauses into the output + tuples. *) let move_tuples used_vars next_cls mode players legal_tuples = (* computing the $d_i(\calN)$ for each $\calN$ *) let fresh_x_f () = @@ -459,7 +465,7 @@ let djs = (* FIXME: check if "negative true" is properly handled *) Aux.map_some (function - | (Pos (Does (dp, d)) | Neg (Does (dp, d))) when dp = p -> Some d + | Pos (Does (dp, d)) when dp = p -> Some d | _ -> None) body in let sb = unify_all sb djs in let d = @@ -526,7 +532,13 @@ with Not_found -> cl_tup ) cl_tup next_clauses in let cl_tups = List.map maximality cl_tups in - List.map (fun (sb, _, n_cls) -> sb, legal_tup, n_cls) cl_tups in + (* removing "does" atoms from clauses *) + List.map (fun (sb, _, n_cls) -> + let n_cls = List.map (fun (head,frame,body) -> + head, frame, + List.filter + (function Pos (Does _) -> false | _ -> true) body) n_cls in + sb, legal_tup, n_cls) cl_tups in Aux.concat_map move_clauses legal_tuples @@ -749,8 +761,21 @@ ) (rule_cases next_cls) -let turnbased_rule_cases used_vars f_paths next_cls players legal_by_player = +let turnbased_rule_cases loc_noops used_vars f_paths next_cls + players legal_by_player = let legal_tuples = Aux.product legal_by_player in + (* remove tuples with multiple players making moves + TODO: could be enhanced by only excluding a noop of a player for + that player *) + let all_noops = Aux.map_some (fun x->x) + (Aux.concat_map Array.to_list (Array.to_list loc_noops)) in + let legal_tuples = List.filter + (fun legal_tup -> + let num_not_noops = + List.length (Aux.list_diff (List.map fst legal_tup) all_noops) in + num_not_noops = 1 + || (num_not_noops = 0 && not !noops_not_moves)) + legal_tuples in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf "turnbased_rule_cases: legal_tuples --\n%!"; @@ -817,7 +842,7 @@ (String.concat "\n"(List.map clause_str legal_cls)) ); (* }}} *) - let is_concurrent = not is_turn_based && + let is_concurrent = is_turn_based = None && List.for_all (fun (_, _, body) -> List.length @@ -835,10 +860,14 @@ let result = if is_concurrent then concurrent_rule_cases used_vars f_paths next_cls players legal_by_player - else if is_turn_based then - turnbased_rule_cases used_vars f_paths next_cls players legal_by_player else - general_int_rule_cases used_vars f_paths next_cls players legal_by_player + match is_turn_based with + | Some (_, loc_noops) -> + turnbased_rule_cases loc_noops used_vars f_paths next_cls + players legal_by_player + | None -> + general_int_rule_cases used_vars f_paths next_cls + players legal_by_player in (* {{{ log entry *) if !debug_level > 2 then ( @@ -1031,14 +1060,18 @@ let struc_elems = List.map (fun sterm -> term_to_name (blank_out transl_data sterm)) case_rhs in + let rulevar_terms = Aux.strmap_of_assoc + (List.combine struc_elems case_rhs) in + let struc_elems = Aux.unique_sorted struc_elems in + let precond = FormulaOps.del_vars_quant + (List.map Formula.fo_var_of_string struc_elems :> Formula.var list) + precond in let discrete = DiscreteRule.translate_from_precond ~precond ~add:rhs_add ~emb_rels:fluents ~signat ~struc_elems in let rule = ContinuousRule.make_rule signat [] discrete [] [] ~pre:discrete.DiscreteRule.pre () in - let rulevar_terms = Aux.strmap_of_assoc - (List.combine struc_elems case_rhs) in let fixvar_terms = Aux.concat_map (fun sterm -> map_paths (fun path -> function Var v -> v, (sterm, path) @@ -1307,7 +1340,7 @@ try Some (check_turn_based players rules) with Not_turn_based -> None in let rule_cands, is_concurrent = - create_rule_cands (turn_data <> None) used_vars f_paths next_cls clauses in + create_rule_cands turn_data used_vars f_paths next_cls clauses in let rule_cands = filter_rule_cands static_base defined_rels rule_cands in let term_arities = Aux.unique_sorted @@ -1365,6 +1398,12 @@ } in let result = game, {Arena.struc = struc; history = []; time = 0.; cur_loc = 0} in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "\n\ntranslate_game: before simplification --\n%s\n%!" + (Arena.sprint_state_full result) + ); + (* }}} *) let tossrule_data = Aux.strmap_of_assoc tossrule_data in let playing_as = Aux.array_argfind (fun x -> x = playing_as) players in Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-12 14:07:42 UTC (rev 1536) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-13 01:39:33 UTC (rev 1537) @@ -220,7 +220,7 @@ (* GDL.debug_level := 2; *) TranslateGame.debug_level := 4; GameSimpl.debug_level := 4; - (* DiscreteRule.debug_level := 4; *) + DiscreteRule.debug_level := 4; () @@ -271,9 +271,9 @@ DiscreteRule.debug_level := discreterule_dl); TranslateGame.generate_test_case := None -let a () = - (* regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; *) - regenerate ~debug:false ~game_name:"connect5" ~player:"x"; +let a = + regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; + (* regenerate ~debug:false ~game_name:"connect5" ~player:"x"; *) (* regenerate ~debug:true ~game_name:"breakthrough" ~player:"white"; *) (* regenerate ~debug:true ~game_name:"pawn_whopping" ~player:"x"; *) (* regen_with_debug ~game_name:"connect4" ~player:"white"; *) Modified: trunk/Toss/GGP/tests/connect5-raw.toss =================================================================== --- trunk/Toss/GGP/tests/connect5-raw.toss 2011-08-12 14:07:42 UTC (rev 1536) +++ trunk/Toss/GGP/tests/connect5-raw.toss 2011-08-13 01:39:33 UTC (rev 1537) @@ -1,4 +1,3 @@ -; not correct yet, but you can have a look at what works already REL adjacent_cell(v0, v1, v2, v3) = ex cell_x22__BLANK___BLANK_, cell_y22__BLANK___BLANK_, cell_x23__BLANK___BLANK_, cell_y23__BLANK___BLANK_ @@ -411,78 +410,40 @@ cell__BLANK___BLANK___BLANK_(cell_e_y8__BLANK_)) PLAYERS x, o RULE mark_x5_y5_noop: - [cell_x5_y5__BLANK_, cell_x5_y5__BLANK_, control__BLANK_ | - _opt_cell_2b {cell_x5_y5__BLANK_; control__BLANK_}; + [cell_x5_y5__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); _opt_cell_2o {cell_x5_y5__BLANK_; control__BLANK_}; _opt_cell_2x {cell_x5_y5__BLANK_; control__BLANK_}; - _opt_control_0o {cell_x5_y5__BLANK_; control__BLANK_}; - _opt_control_0x {cell_x5_y5__BLANK_; control__BLANK_} + _opt_control_0o (cell_x5_y5__BLANK_); + _opt_control_0x (cell_x5_y5__BLANK_); cell_2b (cell_x5_y5__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_x5_y5__BLANK_); + control_0x (control__BLANK_); control__BLANK_ (control__BLANK_) | ] -> - [cell_x5_y5__BLANK_, cell_x5_y5__BLANK_, control__BLANK_ | + [cell_x5_y5__BLANK_, control__BLANK_ | cell_2x (cell_x5_y5__BLANK_); control_0o (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x - pre - (not ex control__BLANK_ control_0o(control__BLANK_) and - ex cell_x5_y5__BLANK_, control__BLANK_ - (cell_2b(cell_x5_y5__BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_x5_y5__BLANK_) and - control_0x(control__BLANK_) and control__BLANK_(control__BLANK_))) -RULE noop_noop: - [control__BLANK_, control__BLANK_ | - _opt_cell_2b (control__BLANK_); _opt_cell_2o (control__BLANK_); - _opt_cell_2x (control__BLANK_); _opt_control_0o (control__BLANK_); - _opt_control_0x (control__BLANK_) - | - ] -> - [control__BLANK_, control__BLANK_ | - control_0o (control__BLANK_); control_0x (control__BLANK_) | - ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x - pre - not - ex control__BLANK_, control__BLANK_ - ((control_0o(control__BLANK_) and control__BLANK_(control__BLANK_)) or - (control_0x(control__BLANK_) and control__BLANK_(control__BLANK_))) RULE noop_mark_x6_y6: - [cell_x6_y6__BLANK_, cell_x6_y6__BLANK_, control__BLANK_ | - _opt_cell_2b {cell_x6_y6__BLANK_; control__BLANK_}; + [cell_x6_y6__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); _opt_cell_2o {cell_x6_y6__BLANK_; control__BLANK_}; _opt_cell_2x {cell_x6_y6__BLANK_; control__BLANK_}; - _opt_control_0o {cell_x6_y6__BLANK_; control__BLANK_}; - _opt_control_0x {cell_x6_y6__BLANK_; control__BLANK_} + _opt_control_0o (cell_x6_y6__BLANK_); + _opt_control_0x (cell_x6_y6__BLANK_); cell_2b (cell_x6_y6__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_x6_y6__BLANK_); + control_0o (control__BLANK_); control__BLANK_ (control__BLANK_) | ] -> - [cell_x6_y6__BLANK_, cell_x6_y6__BLANK_, control__BLANK_ | + [cell_x6_y6__BLANK_, control__BLANK_ | cell_2o (cell_x6_y6__BLANK_); control_0x (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x - pre - (not ex control__BLANK_ control_0x(control__BLANK_) and - ex cell_x6_y6__BLANK_, control__BLANK_ - (cell_2b(cell_x6_y6__BLANK_) and - cell__BLANK___BLANK___BLANK_(cell_x6_y6__BLANK_) and - control_0o(control__BLANK_) and control__BLANK_(control__BLANK_))) -RULE noop_noop0: - [control__BLANK_, control__BLANK_ | - _opt_cell_2b (control__BLANK_); _opt_cell_2o (control__BLANK_); - _opt_cell_2x (control__BLANK_); _opt_control_0o (control__BLANK_); - _opt_control_0x (control__BLANK_) - | - ] -> - [control__BLANK_, control__BLANK_ | - control_0o (control__BLANK_); control_0x (control__BLANK_) | - ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x - pre - not - ex control__BLANK_, control__BLANK_ - ((control_0o(control__BLANK_) and control__BLANK_(control__BLANK_)) or - (control_0x(control__BLANK_) and control__BLANK_(control__BLANK_))) LOC 0 { PLAYER x { PAYOFF 100. * :((true and conn5__x() and true)) + 50. * :((true and not exists_line_of_five() and true)) - MOVES [mark_x5_y5_noop -> 1]; [noop_noop -> 1] } + MOVES [mark_x5_y5_noop -> 1] } PLAYER o { PAYOFF 100. * :((true and conn5__o() and true)) + @@ -500,7 +461,7 @@ PAYOFF 100. * :((true and conn5__o() and true)) + 50. * :((true and not exists_line_of_five() and true)) - MOVES [noop_mark_x6_y6 -> 0]; [noop_noop0 -> 0] } + MOVES [noop_mark_x6_y6 -> 0] } } MODEL [cell_a_a__BLANK_, cell_a_b__BLANK_, cell_a_c__BLANK_, cell_a_d__BLANK_, Modified: trunk/Toss/GGP/tests/connect5-simpl.toss =================================================================== --- trunk/Toss/GGP/tests/connect5-simpl.toss 2011-08-12 14:07:42 UTC (rev 1536) +++ trunk/Toss/GGP/tests/connect5-simpl.toss 2011-08-13 01:39:33 UTC (rev 1537) @@ -1,4 +1,3 @@ -; not correct yet, but you can have a look at what works already REL adjacent_cell(v0, v1, v2, v3) = ex cell_x19__BLANK___BLANK_, cell_y19__BLANK___BLANK_, cell_x19__BLANK___BLANK_, cell_y20__BLANK___BLANK_ @@ -211,75 +210,35 @@ R: EQ___cell_0__cell_0__AND__nextcol__cell_1__cell_1, R1: nextcol__cell_0__cell_0__AND_INV__nextcol__cell_1__cell_1 RULE mark_x5_y5_noop: - [cell_x5_y5__BLANK_, cell_x5_y5__BLANK_, control__BLANK_ | - _opt_cell_2b {cell_x5_y5__BLANK_; control__BLANK_}; + [cell_x5_y5__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); _opt_cell_2o {cell_x5_y5__BLANK_; control__BLANK_}; _opt_cell_2x {cell_x5_y5__BLANK_; control__BLANK_}; - _opt_control_0o {cell_x5_y5__BLANK_; control__BLANK_}; - _opt_control_0x {cell_x5_y5__BLANK_; control__BLANK_} + _opt_control_0o (cell_x5_y5__BLANK_); + _opt_control_0x (cell_x5_y5__BLANK_); cell_2b (cell_x5_y5__BLANK_); + control_0x (control__BLANK_); control__BLANK_ (control__BLANK_) | ] -> - [cell_x5_y5__BLANK_, cell_x5_y5__BLANK_, control__BLANK_ | + [cell_x5_y5__BLANK_, control__BLANK_ | cell_2x (cell_x5_y5__BLANK_); control_0o (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x - pre - (not ex control__BLANK_ control_0o(control__BLANK_) and - ex cell_x5_y5__BLANK_, control__BLANK_ - (control__BLANK_(control__BLANK_) and cell_2b(cell_x5_y5__BLANK_) and - control_0x(control__BLANK_) and - not control__BLANK_(cell_x5_y5__BLANK_))) -RULE noop_noop: - [control__BLANK_, control__BLANK_ | - _opt_cell_2b (control__BLANK_); _opt_cell_2o (control__BLANK_); - _opt_cell_2x (control__BLANK_); _opt_control_0o (control__BLANK_); - _opt_control_0x (control__BLANK_) - | - ] -> - [control__BLANK_, control__BLANK_ | - control_0o (control__BLANK_); control_0x (control__BLANK_) | - ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x - pre - not - ex control__BLANK_, control__BLANK_ - ((control__BLANK_(control__BLANK_) and control_0o(control__BLANK_)) or - (control__BLANK_(control__BLANK_) and control_0x(control__BLANK_))) RULE noop_mark_x6_y6: - [cell_x6_y6__BLANK_, cell_x6_y6__BLANK_, control__BLANK_ | - _opt_cell_2b {cell_x6_y6__BLANK_; control__BLANK_}; + [cell_x6_y6__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); _opt_cell_2o {cell_x6_y6__BLANK_; control__BLANK_}; _opt_cell_2x {cell_x6_y6__BLANK_; control__BLANK_}; - _opt_control_0o {cell_x6_y6__BLANK_; control__BLANK_}; - _opt_control_0x {cell_x6_y6__BLANK_; control__BLANK_} + _opt_control_0o (cell_x6_y6__BLANK_); + _opt_control_0x (cell_x6_y6__BLANK_); cell_2b (cell_x6_y6__BLANK_); + control_0o (control__BLANK_); control__BLANK_ (control__BLANK_) | ] -> - [cell_x6_y6__BLANK_, cell_x6_y6__BLANK_, control__BLANK_ | + [cell_x6_y6__BLANK_, control__BLANK_ | cell_2o (cell_x6_y6__BLANK_); control_0x (control__BLANK_) | ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x - pre - (not ex control__BLANK_ control_0x(control__BLANK_) and - ex cell_x6_y6__BLANK_, control__BLANK_ - (control__BLANK_(control__BLANK_) and cell_2b(cell_x6_y6__BLANK_) and - control_0o(control__BLANK_) and - not control__BLANK_(cell_x6_y6__BLANK_))) -RULE noop_noop0: - [control__BLANK_, control__BLANK_ | - _opt_cell_2b (control__BLANK_); _opt_cell_2o (control__BLANK_); - _opt_cell_2x (control__BLANK_); _opt_control_0o (control__BLANK_); - _opt_control_0x (control__BLANK_) - | - ] -> - [control__BLANK_, control__BLANK_ | - control_0o (control__BLANK_); control_0x (control__BLANK_) | - ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x - pre - not - ex control__BLANK_, control__BLANK_ - ((control__BLANK_(control__BLANK_) and control_0o(control__BLANK_)) or - (control__BLANK_(control__BLANK_) and control_0x(control__BLANK_))) LOC 0 { PLAYER x { PAYOFF 100. * :(conn5__x()) + 50. * :(not exists_line_of_five()) - MOVES [mark_x5_y5_noop -> 1]; [noop_noop -> 1] } + MOVES [mark_x5_y5_noop -> 1] } PLAYER o { PAYOFF 100. * :(conn5__o()) + 50. * :(not exists_line_of_five()) } } @@ -288,7 +247,7 @@ PLAYER x { PAYOFF 100. * :(conn5__x()) + 50. * :(not exists_line_of_five()) } PLAYER o { PAYOFF 100. * :(conn5__o()) + 50. * :(not exists_line_of_five()) - MOVES [noop_mark_x6_y6 -> 0]; [noop_noop0 -> 0] } + MOVES [noop_mark_x6_y6 -> 0] } } MODEL [cell_a_a__BLANK_, cell_a_b__BLANK_, cell_a_c__BLANK_, cell_a_d__BLANK_, Modified: trunk/Toss/GGP/tests/tictactoe-raw.toss =================================================================== --- trunk/Toss/GGP/tests/tictactoe-raw.toss 2011-08-12 14:07:42 UTC (rev 1536) +++ trunk/Toss/GGP/tests/tictactoe-raw.toss 2011-08-13 01:39:33 UTC (rev 1537) @@ -1,542 +1,402 @@ +REL column__b(v0) = + ex cell_1_n4__BLANK_, cell_2_n4__BLANK_, cell_3_n4__BLANK_ + (v0 = cell_1_n4__BLANK_ and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_2_n4__BLANK_) and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_2_n4__BLANK_, cell_1_n4__BLANK_) and + EQ___cell_1__cell_1(cell_2_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_3_n4__BLANK_, cell_1_n4__BLANK_) and + EQ___cell_1__cell_1(cell_3_n4__BLANK_, cell_2_n4__BLANK_) and + cell_01(cell_1_n4__BLANK_) and cell_2b(cell_1_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_n4__BLANK_) and + cell_02(cell_2_n4__BLANK_) and cell_2b(cell_2_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_n4__BLANK_) and + cell_03(cell_3_n4__BLANK_) and cell_2b(cell_3_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_n4__BLANK_)) +REL column__o(v0) = + ex cell_1_n4__BLANK_, cell_2_n4__BLANK_, cell_3_n4__BLANK_ + (v0 = cell_1_n4__BLANK_ and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_2_n4__BLANK_) and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_2_n4__BLANK_, cell_1_n4__BLANK_) and + EQ___cell_1__cell_1(cell_2_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_3_n4__BLANK_, cell_1_n4__BLANK_) and + EQ___cell_1__cell_1(cell_3_n4__BLANK_, cell_2_n4__BLANK_) and + cell_01(cell_1_n4__BLANK_) and cell_2o(cell_1_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_n4__BLANK_) and + cell_02(cell_2_n4__BLANK_) and cell_2o(cell_2_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_n4__BLANK_) and + cell_03(cell_3_n4__BLANK_) and cell_2o(cell_3_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_n4__BLANK_)) +REL column__x(v0) = + ex cell_1_n4__BLANK_, cell_2_n4__BLANK_, cell_3_n4__BLANK_ + (v0 = cell_1_n4__BLANK_ and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_2_n4__BLANK_) and + EQ___cell_1__cell_1(cell_1_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_2_n4__BLANK_, cell_1_n4__BLANK_) and + EQ___cell_1__cell_1(cell_2_n4__BLANK_, cell_3_n4__BLANK_) and + EQ___cell_1__cell_1(cell_3_n4__BLANK_, cell_1_n4__BLANK_) and + EQ___cell_1__cell_1(cell_3_n4__BLANK_, cell_2_n4__BLANK_) and + cell_01(cell_1_n4__BLANK_) and cell_2x(cell_1_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_n4__BLANK_) and + cell_02(cell_2_n4__BLANK_) and cell_2x(cell_2_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_n4__BLANK_) and + cell_03(cell_3_n4__BLANK_) and cell_2x(cell_3_n4__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_n4__BLANK_)) +REL diagonal__b() = + ex cell_1_3__BLANK_, cell_2_2__BLANK_, cell_3_1__BLANK_ + (true and true and + cell_01(cell_1_3__BLANK_) and cell_13(cell_1_3__BLANK_) and + cell_2b(cell_1_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_3__BLANK_) and + cell_02(cell_2_2__BLANK_) and cell_12(cell_2_2__BLANK_) and + cell_2b(cell_2_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_2__BLANK_) and + cell_03(cell_3_1__BLANK_) and cell_11(cell_3_1__BLANK_) and + cell_2b(cell_3_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_1__BLANK_)) or + ex cell_1_1__BLANK_, cell_2_2__BLANK_, cell_3_3__BLANK_ + (true and true and + cell_01(cell_1_1__BLANK_) and cell_11(cell_1_1__BLANK_) and + cell_2b(cell_1_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_1__BLANK_) and + cell_02(cell_2_2__BLANK_) and cell_12(cell_2_2__BLANK_) and + cell_2b(cell_2_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_2__BLANK_) and + cell_03(cell_3_3__BLANK_) and cell_13(cell_3_3__BLANK_) and + cell_2b(cell_3_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_3__BLANK_)) +REL diagonal__o() = + ex cell_1_3__BLANK_, cell_2_2__BLANK_, cell_3_1__BLANK_ + (true and true and + cell_01(cell_1_3__BLANK_) and cell_13(cell_1_3__BLANK_) and + cell_2o(cell_1_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_3__BLANK_) and + cell_02(cell_2_2__BLANK_) and cell_12(cell_2_2__BLANK_) and + cell_2o(cell_2_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_2__BLANK_) and + cell_03(cell_3_1__BLANK_) and cell_11(cell_3_1__BLANK_) and + cell_2o(cell_3_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_1__BLANK_)) or + ex cell_1_1__BLANK_, cell_2_2__BLANK_, cell_3_3__BLANK_ + (true and true and + cell_01(cell_1_1__BLANK_) and cell_11(cell_1_1__BLANK_) and + cell_2o(cell_1_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_1__BLANK_) and + cell_02(cell_2_2__BLANK_) and cell_12(cell_2_2__BLANK_) and + cell_2o(cell_2_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_2__BLANK_) and + cell_03(cell_3_3__BLANK_) and cell_13(cell_3_3__BLANK_) and + cell_2o(cell_3_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_3__BLANK_)) +REL diagonal__x() = + ex cell_1_3__BLANK_, cell_2_2__BLANK_, cell_3_1__BLANK_ + (true and true and + cell_01(cell_1_3__BLANK_) and cell_13(cell_1_3__BLANK_) and + cell_2x(cell_1_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_3__BLANK_) and + cell_02(cell_2_2__BLANK_) and cell_12(cell_2_2__BLANK_) and + cell_2x(cell_2_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_2__BLANK_) and + cell_03(cell_3_1__BLANK_) and cell_11(cell_3_1__BLANK_) and + cell_2x(cell_3_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_1__BLANK_)) or + ex cell_1_1__BLANK_, cell_2_2__BLANK_, cell_3_3__BLANK_ + (true and true and + cell_01(cell_1_1__BLANK_) and cell_11(cell_1_1__BLANK_) and + cell_2x(cell_1_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_1_1__BLANK_) and + cell_02(cell_2_2__BLANK_) and cell_12(cell_2_2__BLANK_) and + cell_2x(cell_2_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_2_2__BLANK_) and + cell_03(cell_3_3__BLANK_) and cell_13(cell_3_3__BLANK_) and + cell_2x(cell_3_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_3_3__BLANK_)) +REL line__b() = + (true and diagonal__b() and true) or + (true and + ex cell__BLANK__m6__BLANK_ (column__b(cell__BLANK__m6__BLANK_) and true) and + true) or + (true and + ex cell_m5__BLANK___BLANK_ (row__b(cell_m5__BLANK___BLANK_) and true) and + true) +REL line__o() = + (true and diagonal__o() and true) or + (true and + ex cell__BLANK__m6__BLANK_ (column__o(cell__BLANK__m6__BLANK_) and true) and + true) or + (true and + ex cell_m5__BLANK___BLANK_ (row__o(cell_m5__BLANK___BLANK_) and true) and + true) +REL line__x() = + (true and diagonal__x() and true) or + (true and + ex cell__BLANK__m6__BLANK_ (column__x(cell__BLANK__m6__BLANK_) and true) and + true) or + (true and + ex cell_m5__BLANK___BLANK_ (row__x(cell_m5__BLANK___BLANK_) and true) and + true) +REL open() = + ex cell_m7_n5__BLANK_ + (true and true and + cell_2b(cell_m7_n5__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m7_n5__BLANK_)) +REL row__b(v0) = + ex cell_m4_1__BLANK_, cell_m4_2__BLANK_, cell_m4_3__BLANK_ + (v0 = cell_m4_1__BLANK_ and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_2__BLANK_) and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_2__BLANK_, cell_m4_1__BLANK_) and + EQ___cell_0__cell_0(cell_m4_2__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_3__BLANK_, cell_m4_1__BLANK_) and + EQ___cell_0__cell_0(cell_m4_3__BLANK_, cell_m4_2__BLANK_) and + cell_11(cell_m4_1__BLANK_) and cell_2b(cell_m4_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_1__BLANK_) and + cell_12(cell_m4_2__BLANK_) and cell_2b(cell_m4_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_2__BLANK_) and + cell_13(cell_m4_3__BLANK_) and cell_2b(cell_m4_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_3__BLANK_)) +REL row__o(v0) = + ex cell_m4_1__BLANK_, cell_m4_2__BLANK_, cell_m4_3__BLANK_ + (v0 = cell_m4_1__BLANK_ and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_2__BLANK_) and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_2__BLANK_, cell_m4_1__BLANK_) and + EQ___cell_0__cell_0(cell_m4_2__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_3__BLANK_, cell_m4_1__BLANK_) and + EQ___cell_0__cell_0(cell_m4_3__BLANK_, cell_m4_2__BLANK_) and + cell_11(cell_m4_1__BLANK_) and cell_2o(cell_m4_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_1__BLANK_) and + cell_12(cell_m4_2__BLANK_) and cell_2o(cell_m4_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_2__BLANK_) and + cell_13(cell_m4_3__BLANK_) and cell_2o(cell_m4_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_3__BLANK_)) +REL row__x(v0) = + ex cell_m4_1__BLANK_, cell_m4_2__BLANK_, cell_m4_3__BLANK_ + (v0 = cell_m4_1__BLANK_ and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_2__BLANK_) and + EQ___cell_0__cell_0(cell_m4_1__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_2__BLANK_, cell_m4_1__BLANK_) and + EQ___cell_0__cell_0(cell_m4_2__BLANK_, cell_m4_3__BLANK_) and + EQ___cell_0__cell_0(cell_m4_3__BLANK_, cell_m4_1__BLANK_) and + EQ___cell_0__cell_0(cell_m4_3__BLANK_, cell_m4_2__BLANK_) and + cell_11(cell_m4_1__BLANK_) and cell_2x(cell_m4_1__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_1__BLANK_) and + cell_12(cell_m4_2__BLANK_) and cell_2x(cell_m4_2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_2__BLANK_) and + cell_13(cell_m4_3__BLANK_) and cell_2x(cell_m4_3__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_m4_3__BLANK_)) PLAYERS xplayer, oplayer -RULE mark_x64_y19_0: - [cell_x64_y19__blank_, control__blank_ | - _opt_cell_m_n_b (control__blank_); - _opt_cell_m_n_o {cell_x64_y19__blank_; control__blank_}; - _opt_cell_m_n_x {cell_x64_y19__blank_; control__blank_}; - _opt_control_oplayer (cell_x64_y19__blank_); - _opt_control_xplayer (cell_x64_y19__blank_); - cell_m_n_b (cell_x64_y19__blank_); control_xplayer (control__blank_) +RULE mark_x6_y_noop: + [cell_x6_y__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2o {cell_x6_y__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x6_y__BLANK_; control__BLANK_}; + _opt_control_0oplayer {cell_x6_y__BLANK_; control__BLANK_}; + _opt_control_0xplayer {cell_x6_y__BLANK_; control__BLANK_}; + cell_2b (cell_x6_y__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_x6_y__BLANK_) | ] -> - [cell_x64_y19__blank_, control__blank_ | - cell_m_n_x (cell_x64_y19__blank_); control_oplayer (control__blank_) | - ] - emb cell_m_n_b, cell_m_n_o, cell_m_n_x, control_oplayer, control_xplayer + [cell_x6_y__BLANK_, control__BLANK_ | + cell_2x (cell_x6_y__BLANK_); control_0oplayer (control__BLANK_); + control_0xplayer (control__BLANK_) + | + ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer pre - (not - ex cell_m44_3__blank_, cell_m44_2__blank_, cell_m44_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m44_1__blank_, cell_m44_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m44_1__blank_, cell_m44_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m44_2__blank_, cell_m44_3__blank_) and - cell_m_1_MV1(cell_m44_1__blank_) and - cell_m_2_MV1(cell_m44_2__blank_) and - cell_m_3_MV1(cell_m44_3__blank_) and - cell_m_n_x(cell_m44_1__blank_) and cell_m_n_x(cell_m44_2__blank_) and - cell_m_n_x(cell_m44_3__blank_)) and - not - ex cell_3_m45__blank_, cell_2_m45__blank_, cell_1_m45__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m45__blank_, cell_2_m45__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m45__blank_, cell_3_m45__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m45__blank_, cell_3_m45__blank_) and - cell_1_n_MV1(cell_1_m45__blank_) and - cell_2_n_MV1(cell_2_m45__blank_) and - cell_3_n_MV1(cell_3_m45__blank_) and - cell_m_n_x(cell_1_m45__blank_) and cell_m_n_x(cell_2_m45__blank_) and - cell_m_n_x(cell_3_m45__blank_)) and - not - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and cell_3_n_MV1(cell_3_3__blank_) and - cell_m_n_x(cell_1_1__blank_) and cell_m_n_x(cell_2_2__blank_) and - cell_m_n_x(cell_3_3__blank_)) and - not - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and cell_3_n_MV1(cell_3_1__blank_) and - cell_m_n_x(cell_1_3__blank_) and cell_m_n_x(cell_2_2__blank_) and - cell_m_n_x(cell_3_1__blank_)) and - not - ex cell_m46_3__blank_, cell_m46_2__blank_, cell_m46_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m46_1__blank_, cell_m46_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m46_1__blank_, cell_m46_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m46_2__blank_, cell_m46_3__blank_) and - cell_m_1_MV1(cell_m46_1__blank_) and - cell_m_2_MV1(cell_m46_2__blank_) and - cell_m_3_MV1(cell_m46_3__blank_) and - cell_m_n_o(cell_m46_1__blank_) and cell_m_n_o(cell_m46_2__blank_) and - cell_m_n_o(cell_m46_3__blank_)) and - not - ex cell_3_m47__blank_, cell_2_m47__blank_, cell_1_m47__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m47__blank_, cell_2_m47__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m47__blank_, cell_3_m47__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m47__blank_, cell_3_m47__blank_) and - cell_1_n_MV1(cell_1_m47__blank_) and - cell_2_n_MV1(cell_2_m47__blank_) and - cell_3_n_MV1(cell_3_m47__blank_) and - cell_m_n_o(cell_1_m47__blank_) and cell_m_n_o(cell_2_m47__blank_) and - cell_m_n_o(cell_3_m47__blank_)) and - not - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and cell_3_n_MV1(cell_3_3__blank_) and - cell_m_n_o(cell_1_1__blank_) and cell_m_n_o(cell_2_2__blank_) and - cell_m_n_o(cell_3_3__blank_)) and - not - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and cell_3_n_MV1(cell_3_1__blank_) and - cell_m_n_o(cell_1_3__blank_) and cell_m_n_o(cell_2_2__blank_) and - cell_m_n_o(cell_3_1__blank_)) and - ex cell_m48_n23__blank_ cell_m_n_b(cell_m48_n23__blank_)) -RULE mark_x71_y26_1: - [cell_x71_y26__blank_, control__blank_ | - _opt_cell_m_n_b (control__blank_); - _opt_cell_m_n_o {cell_x71_y26__blank_; control__blank_}; - _opt_cell_m_n_x {cell_x71_y26__blank_; control__blank_}; - _opt_control_oplayer (cell_x71_y26__blank_); - _opt_control_xplayer (cell_x71_y26__blank_); - cell_m_n_b (cell_x71_y26__blank_); control_oplayer (control__blank_) + (not (cell_0x6(cell_x6_y__BLANK_) and cell_1y(cell_x6_y__BLANK_)) and + ex control__BLANK_ + (control_0oplayer(control__BLANK_) and + control_0xplayer(control__BLANK_) and control__BLANK_(control__BLANK_))) +RULE noop_mark_x7_y0: + [cell_x7_y0__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); + _opt_cell_2o {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_control_0oplayer {cell_x7_y0__BLANK_; control__BLANK_}; + _opt_control_0xplayer {cell_x7_y0__BLANK_; control__BLANK_}; + cell_2b (cell_x7_y0__BLANK_); + cell__BLANK___BLANK___BLANK_ (cell_x7_y0__BLANK_) | ] -> - [cell_x71_y26__blank_, control__blank_ | - cell_m_n_o (cell_x71_y26__blank_); control_xplayer (control__blank_) | - ] - emb cell_m_n_b, cell_m_n_o, cell_m_n_x, control_oplayer, control_xplayer + [cell_x7_y0__BLANK_, control__BLANK_ | + cell_2o (cell_x7_y0__BLANK_); control_0oplayer (control__BLANK_); + control_0xplayer (control__BLANK_) + | + ] emb cell_2b, cell_2o, cell_2x, control_0oplayer, control_0xplayer pre - (not - ex cell_m44_3__blank_, cell_m44_2__blank_, cell_m44_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m44_1__blank_, cell_m44_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m44_1__blank_, cell_m44_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m44_2__blank_, cell_m44_3__blank_) and - cell_m_1_MV1(cell_m44_1__blank_) and - cell_m_2_MV1(cell_m44_2__blank_) and - cell_m_3_MV1(cell_m44_3__blank_) and - cell_m_n_x(cell_m44_1__blank_) and cell_m_n_x(cell_m44_2__blank_) and - cell_m_n_x(cell_m44_3__blank_)) and - not - ex cell_3_m45__blank_, cell_2_m45__blank_, cell_1_m45__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m45__blank_, cell_2_m45__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m45__blank_, cell_3_m45__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m45__blank_, cell_3_m45__blank_) and - cell_1_n_MV1(cell_1_m45__blank_) and - cell_2_n_MV1(cell_2_m45__blank_) and - cell_3_n_MV1(cell_3_m45__blank_) and - cell_m_n_x(cell_1_m45__blank_) and cell_m_n_x(cell_2_m45__blank_) and - cell_m_n_x(cell_3_m45__blank_)) and - not - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and cell_3_n_MV1(cell_3_3__blank_) and - cell_m_n_x(cell_1_1__blank_) and cell_m_n_x(cell_2_2__blank_) and - cell_m_n_x(cell_3_3__blank_)) and - not - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and cell_3_n_MV1(cell_3_1__blank_) and - cell_m_n_x(cell_1_3__blank_) and cell_m_n_x(cell_2_2__blank_) and - cell_m_n_x(cell_3_1__blank_)) and - not - ex cell_m46_3__blank_, cell_m46_2__blank_, cell_m46_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m46_1__blank_, cell_m46_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m46_1__blank_, cell_m46_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m46_2__blank_, cell_m46_3__blank_) and - cell_m_1_MV1(cell_m46_1__blank_) and - cell_m_2_MV1(cell_m46_2__blank_) and - cell_m_3_MV1(cell_m46_3__blank_) and - cell_m_n_o(cell_m46_1__blank_) and cell_m_n_o(cell_m46_2__blank_) and - cell_m_n_o(cell_m46_3__blank_)) and - not - ex cell_3_m47__blank_, cell_2_m47__blank_, cell_1_m47__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m47__blank_, cell_2_m47__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m47__blank_, cell_3_m47__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m47__blank_, cell_3_m47__blank_) and - cell_1_n_MV1(cell_1_m47__blank_) and - cell_2_n_MV1(cell_2_m47__blank_) and - cell_3_n_MV1(cell_3_m47__blank_) and - cell_m_n_o(cell_1_m47__blank_) and cell_m_n_o(cell_2_m47__blank_) and - cell_m_n_o(cell_3_m47__blank_)) and - not - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and cell_3_n_MV1(cell_3_3__blank_) and - cell_m_n_o(cell_1_1__blank_) and cell_m_n_o(cell_2_2__blank_) and - cell_m_n_o(cell_3_3__blank_)) and - not - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and cell_3_n_MV1(cell_3_1__blank_) and - cell_m_n_o(cell_1_3__blank_) and cell_m_n_o(cell_2_2__blank_) and - cell_m_n_o(cell_3_1__blank_)) and - ex cell_m48_n23__blank_ cell_m_n_b(cell_m48_n23__blank_)) + (not (cell_0x7(cell_x7_y0__BLANK_) and cell_1y0(cell_x7_y0__BLANK_)) and + ex control__BLANK_ + (control_0oplayer(control__BLANK_) and + control_0xplayer(control__BLANK_) and control__BLANK_(control__BLANK_))) LOC 0 { PLAYER xplayer { PAYOFF - 50. + - -50. * - :( - ex cell_m8_3__blank_, cell_m8_2__blank_, cell_m8_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m8_1__blank_, cell_m8_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m8_1__blank_, cell_m8_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m8_2__blank_, cell_m8_3__blank_) and - cell_m_1_MV1(cell_m8_1__blank_) and - cell_m_2_MV1(cell_m8_2__blank_) and - cell_m_3_MV1(cell_m8_3__blank_) and cell_m_n_o(cell_m8_1__blank_) and - cell_m_n_o(cell_m8_2__blank_) and cell_m_n_o(cell_m8_3__blank_)) or - ex cell_3_m9__blank_, cell_2_m9__blank_, cell_1_m9__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m9__blank_, cell_2_m9__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m9__blank_, cell_3_m9__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m9__blank_, cell_3_m9__blank_) and - cell_1_n_MV1(cell_1_m9__blank_) and - cell_2_n_MV1(cell_2_m9__blank_) and - cell_3_n_MV1(cell_3_m9__blank_) and - cell_m_n_o(cell_1_m9__blank_) and cell_m_n_o(cell_2_m9__blank_) and - cell_m_n_o(cell_3_m9__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and - cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and - cell_3_n_MV1(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and - cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and - cell_3_n_MV1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) - ) - + + 100. * :((true and line__x() and true)) + 50. * - :( - ex cell_m1_3__blank_, cell_m1_2__blank_, cell_m1_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m1_1__blank_, cell_m1_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m1_1__blank_, cell_m1_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m1_2__blank_, cell_m1_3__blank_) and - cell_m_1_MV1(cell_m1_1__blank_) and - cell_m_2_MV1(cell_m1_2__blank_) and - cell_m_3_MV1(cell_m1_3__blank_) and cell_m_n_x(cell_m1_1__blank_) and - cell_m_n_x(cell_m1_2__blank_) and cell_m_n_x(cell_m1_3__blank_)) or - ex cell_3_m2__blank_, cell_2_m2__blank_, cell_1_m2__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m2__blank_, cell_2_m2__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m2__blank_, cell_3_m2__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m2__blank_, cell_3_m2__blank_) and - cell_1_n_MV1(cell_1_m2__blank_) and - cell_2_n_MV1(cell_2_m2__blank_) and - cell_3_n_MV1(cell_3_m2__blank_) and - cell_m_n_x(cell_1_m2__blank_) and cell_m_n_x(cell_2_m2__blank_) and - cell_m_n_x(cell_3_m2__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and - cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and - cell_3_n_MV1(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and - cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and - cell_3_n_MV1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) - ) - MOVES [mark_x64_y19_0 -> 1] } + :((true and not line__x() and not line__o() and not open() and true)) + MOVES [mark_x6_y_noop -> 1] } PLAYER oplayer { PAYOFF - 50. + - -50. * - :( - ex cell_m17_3__blank_, cell_m17_2__blank_, cell_m17_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m17_1__blank_, cell_m17_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m17_1__blank_, cell_m17_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m17_2__blank_, cell_m17_3__blank_) and - cell_m_1_MV1(cell_m17_1__blank_) and - cell_m_2_MV1(cell_m17_2__blank_) and - cell_m_3_MV1(cell_m17_3__blank_) and - cell_m_n_x(cell_m17_1__blank_) and cell_m_n_x(cell_m17_2__blank_) and - cell_m_n_x(cell_m17_3__blank_)) or - ex cell_3_m18__blank_, cell_2_m18__blank_, cell_1_m18__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m18__blank_, cell_2_m18__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m18__blank_, cell_3_m18__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m18__blank_, cell_3_m18__blank_) and - cell_1_n_MV1(cell_1_m18__blank_) and - cell_2_n_MV1(cell_2_m18__blank_) and - cell_3_n_MV1(cell_3_m18__blank_) and - cell_m_n_x(cell_1_m18__blank_) and - cell_m_n_x(cell_2_m18__blank_) and cell_m_n_x(cell_3_m18__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and - cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and - cell_3_n_MV1(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and - cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and - cell_3_n_MV1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) - ) - + + 100. * :((true and line__o() and true)) + 50. * - :( - ex cell_m10_3__blank_, cell_m10_2__blank_, cell_m10_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m10_1__blank_, cell_m10_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m10_1__blank_, cell_m10_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m10_2__blank_, cell_m10_3__blank_) and - cell_m_1_MV1(cell_m10_1__blank_) and - cell_m_2_MV1(cell_m10_2__blank_) and - cell_m_3_MV1(cell_m10_3__blank_) and - cell_m_n_o(cell_m10_1__blank_) and cell_m_n_o(cell_m10_2__blank_) and - cell_m_n_o(cell_m10_3__blank_)) or - ex cell_3_m11__blank_, cell_2_m11__blank_, cell_1_m11__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m11__blank_, cell_2_m11__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m11__blank_, cell_3_m11__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m11__blank_, cell_3_m11__blank_) and - cell_1_n_MV1(cell_1_m11__blank_) and - cell_2_n_MV1(cell_2_m11__blank_) and - cell_3_n_MV1(cell_3_m11__blank_) and - cell_m_n_o(cell_1_m11__blank_) and - cell_m_n_o(cell_2_m11__blank_) and cell_m_n_o(cell_3_m11__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and - cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and - cell_3_n_MV1(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and - cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and - cell_3_n_MV1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) - ) + :((true and not line__x() and not line__o() and not open() and true)) } } LOC 1 { PLAYER xplayer { PAYOFF - 50. + - -50. * - :( - ex cell_m8_3__blank_, cell_m8_2__blank_, cell_m8_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m8_1__blank_, cell_m8_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m8_1__blank_, cell_m8_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m8_2__blank_, cell_m8_3__blank_) and - cell_m_1_MV1(cell_m8_1__blank_) and - cell_m_2_MV1(cell_m8_2__blank_) and - cell_m_3_MV1(cell_m8_3__blank_) and cell_m_n_o(cell_m8_1__blank_) and - cell_m_n_o(cell_m8_2__blank_) and cell_m_n_o(cell_m8_3__blank_)) or - ex cell_3_m9__blank_, cell_2_m9__blank_, cell_1_m9__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m9__blank_, cell_2_m9__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m9__blank_, cell_3_m9__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m9__blank_, cell_3_m9__blank_) and - cell_1_n_MV1(cell_1_m9__blank_) and - cell_2_n_MV1(cell_2_m9__blank_) and - cell_3_n_MV1(cell_3_m9__blank_) and - cell_m_n_o(cell_1_m9__blank_) and cell_m_n_o(cell_2_m9__blank_) and - cell_m_n_o(cell_3_m9__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and - cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and - cell_3_n_MV1(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and - cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and - cell_3_n_MV1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) - ) - + + 100. * :((true and line__x() and true)) + 50. * - :( - ex cell_m1_3__blank_, cell_m1_2__blank_, cell_m1_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m1_1__blank_, cell_m1_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m1_1__blank_, cell_m1_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m1_2__blank_, cell_m1_3__blank_) and - cell_m_1_MV1(cell_m1_1__blank_) and - cell_m_2_MV1(cell_m1_2__blank_) and - cell_m_3_MV1(cell_m1_3__blank_) and cell_m_n_x(cell_m1_1__blank_) and - cell_m_n_x(cell_m1_2__blank_) and cell_m_n_x(cell_m1_3__blank_)) or - ex cell_3_m2__blank_, cell_2_m2__blank_, cell_1_m2__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m2__blank_, cell_2_m2__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m2__blank_, cell_3_m2__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m2__blank_, cell_3_m2__blank_) and - cell_1_n_MV1(cell_1_m2__blank_) and - cell_2_n_MV1(cell_2_m2__blank_) and - cell_3_n_MV1(cell_3_m2__blank_) and - cell_m_n_x(cell_1_m2__blank_) and cell_m_n_x(cell_2_m2__blank_) and - cell_m_n_x(cell_3_m2__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and - cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and - cell_3_n_MV1(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and - cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and - cell_3_n_MV1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) - ) + :((true and not line__x() and not line__o() and not open() and true)) } PLAYER oplayer { PAYOFF - 50. + - -50. * - :( - ex cell_m17_3__blank_, cell_m17_2__blank_, cell_m17_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m17_1__blank_, cell_m17_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m17_1__blank_, cell_m17_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m17_2__blank_, cell_m17_3__blank_) and - cell_m_1_MV1(cell_m17_1__blank_) and - cell_m_2_MV1(cell_m17_2__blank_) and - cell_m_3_MV1(cell_m17_3__blank_) and - cell_m_n_x(cell_m17_1__blank_) and cell_m_n_x(cell_m17_2__blank_) and - cell_m_n_x(cell_m17_3__blank_)) or - ex cell_3_m18__blank_, cell_2_m18__blank_, cell_1_m18__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m18__blank_, cell_2_m18__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m18__blank_, cell_3_m18__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m18__blank_, cell_3_m18__blank_) and - cell_1_n_MV1(cell_1_m18__blank_) and - cell_2_n_MV1(cell_2_m18__blank_) and - cell_3_n_MV1(cell_3_m18__blank_) and - cell_m_n_x(cell_1_m18__blank_) and - cell_m_n_x(cell_2_m18__blank_) and cell_m_n_x(cell_3_m18__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and - cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and - cell_3_n_MV1(cell_3_3__blank_) and cell_m_n_x(cell_1_1__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_3__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and - cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and - cell_3_n_MV1(cell_3_1__blank_) and cell_m_n_x(cell_1_3__blank_) and - cell_m_n_x(cell_2_2__blank_) and cell_m_n_x(cell_3_1__blank_)) - ) - + + 100. * :((true and line__o() and true)) + 50. * - :( - ex cell_m10_3__blank_, cell_m10_2__blank_, cell_m10_1__blank_ - (EQ___cell_m_n_MV1_m(cell_m10_1__blank_, cell_m10_2__blank_) and - EQ___cell_m_n_MV1_m(cell_m10_1__blank_, cell_m10_3__blank_) and - EQ___cell_m_n_MV1_m(cell_m10_2__blank_, cell_m10_3__blank_) and - cell_m_1_MV1(cell_m10_1__blank_) and - cell_m_2_MV1(cell_m10_2__blank_) and - cell_m_3_MV1(cell_m10_3__blank_) and - cell_m_n_o(cell_m10_1__blank_) and cell_m_n_o(cell_m10_2__blank_) and - cell_m_n_o(cell_m10_3__blank_)) or - ex cell_3_m11__blank_, cell_2_m11__blank_, cell_1_m11__blank_ - (EQ___cell_m_n_MV1_n(cell_1_m11__blank_, cell_2_m11__blank_) and - EQ___cell_m_n_MV1_n(cell_1_m11__blank_, cell_3_m11__blank_) and - EQ___cell_m_n_MV1_n(cell_2_m11__blank_, cell_3_m11__blank_) and - cell_1_n_MV1(cell_1_m11__blank_) and - cell_2_n_MV1(cell_2_m11__blank_) and - cell_3_n_MV1(cell_3_m11__blank_) and - cell_m_n_o(cell_1_m11__blank_) and - cell_m_n_o(cell_2_m11__blank_) and cell_m_n_o(cell_3_m11__blank_)) or - ex cell_3_3__blank_, cell_2_2__blank_, cell_1_1__blank_ - (cell_m_1_MV1(cell_1_1__blank_) and - cell_1_n_MV1(cell_1_1__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_3_MV1(cell_3_3__blank_) and - cell_3_n_MV1(cell_3_3__blank_) and cell_m_n_o(cell_1_1__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_3__blank_)) or - ex cell_3_1__blank_, cell_2_2__blank_, cell_1_3__blank_ - (cell_m_3_MV1(cell_1_3__blank_) and - cell_1_n_MV1(cell_1_3__blank_) and - cell_m_2_MV1(cell_2_2__blank_) and - cell_2_n_MV1(cell_2_2__blank_) and - cell_m_1_MV1(cell_3_1__blank_) and - cell_3_n_MV1(cell_3_1__blank_) and cell_m_n_o(cell_1_3__blank_) and - cell_m_n_o(cell_2_2__blank_) and cell_m_n_o(cell_3_1__blank_)) - ) - MOVES [mark_x71_y26_1 -> 0] } + :((true and not line__x() and not line__o() and not open() and true)) + MOVES [noop_mark_x7_y0 -> 0] } } MODEL - [control_MV1, cell_3_3_MV1, cell_3_2_MV1, cell_3_1_MV1, cell_2_3_MV1, - cell_2_2_MV1, cell_2_1_MV1, cell_1_3_MV1, cell_1_2_MV1, cell_1_1_MV1 | - EQ___cell_m_n_MV1_m { - (cell_3_3_MV1, cell_3_3_MV1); (cell_3_3_MV1, cell_3_2_MV1); - (cell_3_3_MV1, cell_3_1_MV1); (cell_3_2_MV1, cell_3_3_MV1); - (cell_3_2_MV1, cell_3_2_MV1); (cell_3_2_MV1, cell_3_1_MV1); - (cell_3_1_MV1, cell_3_3_MV1); (cell_3_1_MV1, cell_3_2_MV1); - (cell_3_1_MV1, cell_3_1_MV1); (cell_2_3_MV1, cell_2_3_MV1); - (cell_2_3_MV1, cell_2_2_MV1); (cell_2_3_MV1, cell_2_1_MV1); - (cell_2_2_MV1, cell_2_3_MV1); (cell_2_2_MV1, cell_2_2_MV1); - (cell_2_2_MV1, cell_2_1_MV1); (cell_2_1_MV1, cell_2_3_MV1); - (cell_2_1_MV1, cell_2_2_MV1); (cell_2_1_MV1, cell_2_1_MV1); - (cell_1_3_MV1, cell_1_3_MV1); (cell_1_3_MV1, cell_1_2_MV1); - (cell_1_3_MV1, cell_1_1_MV1); (cell_1_2_MV1, cell_1_3_MV1); - (cell_1_2_MV1, cell_1_2_MV1); (cell_1_2_MV1, cell_1_1_MV1); - (cell_1_1_MV1, cell_1_3_MV1); (cell_1_1_MV1, cell_1_2_MV1); - (cell_1_1_MV1, cell_1_1_MV1) + [cell_1_1__BLANK_, cell_1_2__BLANK_, cell_1_3__BLANK_, cell_2_1__BLANK_, + cell_2_2__BLANK_, cell_2_3__BLANK_, cell_3_1__BLANK_, cell_3_2__BLANK_, ... [truncated message content] |
From: <luk...@us...> - 2011-08-12 14:07:51
|
Revision: 1536 http://toss.svn.sourceforge.net/toss/?rev=1536&view=rev Author: lukstafi Date: 2011-08-12 14:07:42 +0000 (Fri, 12 Aug 2011) Log Message: ----------- GDL translation fixing: debugged and refined erasure clause generation; small fix in GameSimpl. Modified Paths: -------------- trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/GameSimpl.ml trunk/Toss/GGP/GameSimplTest.ml trunk/Toss/GGP/TranslateFormulaTest.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGame.mli trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/GGP/tests/connect5-raw.toss trunk/Toss/GGP/tests/connect5-simpl.toss trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/GDL.ml 2011-08-12 14:07:42 UTC (rev 1536) @@ -242,6 +242,13 @@ | Func (f, args) -> Func (f, Array.map (subst sb) args) +let rec subst_consts sb = function + | Const y as t -> + (try List.assoc y sb with Not_found -> t) + | Var _ as t -> t + | Func (f, args) -> + Func (f, Array.map (subst sb) args) + let rec unify_all sb = function | [] | [_] -> sb | t1::t2::tl -> @@ -266,6 +273,8 @@ let subst_rel sb (rel, args) = rel, Array.map (subst sb) args let subst_rels sb body = List.map (subst_rel sb) body +let subst_consts_rel sb (rel, args) = rel, Array.map (subst_consts sb) args + let compose_sb sb1 sb2 = let vars1, terms1 = List.split sb1 in let vars2, terms2 = List.split sb2 in @@ -285,16 +294,33 @@ | True arg -> True (subst sb arg) | Does (arg1, arg2) -> Does (subst sb arg1, subst sb arg2) +let subst_consts_atom sb = function + | Distinct args -> Distinct (Array.map (subst sb) args) + | Rel rel_atom -> Rel (subst_consts_rel sb rel_atom) + | Role arg -> Role (subst_consts sb arg) + | True arg -> True (subst_consts sb arg) + | Does (arg1, arg2) -> Does (subst_consts sb arg1, subst sb arg2) + let rec subst_literal sb = function | Pos atom -> Pos (subst_atom sb atom) | Neg atom -> Neg (subst_atom sb atom) | Disj disjs -> Disj (List.map (subst_literal sb) disjs) +let rec subst_consts_literal sb = function + | Pos atom -> Pos (subst_consts_atom sb atom) + | Neg atom -> Neg (subst_consts_atom sb atom) + | Disj disjs -> Disj (List.map (subst_consts_literal sb) disjs) + let rec subst_literals sb = List.map (subst_literal sb) +let rec subst_consts_literals sb = List.map (subst_consts_literal sb) + let subst_clause sb (head, body) = subst_rel sb head, subst_literals sb body +let subst_consts_clause sb (head, body) = + subst_consts_rel sb head, subst_consts_literals sb body + let rel_atom_str (rel, args) = "(" ^ rel ^ " " ^ String.concat " " (Array.to_list (Array.map term_str args)) ^ ")" @@ -473,7 +499,9 @@ (** Form clause bodies whose disjunction is equivalent to the - negation of disjunction of given clause bodies. *) + negation of disjunction of given clause bodies. Keep the + substitution so that the heads of corresponding clauses can be + substituted too. *) let negate_bodies conjs = let placeholder = "", [] in let clauses = List.map (fun body -> placeholder, body) conjs in @@ -491,7 +519,7 @@ | Pos atom -> Aux.Right (Neg atom) | Disj _ -> assert false) body in let sb = List.fold_left unify_all [] uniterms in - List.map (subst_literal sb) lits in + sb, List.map (subst_literal sb) lits in Aux.map_try nclause negated @@ -825,8 +853,8 @@ let exp_clause clause = (* TODO: remove "role" atoms *) (* determine variables standing for players *) - let plvars = - player_vars_of (List.map rel_of_atom (atoms_of_clause clause)) in + let plvars = Aux.unique_sorted + (player_vars_of (List.map rel_of_atom (atoms_of_clause clause))) in if plvars = [] then [clause] else let sbs = Aux.power plvars players in @@ -1081,13 +1109,14 @@ let blank = Const "_BLANK_" -(* [expand_path_vars_by p ts clauses] expands variables that have - occurrences at path [p] in some state term of a clause, by terms - [ts]. *) -let expand_path_vars_by p ts clauses = - let exp_clause ((h_rel, h_args), body as clause) = +(* [expand_path_vars_by prepare_lits p ts clauses] expands variables + that have occurrences at path [p] in some state term of a clause + (from which pre-processed literals are extracted by + [prepare_lits]), by terms [ts]. *) +let expand_path_vars_by prepare_lits p ts clauses = + let exp_clause clause = (* determine variables standing for players *) - let pstates = state_terms (Pos (Rel (h_rel, h_args))::body) in + let pstates = state_terms (prepare_lits clause) in let pvars = Aux.map_try (fun s -> term_vars (at_path s p)) pstates in let pvars = Aux.Strings.elements @@ -1099,7 +1128,7 @@ Aux.concat_map exp_clause clauses -let ground_vars_at_paths ps_sterms clauses = +let ground_vars_at_paths prepare_lits ps_sterms clauses = List.fold_left (fun clauses (p, ts) -> - expand_path_vars_by p ts clauses + expand_path_vars_by prepare_lits p ts clauses ) clauses ps_sterms Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/GDL.mli 2011-08-12 14:07:42 UTC (rev 1536) @@ -51,6 +51,7 @@ val rel_of_atom : atom -> rel_atom val term_vars : term -> Aux.Strings.t +val terms_vars : term array -> Aux.Strings.t val clause_vars : clause -> Aux.Strings.t val defs_of_rules : gdl_rule list -> gdl_defs @@ -64,11 +65,13 @@ val unify_all : substitution -> term list -> substitution val rels_unify : rel_atom -> rel_atom -> bool val subst : substitution -> term -> term +val subst_consts : substitution -> term -> term val subst_rel : substitution -> rel_atom -> rel_atom val subst_rels : substitution -> rel_atom list -> rel_atom list val subst_literal : substitution -> literal -> literal val subst_literals : substitution -> literal list -> literal list val subst_clause : substitution -> clause -> clause +val subst_consts_clause : substitution -> clause -> clause (** Saturation currently exposed for testing purposes. *) val saturate : @@ -82,8 +85,11 @@ val expand_positive_lits : gdl_defs -> def_branch list -> def_branch list (** Form clause bodies whose disjunction is equivalent to the - negation of disjunction of given clause bodies. *) -val negate_bodies : literal list list -> literal list list + negation of disjunction of given clause bodies. Keep the + substitution so that the heads of corresponding clauses can be + substituted too. *) +val negate_bodies : + literal list list -> (substitution * literal list) list (** Rename clauses so that they have disjoint variables. Return a cell storing all variables. *) @@ -107,6 +113,7 @@ val state_terms : literal list -> term list val term_arities : term -> (string * int) list +val atom_str : atom -> string val rel_atom_str : rel_atom -> string val def_str : string * def_branch list -> string val literal_str : literal -> string @@ -189,8 +196,10 @@ val path_str : path -> string -(** Expand variables that have occurrences at given paths in some - state term of a clause, by subterms at those paths in the list of - ground terms. *) +(* [ground_vars_at_paths prepare_lits ps_sterms clauses] expands + variables that have occurrences at paths in [ps_sterms] in some + state term of a clause (from which pre-processed literals are + extracted by [prepare_lits]), by terms provided in [ps_sterms]. *) val ground_vars_at_paths : + (clause -> literal list) -> (path * term list) list -> clause list -> clause list Modified: trunk/Toss/GGP/GameSimpl.ml =================================================================== --- trunk/Toss/GGP/GameSimpl.ml 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/GameSimpl.ml 2011-08-12 14:07:42 UTC (rev 1536) @@ -143,6 +143,12 @@ module Tups = Structure.Tuples let simplify ?(keep_nonempty_predicates=true) (game, state) = + (* {{{ log entry *) + if !debug_level > 0 then ( + Printf.printf "GameSimpl: defined_rels = %s\n%!" + (String.concat ", " (List.map fst game.Arena.defined_rels)) + ); + (* }}} *) let struc = state.Arena.struc in let signat = Structure.rel_signature struc in let nelems = Structure.nbr_elems struc in @@ -254,7 +260,9 @@ let rel2, _ = List.find (fun (rel2, arity2) -> arity = arity2 && - not (Aux.Strings.mem rel2 fluents || + not (Aux.Strings.mem rel1 fluents || + Aux.Strings.mem rel2 fluents || + List.mem_assoc rel1 game.Arena.defined_rels || List.mem_assoc rel2 game.Arena.defined_rels) && included_in rel1 rel2 && included_in rel2 rel1 ) signat in @@ -419,8 +427,10 @@ match phi1, phi2 with | _ when phi1 = phi2 -> true | Rel (rel1, args1), Rel (rel2, args2) when args1 = args2 -> - not (Aux.Strings.mem rel1 fluents) && - not (Aux.Strings.mem rel2 fluents) && + not (Aux.Strings.mem rel1 fluents || + Aux.Strings.mem rel2 fluents || + List.mem_assoc rel1 game.Arena.defined_rels || + List.mem_assoc rel2 game.Arena.defined_rels) && included_in rel1 rel2 | _ -> false in let game = Modified: trunk/Toss/GGP/GameSimplTest.ml =================================================================== --- trunk/Toss/GGP/GameSimplTest.ml 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/GameSimplTest.ml 2011-08-12 14:07:42 UTC (rev 1536) @@ -48,7 +48,7 @@ ] -let a = +let a () = Aux.run_test_if_target "GameSimplTest" tests let a () = @@ -73,3 +73,20 @@ output_string resf res_str; close_out resf; Printf.printf "\nRESULT:\n%s\n%!" res_str + + +let a () = + GameSimpl.debug_level := 5; + let connect5 = state_of_file "./GGP/tests/connect5-raw.toss" in + let res = GameSimpl.simplify connect5 in + let goal = state_of_file "./GGP/tests/connect5-simpl.toss" in + let resf = open_out "./GGP/tests/connect5-temp.toss" in + let res_str = Arena.state_str res in + output_string resf 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" Modified: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-12 14:07:42 UTC (rev 1536) @@ -144,8 +144,13 @@ let descr = load_rules ("./GGP/examples/connect5.gdl") in let ground_at_f_paths, transl_data = connect5_data in let clauses = GDL.expand_players descr in + let prepare_lits ((h_rel, h_args), body) = + if h_rel = "next" then (GDL.Pos (GDL.True h_args.(0))::body) + else if h_rel = "frame next" + then Aux.list_remove (GDL.Pos (GDL.True h_args.(0))) body + else body in let clauses = - GDL.ground_vars_at_paths ground_at_f_paths clauses in + GDL.ground_vars_at_paths prepare_lits ground_at_f_paths clauses in let defined_rels, clauses = GDL.elim_ground_args transl_data.defined_rels clauses in (* {{{ log entry *) @@ -201,20 +206,21 @@ ~printer:(fun x->x) "conn5__o() = col__o() or diag1__o() or diag2__o() or row__o()" (result "conn5__o"); - assert_equal ~msg:"col__o defined relation translation" + + assert_equal ~msg:"col__x defined relation translation" ~printer:(fun x->x) - "col__o() = ex cell_x_a__BLANK_, cell_x_b__BLANK_, cell_x_c__BLANK_, cell_x_d__BLANK_, + "col__x() = ex cell_x_a__BLANK_, cell_x_b__BLANK_, cell_x_c__BLANK_, cell_x_d__BLANK_, cell_x_e__BLANK_ (cell__BLANK___BLANK___BLANK_(cell_x_a__BLANK_) and - cell_2o(cell_x_a__BLANK_) and + cell_2x(cell_x_a__BLANK_) and cell__BLANK___BLANK___BLANK_(cell_x_b__BLANK_) and - cell_2o(cell_x_b__BLANK_) and + cell_2x(cell_x_b__BLANK_) and cell__BLANK___BLANK___BLANK_(cell_x_c__BLANK_) and - cell_2o(cell_x_c__BLANK_) and + cell_2x(cell_x_c__BLANK_) and cell__BLANK___BLANK___BLANK_(cell_x_d__BLANK_) and - cell_2o(cell_x_d__BLANK_) and + cell_2x(cell_x_d__BLANK_) and cell__BLANK___BLANK___BLANK_(cell_x_e__BLANK_) and - cell_2o(cell_x_e__BLANK_) and nextcol__cell_1__cell_1(cell_x_a__BLANK_, + cell_2x(cell_x_e__BLANK_) and nextcol__cell_1__cell_1(cell_x_a__BLANK_, cell_x_b__BLANK_) and nextcol__cell_1__cell_1(cell_x_b__BLANK_, cell_x_c__BLANK_) and nextcol__cell_1__cell_1(cell_x_c__BLANK_, cell_x_d__BLANK_) and nextcol__cell_1__cell_1(cell_x_d__BLANK_, @@ -239,7 +245,7 @@ cell_x_b__BLANK_) and EQ___cell_0__cell_0(cell_x_e__BLANK_, cell_x_c__BLANK_) and EQ___cell_0__cell_0(cell_x_e__BLANK_, cell_x_d__BLANK_))" - (result "col__o"); + (result "col__x"); ); ] Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-12 14:07:42 UTC (rev 1536) @@ -20,9 +20,11 @@ open GDL open TranslateFormula +open Aux.BasicOperators (** Local level of logging. *) let debug_level = ref 0 +let generate_test_case = ref None (** Translate static relations that otherwise would be translated as structure relations, but have arity above the threshold, as @@ -528,14 +530,27 @@ Aux.concat_map move_clauses legal_tuples -let add_erasure_clauses (legal_tup, next_cls) = - (* let fixed_vars = terms_vars legal_tup in *) +let add_erasure_clauses f_paths (legal_tup, next_cls) = + let fixed_vars = terms_vars (Aux.array_map_of_list fst legal_tup) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "add_erasure_clauses: fixed_vars=%s\n%!" + (String.concat ", " (Aux.Strings.elements fixed_vars)) + ); + (* }}} *) let frame_cls = Aux.map_some (fun (s, frame, body) -> if frame then Some (s, body) else None) next_cls in - (* two passes to ensure coverage and maximality *) - (* FIXME-TODO: treat fixed-vars as consts, by substituting them with + (* two passes to ensure coverage and maximality *) + (* Treating fixed-vars as consts, by substituting them with Const, and later substituting-back Var *) + let fixed_to_const = List.map + (fun v -> v, Const v) (Aux.Strings.elements fixed_vars) in + let frame_cls = List.map + (subst_clause fixed_to_const) + (List.map (fun (s,body)->("frame next",[|s|]),body) frame_cls) in + let frame_cls = + List.map (fun ((_,h),body) -> h.(0),body) frame_cls in let rec coverage = function | (s, body)::more_cls , ((sb, s_acc, bodies)::other_frames as all_frames) -> @@ -556,20 +571,67 @@ if List.mem body bodies then frame else try - let sb = unify sb [s] [s_acc] in - let s_acc = subst sb s in - (sb, s_acc, body::bodies) + let sb = unify sb [s] [s_acc] in + let s_acc = subst sb s in + (sb, s_acc, body::bodies) with Not_found -> frame ) frame frame_cls in let frames = List.map maximality frames in let frames = List.map (fun (sb, s, bodies) -> s, List.map (subst_literals sb) bodies) frames in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "add_erasure_clauses: frames --\n%!"; + let print_frame (s, bodies) = + Printf.printf "FRAME: %s\n%!" (term_str s); + List.iter + (fun body-> print_endline + (String.concat " "(List.map literal_str body))) bodies in + List.iter print_frame frames; flush stdout; + ); + (* }}} *) let erasure_cls = Aux.concat_map (fun (s, bodies) -> let nbodies = negate_bodies bodies in - List.map (fun b -> s, b) nbodies + List.map + (fun (nsb, b) -> + simult_subst f_paths blank (subst nsb s), + Aux.unique_sorted b) + nbodies ) frames in + (* Remove erasure clauses that still have free variables, because + after negation they have universal interpretation. *) + let erasure_cls = List.filter + (fun (s, body) -> + let cl_vars = clause_vars (("erasure",[|s|]), body) in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "ERASURE: %s with vars %s\nbody: %s\n%!" + (term_str s) + (String.concat ", " (Aux.Strings.elements cl_vars)) + (String.concat " " (List.map literal_str body)) + ); + (* }}} *) + Aux.Strings.is_empty cl_vars) + (Aux.unique_sorted erasure_cls) in + (* Recover fixed variables. *) + let fixed_to_var = List.map + (fun v -> v, Var v) (Aux.Strings.elements fixed_vars) in + let erasure_cls = List.map + (subst_consts_clause fixed_to_var) + (List.map (fun (s,body)->("erasure next",[|s|]),body) erasure_cls) in + let erasure_cls = + List.map (fun ((_,h),body) -> h.(0),body) erasure_cls in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "add_erasure_clauses: erasure clauses --\n%!"; + let print_erasure (s, body) = + Printf.printf "ERASURE: %s <== %s\n%!" (term_str s) + (String.concat " " (List.map literal_str body)) in + List.iter print_erasure erasure_cls; flush stdout; + ); + (* }}} *) let next_cls = Aux.map_some (fun (s, frame, body) -> if not frame then Some (s, body) else None) next_cls in @@ -586,65 +648,121 @@ | (Pos (True _ as a) | Neg (True _ as a)) when !split_on_state_atoms -> Some a | _ -> None) body) next_cls in - let patterns = - let next_cls = Array.of_list next_cls in - List.map (fun a -> - Array.mapi (fun i (_, body) -> - if List.mem (Neg a) body then -1 - else if List.mem (Pos a) body then 1 - else 0 - ) next_cls, - a) atoms in - let patterns = Aux.collect patterns in - let patterns = List.filter (fun (pat, _) -> - Aux.array_existsi (fun _ v-> v < 1) pat && - Aux.array_existsi (fun _ v-> v > -1) pat) patterns in - let pos_choice = List.map (fun _ -> true) patterns in - let neg_choice = List.map (fun _ -> false) patterns in - let choices = Aux.product [pos_choice; neg_choice] in - let rule_case choice = - let separation_cond = - List.concat - (List.map2 (fun b (_, atoms) -> - if b then List.map (fun a -> Pos a) atoms - else List.map (fun a -> Neg a) atoms) choice patterns) in - let case_cls = - List.filter (fun (_, body) -> - List.for_all2 (fun b (_, atoms) -> - if b then (* atoms not excluded *) - List.for_all (fun a -> not (List.mem (Neg a) body)) atoms - else (* atoms not included *) - List.for_all (fun a -> not (List.mem (Pos a) body)) atoms + if atoms = [] then (* single partition *) + let case_rhs, case_conds = List.split next_cls in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "rule_cases: single partition\n%!"; + ); + (* }}} *) + [next_cls, case_rhs, List.concat case_conds] + else + let patterns = + let next_cls = Array.of_list next_cls in + List.map (fun a -> + Array.mapi (fun i (_, body) -> + if List.mem (Neg a) body then -1 + else if List.mem (Pos a) body then 1 + else 0 + ) next_cls, + a) atoms in + let patterns = Aux.collect patterns in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "rule_cases: patterns --\n%!"; + let print_pat (pattern, atoms) = + Printf.printf "%a: %s\n%!" + (Aux.array_fprint (fun ch -> Printf.fprintf ch "%+d")) pattern + (String.concat " " (List.map atom_str atoms)) in + List.iter print_pat patterns + ); + (* }}} *) + let patterns = List.filter (fun (pat, _) -> + Aux.array_existsi (fun _ v-> v < 1) pat && + Aux.array_existsi (fun _ v-> v > -1) pat) patterns in + let pos_choice = List.map (fun _ -> true) patterns in + let neg_choice = List.map (fun _ -> false) patterns in + let choices = Aux.product [pos_choice; neg_choice] in + let rule_case choice = + let separation_cond = + List.concat + (List.map2 (fun b (_, atoms) -> + if b then List.map (fun a -> Pos a) atoms + else List.map (fun a -> Neg a) atoms) choice patterns) in + let case_cls = + List.filter (fun (_, body) -> + List.for_all2 (fun b (_, atoms) -> + if b then (* atoms not excluded *) + List.for_all (fun a -> not (List.mem (Neg a) body)) atoms + else (* atoms not included *) + List.for_all (fun a -> not (List.mem (Pos a) body)) atoms ) choice patterns - ) next_cls in - let case_rhs, case_conds = List.split case_cls in - case_cls, case_rhs, separation_cond @ List.concat case_conds in - List.map rule_case choices + ) next_cls in + let case_rhs, case_conds = List.split case_cls in + case_cls, case_rhs, separation_cond @ List.concat case_conds in + let res = List.map rule_case choices in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "rule_cases: next clauses partitioned into rules\n%!"; + let print_case i (_, case_rhs, case_cond) = + Printf.printf "\nRCAND: #%d\nRHS: %s\nLHS: %s\n%!" i + (String.concat " " (List.map term_str case_rhs)) + (String.concat " " (List.map literal_str case_cond)) in + Array.iteri print_case (Array.of_list res) + ); + (* }}} *) + res -let process_rule_cands used_vars next_cls mode players legal_tuples = +let process_rule_cands used_vars f_paths next_cls mode players legal_tuples = let move_tups = move_tuples used_vars next_cls mode players legal_tuples in let move_tups = List.map (fun (sb, legal_tup, n_cls) -> List.map (subst_ln_cl sb) legal_tup, List.map (subst_fnextcl sb) n_cls) move_tups in - List.map add_erasure_clauses move_tups + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "process_rule_cands: move tuples before adding erasure cls--\n%!"; + let nclause_str (rhs, is_frame, body) = + Printf.printf + "%s <=fr:%b= %s\n%!"(term_str rhs) is_frame + (String.concat " "(List.map literal_str body)) in + let print_tup i (legal_tup, n_cls) = + Printf.printf "CAND: #%d\nlegal_tup: %s\n%!" i + (String.concat ", "(List.map (term_str -| fst) legal_tup)); + Printf.printf "clauses:\n%!"; + List.iter nclause_str n_cls in + Array.iteri print_tup (Array.of_list move_tups) + ); + (* }}} *) + List.map (add_erasure_clauses f_paths) move_tups let add_legal_cond (legal_tup, next_cls) = let legal_tup, legal_cond = List.split legal_tup in let legal_cond = List.concat legal_cond in List.map (fun (case_cls, case_rhs, case_cond) -> - legal_tup, case_rhs, case_cond @ legal_cond + legal_tup, Aux.unique_sorted case_rhs, + Aux.unique_sorted (case_cond @ legal_cond) ) (rule_cases next_cls) -let turnbased_rule_cases used_vars next_cls players legal_by_player = +let turnbased_rule_cases used_vars f_paths next_cls players legal_by_player = let legal_tuples = Aux.product legal_by_player in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "turnbased_rule_cases: legal_tuples --\n%!"; + let print_ltup i ltuple = + Printf.printf "LEGAL: #%d -- %s\n%!" i + (String.concat "; "(List.map (term_str -| fst) ltuple)) in + Array.iteri print_ltup (Array.of_list legal_tuples); + ); + (* }}} *) let move_tups = process_rule_cands - used_vars next_cls `General players legal_tuples in + used_vars f_paths next_cls `General players legal_tuples in let rules = Aux.concat_map add_legal_cond move_tups in (* we do not look for the players -- for turn-based case, it's done while building game graph *) @@ -652,17 +770,17 @@ (* If "Concurrent Moves" case, divide rule clauses among players. *) -let concurrent_rule_cases used_vars next_cls players legal_by_player = +let concurrent_rule_cases used_vars f_paths next_cls players legal_by_player = let env_pl_tups = env_player, - process_rule_cands used_vars next_cls `Environment [] [[]] in + process_rule_cands used_vars f_paths next_cls `Environment [] [[]] in let player_rules = List.map2 (fun player legal_cls -> (* [process_rule_cands] works with players tuples, so we "cheat" *) let legal_tuples = List.map (fun cl -> [cl]) legal_cls in let move_tups = process_rule_cands - used_vars next_cls `Concurrent [player] legal_tuples in + used_vars f_paths next_cls `Concurrent [player] legal_tuples in player, move_tups ) players legal_by_player in let player_rules = List.map @@ -671,7 +789,7 @@ (player_rules @ [env_pl_tups]) in Aux.Right player_rules -let general_int_rule_cases used_vars next_cls players legal_by_player = +let general_int_rule_cases used_vars f_paths next_cls players legal_by_player = failwith "General Interaction Games not implemented yet" @@ -685,7 +803,7 @@ are built. The rules are partitioned among players. The last player is the environment, [env_player] (this way, the numbering of players can be the same as in turn-based case). *) -let create_rule_cands is_turn_based used_vars next_cls clauses = +let create_rule_cands is_turn_based used_vars f_paths next_cls clauses = let players = (* Array.of_list *) Aux.map_some (function | ("role", [|player|]), _ -> Some player @@ -693,6 +811,12 @@ ) clauses in let legal_cls = List.filter (fun ((rel,_),_) -> rel="legal") clauses in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "create_rule_cands: legal_clauses --\n%s\n%!" + (String.concat "\n"(List.map clause_str legal_cls)) + ); + (* }}} *) let is_concurrent = not is_turn_based && List.for_all (fun (_, _, body) -> @@ -710,12 +834,28 @@ ) players in let result = if is_concurrent then - concurrent_rule_cases used_vars next_cls players legal_by_player + concurrent_rule_cases used_vars f_paths next_cls players legal_by_player else if is_turn_based then - turnbased_rule_cases used_vars next_cls players legal_by_player + turnbased_rule_cases used_vars f_paths next_cls players legal_by_player else - general_int_rule_cases used_vars next_cls players legal_by_player + general_int_rule_cases used_vars f_paths next_cls players legal_by_player in + (* {{{ log entry *) + if !debug_level > 2 then ( + let pl_rulecands = match result with + | Aux.Left rcands -> [Const "All Players", rcands] + | Aux.Right pl_rcands -> pl_rcands in + let print_rcand i (_, case_rhs, case_cond) = + Printf.printf "\nRCAND: #%d\nRHS: %s\nLHS: %s\n%!" i + (String.concat " " (List.map term_str case_rhs)) + (String.concat " " (List.map literal_str case_cond)) in + let print_rcands (player, rcands) = + Printf.printf "create_rule_cands: player %s --\n%!" + (term_str player); + Array.iteri print_rcand (Array.of_list rcands) in + List.iter print_rcands pl_rulecands + ); + (* }}} *) result, is_concurrent @@ -730,7 +870,14 @@ | _ -> true in let check_cands cands = List.filter (fun (_, _, case_conds) -> - List.for_all check_atom case_conds + let res = List.for_all check_atom case_conds in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "check_cands: cond %s -- %b\n%!" + (String.concat " "(List.map literal_str case_conds)) res + ); + (* }}} *) + res ) cands in match rule_cands with | Aux.Left cands -> Aux.Left (check_cands cands) @@ -848,8 +995,8 @@ (* doing the playouts "a couple" = 3 times *) let data1 = check_one_playout () in let data2 = check_one_playout () in - let data3 = check_one_playout () in - if data1 = data2 && data1 = data3 then data1 + (* let data3 = check_one_playout () in *) + if data1 = data2 (* && data1 = data3 *) then data1 else raise Not_turn_based @@ -1136,11 +1283,17 @@ create_init_struc clauses in let ground_at paths = List.map (fun p -> - p, Aux.map_try (fun s -> at_path s p) ground_state_terms) + p, Aux.unique_sorted + (Aux.map_try (fun s -> at_path s p) ground_state_terms)) (paths_to_list paths) in let ground_at_f_paths = ground_at f_paths in + let prepare_lits ((h_rel, h_args), body) = + if h_rel = "next" then (Pos (True h_args.(0))::body) + else if h_rel = "frame next" + then Aux.list_remove (Pos (True h_args.(0))) body + else body in let clauses = - ground_vars_at_paths ground_at_f_paths clauses in + GDL.ground_vars_at_paths prepare_lits ground_at_f_paths clauses in let defined_rels = Aux.list_diff defined_rels ["goal"; "legal"; "next"; "terminal"] in let defined_rels, clauses = elim_ground_args defined_rels clauses in @@ -1154,7 +1307,7 @@ try Some (check_turn_based players rules) with Not_turn_based -> None in let rule_cands, is_concurrent = - create_rule_cands (turn_data <> None) used_vars next_cls clauses in + create_rule_cands (turn_data <> None) used_vars f_paths next_cls clauses in let rule_cands = filter_rule_cands static_base defined_rels rule_cands in let term_arities = Aux.unique_sorted @@ -1210,12 +1363,14 @@ defined_rels = defined_rels; starting_struc = struc; } in + let result = + game, {Arena.struc = struc; history = []; time = 0.; cur_loc = 0} in let tossrule_data = Aux.strmap_of_assoc tossrule_data in let playing_as = Aux.array_argfind (fun x -> x = playing_as) players in let gdl_translation = { - (* map between structure elements and their term representations; - the reverse direction is by using element names *) + (* map between structure elements and their term representations; + the reverse direction is by using element names *) elem_term_map = elem_term_map; f_paths = f_paths; m_paths = m_paths; @@ -1227,8 +1382,33 @@ transl_data = transl_data; fluents = fluents; } in - gdl_translation, - (game, {Arena.struc = struc; history = []; time = 0.; cur_loc = 0}) + (match !generate_test_case with + | None -> () + | Some game_name -> + let file = open_out ("./GGP/tests/"^game_name^"-raw.toss") in + output_string file (Arena.state_str result); + flush file; close_out file); + let result = GameSimpl.simplify result in + (match !generate_test_case with + | None -> () + | Some game_name -> + let file = open_out ("./GGP/tests/"^game_name^"-simpl.toss") in + output_string file (Arena.state_str result); + flush file; close_out file); + (* {{{ log entry *) + if !debug_level > 1 then ( + Printf.printf "\n\ntranslate_game: simplified rel sizes --\n%s\n%!" + (String.concat ", "(List.map (fun (rel,ar) -> + rel^":"^string_of_int ar) (Structure.rel_sizes + (snd result).Arena.struc))) + ); + if !debug_level > 1 then ( + Printf.printf "\n\ntranslate_game: after simplification --\n%s\n%!" + (Arena.sprint_state_full result) + ); + (* }}} *) + gdl_translation, result + (* ************************************************************ *) Modified: trunk/Toss/GGP/TranslateGame.mli =================================================================== --- trunk/Toss/GGP/TranslateGame.mli 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/TranslateGame.mli 2011-08-12 14:07:42 UTC (rev 1536) @@ -1,5 +1,6 @@ (** Local level of logging. *) val debug_level : int ref +val generate_test_case : string option ref (** Limit on plys for both aggregate and random playouts. *) val playout_horizon : int ref Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-12 14:07:42 UTC (rev 1536) @@ -247,23 +247,37 @@ | Some tests -> ignore (run_test_tt ~verbose:true tests) | None -> () -(* let regenerate ~debug ~game_name ~player = +let regenerate ~debug ~game_name ~player = Printf.printf "Regenerating %s...\n%!" game_name; + let gamesimpl_dl = !GameSimpl.debug_level + and gdl_dl = !GDL.debug_level + and translateformula_dl = !TranslateFormula.debug_level + and translategame_dl = !TranslateGame.debug_level + and discreterule_dl = !DiscreteRule.debug_level in if debug then ( GameSimpl.debug_level := 4; + GDL.debug_level := 4; + TranslateFormula.debug_level := 4; + TranslateGame.debug_level := 4; DiscreteRule.debug_level := 4); - Translate.generate_test_case := Some game_name; + TranslateGame.generate_test_case := Some game_name; let game = load_rules ("./GGP/examples/"^game_name^".gdl") in - ignore (Translate.translate_game (Const player) game); - Translate.generate_test_case := None + ignore (TranslateGame.translate_game (Const player) game); + if debug then ( + GameSimpl.debug_level := gamesimpl_dl; + GDL.debug_level := gdl_dl; + TranslateFormula.debug_level := translateformula_dl; + TranslateGame.debug_level := translategame_dl; + DiscreteRule.debug_level := discreterule_dl); + TranslateGame.generate_test_case := None let a () = (* regenerate ~debug:false ~game_name:"tictactoe" ~player:"xplayer"; *) regenerate ~debug:false ~game_name:"connect5" ~player:"x"; - regenerate ~debug:false ~game_name:"breakthrough" ~player:"white"; + (* regenerate ~debug:true ~game_name:"breakthrough" ~player:"white"; *) (* regenerate ~debug:true ~game_name:"pawn_whopping" ~player:"x"; *) - (* regen_with_debug ~game_name:"connect4" ~player:"white" *) -*) + (* regen_with_debug ~game_name:"connect4" ~player:"white"; *) + () let exec () = Aux.run_test_if_target "TranslateGameTest" Modified: trunk/Toss/GGP/tests/connect5-raw.toss =================================================================== --- trunk/Toss/GGP/tests/connect5-raw.toss 2011-08-11 14:04:23 UTC (rev 1535) +++ trunk/Toss/GGP/tests/connect5-raw.toss 2011-08-12 14:07:42 UTC (rev 1536) @@ -1,2759 +1,8111 @@ +; not correct yet, but you can have a look at what works already +REL adjacent_cell(v0, v1, v2, v3) = + ex cell_x22__BLANK___BLANK_, cell_y22__BLANK___BLANK_, + cell_x23__BLANK___BLANK_, cell_y23__BLANK___BLANK_ + (v0 = cell_x22__BLANK___BLANK_ and v1 = cell_y22__BLANK___BLANK_ and + v2 = cell_x23__BLANK___BLANK_ and v3 = cell_y23__BLANK___BLANK_ and + adjacent__cell_0__cell_0(cell_x22__BLANK___BLANK_, + cell_x23__BLANK___BLANK_) and + adjacent__cell_0__cell_0(cell_y22__BLANK___BLANK_, + cell_y23__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x22__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y22__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x23__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y23__BLANK___BLANK_)) or + ex cell_x20__BLANK___BLANK_, cell_y21__BLANK___BLANK_, + cell_x21__BLANK___BLANK_, cell_y21__BLANK___BLANK_ + (v0 = cell_x20__BLANK___BLANK_ and v1 = cell_y21__BLANK___BLANK_ and + v2 = cell_x21__BLANK___BLANK_ and v3 = cell_y21__BLANK___BLANK_ and + adjacent__cell_0__cell_0(cell_x20__BLANK___BLANK_, + cell_x21__BLANK___BLANK_) and + coordinate__cell_0(cell_y21__BLANK___BLANK_) and + coordinate__cell_0(cell_y21__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x20__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y21__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x21__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y21__BLANK___BLANK_)) or + ex cell_x19__BLANK___BLANK_, cell_y19__BLANK___BLANK_, + cell_x19__BLANK___BLANK_, cell_y20__BLANK___BLANK_ + (v0 = cell_x19__BLANK___BLANK_ and v1 = cell_y19__BLANK___BLANK_ and + v2 = cell_x19__BLANK___BLANK_ and v3 = cell_y20__BLANK___BLANK_ and + adjacent__cell_0__cell_0(cell_y19__BLANK___BLANK_, + cell_y20__BLANK___BLANK_) and + coordinate__cell_0(cell_x19__BLANK___BLANK_) and + coordinate__cell_0(cell_x19__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x19__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y19__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x19__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y20__BLANK___BLANK_)) +REL col__b() = + ex cell_x8_a0__BLANK_, cell_x8_b0__BLANK_, cell_x8_c2__BLANK_, + cell_x8_d0__BLANK_, cell_x8_e0__BLANK_ + (true and + nextcol__cell_1__cell_1(cell_x8_a0__BLANK_, cell_x8_b0__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_b0__BLANK_, cell_x8_c2__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_c2__BLANK_, cell_x8_d0__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_d0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_d0__BLANK_) and + cell_2b(cell_x8_a0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_a0__BLANK_) and + cell_2b(cell_x8_b0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_b0__BLANK_) and + cell_2b(cell_x8_c2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_c2__BLANK_) and + cell_2b(cell_x8_d0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_d0__BLANK_) and + cell_2b(cell_x8_e0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_e0__BLANK_)) +REL col__o() = + ex cell_x8_a0__BLANK_, cell_x8_b0__BLANK_, cell_x8_c2__BLANK_, + cell_x8_d0__BLANK_, cell_x8_e0__BLANK_ + (true and + nextcol__cell_1__cell_1(cell_x8_a0__BLANK_, cell_x8_b0__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_b0__BLANK_, cell_x8_c2__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_c2__BLANK_, cell_x8_d0__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_d0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_d0__BLANK_) and + cell_2o(cell_x8_a0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_a0__BLANK_) and + cell_2o(cell_x8_b0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_b0__BLANK_) and + cell_2o(cell_x8_c2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_c2__BLANK_) and + cell_2o(cell_x8_d0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_d0__BLANK_) and + cell_2o(cell_x8_e0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_e0__BLANK_)) +REL col__x() = + ex cell_x8_a0__BLANK_, cell_x8_b0__BLANK_, cell_x8_c2__BLANK_, + cell_x8_d0__BLANK_, cell_x8_e0__BLANK_ + (true and + nextcol__cell_1__cell_1(cell_x8_a0__BLANK_, cell_x8_b0__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_b0__BLANK_, cell_x8_c2__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_c2__BLANK_, cell_x8_d0__BLANK_) and + nextcol__cell_1__cell_1(cell_x8_d0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_a0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_b0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_d0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_c2__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_d0__BLANK_, cell_x8_e0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_a0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_b0__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_c2__BLANK_) and + EQ___cell_0__cell_0(cell_x8_e0__BLANK_, cell_x8_d0__BLANK_) and + cell_2x(cell_x8_a0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_a0__BLANK_) and + cell_2x(cell_x8_b0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_b0__BLANK_) and + cell_2x(cell_x8_c2__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_c2__BLANK_) and + cell_2x(cell_x8_d0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_d0__BLANK_) and + cell_2x(cell_x8_e0__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x8_e0__BLANK_)) +REL conn5__b() = + (true and (col__b() or row__b() or diag1__b() or diag2__b()) and true) +REL conn5__o() = + (true and (col__o() or row__o() or diag1__o() or diag2__o()) and true) +REL conn5__x() = + (true and (col__x() or row__x() or diag1__x() or diag2__x()) and true) +REL diag1__b() = + ex cell_x9_y9__BLANK_, cell_x10_y10__BLANK_, cell_x11_y11__BLANK_, + cell_x12_y12__BLANK_, cell_x13_y13__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_x9_y9__BLANK_, cell_x10_y10__BLANK_) and + nextcol__cell_1__cell_1(cell_x9_y9__BLANK_, cell_x10_y10__BLANK_) and + nextcol__cell_0__cell_0(cell_x10_y10__BLANK_, cell_x11_y11__BLANK_) and + nextcol__cell_1__cell_1(cell_x10_y10__BLANK_, cell_x11_y11__BLANK_) and + nextcol__cell_0__cell_0(cell_x11_y11__BLANK_, cell_x12_y12__BLANK_) and + nextcol__cell_1__cell_1(cell_x11_y11__BLANK_, cell_x12_y12__BLANK_) and + nextcol__cell_0__cell_0(cell_x12_y12__BLANK_, cell_x13_y13__BLANK_) and + nextcol__cell_1__cell_1(cell_x12_y12__BLANK_, cell_x13_y13__BLANK_) and + cell_2b(cell_x9_y9__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x9_y9__BLANK_) and + cell_2b(cell_x10_y10__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x10_y10__BLANK_) and + cell_2b(cell_x11_y11__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x11_y11__BLANK_) and + cell_2b(cell_x12_y12__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x12_y12__BLANK_) and + cell_2b(cell_x13_y13__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x13_y13__BLANK_)) +REL diag1__o() = + ex cell_x9_y9__BLANK_, cell_x10_y10__BLANK_, cell_x11_y11__BLANK_, + cell_x12_y12__BLANK_, cell_x13_y13__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_x9_y9__BLANK_, cell_x10_y10__BLANK_) and + nextcol__cell_1__cell_1(cell_x9_y9__BLANK_, cell_x10_y10__BLANK_) and + nextcol__cell_0__cell_0(cell_x10_y10__BLANK_, cell_x11_y11__BLANK_) and + nextcol__cell_1__cell_1(cell_x10_y10__BLANK_, cell_x11_y11__BLANK_) and + nextcol__cell_0__cell_0(cell_x11_y11__BLANK_, cell_x12_y12__BLANK_) and + nextcol__cell_1__cell_1(cell_x11_y11__BLANK_, cell_x12_y12__BLANK_) and + nextcol__cell_0__cell_0(cell_x12_y12__BLANK_, cell_x13_y13__BLANK_) and + nextcol__cell_1__cell_1(cell_x12_y12__BLANK_, cell_x13_y13__BLANK_) and + cell_2o(cell_x9_y9__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x9_y9__BLANK_) and + cell_2o(cell_x10_y10__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x10_y10__BLANK_) and + cell_2o(cell_x11_y11__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x11_y11__BLANK_) and + cell_2o(cell_x12_y12__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x12_y12__BLANK_) and + cell_2o(cell_x13_y13__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x13_y13__BLANK_)) +REL diag1__x() = + ex cell_x9_y9__BLANK_, cell_x10_y10__BLANK_, cell_x11_y11__BLANK_, + cell_x12_y12__BLANK_, cell_x13_y13__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_x9_y9__BLANK_, cell_x10_y10__BLANK_) and + nextcol__cell_1__cell_1(cell_x9_y9__BLANK_, cell_x10_y10__BLANK_) and + nextcol__cell_0__cell_0(cell_x10_y10__BLANK_, cell_x11_y11__BLANK_) and + nextcol__cell_1__cell_1(cell_x10_y10__BLANK_, cell_x11_y11__BLANK_) and + nextcol__cell_0__cell_0(cell_x11_y11__BLANK_, cell_x12_y12__BLANK_) and + nextcol__cell_1__cell_1(cell_x11_y11__BLANK_, cell_x12_y12__BLANK_) and + nextcol__cell_0__cell_0(cell_x12_y12__BLANK_, cell_x13_y13__BLANK_) and + nextcol__cell_1__cell_1(cell_x12_y12__BLANK_, cell_x13_y13__BLANK_) and + cell_2x(cell_x9_y9__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x9_y9__BLANK_) and + cell_2x(cell_x10_y10__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x10_y10__BLANK_) and + cell_2x(cell_x11_y11__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x11_y11__BLANK_) and + cell_2x(cell_x12_y12__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x12_y12__BLANK_) and + cell_2x(cell_x13_y13__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x13_y13__BLANK_)) +REL diag2__b() = + ex cell_x14_y18__BLANK_, cell_x15_y17__BLANK_, cell_x16_y16__BLANK_, + cell_x17_y15__BLANK_, cell_x18_y14__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_x14_y18__BLANK_, cell_x15_y17__BLANK_) and + nextcol__cell_1__cell_1(cell_x15_y17__BLANK_, cell_x14_y18__BLANK_) and + nextcol__cell_0__cell_0(cell_x15_y17__BLANK_, cell_x16_y16__BLANK_) and + nextcol__cell_1__cell_1(cell_x16_y16__BLANK_, cell_x15_y17__BLANK_) and + nextcol__cell_0__cell_0(cell_x16_y16__BLANK_, cell_x17_y15__BLANK_) and + nextcol__cell_1__cell_1(cell_x17_y15__BLANK_, cell_x16_y16__BLANK_) and + nextcol__cell_0__cell_0(cell_x17_y15__BLANK_, cell_x18_y14__BLANK_) and + nextcol__cell_1__cell_1(cell_x18_y14__BLANK_, cell_x17_y15__BLANK_) and + cell_2b(cell_x14_y18__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x14_y18__BLANK_) and + cell_2b(cell_x15_y17__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x15_y17__BLANK_) and + cell_2b(cell_x16_y16__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x16_y16__BLANK_) and + cell_2b(cell_x17_y15__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x17_y15__BLANK_) and + cell_2b(cell_x18_y14__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x18_y14__BLANK_)) +REL diag2__o() = + ex cell_x14_y18__BLANK_, cell_x15_y17__BLANK_, cell_x16_y16__BLANK_, + cell_x17_y15__BLANK_, cell_x18_y14__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_x14_y18__BLANK_, cell_x15_y17__BLANK_) and + nextcol__cell_1__cell_1(cell_x15_y17__BLANK_, cell_x14_y18__BLANK_) and + nextcol__cell_0__cell_0(cell_x15_y17__BLANK_, cell_x16_y16__BLANK_) and + nextcol__cell_1__cell_1(cell_x16_y16__BLANK_, cell_x15_y17__BLANK_) and + nextcol__cell_0__cell_0(cell_x16_y16__BLANK_, cell_x17_y15__BLANK_) and + nextcol__cell_1__cell_1(cell_x17_y15__BLANK_, cell_x16_y16__BLANK_) and + nextcol__cell_0__cell_0(cell_x17_y15__BLANK_, cell_x18_y14__BLANK_) and + nextcol__cell_1__cell_1(cell_x18_y14__BLANK_, cell_x17_y15__BLANK_) and + cell_2o(cell_x14_y18__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x14_y18__BLANK_) and + cell_2o(cell_x15_y17__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x15_y17__BLANK_) and + cell_2o(cell_x16_y16__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x16_y16__BLANK_) and + cell_2o(cell_x17_y15__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x17_y15__BLANK_) and + cell_2o(cell_x18_y14__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x18_y14__BLANK_)) +REL diag2__x() = + ex cell_x14_y18__BLANK_, cell_x15_y17__BLANK_, cell_x16_y16__BLANK_, + cell_x17_y15__BLANK_, cell_x18_y14__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_x14_y18__BLANK_, cell_x15_y17__BLANK_) and + nextcol__cell_1__cell_1(cell_x15_y17__BLANK_, cell_x14_y18__BLANK_) and + nextcol__cell_0__cell_0(cell_x15_y17__BLANK_, cell_x16_y16__BLANK_) and + nextcol__cell_1__cell_1(cell_x16_y16__BLANK_, cell_x15_y17__BLANK_) and + nextcol__cell_0__cell_0(cell_x16_y16__BLANK_, cell_x17_y15__BLANK_) and + nextcol__cell_1__cell_1(cell_x17_y15__BLANK_, cell_x16_y16__BLANK_) and + nextcol__cell_0__cell_0(cell_x17_y15__BLANK_, cell_x18_y14__BLANK_) and + nextcol__cell_1__cell_1(cell_x18_y14__BLANK_, cell_x17_y15__BLANK_) and + cell_2x(cell_x14_y18__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x14_y18__BLANK_) and + cell_2x(cell_x15_y17__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x15_y17__BLANK_) and + cell_2x(cell_x16_y16__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x16_y16__BLANK_) and + cell_2x(cell_x17_y15__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x17_y15__BLANK_) and + cell_2x(cell_x18_y14__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x18_y14__BLANK_)) +REL exists_empty_cell() = + ex cell_x7_y7__BLANK_ + (true and true and + cell_2b(cell_x7_y7__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x7_y7__BLANK_)) +REL exists_line_of_five() = + (true and conn5__o() and true) or (true and conn5__x() and true) +REL row__b() = + ex cell_a_y8__BLANK_, cell_b_y8__BLANK_, cell_c1_y8__BLANK_, + cell_d_y8__BLANK_, cell_e_y8__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_a_y8__BLANK_, cell_b_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_b_y8__BLANK_, cell_c1_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_c1_y8__BLANK_, cell_d_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_d_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_d_y8__BLANK_) and + cell_2b(cell_a_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_a_y8__BLANK_) and + cell_2b(cell_b_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_b_y8__BLANK_) and + cell_2b(cell_c1_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c1_y8__BLANK_) and + cell_2b(cell_d_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_d_y8__BLANK_) and + cell_2b(cell_e_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_e_y8__BLANK_)) +REL row__o() = + ex cell_a_y8__BLANK_, cell_b_y8__BLANK_, cell_c1_y8__BLANK_, + cell_d_y8__BLANK_, cell_e_y8__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_a_y8__BLANK_, cell_b_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_b_y8__BLANK_, cell_c1_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_c1_y8__BLANK_, cell_d_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_d_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_d_y8__BLANK_) and + cell_2o(cell_a_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_a_y8__BLANK_) and + cell_2o(cell_b_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_b_y8__BLANK_) and + cell_2o(cell_c1_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c1_y8__BLANK_) and + cell_2o(cell_d_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_d_y8__BLANK_) and + cell_2o(cell_e_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_e_y8__BLANK_)) +REL row__x() = + ex cell_a_y8__BLANK_, cell_b_y8__BLANK_, cell_c1_y8__BLANK_, + cell_d_y8__BLANK_, cell_e_y8__BLANK_ + (true and + nextcol__cell_0__cell_0(cell_a_y8__BLANK_, cell_b_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_b_y8__BLANK_, cell_c1_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_c1_y8__BLANK_, cell_d_y8__BLANK_) and + nextcol__cell_0__cell_0(cell_d_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_a_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_b_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_d_y8__BLANK_) and + EQ___cell_1__cell_1(cell_c1_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_d_y8__BLANK_, cell_e_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_a_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_b_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_c1_y8__BLANK_) and + EQ___cell_1__cell_1(cell_e_y8__BLANK_, cell_d_y8__BLANK_) and + cell_2x(cell_a_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_a_y8__BLANK_) and + cell_2x(cell_b_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_b_y8__BLANK_) and + cell_2x(cell_c1_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_c1_y8__BLANK_) and + cell_2x(cell_d_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_d_y8__BLANK_) and + cell_2x(cell_e_y8__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_e_y8__BLANK_)) PLAYERS x, o -RULE mark_x161_y162_0: - [cell_x161_y162__blank_, control__blank_ | - _opt_cell_x_y_b (control__blank_); - _opt_cell_x_y_o {cell_x161_y162__blank_; control__blank_}; - _opt_cell_x_y_x {cell_x161_y162__blank_; control__blank_}; - _opt_control_o (cell_x161_y162__blank_); - _opt_control_x (cell_x161_y162__blank_); - cell_x_y_b (cell_x161_y162__blank_); control_MV1 (control__blank_); - control_x (control__blank_) +RULE mark_x5_y5_noop: + [cell_x5_y5__BLANK_, cell_x5_y5__BLANK_, control__BLANK_ | + _opt_cell_2b {cell_x5_y5__BLANK_; control__BLANK_}; + _opt_cell_2o {cell_x5_y5__BLANK_; control__BLANK_}; + _opt_cell_2x {cell_x5_y5__BLANK_; control__BLANK_}; + _opt_control_0o {cell_x5_y5__BLANK_; control__BLANK_}; + _opt_control_0x {cell_x5_y5__BLANK_; control__BLANK_} | ] -> - [cell_x161_y162__blank_, control__blank_ | - cell_x_y_x (cell_x161_y162__blank_); control_o (control__blank_) | - ] - emb cell_x_y_b, cell_x_y_o, cell_x_y_x, control_o, control_x + [cell_x5_y5__BLANK_, cell_x5_y5__BLANK_, control__BLANK_ | + cell_2x (cell_x5_y5__BLANK_); control_0o (control__BLANK_) | + ] emb cell_2b, cell_2o, cell_2x, control_0o, control_0x pre + (not ex control__BLANK_ control_0o(control__BLANK_) and + ex cell_x5_y5__BLANK_, control__BLANK_ + (cell_2b(cell_x5_y5__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x5_y5__BLANK_) and + control_0x(control__BLANK_) and control__BLANK_(control__BLANK_))) +RULE noop_noop: + [control__BLANK_, control__BLANK_ | + _opt_cell_2b (control__BLANK_); _opt_cell_2o (control__BLANK_); + _opt_cell_2x (control__BLANK_); _opt_control_0o (control__BLANK_); + _opt_control_0x (control__BLANK_) + | + ] -> + [control__BLANK_, control__BLANK_ | + control_0o (control__BLANK_); ... [truncated message content] |
From: <luk...@us...> - 2011-08-11 14:04:30
|
Revision: 1535 http://toss.svn.sourceforge.net/toss/?rev=1535&view=rev Author: lukstafi Date: 2011-08-11 14:04:23 +0000 (Thu, 11 Aug 2011) Log Message: ----------- GDL translation fixing: simple bugs, TranslateFormula tests pass. Modified Paths: -------------- trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/TranslateFormula.ml trunk/Toss/GGP/TranslateFormulaTest.ml Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-11 00:29:00 UTC (rev 1534) +++ trunk/Toss/GGP/GDL.mli 2011-08-11 14:04:23 UTC (rev 1535) @@ -109,6 +109,7 @@ val rel_atom_str : rel_atom -> string val def_str : string * def_branch list -> string +val literal_str : literal -> string val clause_str : clause -> string (** {3 GDL whole-game operations.} Modified: trunk/Toss/GGP/TranslateFormula.ml =================================================================== --- trunk/Toss/GGP/TranslateFormula.ml 2011-08-11 00:29:00 UTC (rev 1534) +++ trunk/Toss/GGP/TranslateFormula.ml 2011-08-11 14:04:23 UTC (rev 1535) @@ -115,26 +115,39 @@ sterms_all in let s_subterms = List.filter (fun (subt, _) -> subt <> blank) s_subterms in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "transl_rels: rels_phi=%s; s_subterms=\n%s\n%!" + (String.concat " " (List.map literal_str rels_phi)) + (String.concat ", " (List.map (fun (subt,(sterm,path)) -> + Printf.sprintf "{sterm=%s; subt=%s; path=%s}" + (term_str sterm) (term_str subt) (path_str path)) s_subterms)) + ); + (* }}} *) let s_subterms = Aux.collect s_subterms in let transl_rel sign rel args = - try - let (stuples : (GDL.term * GDL.path) list list) = - List.map (fun arg -> List.assoc arg s_subterms) - (Array.to_list args) in - let (stuples : (GDL.term * GDL.path) list list) = Aux.product stuples in - let stuples = List.filter - (fun stup -> - List.exists (fun (sterm,_) -> List.mem sterm sterms_in) stup) - stuples in - let atoms = List.map - (fun stup -> - let vartup = List.map (fun (sterm,_) -> - var_of_term data sterm) stup in - let fact_rel = rel_on_paths rel (List.map snd stup) in - Formula.Rel (fact_rel, Array.of_list vartup)) stuples in - if sign then atoms - else List.map (fun a -> Formula.Not a) atoms - with Not_found -> [] in + (let try stuples = + List.map (fun arg -> List.assoc arg s_subterms) + (Array.to_list args) in + let stuples = Aux.product stuples in + let stuples = List.filter + (fun stup -> + List.exists (fun (sterm,_) -> List.mem sterm sterms_in) stup) + stuples in + let atoms = Aux.map_some + (fun stup -> + let vartup = Aux.array_map_of_list + (fun (sterm,_) -> var_of_term data sterm) stup in + (* a bit of simplification for easier debugging *) + if rel = "EQ_" && vartup.(0) = vartup.(1) + then None + else + let fact_rel = rel_on_paths rel (List.map snd stup) in + Some (Formula.Rel (fact_rel, vartup))) + stuples in + if sign then atoms + else List.map (fun a -> Formula.Not a) atoms + with Not_found -> []) in let transl_posdefrel sign rel args = if List.mem rel data.defined_rels then @@ -162,7 +175,9 @@ let s_subterms = map_paths (fun path subt -> subt, path) data.all_paths sterm in let s_subterms = List.filter - (fun (subt, _) -> subt <> blank) s_subterms in + (fun (subt, _) -> + subt <> blank && Aux.Strings.is_empty (term_vars subt)) + s_subterms in let vartup = [|var_of_term data sterm|] in let anchor_and_fluent_preds = List.map (fun (subt, path) -> @@ -204,28 +219,35 @@ (Aux.Strings.elements phi_vars) in let rels_eqs = rels_phi @ eqs in (* {{{ log entry *) -if !debug_level > 2 then ( + if !debug_level > 2 then ( Printf.printf "\ntransl_disjunct:\n%s\n%s\n%s\n%s\n%!" (clause_str (("rels_phi", [||]),rels_phi)) (clause_str (("pos_state_phi", [||]),pos_state_phi)) (clause_str (("neg_state_phi", [||]),neg_state_phi)) ("ext_phi="^Formula.str ext_phi) -); -(* }}} *) + ); + (* }}} *) let negated_neg_state_transl = (* negation-normal-form of "not neg_state_phi" *) Formula.Or ( List.map (transl_state data) (nnf_dnf neg_state_phi)) in - Formula.Ex ((pos_vars :> Formula.var list), - Formula.And [ - ext_phi; - transl_rels data rels_eqs pos_terms pos_terms; - transl_state data pos_state_phi; - Formula.Not ( - Formula.Ex ((neg_vars :> Formula.var list), - Formula.And [ - transl_rels data rels_eqs all_terms pos_terms; - negated_neg_state_transl]))]) + let universal_part = + if neg_terms = [] then [] + else [Formula.Not ( + Formula.Ex ((neg_vars :> Formula.var list), + Formula.And [ + (* positive because they form a "premise" *) + transl_rels data rels_eqs all_terms neg_terms; + (* the universal "conclusion" *) + negated_neg_state_transl]))] in + let base_part = + Formula.And ( + [ ext_phi; + transl_rels data rels_eqs pos_terms pos_terms; + transl_state data pos_state_phi] @ + universal_part) in + if pos_vars = [] then base_part + else Formula.Ex ((pos_vars :> Formula.var list), base_part) @@ -247,7 +269,7 @@ let branches = Aux.assoc_all rel all_branches in (* {{{ log entry *) if !debug_level > 2 then ( - Printf.printf "build_defrel: rel=%s, no of brs=%d\n%!" + Printf.printf "select_defrel_argpaths: rel=%s, no of brs=%d\n%!" rel (List.length branches) ); (* }}} *) @@ -348,7 +370,7 @@ let defvars = Array.mapi (fun i _ -> "v"^string_of_int i) arg_paths in let defbody (args,(rels_phi,pos_state,neg_state)) s_defside = - let arg_eqs = Array.mapi + let arg_eqs = Array.mapi (* $E_{j,l}$ *) (fun i v -> let v = Formula.fo_var_of_string v in let in_I = p_defside.(i) <> None in @@ -361,12 +383,12 @@ else Formula.Eq (v, var_of_subterm data arg_paths.(i) args.(i))) defvars in let arg_eqs = Formula.And (Array.to_list arg_eqs) in - let callside_sterms = + let callside_sterms = (* $S_{j,l}$ *) Aux.array_mapi_some - (fun i -> function None -> None - | Some path -> - Some (blank_outside_subterm data path args.(i))) - p_defside in + (fun i path -> + if p_defside.(i) <> None then None (* only for not in I *) + else Some (blank_outside_subterm data path args.(i))) + arg_paths in (* packing sterms back as a formula *) let callside_sterms = Array.to_list (Array.map (fun sterm -> Pos (True sterm)) callside_sterms) in @@ -416,8 +438,11 @@ else None in let eqs_phi = Array.to_list (Aux.array_mapi_some in_J_eq_transl arg_type) in - Formula.Ex ((ex_vars :> Formula.var list), - Formula.And (defrel_phi::eqs_phi)) + let base = + if eqs_phi = [] then defrel_phi + else Formula.And (defrel_phi::eqs_phi) in + if ex_vars = [] then base + else Formula.Ex ((ex_vars :> Formula.var list), base) let _ = translate_defrel := transl_defrel Modified: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-11 00:29:00 UTC (rev 1534) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-11 14:04:23 UTC (rev 1535) @@ -157,13 +157,89 @@ let transl_data = {transl_data with defined_rels = defined_rels} in let defined_rels = TranslateFormula.build_defrels transl_data clauses in - let res = String.concat "\n" - (List.map (fun (rel,(args,body)) -> - rel^"("^String.concat ", " args^ - ") = "^Formula.str body) defined_rels) in - assert_equal ~msg:"connect5 noop moves by players" + let result drel = + let args, body = List.assoc drel defined_rels in + drel^"("^String.concat ", " args^ + ") = "^Formula.str (FormulaOps.simplify body) in + + assert_equal ~msg:"adjacent_cell defined relation translation" ~printer:(fun x->x) - "" res + "adjacent_cell(v0, v1, v2, v3) = ex cell_x__BLANK___BLANK_, cell_y__BLANK___BLANK_, cell_x1__BLANK___BLANK_, + cell_y1__BLANK___BLANK_ + (cell__BLANK___BLANK___BLANK_(cell_x__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x1__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y1__BLANK___BLANK_) and + adjacent__cell_0__cell_0(cell_x__BLANK___BLANK_, + cell_x1__BLANK___BLANK_) and + adjacent__cell_0__cell_0(cell_y__BLANK___BLANK_, + cell_y1__BLANK___BLANK_) and v0 = cell_x__BLANK___BLANK_ and + v1 = cell_y__BLANK___BLANK_ and v2 = cell_x1__BLANK___BLANK_ and + v3 = cell_y1__BLANK___BLANK_) or + ex cell_x__BLANK___BLANK_, cell_y__BLANK___BLANK_, cell_x1__BLANK___BLANK_, + cell_y__BLANK___BLANK_ + (cell__BLANK___BLANK___BLANK_(cell_x__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x1__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y__BLANK___BLANK_) and + adjacent__cell_0__cell_0(cell_x__BLANK___BLANK_, + cell_x1__BLANK___BLANK_) and + coordinate__cell_0(cell_y__BLANK___BLANK_) and + v0 = cell_x__BLANK___BLANK_ and v1 = cell_y__BLANK___BLANK_ and + v2 = cell_x1__BLANK___BLANK_ and v3 = cell_y__BLANK___BLANK_) or + ex cell_x__BLANK___BLANK_, cell_y__BLANK___BLANK_, cell_x__BLANK___BLANK_, + cell_y1__BLANK___BLANK_ + (cell__BLANK___BLANK___BLANK_(cell_y__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x__BLANK___BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_y1__BLANK___BLANK_) and + adjacent__cell_0__cell_0(cell_y__BLANK___BLANK_, + cell_y1__BLANK___BLANK_) and + coordinate__cell_0(cell_x__BLANK___BLANK_) and + v0 = cell_x__BLANK___BLANK_ and v1 = cell_y__BLANK___BLANK_ and + v2 = cell_x__BLANK___BLANK_ and v3 = cell_y1__BLANK___BLANK_)" + (result "adjacent_cell"); + assert_equal ~msg:"conn5__o defined relation translation" + ~printer:(fun x->x) + "conn5__o() = col__o() or diag1__o() or diag2__o() or row__o()" + (result "conn5__o"); + assert_equal ~msg:"col__o defined relation translation" + ~printer:(fun x->x) + "col__o() = ex cell_x_a__BLANK_, cell_x_b__BLANK_, cell_x_c__BLANK_, cell_x_d__BLANK_, + cell_x_e__BLANK_ + (cell__BLANK___BLANK___BLANK_(cell_x_a__BLANK_) and + cell_2o(cell_x_a__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x_b__BLANK_) and + cell_2o(cell_x_b__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x_c__BLANK_) and + cell_2o(cell_x_c__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x_d__BLANK_) and + cell_2o(cell_x_d__BLANK_) and + cell__BLANK___BLANK___BLANK_(cell_x_e__BLANK_) and + cell_2o(cell_x_e__BLANK_) and nextcol__cell_1__cell_1(cell_x_a__BLANK_, + cell_x_b__BLANK_) and nextcol__cell_1__cell_1(cell_x_b__BLANK_, + cell_x_c__BLANK_) and nextcol__cell_1__cell_1(cell_x_c__BLANK_, + cell_x_d__BLANK_) and nextcol__cell_1__cell_1(cell_x_d__BLANK_, + cell_x_e__BLANK_) and EQ___cell_0__cell_0(cell_x_a__BLANK_, + cell_x_b__BLANK_) and EQ___cell_0__cell_0(cell_x_a__BLANK_, + cell_x_c__BLANK_) and EQ___cell_0__cell_0(cell_x_a__BLANK_, + cell_x_d__BLANK_) and EQ___cell_0__cell_0(cell_x_a__BLANK_, + cell_x_e__BLANK_) and EQ___cell_0__cell_0(cell_x_b__BLANK_, + cell_x_a__BLANK_) and EQ___cell_0__cell_0(cell_x_b__BLANK_, + cell_x_c__BLANK_) and EQ___cell_0__cell_0(cell_x_b__BLANK_, + cell_x_d__BLANK_) and EQ___cell_0__cell_0(cell_x_b__BLANK_, + cell_x_e__BLANK_) and EQ___cell_0__cell_0(cell_x_c__BLANK_, + cell_x_a__BLANK_) and EQ___cell_0__cell_0(cell_x_c__BLANK_, + cell_x_b__BLANK_) and EQ___cell_0__cell_0(cell_x_c__BLANK_, + cell_x_d__BLANK_) and EQ___cell_0__cell_0(cell_x_c__BLANK_, + cell_x_e__BLANK_) and EQ___cell_0__cell_0(cell_x_d__BLANK_, + cell_x_a__BLANK_) and EQ___cell_0__cell_0(cell_x_d__BLANK_, + cell_x_b__BLANK_) and EQ___cell_0__cell_0(cell_x_d__BLANK_, + cell_x_c__BLANK_) and EQ___cell_0__cell_0(cell_x_d__BLANK_, + cell_x_e__BLANK_) and EQ___cell_0__cell_0(cell_x_e__BLANK_, + cell_x_a__BLANK_) and EQ___cell_0__cell_0(cell_x_e__BLANK_, + cell_x_b__BLANK_) and EQ___cell_0__cell_0(cell_x_e__BLANK_, + cell_x_c__BLANK_) and EQ___cell_0__cell_0(cell_x_e__BLANK_, + cell_x_d__BLANK_))" + (result "col__o"); ); ] @@ -174,28 +250,6 @@ () let a () = - let descr = load_rules ("./GGP/examples/connect5.gdl") in - let ground_at_f_paths, transl_data = connect5_data in - let clauses = GDL.expand_players descr in - let clauses = - GDL.ground_vars_at_paths ground_at_f_paths clauses in - let defined_rels, clauses = - GDL.elim_ground_args transl_data.defined_rels clauses in - (* {{{ log entry *) - if !TranslateFormula.debug_level > 2 then ( - Printf.printf "defined relations connect5: clauses =\n%s\n%!" - (String.concat "\n" (List.map GDL.clause_str clauses)) - ); - (* }}} *) - let transl_data = {transl_data with defined_rels = defined_rels} in - let defined_rels = - TranslateFormula.build_defrels transl_data clauses in - let res = String.concat "\n" - (List.map (fun (rel,(args,body)) -> - rel^"("^String.concat ", " args^ - ") = "^Formula.str body) defined_rels) in - assert_equal ~msg:"connect5 noop moves by players" - ~printer:(fun x->x) - "" res + () let exec = Aux.run_test_if_target "TranslateFormulaTest" tests This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-11 00:29:08
|
Revision: 1534 http://toss.svn.sourceforge.net/toss/?rev=1534&view=rev Author: lukstafi Date: 2011-08-11 00:29:00 +0000 (Thu, 11 Aug 2011) Log Message: ----------- GDL translation fixing: two small bugs in preparing for formula translation (which somehow is very wrong but can be debugged now). Modified Paths: -------------- trunk/Toss/GGP/GDLParser.mly trunk/Toss/GGP/TranslateFormula.ml trunk/Toss/GGP/TranslateFormula.mli trunk/Toss/GGP/TranslateFormulaTest.ml Modified: trunk/Toss/GGP/GDLParser.mly =================================================================== --- trunk/Toss/GGP/GDLParser.mly 2011-08-10 12:15:33 UTC (rev 1533) +++ trunk/Toss/GGP/GDLParser.mly 2011-08-11 00:29:00 UTC (rev 1534) @@ -14,9 +14,10 @@ %token FORALL EXISTS EOF -%start parse_game_description parse_request parse_term +%start parse_game_description parse_request parse_term parse_literal_list %type <GDL.request> parse_request request %type <GDL.term> parse_term +%type <GDL.literal list> parse_literal_list %type <GDL.clause list> parse_game_description game_description @@ -146,3 +147,6 @@ parse_term: | term EOF { $1 } + +parse_literal_list: + | body=list (literal) EOF { body } Modified: trunk/Toss/GGP/TranslateFormula.ml =================================================================== --- trunk/Toss/GGP/TranslateFormula.ml 2011-08-10 12:15:33 UTC (rev 1533) +++ trunk/Toss/GGP/TranslateFormula.ml 2011-08-11 00:29:00 UTC (rev 1534) @@ -17,21 +17,26 @@ splitting disjuncts if necessary, into "positive state terms", "negative state terms" and "reminder". *) let separate_disj disj = + (* FIXME see tests *) let aux conj = List.fold_right (fun lit acc -> match lit with | (Pos (True _) | Neg (True _)) as lit -> List.map (fun conj -> Aux.Left lit::conj) acc | Disj ls as lit -> - if List.for_all (function Pos _ -> true | _ -> false) ls - || List.for_all (function Neg _ -> true | _ -> false) ls + if List.for_all (function Pos (True _) -> true | _ -> false) ls + || List.for_all (function Neg (True _) -> true | _ -> false) ls then List.map (fun conj -> Aux.Left lit::conj) acc - else + else if List.exists + (function Pos (True _) | Neg (True _) -> true | _ -> false) ls + then Aux.concat_map (function | (Pos (True _) | Neg (True _)) as lit -> List.map (fun conj -> Aux.Left lit::conj) acc | lit -> List.map (fun conj -> Aux.Right lit::conj) acc ) ls + else (* none is [True _] *) + List.map (fun conj -> Aux.Right lit::conj) acc | lit -> List.map (fun conj -> Aux.Right lit::conj) acc ) conj [[]] in let disj = Aux.concat_map aux disj in @@ -42,10 +47,10 @@ | Pos _ as lit -> Aux.Left lit | Neg _ as lit -> Aux.Right lit | Disj ls as lit - when List.for_all (function Pos _ -> true | _ -> false) ls + when List.for_all (function Pos (True _) -> true | _ -> false) ls -> Aux.Left lit | Disj ls as lit - when List.for_all (function Neg _ -> true | _ -> false) ls + when List.for_all (function Neg (True _) -> true | _ -> false) ls -> Aux.Right lit | _ -> assert false ) state_terms in @@ -130,15 +135,15 @@ if sign then atoms else List.map (fun a -> Formula.Not a) atoms with Not_found -> [] in - let transl_defrel sign rel args = + let transl_posdefrel sign rel args = if List.mem rel data.defined_rels then [!translate_defrel data sterms_all sterms_in s_subterms sign rel args] - else transl_rel false rel args in + else transl_rel sign rel args in let rec aux = function - | Pos (Rel (rel, args)) -> transl_defrel true rel args - | Neg (Rel (rel, args)) -> transl_defrel false rel args + | Pos (Rel (rel, args)) -> transl_posdefrel true rel args + | Neg (Rel (rel, args)) -> transl_posdefrel false rel args | Pos (Does _ | Role _) | Neg (Does _ | Role _) -> [] | Disj lits -> @@ -147,6 +152,12 @@ Formula.And (Aux.concat_map aux rels_phi) let transl_state data phi = + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf "transl_state:\n%s\n%!" + (clause_str (("transl_state phi", [||]),phi)) + ); + (* }}} *) let transl_sterm sterm = let s_subterms = map_paths (fun path subt -> subt, path) data.all_paths sterm in @@ -182,7 +193,7 @@ let transl_disjunct data rels_phi pos_state_phi neg_state_phi ext_phi = let pos_terms = state_terms pos_state_phi in let pos_vars = List.map (var_of_term data) pos_terms in - let neg_terms = state_terms pos_state_phi in + let neg_terms = state_terms neg_state_phi in let neg_vars = List.map (var_of_term data) neg_terms in let all_terms = pos_terms @ neg_terms in let phi_vars = clause_vars @@ -192,6 +203,15 @@ List.map (fun v -> Pos (Rel ("EQ_", [|Var v; Var v|]))) (Aux.Strings.elements phi_vars) in let rels_eqs = rels_phi @ eqs in + (* {{{ log entry *) +if !debug_level > 2 then ( + Printf.printf "\ntransl_disjunct:\n%s\n%s\n%s\n%s\n%!" + (clause_str (("rels_phi", [||]),rels_phi)) + (clause_str (("pos_state_phi", [||]),pos_state_phi)) + (clause_str (("neg_state_phi", [||]),neg_state_phi)) + ("ext_phi="^Formula.str ext_phi) +); +(* }}} *) let negated_neg_state_transl = (* negation-normal-form of "not neg_state_phi" *) Formula.Or ( @@ -220,12 +240,9 @@ (* **************************************** *) (* {3 Build and use defined relations.} *) -let build_defrels data clauses = - let all_branches = Aux.concat_map - (fun ((rel,args),body) -> - List.map (fun phi -> rel, (args, phi)) (separate_disj [body])) - clauses in - let build_defrel rel = +let select_defrel_argpaths data all_branches = + (* TODO: code-review this and [build_defrel] functions *) + let select_for_defrel rel = (* searching for ArgType = DefSide,S,p *) let branches = Aux.assoc_all rel all_branches in (* {{{ log entry *) @@ -309,7 +326,25 @@ "TranslateFormula.build_defrels: could not \ determine path for relation %s argument %d" rel i) ) p_defside in + let defrel_arg_type = Aux.array_map2 + (fun defside path -> defside <> None, path) + p_defside arg_paths in + data.defrel_arg_type := + (rel, defrel_arg_type) :: !(data.defrel_arg_type); + rel, (p_defside, s_defside, arg_paths) in + List.map select_for_defrel data.defined_rels + + +let build_defrels data clauses = + let all_branches = Aux.concat_map + (fun ((rel,args),body) -> + List.map (fun phi -> rel, (args, phi)) (separate_disj [body])) + clauses in + let sel_argpaths = select_defrel_argpaths data all_branches in + let build_defrel rel = (* now building the translation *) + let (p_defside, s_defside, arg_paths) = + List.assoc rel sel_argpaths in let defvars = Array.mapi (fun i _ -> "v"^string_of_int i) arg_paths in let defbody (args,(rels_phi,pos_state,neg_state)) s_defside = @@ -323,8 +358,7 @@ | Some s -> var_of_term data s | None -> assert false in Formula.Eq (v, s_i) - else Formula.Eq (v, - var_of_subterm data arg_paths.(i) args.(i))) + else Formula.Eq (v, var_of_subterm data arg_paths.(i) args.(i))) defvars in let arg_eqs = Formula.And (Array.to_list arg_eqs) in let callside_sterms = @@ -338,17 +372,19 @@ (Array.map (fun sterm -> Pos (True sterm)) callside_sterms) in transl_disjunct data rels_phi (callside_sterms @ pos_state) neg_state arg_eqs in + let branches = Aux.assoc_all rel all_branches in let def_disjuncts = List.map2 defbody branches s_defside in - let defrel_arg_type = Aux.array_map2 - (fun defside path -> defside <> None, path) - p_defside arg_paths in - data.defrel_arg_type := - (rel, defrel_arg_type) :: !(data.defrel_arg_type); rel, (Array.to_list defvars, Formula.Or def_disjuncts) in List.map build_defrel data.defined_rels let transl_defrel data sterms_all sterms_in s_subterms sign rel args = + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "transl_defrel: phi=%s, sign=%b\n" + (rel_atom_str (rel, args)) sign + ); + (* }}} *) let arg_type = List.assoc rel !(data.defrel_arg_type) in (* the $s \tpos_{p_{R,i}} = t_i$ state terms *) let arg_sterms = Array.mapi Modified: trunk/Toss/GGP/TranslateFormula.mli =================================================================== --- trunk/Toss/GGP/TranslateFormula.mli 2011-08-10 12:15:33 UTC (rev 1533) +++ trunk/Toss/GGP/TranslateFormula.mli 2011-08-11 00:29:00 UTC (rev 1534) @@ -21,6 +21,11 @@ val empty_transl_data : transl_data +(** Exposed for testing purposes only. *) +val separate_disj : + GDL.literal list list -> + (GDL.literal list * GDL.literal list * GDL.literal list) list + val translate : transl_data -> GDL.literal list list -> Formula.formula Modified: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-10 12:15:33 UTC (rev 1533) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-11 00:29:00 UTC (rev 1534) @@ -9,6 +9,10 @@ GDLParser.parse_term KIFLexer.lex (Lexing.from_string s) +let parse_literal_list s = + GDLParser.parse_literal_list KIFLexer.lex + (Lexing.from_string s) + let pte = parse_term let state_of_file s = @@ -69,6 +73,72 @@ let tests = "TranslateFormula" >::: [ + "separate_disj" >:: + (fun () -> + let i2s = string_of_int in + let str_res disj = Array.mapi + (fun i (rels, pos_s, neg_s) -> + GDL.clause_str (("rels#"^i2s i, [||]),rels) ^"\n" ^ + GDL.clause_str (("pos_s#"^i2s i, [||]),pos_s) ^"\n" ^ + GDL.clause_str (("neg_s#"^i2s i, [||]),neg_s) ^"\n") + (Array.of_list disj) in + + let phi = "(or (col ?r) (row ?r) (diag1 ?r) (diag2 ?r))" in + let conj = parse_literal_list phi in + let disj = separate_disj [conj] in + assert_equal ~msg:phi ~printer:(fun x->x) + "(<= (rels#0 ) + (or (col ?r) (row ?r) (diag1 ?r) (diag2 ?r))) +(<= (pos_s#0 ) + ) +(<= (neg_s#0 ) + ) +" + (String.concat "\n" (Array.to_list (str_res disj))); + + let phi = "(or (arel x) (true s1)) (brel y)" in + let conj = parse_literal_list phi in + let disj = separate_disj [conj] in + assert_equal ~msg:phi ~printer:(fun x->x) + "(<= (rels#0 ) + (arel x) + (brel y)) +(<= (pos_s#0 ) + ) +(<= (neg_s#0 ) + ) + +(<= (rels#1 ) + (brel y)) +(<= (pos_s#1 ) + (true s1)) +(<= (neg_s#1 ) + ) +" + (String.concat "\n" (Array.to_list (str_res disj))); + + let phi = "(or (arel x) (true s1)) (not (true s2))" in + let conj = parse_literal_list phi in + let disj = separate_disj [conj] in + assert_equal ~msg:phi ~printer:(fun x->x) + "(<= (rels#0 ) + (arel x)) +(<= (pos_s#0 ) + ) +(<= (neg_s#0 ) + (not (true s2))) + +(<= (rels#1 ) + ) +(<= (pos_s#1 ) + (true s1)) +(<= (neg_s#1 ) + (not (true s2))) +" + (String.concat "\n" (Array.to_list (str_res disj))); + + ); + "defined relations connect5" >:: (fun () -> let descr = load_rules ("./GGP/examples/connect5.gdl") in @@ -100,7 +170,7 @@ let a () = TranslateFormula.debug_level := 5; - GDL.debug_level := 2; + (* GDL.debug_level := 2; *) () let a () = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-10 12:15:40
|
Revision: 1533 http://toss.svn.sourceforge.net/toss/?rev=1533&view=rev Author: lukstafi Date: 2011-08-10 12:15:33 +0000 (Wed, 10 Aug 2011) Log Message: ----------- GDL translation fixing: eliminating ground arguments of relations integrated. Modified Paths: -------------- trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/GDLTest.ml trunk/Toss/GGP/TranslateFormula.ml trunk/Toss/GGP/TranslateFormula.mli trunk/Toss/GGP/TranslateFormulaTest.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGame.mli trunk/Toss/GGP/TranslateGameTest.ml Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/GDL.ml 2011-08-10 12:15:33 UTC (rev 1533) @@ -555,7 +555,7 @@ let sb = unify sb [ground] [inst_arg] in let r_gr = rel ^ "__" ^ term_to_name ground in let r_br = head, add_lit (Rel (r_gr, short_args)) body in - sb, subst_clause sb r_br) + sb, (* subst_clause sb *) r_br) grounding in let rec expand_literal emb_lit literal (sb, (head, body) as accu) = @@ -580,7 +580,7 @@ Aux.concat_foldr (expand_literal (fun l body-> l::body)) body init in List.map (fun (sb, cl) -> subst_clause sb cl) result -let elim_ground_arg rel arg clauses = +let elim_ground_arg new_rels rel arg clauses = let rel_brs, clauses = List.partition (fun ((r,_),_) -> r=rel) clauses in let grounding = Aux.unique_sorted @@ -590,24 +590,33 @@ let short_args = Array.init (Array.length args - 1) (fun i -> if i < arg then args.(i) else args.(i+1)) in let rname = rel ^ "__" ^ term_to_name args.(arg) in + new_rels := rname:: !new_rels; (rname, short_args), body) rel_brs in Aux.concat_map (elim_ground_arg_in_body rel arg grounding) (renamed_brs @ clauses) let elim_ground_args rels clauses = - let modified = ref false in + let new_rels = ref [] and all_rels = ref [] in let rec aux clauses = function | [] -> clauses | rel::rels -> (let try arg = find_ground_arg rel clauses in - modified := true; - aux (elim_ground_arg rel arg clauses) rels - with Not_found -> aux clauses rels) in + aux (elim_ground_arg new_rels rel arg clauses) rels + with Not_found -> + all_rels := rel:: !all_rels; aux clauses rels) in let rec fix clauses = - modified := false; + all_rels := !new_rels @ !all_rels; + new_rels := []; let clauses = aux clauses rels in - if !modified then fix clauses else clauses in + if !new_rels <> [] + then fix clauses + else + let all_rels = List.filter + (fun r->List.exists + (function ((rel,_),_) when r=rel -> true | _ -> false) clauses) + (Aux.unique_sorted !all_rels) in + all_rels, clauses in fix clauses @@ -799,6 +808,7 @@ let player_vars_of rels = Aux.map_some (function + | "role", [|Var v|] -> Some v | "goal", [|Var v; _|] -> Some v | "does", [|Var v; _|] -> Some v | "legal", [|Var v; _|] -> Some v Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/GDL.mli 2011-08-10 12:15:33 UTC (rev 1533) @@ -91,7 +91,11 @@ val func_graph : string -> term list -> term array list -val elim_ground_args : string list -> clause list -> clause list +(** Eliminate arguments of relations that are constant in each + defining clause. Return the new clauses, and also the new + relation set. *) +val elim_ground_args : + string list -> clause list -> string list * clause list (** {3 GDL translation helpers.} *) Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/GDLTest.ml 2011-08-10 12:15:33 UTC (rev 1533) @@ -218,10 +218,14 @@ (nextcol ?d ?e) (true (cell ?x ?e o))) " in - let result = elim_ground_args ["conn5"; "col"; "row"] descr in + let defined_rels, result = + elim_ground_args ["conn5"; "col"; "row"] descr in let res_s = (String.concat "\n" (List.map GDL.clause_str result)) in assert_equal ~printer:(fun x->x) + "col__o, col__x, conn5__o, conn5__x, row__o, row__x" + (String.concat ", " defined_rels); + assert_equal ~printer:(fun x->x) "(<= (conn5__o ) (or (col__o ) (row__o ))) (<= (conn5__x ) Modified: trunk/Toss/GGP/TranslateFormula.ml =================================================================== --- trunk/Toss/GGP/TranslateFormula.ml 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/TranslateFormula.ml 2011-08-10 12:15:33 UTC (rev 1533) @@ -2,6 +2,8 @@ open GDL +let debug_level = ref 0 + let rel_atoms body = Aux.map_some (function Rel (rel, args) -> Some (rel, args) | _ -> None) (atoms_of_body body) @@ -226,6 +228,12 @@ let build_defrel rel = (* searching for ArgType = DefSide,S,p *) let branches = Aux.assoc_all rel all_branches in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "build_defrel: rel=%s, no of brs=%d\n%!" + rel (List.length branches) + ); + (* }}} *) (* first find the common paths, we will find the state terms later *) let branch_paths = List.map (fun (args, (_, sterms_pos, sterms_neg)) -> @@ -290,10 +298,13 @@ match defside, callside with | Some p, _ | None, Some p -> p | None, None -> - (* the ArgType(R,i) = NoSide,p variant is precomputed *) - match (List.assoc rel data.rel_default_path).(i) with - | Some p -> p - | None -> failwith + (* the ArgType(R,i) = NoSide,p variant is precomputed *) + try + match (List.assoc rel data.rel_default_path).(i) with + | Some p -> p + | None -> raise Not_found + with Not_found -> + failwith (Printf.sprintf "TranslateFormula.build_defrels: could not \ determine path for relation %s argument %d" rel i) @@ -313,7 +324,7 @@ | None -> assert false in Formula.Eq (v, s_i) else Formula.Eq (v, - var_of_subterm data arg_paths.(i) args.(i))) + var_of_subterm data arg_paths.(i) args.(i))) defvars in let arg_eqs = Formula.And (Array.to_list arg_eqs) in let callside_sterms = Modified: trunk/Toss/GGP/TranslateFormula.mli =================================================================== --- trunk/Toss/GGP/TranslateFormula.mli 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/TranslateFormula.mli 2011-08-10 12:15:33 UTC (rev 1533) @@ -1,3 +1,5 @@ +val debug_level : int ref + (* Whether $i$th argument is a $\mathrm{DefSide}$ or a $\mathrm{CallSide}$, and the $p_{R,i}$ path for a relation $R$. *) type defrel_arg_type = (bool * GDL.path) array Modified: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-10 12:15:33 UTC (rev 1533) @@ -30,15 +30,18 @@ ["control", 1; "cell", 3; "x", 0; "o", 0; "b", 0; "mark", 2; "a", 0; "b", 0; "c", 0; "d", 0; "e", 0; "f", 0; "g", 0; "h", 0] in let arities f = List.assoc f term_arities in + let f_paths = [["cell", 2]; ["control", 0]] in + let ground_flu = [GDL.Const "x"; GDL.Const "o"; GDL.Const "b"] in + let ground_at_f_paths = List.map (fun f -> f, ground_flu) f_paths in let f_paths = List.fold_right (GDL.add_path arities) - [["cell", 2]; ["control", 0]] GDL.empty_path_set in + f_paths GDL.empty_path_set in let m_paths = List.fold_right (GDL.add_path arities) [["cell", 0]; ["cell", 1]] GDL.empty_path_set in let all_paths = GDL.paths_union f_paths m_paths in let mask_reps = [GDL.Func ("control", [|GDL.blank|]); GDL.Func ("cell", [|GDL.blank; GDL.blank; GDL.blank|])] in - let defrel_arities = [ + let exp_defrel_arities = [ "adjacent_cell", 4; "col__x", 0; "col__o", 0; "col__b", 0; "conn5__x", 0; "conn5__o", 0; "conn5__b", 0; @@ -46,10 +49,13 @@ "diag2__x", 0; "diag2__o", 0; "diag2__b", 0; "exists_empty_cell", 0; "exists_line_of_five", 0; "row__x", 0; "row__o", 0; "row__b", 0] in - let defined_rels = List.map fst defrel_arities in + let defined_rels = + ["adjacent_cell"; "col"; "conn5"; "diag1"; "diag2"; + "exists_empty_cell"; "exists_line_of_five"; "row"] in let default_path = Some ["cell", 0] in let rel_default_path = List.map - (fun (rel, ar) -> rel, Array.make ar default_path) defrel_arities in + (fun (rel, ar) -> rel, Array.make ar default_path) exp_defrel_arities in + ground_at_f_paths, { f_paths = f_paths; m_paths = m_paths; @@ -66,10 +72,19 @@ "defined relations connect5" >:: (fun () -> let descr = load_rules ("./GGP/examples/connect5.gdl") in - let transl_data = connect5_data in + let ground_at_f_paths, transl_data = connect5_data in let clauses = GDL.expand_players descr in let clauses = + GDL.ground_vars_at_paths ground_at_f_paths clauses in + let defined_rels, clauses = GDL.elim_ground_args transl_data.defined_rels clauses in + (* {{{ log entry *) + if !TranslateFormula.debug_level > 2 then ( + Printf.printf "defined relations connect5: clauses =\n%s\n%!" + (String.concat "\n" (List.map GDL.clause_str clauses)) + ); + (* }}} *) + let transl_data = {transl_data with defined_rels = defined_rels} in let defined_rels = TranslateFormula.build_defrels transl_data clauses in let res = String.concat "\n" @@ -78,9 +93,39 @@ ") = "^Formula.str body) defined_rels) in assert_equal ~msg:"connect5 noop moves by players" ~printer:(fun x->x) - "" res; + "" res ); ] +let a () = + TranslateFormula.debug_level := 5; + GDL.debug_level := 2; + () + +let a () = + let descr = load_rules ("./GGP/examples/connect5.gdl") in + let ground_at_f_paths, transl_data = connect5_data in + let clauses = GDL.expand_players descr in + let clauses = + GDL.ground_vars_at_paths ground_at_f_paths clauses in + let defined_rels, clauses = + GDL.elim_ground_args transl_data.defined_rels clauses in + (* {{{ log entry *) + if !TranslateFormula.debug_level > 2 then ( + Printf.printf "defined relations connect5: clauses =\n%s\n%!" + (String.concat "\n" (List.map GDL.clause_str clauses)) + ); + (* }}} *) + let transl_data = {transl_data with defined_rels = defined_rels} in + let defined_rels = + TranslateFormula.build_defrels transl_data clauses in + let res = String.concat "\n" + (List.map (fun (rel,(args,body)) -> + rel^"("^String.concat ", " args^ + ") = "^Formula.str body) defined_rels) in + assert_equal ~msg:"connect5 noop moves by players" + ~printer:(fun x->x) + "" res + let exec = Aux.run_test_if_target "TranslateFormulaTest" tests Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-10 12:15:33 UTC (rev 1533) @@ -231,7 +231,8 @@ (* Expand role variables, find fluent and mask paths, generate the - initial structure. *) + initial structure. Encode frame clauses by using the unique + relation name "frame next". *) let create_init_struc clauses = let players = Aux.map_some (function @@ -389,8 +390,13 @@ let elem_term_map = Aux.intmap_of_assoc (List.map (fun e -> Structure.find_elem struc (term_to_name e), e) element_reps) in + let clauses = + List.filter (fun ((rel,_),_) -> rel <> "next") clauses in + let frame_clauses = List.map + (fun ((_,args),body) -> ("frame next", args), body) frame_clauses in players, rules, - frame_clauses, move_clauses, f_paths, m_paths, mask_reps, defined_rels, + frame_clauses @ move_clauses @ clauses, + f_paths, m_paths, mask_reps, defined_rels, Aux.Strings.elements !stable_rels, Aux.Strings.elements !fluents, static_base, init_state, struc, ground_state_terms, elem_term_map @@ -1124,7 +1130,7 @@ let clauses = expand_players clauses in let used_vars, clauses = rename_clauses clauses in let players, rules, - frame_clauses, move_clauses, f_paths, m_paths, + clauses, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, static_base, init_state, struc, ground_state_terms, elem_term_map = create_init_struc clauses in @@ -1135,20 +1141,15 @@ let ground_at_f_paths = ground_at f_paths in let clauses = ground_vars_at_paths ground_at_f_paths clauses in - let frame_clauses = - ground_vars_at_paths ground_at_f_paths frame_clauses in - let move_clauses = - ground_vars_at_paths ground_at_f_paths move_clauses in let defined_rels = Aux.list_diff defined_rels ["goal"; "legal"; "next"; "terminal"] in - let clauses = elim_ground_args defined_rels clauses in - let next_cls = - List.map (function - | (_,[|s_C|]),body_C -> s_C, true, body_C - | _ -> assert false) frame_clauses - @ List.map (function - | (_,[|s_C|]),body_C -> s_C, false, body_C - | _ -> assert false) move_clauses in + let defined_rels, clauses = elim_ground_args defined_rels clauses in + let next_cls = Aux.map_some + (function + | ("frame next",[|s_C|]),body_C -> Some (s_C, true, body_C) + | ("next",[|s_C|]),body_C -> Some (s_C, false, body_C) + | _ -> None) + clauses in let turn_data = try Some (check_turn_based players rules) with Not_turn_based -> None in Modified: trunk/Toss/GGP/TranslateGame.mli =================================================================== --- trunk/Toss/GGP/TranslateGame.mli 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/TranslateGame.mli 2011-08-10 12:15:33 UTC (rev 1533) @@ -49,7 +49,8 @@ val empty_gdl_translation : gdl_translation (* Create the initial structure and assorted data. Exposed for testing - purposes. + purposes. Encode frame clauses by using the unique + relation name "frame next". [players, rules, frame_cls, move_cls, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, stable_base, init_state, @@ -57,7 +58,7 @@ val create_init_struc : GDL.clause list -> GDL.term array * GDL.gdl_rule list * - GDL.clause list * GDL.clause list * GDL.path_set * + GDL.clause list * GDL.path_set * GDL.path_set * GDL.term list * string list * string list * string list * GDL.rel_atom list * GDL.term list * Structure.structure * GDL.term list * Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-10 03:31:00 UTC (rev 1532) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-10 12:15:33 UTC (rev 1533) @@ -120,7 +120,7 @@ let descr = load_rules ("./GGP/examples/connect5.gdl") in let clauses = GDL.expand_players descr in let players, rules, - frame_cls, move_cls, f_paths, m_paths, mask_reps, defined_rels, + clauses, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, stable_base, init_state, struc, ground_state_terms, elem_term_map = TranslateGame.create_init_struc clauses in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-10 03:31:08
|
Revision: 1532 http://toss.svn.sourceforge.net/toss/?rev=1532&view=rev Author: lukstafi Date: 2011-08-10 03:31:00 +0000 (Wed, 10 Aug 2011) Log Message: ----------- GDL translation: eliminating ground arguments of relations. (TranslateFormula and TranslateGame tests do not pass yet.) Modified Paths: -------------- 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/GGP/TranslateFormulaTest.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/Server/Tests.ml trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/Formula/Aux.ml 2011-08-10 03:31:00 UTC (rev 1532) @@ -117,6 +117,11 @@ match l with | [] -> init | a::l -> concat_map (f a) (concat_foldr f l init) + +let rec concat_foldl f l init = + match l with + | [] -> init + | a::l -> concat_foldl f l (concat_map (f a) init) let list_remove v l = List.filter (fun w->v<>w) l @@ -394,6 +399,14 @@ if !i >= n then raise Not_found else !i +let array_argfindi f a = + let i = ref 0 in + let n = Array.length a in + while !i < n && not (f !i (Array.unsafe_get a !i)) do + incr i done; + if !i >= n then raise Not_found + else !i + let array_find_all f a = let r = ref [] in for i = Array.length a - 1 downto 0 do Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/Formula/Aux.mli 2011-08-10 03:31:00 UTC (rev 1532) @@ -72,6 +72,9 @@ [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 +(** [concat_foldl f (a::l) init = concat_foldl f l (concat_map (f a) init)] *) +val concat_foldl : ('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 @@ -212,6 +215,8 @@ val array_argfind : ('a -> bool) -> 'a array -> int +val array_argfindi : (int -> 'a -> bool) -> 'a array -> int + (** Find all elements for which [f] holds. *) val array_find_all : ('a -> bool) -> 'a array -> 'a list (** Find all indices for which [f] holds. *) Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/GGP/GDL.ml 2011-08-10 03:31:00 UTC (rev 1532) @@ -315,6 +315,18 @@ let def_str (rel, branches) = String.concat "\n" (List.map (branch_str rel) branches) +let atom_str a = rel_atom_str (rel_of_atom a) + +let rec literal_str = function + | Pos atom -> atom_str atom + | Neg atom -> "(not "^atom_str atom^")" + | Disj disjs -> + "(or "^String.concat " " (List.map literal_str disjs)^")" + +let clause_str (head, body) = + "(<= "^rel_atom_str head^"\n "^String.concat "\n " + (List.map literal_str body)^")" + let sb_str sb = String.concat ", " (List.map (fun (v,t)->v^":="^term_str t) sb) @@ -521,6 +533,84 @@ ) (flatten_disjs body) +let find_ground_arg rel clauses = + match Aux.assoc_all rel (List.map fst clauses) with + | [] -> raise Not_found + | (args::_ as all_args) -> + Aux.array_argfindi + (fun i _ -> + List.for_all (fun args -> + Aux.Strings.is_empty (term_vars args.(i))) all_args) + args + +let elim_ground_arg_in_body rel arg grounding (head, body) = + + let expand_atom args add_lit (sb, (head, body)) = + (* [short_args] will be subsituted with [sb] inside [r_br] *) + let short_args = Array.init (Array.length args - 1) + (fun i -> if i < arg then args.(i) else args.(i+1)) in + let inst_arg = subst sb args.(arg) in + Aux.map_try + (fun ground -> + let sb = unify sb [ground] [inst_arg] in + let r_gr = rel ^ "__" ^ term_to_name ground in + let r_br = head, add_lit (Rel (r_gr, short_args)) body in + sb, subst_clause sb r_br) + grounding in + + let rec expand_literal emb_lit literal (sb, (head, body) as accu) = + match literal with + | Pos (Rel (r, args)) when r=rel -> + expand_atom args (fun a body -> emb_lit (Pos a) body) accu + | Neg (Rel (r, args)) when r=rel -> + expand_atom args (fun a body -> emb_lit (Neg a) body) accu + | Pos _ | Neg _ -> [sb, (head, emb_lit literal body)] + | Disj disjs -> + let emb_lit lit body = + match body with + | Disj disjs::body -> Disj (lit::disjs)::body + | _ -> assert false in + (* unfortunately only works with one level of disjunctions *) + (* TODO: optimization when splitting clause not necessary *) + Aux.concat_foldr (expand_literal emb_lit) disjs + [sb, (head, Disj []::body)] in + + let init = [[], (head, [])] in + let result = + Aux.concat_foldr (expand_literal (fun l body-> l::body)) body init in + List.map (fun (sb, cl) -> subst_clause sb cl) result + +let elim_ground_arg rel arg clauses = + let rel_brs, clauses = + List.partition (fun ((r,_),_) -> r=rel) clauses in + let grounding = Aux.unique_sorted + (List.map (fun ((_,args),_) -> args.(arg)) rel_brs) in + let renamed_brs = List.map + (fun ((_,args), body) -> + let short_args = Array.init (Array.length args - 1) + (fun i -> if i < arg then args.(i) else args.(i+1)) in + let rname = rel ^ "__" ^ term_to_name args.(arg) in + (rname, short_args), body) + rel_brs in + Aux.concat_map (elim_ground_arg_in_body rel arg grounding) + (renamed_brs @ clauses) + +let elim_ground_args rels clauses = + let modified = ref false in + let rec aux clauses = function + | [] -> clauses + | rel::rels -> + (let try arg = find_ground_arg rel clauses in + modified := true; + aux (elim_ground_arg rel arg clauses) rels + with Not_found -> aux clauses rels) in + let rec fix clauses = + modified := false; + let clauses = aux clauses rels in + if !modified then fix clauses else clauses in + fix clauses + + (* ************************************************************ *) (* ************************************************************ *) (** {3 GDL whole-game operations.} Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/GGP/GDL.mli 2011-08-10 03:31:00 UTC (rev 1532) @@ -91,8 +91,8 @@ val func_graph : string -> term list -> term array list +val elim_ground_args : string list -> clause list -> clause list - (** {3 GDL translation helpers.} *) val blank : term @@ -105,6 +105,7 @@ val rel_atom_str : rel_atom -> string val def_str : string * def_branch list -> string +val clause_str : clause -> string (** {3 GDL whole-game operations.} Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/GGP/GDLTest.ml 2011-08-10 03:31:00 UTC (rev 1532) @@ -171,6 +171,106 @@ (GDL.def_str ("legal", legal_def)); ); + "eliminate ground args simple" >:: + (fun () -> + let descr = parse_game_descr + " +(<= (conn5 ?r) + (or (col ?r) (row ?r))) +(<= (row x) + (true (cell ?a ?y x)) + (nextcol ?a ?b) + (true (cell ?b ?y x)) + (nextcol ?b ?c) + (true (cell ?c ?y x)) + (nextcol ?c ?d) + (true (cell ?d ?y x)) + (nextcol ?d ?e) + (true (cell ?e ?y x))) +(<= (col x) + (true (cell ?x ?a x)) + (nextcol ?a ?b) + (true (cell ?x ?b x)) + (nextcol ?b ?c) + (true (cell ?x ?c x)) + (nextcol ?c ?d) + (true (cell ?x ?d x)) + (nextcol ?d ?e) + (true (cell ?x ?e x))) +(<= (row o) + (true (cell ?a ?y o)) + (nextcol ?a ?b) + (true (cell ?b ?y o)) + (nextcol ?b ?c) + (true (cell ?c ?y o)) + (nextcol ?c ?d) + (true (cell ?d ?y o)) + (nextcol ?d ?e) + (true (cell ?e ?y o))) +(<= (col o) + (true (cell ?x ?a o)) + (nextcol ?a ?b) + (true (cell ?x ?b o)) + (nextcol ?b ?c) + (true (cell ?x ?c o)) + (nextcol ?c ?d) + (true (cell ?x ?d o)) + (nextcol ?d ?e) + (true (cell ?x ?e o))) +" in + let result = elim_ground_args ["conn5"; "col"; "row"] descr in + let res_s = + (String.concat "\n" (List.map GDL.clause_str result)) in + assert_equal ~printer:(fun x->x) + "(<= (conn5__o ) + (or (col__o ) (row__o ))) +(<= (conn5__x ) + (or (col__x ) (row__x ))) +(<= (row__x ) + (true (cell ?a ?y x)) + (nextcol ?a ?b) + (true (cell ?b ?y x)) + (nextcol ?b ?c) + (true (cell ?c ?y x)) + (nextcol ?c ?d) + (true (cell ?d ?y x)) + (nextcol ?d ?e) + (true (cell ?e ?y x))) +(<= (row__o ) + (true (cell ?a ?y o)) + (nextcol ?a ?b) + (true (cell ?b ?y o)) + (nextcol ?b ?c) + (true (cell ?c ?y o)) + (nextcol ?c ?d) + (true (cell ?d ?y o)) + (nextcol ?d ?e) + (true (cell ?e ?y o))) +(<= (col__x ) + (true (cell ?x ?a x)) + (nextcol ?a ?b) + (true (cell ?x ?b x)) + (nextcol ?b ?c) + (true (cell ?x ?c x)) + (nextcol ?c ?d) + (true (cell ?x ?d x)) + (nextcol ?d ?e) + (true (cell ?x ?e x))) +(<= (col__o ) + (true (cell ?x ?a o)) + (nextcol ?a ?b) + (true (cell ?x ?b o)) + (nextcol ?b ?c) + (true (cell ?x ?c o)) + (nextcol ?c ?d) + (true (cell ?x ?d o)) + (nextcol ?d ?e) + (true (cell ?x ?e o)))" + res_s + ); +] + +let bigtests = "GDLBig" >::: [ "playout connect5" >:: (fun () -> let descr = load_rules ("./GGP/examples/connect5.gdl") in @@ -194,4 +294,8 @@ ] +let a () = + GDL.debug_level := 5 + + let exec = Aux.run_test_if_target "GDLTest" tests Modified: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-10 03:31:00 UTC (rev 1532) @@ -66,8 +66,10 @@ "defined relations connect5" >:: (fun () -> let descr = load_rules ("./GGP/examples/connect5.gdl") in + let transl_data = connect5_data in let clauses = GDL.expand_players descr in - let transl_data = connect5_data in + let clauses = + GDL.elim_ground_args transl_data.defined_rels clauses in let defined_rels = TranslateFormula.build_defrels transl_data clauses in let res = String.concat "\n" Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-10 03:31:00 UTC (rev 1532) @@ -1139,6 +1139,9 @@ ground_vars_at_paths ground_at_f_paths frame_clauses in let move_clauses = ground_vars_at_paths ground_at_f_paths move_clauses in + let defined_rels = Aux.list_diff defined_rels + ["goal"; "legal"; "next"; "terminal"] in + let clauses = elim_ground_args defined_rels clauses in let next_cls = List.map (function | (_,[|s_C|]),body_C -> s_C, true, body_C Modified: trunk/Toss/Server/Tests.ml =================================================================== --- trunk/Toss/Server/Tests.ml 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/Server/Tests.ml 2011-08-10 03:31:00 UTC (rev 1532) @@ -33,7 +33,7 @@ let ggp_tests = "GGP", [ "GameSimplTest", [GameSimplTest.tests]; - "GDLTest", [GDLTest.tests]; + "GDLTest", [GDLTest.tests; GDLTest.bigtests]; "TranslateGameTest", [TranslateGameTest.tests; TranslateGameTest.bigtests]; "TranslateFormulaTest", [TranslateFormulaTest.tests]; ] Modified: trunk/Toss/www/reference/reference.tex =================================================================== --- trunk/Toss/www/reference/reference.tex 2011-08-10 02:59:51 UTC (rev 1531) +++ trunk/Toss/www/reference/reference.tex 2011-08-10 03:31:00 UTC (rev 1532) @@ -1646,8 +1646,13 @@ (by virtue of occurring in \texttt{does}, \texttt{legal} or \texttt{goal} atoms), by the players of the game. -Before generating Toss formulas we also transform the definition $G$ -by grounding all variables that have occurrences at fluent paths, \ie +Another form of expansion was the inlining of clauses, used only for +finding fluent paths. (In particular, \texttt{does} atoms were then +replaced by appropriately instantiated bodies of \texttt{legal} +clauses.) + +Before generating Toss formulas we transform the definition $G$ by +grounding all variables that have occurrences at fluent paths, \ie eliminating these variables by constants that occur at these paths in ground state terms $\calS$. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-10 02:59:57
|
Revision: 1531 http://toss.svn.sourceforge.net/toss/?rev=1531&view=rev Author: lukaszkaiser Date: 2011-08-10 02:59:51 +0000 (Wed, 10 Aug 2011) Log Message: ----------- Adding history to game state and related changes. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/Arena/ArenaParser.mly trunk/Toss/GGP/TranslateGame.ml trunk/Toss/Play/GameTreeTest.ml trunk/Toss/Play/Move.ml trunk/Toss/Play/Move.mli trunk/Toss/Play/PlayTest.ml Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2011-08-09 06:21:46 UTC (rev 1530) +++ trunk/Toss/Arena/Arena.ml 2011-08-10 02:59:51 UTC (rev 1531) @@ -38,15 +38,10 @@ player_names : (string * int) list ; data : (string * string) list ; defined_rels : (string * (string list * Formula.formula)) list ; + starting_struc : Structure.structure ; } -(* State of the game and additional information. *) -type game_state = { - struc : Structure.structure ; - time : float ; - cur_loc : int ; -} - +(* Move - complete basic action data. *) type move = { mv_time : float ; parameters : (string * float) list ; @@ -55,6 +50,16 @@ embedding : (int * int) list ; } +(* State of the game and additional information. *) +type game_state = { + struc : Structure.structure ; + time : float ; + cur_loc : int ; + history : (move * float option) list ; +} + + + let zero_loc = { payoff = Formula.Const 0. ; view = (Formula.And [], []); heur = []; @@ -68,12 +73,13 @@ player_names = ["1", 0] ; data = [] ; defined_rels = [] ; + starting_struc = emp_struc ; num_players=1;}, {struc = emp_struc ; time = 0.0 ; cur_loc = 0 ; + history = [] ; } - (* -------------------- PARSER HELPER ------------------------------ *) @@ -137,7 +143,7 @@ exception Arena_definition_error of string -let make_move rname params target_loc = +let make_move_arena rname params target_loc = let time_in, parameters_in = try Aux.pop_assoc "t" params with Not_found -> (cDEFAULT_TIMESTEP, cDEFAULT_TIMESTEP), params in @@ -282,10 +288,12 @@ player_names = player_names; data = data; defined_rels = List.map (fun (a, b, c) -> (a, (b, c))) defined_rels; + starting_struc = state; }, { struc = state; time = time; cur_loc = cur_loc; + history = []; } @@ -1061,3 +1069,14 @@ | GetState -> false | SetModel _ -> true | GetModel -> false + + +(* Make a move in a game. *) +let make_move m (game, state) = + let req = ApplyRuleInt (m.rule, m.embedding, m.mv_time, m.parameters) in + let (new_game, new_state), _ = handle_request (game, state) req in + (new_game, + { new_state with cur_loc = m.next_loc ; + history = (m, None) :: state.history }) + + Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2011-08-09 06:21:46 UTC (rev 1530) +++ trunk/Toss/Arena/Arena.mli 2011-08-10 02:59:51 UTC (rev 1531) @@ -32,8 +32,10 @@ player_names : (string * int) list ; data : (string * string) list ; defined_rels : (string * (string list * Formula.formula)) list ; + starting_struc : Structure.structure ; } + (** Move - complete basic action data. **) type move = { mv_time : float ; @@ -43,15 +45,21 @@ embedding : (int * int) list ; } + (** State of the game. *) type game_state = { struc : Structure.structure ; time : float ; cur_loc : int ; + history : (move * float option) list ; } val empty_state : game * game_state +(** Make a move in a game. *) +val make_move : move -> game * game_state -> game * game_state + + (** Translate from names to elements to get rule embedding. *) val emb_of_names : game * game_state -> string -> (string * string) list -> (int * int) list @@ -113,7 +121,7 @@ val array_of_players : 'a -> (string * int) list -> (string * 'a) list -> 'a array -val make_move : +val make_move_arena : string -> (string * (float * float)) list -> int -> label * int Modified: trunk/Toss/Arena/ArenaParser.mly =================================================================== --- trunk/Toss/Arena/ArenaParser.mly 2011-08-09 06:21:46 UTC (rev 1530) +++ trunk/Toss/Arena/ArenaParser.mly 2011-08-10 02:59:51 UTC (rev 1531) @@ -31,7 +31,7 @@ COMMA, separated_pair (ID, COLON, separated_pair (FLOAT, INTERV, FLOAT))) RARR LOC_MOD? target = INT CLOSESQ - { make_move r params target } + { make_move_arena r params target } | OPENSQ error { Lexer.report_parsing_error $startpos $endpos "Syntax error in move definition." Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-09 06:21:46 UTC (rev 1530) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-10 02:59:51 UTC (rev 1531) @@ -1204,6 +1204,7 @@ player_names = player_names; data = []; defined_rels = defined_rels; + starting_struc = struc; } in let tossrule_data = Aux.strmap_of_assoc tossrule_data in let playing_as = @@ -1223,7 +1224,7 @@ fluents = fluents; } in gdl_translation, - (game, {Arena.struc = struc; time = 0.; cur_loc = 0}) + (game, {Arena.struc = struc; history = []; time = 0.; cur_loc = 0}) (* ************************************************************ *) Modified: trunk/Toss/Play/GameTreeTest.ml =================================================================== --- trunk/Toss/Play/GameTreeTest.ml 2011-08-09 06:21:46 UTC (rev 1530) +++ trunk/Toss/Play/GameTreeTest.ml 2011-08-10 02:59:51 UTC (rev 1531) @@ -21,13 +21,14 @@ 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 }) + (g, { Arena.struc = structure; time = time; cur_loc = loc; history = [] }) let tests = "GameTree" >::: [ "abstract tree init, to string" >:: (fun () -> - let s = {Arena.struc=Structure.empty_structure(); cur_loc=0; time=0.} in + let s = {Arena.struc=Structure.empty_structure(); + cur_loc=0; time=0.; history = []} 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" Modified: trunk/Toss/Play/Move.ml =================================================================== --- trunk/Toss/Play/Move.ml 2011-08-09 06:21:46 UTC (rev 1530) +++ trunk/Toss/Play/Move.ml 2011-08-10 02:59:51 UTC (rev 1531) @@ -5,14 +5,6 @@ let cGRID_SIZE = 5 -(* Make a move in a game. *) -let make_move m (game, state) = - let req = Arena.ApplyRuleInt - (m.Arena.rule, m.Arena.embedding, m.Arena.mv_time, m.Arena.parameters) in - let (new_game, new_state), _ = Arena.handle_request (game, state) req in - (new_game, { new_state with Arena.cur_loc = m.Arena.next_loc }) - - (* Print a move as string. TODO: perhaps find a nicer syntax? See {!TestGame.move_str}. *) let move_str rules struc move = @@ -92,19 +84,23 @@ -let gen_models_list rules model time moves = +let gen_models_list rules state time moves = Aux.map_some (fun mv -> let rule = List.assoc mv.Arena.rule rules in Aux.map_option (fun (model, time, _) -> (* ignoring shifts, i.e. animation steps *) - (mv, {Arena.cur_loc = mv.Arena.next_loc; struc = model; time = time})) - (ContinuousRule.rewrite_single model time mv.Arena.embedding + (mv, + {Arena.cur_loc = mv.Arena.next_loc; + history = (mv, None) :: state.Arena.history; + struc = model; + time = time})) + (ContinuousRule.rewrite_single state.Arena.struc time mv.Arena.embedding rule mv.Arena.mv_time mv.Arena.parameters)) (Array.to_list moves) -let gen_models rules model time moves = - let res = gen_models_list rules model time moves in - let moves, models = List.split res in - Array.of_list moves, Array.of_list models +let gen_models rules state time moves = + let res = gen_models_list rules state time moves in + let moves, states = List.split res in + Array.of_list moves, Array.of_list states let list_moves game s = let select_moving a = @@ -114,6 +110,6 @@ let moving = select_moving loc in let get_moves pl = let m = gen_moves cGRID_SIZE game.Arena.rules s.Arena.struc loc.(pl) in - (gen_models_list game.Arena.rules s.Arena.struc s.Arena.time m) in + (gen_models_list game.Arena.rules s s.Arena.time m) in Array.of_list (List.concat ( List.map (fun p -> List.map (fun (a,b) -> (p,a,b)) (get_moves p)) moving)) Modified: trunk/Toss/Play/Move.mli =================================================================== --- trunk/Toss/Play/Move.mli 2011-08-09 06:21:46 UTC (rev 1530) +++ trunk/Toss/Play/Move.mli 2011-08-10 02:59:51 UTC (rev 1531) @@ -8,11 +8,6 @@ val move_gs_str_short : Arena.game_state -> Arena.move -> string -(** Make a move in a game. *) -val make_move : Arena.move -> - Arena.game * Arena.game_state -> Arena.game * Arena.game_state - - (** Default number of sample points per parameter in tree search. TODO: fixed for now. *) val cGRID_SIZE : int @@ -21,7 +16,7 @@ val gen_moves : int -> (string * ContinuousRule.rule) list -> Structure.structure -> Arena.player_loc -> Arena.move array -val gen_models : (string * ContinuousRule.rule) list -> Structure.structure -> +val gen_models : (string * ContinuousRule.rule) list -> Arena.game_state -> float -> Arena.move array -> Arena.move array * Arena.game_state array val list_moves : Arena.game -> Arena.game_state -> Modified: trunk/Toss/Play/PlayTest.ml =================================================================== --- trunk/Toss/Play/PlayTest.ml 2011-08-09 06:21:46 UTC (rev 1530) +++ trunk/Toss/Play/PlayTest.ml 2011-08-10 02:59:51 UTC (rev 1531) @@ -21,7 +21,7 @@ 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 }) + (g, { Arena.struc = structure; time = time; cur_loc = loc; history = [] }) let test_maximax ?(debug=0) ?(advr=4.) ?(struc="") ?(time=0.) ?(loc=0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-09 06:21:54
|
Revision: 1530 http://toss.svn.sourceforge.net/toss/?rev=1530&view=rev Author: lukaszkaiser Date: 2011-08-09 06:21:46 +0000 (Tue, 09 Aug 2011) Log Message: ----------- Moving move type to Arena. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/GGP/TranslateGame.ml trunk/Toss/Play/GameTree.ml trunk/Toss/Play/GameTree.mli trunk/Toss/Play/Move.ml trunk/Toss/Play/Move.mli trunk/Toss/Play/MoveTest.ml trunk/Toss/Play/Play.mli trunk/Toss/Server/ReqHandler.ml Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Arena/Arena.ml 2011-08-09 06:21:46 UTC (rev 1530) @@ -10,7 +10,7 @@ (* A single move consists of applying a rewrite rule for a time from the [time_in] interval, and parameters from the interval list. *) type label = { - rule : string ; + lb_rule : string ; time_in : float * float ; parameters_in : (string * (float * float)) list ; } @@ -47,6 +47,14 @@ cur_loc : int ; } +type move = { + mv_time : float ; + parameters : (string * float) list ; + rule : string ; + next_loc : int ; + embedding : (int * int) list ; +} + let zero_loc = { payoff = Formula.Const 0. ; view = (Formula.And [], []); heur = []; @@ -80,7 +88,8 @@ (* Rules with which a player with given number can move. *) let rules_for_player player_no game = - let rules_of_loc l = List.map (fun (lab,_) -> lab.rule) l.(player_no).moves in + let rules_of_loc l = + List.map (fun (lab,_) -> lab.lb_rule) l.(player_no).moves in List.concat (List.map rules_of_loc (Array.to_list game.graph)) (* Add a defined relation to a structure. *) @@ -132,7 +141,7 @@ let time_in, parameters_in = try Aux.pop_assoc "t" params with Not_found -> (cDEFAULT_TIMESTEP, cDEFAULT_TIMESTEP), params in - { rule = rname; + { lb_rule = rname; time_in = time_in; parameters_in = parameters_in; }, target_loc @@ -285,7 +294,7 @@ (* Print a label as a string. *) let label_str - {rule = rr; time_in = t_interval; parameters_in = param_intervals} = + {lb_rule = rr; time_in = t_interval; parameters_in = param_intervals} = let fpstr (f,(fs, fe)) = f ^ ": " ^ (string_of_float fs) ^ " -- " ^ (string_of_float fe) in let par_str = if param_intervals = [] then " " else @@ -304,7 +313,7 @@ if moves <> [] then Format.fprintf f "@[<1>MOVES@ %a@]@ " (Aux.fprint_sep_list ";" (fun f ({ - rule=r; time_in=(t_l, t_r); parameters_in=params}, target) -> + lb_rule=r; time_in=(t_l, t_r); parameters_in=params}, target) -> Format.fprintf f "[@,@[<1>%s" r; if t_l <> cDEFAULT_TIMESTEP || t_r <> cDEFAULT_TIMESTEP then Format.fprintf f ",@ @[<1>t:@ %F@ --@ %F@]" t_l t_r; @@ -492,13 +501,13 @@ let label, dest = List.hd dmoves1 in Printf.sprintf "At location %d, only the first game has label %s->%d" - i label.rule dest)); + i label.lb_rule dest)); let dmoves2 = Aux.list_diff loc2.moves loc1.moves in if dmoves2 <> [] then raise (Diff_result ( let label, dest = List.hd dmoves1 in Printf.sprintf "At location %d, only the second game has label %s->%d" - i label.rule dest)); + i label.lb_rule dest)); let poff1 = FormulaOps.map_to_formulas_expr Formula.flatten loc1.payoff in let poff2 = Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Arena/Arena.mli 2011-08-09 06:21:46 UTC (rev 1530) @@ -5,7 +5,7 @@ (** A single move consists of applying a rewrite rule for a time from the [time_in] interval, and parameters from the interval list. *) type label = { - rule : string ; + lb_rule : string ; time_in : float * float ; parameters_in : (string * (float * float)) list ; } @@ -34,6 +34,15 @@ defined_rels : (string * (string list * Formula.formula)) list ; } +(** Move - complete basic action data. **) +type move = { + mv_time : float ; + parameters : (string * float) list ; + rule : string ; + next_loc : int ; + embedding : (int * int) list ; +} + (** State of the game. *) type game_state = { struc : Structure.structure ; Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-09 06:21:46 UTC (rev 1530) @@ -854,7 +854,7 @@ (String.concat "_" (List.map term_to_name legal_tuple)) in rule_names := Aux.Strings.add rname !rule_names; let label = - {Arena.rule = rname; time_in = 0.1, 0.1; parameters_in = []} in + {Arena.lb_rule = rname; time_in = 0.1, 0.1; parameters_in = []} in let precond = Formula.And (synch_precond @ Modified: trunk/Toss/Play/GameTree.ml =================================================================== --- trunk/Toss/Play/GameTree.ml 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Play/GameTree.ml 2011-08-09 06:21:46 UTC (rev 1530) @@ -27,7 +27,7 @@ | 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 + (Arena.move * ('a, 'b) abstract_game_tree) array (* node with state, player, moves and info *) (* Abstract tree printing function. *) Modified: trunk/Toss/Play/GameTree.mli =================================================================== --- trunk/Toss/Play/GameTree.mli 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Play/GameTree.mli 2011-08-09 06:21:46 UTC (rev 1530) @@ -16,7 +16,7 @@ | 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 + (Arena.move * ('a, 'b) abstract_game_tree) array (** node with state, player, moves *) (** Abstract tree printing function. *) @@ -43,9 +43,9 @@ info_terminal : (int -> Arena.game -> Arena.game_state -> int -> 'a -> 'b) -> info_leaf : (int -> Arena.game -> Arena.game_state -> int -> int -> 'a) -> info_node : (int -> Arena.game -> Arena.game_state -> int -> - (Move.move * ('a, 'b) abstract_game_tree) array -> 'a) -> + (Arena.move * ('a, 'b) abstract_game_tree) array -> 'a) -> choice : (int -> Arena.game -> Arena.game_state -> int -> 'a -> - (Move.move * ('a, 'b) abstract_game_tree) array -> int) -> + (Arena.move * ('a, 'b) abstract_game_tree) array -> int) -> ('a, 'b) abstract_game_tree -> ('a, 'b) abstract_game_tree @@ -84,7 +84,7 @@ (** Choose all maximizing moves given a game tree. *) val choose_moves : Arena.game -> 'a game_tree -> - (Move.move * Arena.game_state) list + (Arena.move * Arena.game_state) list (** Game tree initialization. *) @@ -97,8 +97,8 @@ Formula.real_expr array array -> info_leaf : (int -> Arena.game -> Arena.game_state -> 'a) -> info_node : (int -> int -> float array -> - (Move.move * 'a game_tree) array -> 'a) -> + (Arena.move * 'a game_tree) array -> 'a) -> choice : (float array option ref -> int -> Arena.game -> Arena.game_state -> - int -> 'a node_info -> (Move.move * 'a game_tree) array -> int) -> + int -> 'a node_info -> (Arena.move * 'a game_tree) array -> int) -> 'a game_tree -> 'a game_tree Modified: trunk/Toss/Play/Move.ml =================================================================== --- trunk/Toss/Play/Move.ml 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Play/Move.ml 2011-08-09 06:21:46 UTC (rev 1530) @@ -5,36 +5,28 @@ let cGRID_SIZE = 5 -(* Data to return a move as a suggestion rather than directly. *) -type move = { - mv_time : float ; - parameters : (string * float) list ; - rule : string ; - next_loc : int ; (* next location in the arena *) - embedding : (int * int) list ; -} - (* Make a move in a game. *) let make_move m (game, state) = - let req = Arena.ApplyRuleInt (m.rule, m.embedding, m.mv_time, m.parameters) in + let req = Arena.ApplyRuleInt + (m.Arena.rule, m.Arena.embedding, m.Arena.mv_time, m.Arena.parameters) in let (new_game, new_state), _ = Arena.handle_request (game, state) req in - (new_game, { new_state with Arena.cur_loc = m.next_loc }) + (new_game, { new_state with Arena.cur_loc = m.Arena.next_loc }) (* Print a move as string. TODO: perhaps find a nicer syntax? See {!TestGame.move_str}. *) let move_str rules struc move = - let r = List.assoc move.rule rules in + let r = List.assoc move.Arena.rule rules in let rhs_struc = r.ContinuousRule.discrete.DiscreteRule.rhs_struc in let fpstr (f, fv) = f ^ ": " ^ (string_of_float fv) in - let par_str = if move.parameters = [] then " " else - ", " ^ (String.concat ", " (List.map fpstr move.parameters)) in + let par_str = if move.Arena.parameters = [] then " " else + ", " ^ (String.concat ", " (List.map fpstr move.Arena.parameters)) in let p_name (r, e) = Structure.elem_str rhs_struc r ^": "^ Structure.elem_str struc e in - let emb = String.concat ", " (List.map p_name move.embedding) in - (move.rule) ^ "; " ^ emb ^ "; " ^ fpstr ("t", move.mv_time) ^ par_str ^ - "; " ^ (string_of_int move.next_loc) + let emb = String.concat ", " (List.map p_name move.Arena.embedding) in + (move.Arena.rule) ^ "; " ^ emb ^ "; " ^ fpstr ("t", move.Arena.mv_time) ^ + par_str ^ "; " ^ (string_of_int move.Arena.next_loc) let move_gs_str (game, state) move = move_str game.Arena.rules state.Arena.struc move @@ -45,8 +37,8 @@ let p_name (r, e) = string_of_int r ^ ":" ^ Structure.elem_str struc e in let emb = String.concat ", " - (List.map p_name (List.sort Pervasives.compare move.embedding)) in - move.rule ^ "{" ^ emb ^ "}" + (List.map p_name (List.sort Pervasives.compare move.Arena.embedding)) in + move.Arena.rule ^ "{" ^ emb ^ "}" let move_gs_str_short state move = move_str_short state.Arena.struc move @@ -56,7 +48,7 @@ let matchings = Aux.concat_map (fun (label,next_loc) -> - let rule = List.assoc label.Arena.rule rules in + let rule = List.assoc label.Arena.lb_rule rules in List.map (fun emb -> label,next_loc,emb) (ContinuousRule.matches model rule)) loc.Arena.moves in @@ -70,9 +62,9 @@ let t = (t_r +. t_l) /. 2. in if label.Arena.parameters_in = [] then [| { - mv_time = t; + Arena.mv_time = t; parameters = []; - rule = label.Arena.rule; + rule = label.Arena.lb_rule; next_loc = next_loc; embedding = emb } |] @@ -90,9 +82,9 @@ ) params_in in let grid = Aux.product axes in Aux.array_map_of_list (fun params -> { - mv_time = t; + Arena.mv_time = t; parameters = List.combine param_names params; - rule = label.Arena.rule; + rule = label.Arena.lb_rule; next_loc = next_loc; embedding = emb} ) grid @@ -102,12 +94,12 @@ let gen_models_list rules model time moves = Aux.map_some (fun mv -> - let rule = List.assoc mv.rule rules in + let rule = List.assoc mv.Arena.rule rules in Aux.map_option (fun (model, time, _) -> (* ignoring shifts, i.e. animation steps *) - (mv, {Arena.cur_loc = mv.next_loc; struc = model; time = time})) - (ContinuousRule.rewrite_single model time mv.embedding - rule mv.mv_time mv.parameters)) (Array.to_list moves) + (mv, {Arena.cur_loc = mv.Arena.next_loc; struc = model; time = time})) + (ContinuousRule.rewrite_single model time mv.Arena.embedding + rule mv.Arena.mv_time mv.Arena.parameters)) (Array.to_list moves) let gen_models rules model time moves = let res = gen_models_list rules model time moves in Modified: trunk/Toss/Play/Move.mli =================================================================== --- trunk/Toss/Play/Move.mli 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Play/Move.mli 2011-08-09 06:21:46 UTC (rev 1530) @@ -1,24 +1,15 @@ (** Move definition, generation and helper functions. *) -(** Data to return a move as a suggestion rather than directly. *) -type move = { - mv_time : float ; - parameters : (string * float) list ; - rule : string ; - next_loc : int ; (** next location in the arena *) - embedding : (int * int) list ; -} - val move_str : (string * ContinuousRule.rule) list -> - Structure.structure -> move -> string -val move_gs_str : Arena.game * Arena.game_state -> move -> string + Structure.structure -> Arena.move -> string +val move_gs_str : Arena.game * Arena.game_state -> Arena.move -> string -val move_str_short : Structure.structure -> move -> string -val move_gs_str_short : Arena.game_state -> move -> string +val move_str_short : Structure.structure -> Arena.move -> string +val move_gs_str_short : Arena.game_state -> Arena.move -> string (** Make a move in a game. *) -val make_move : move -> +val make_move : Arena.move -> Arena.game * Arena.game_state -> Arena.game * Arena.game_state @@ -28,10 +19,10 @@ (** Generate moves available from a state, as an array, in fixed order. *) val gen_moves : int -> (string * ContinuousRule.rule) list -> - Structure.structure -> Arena.player_loc -> move array + Structure.structure -> Arena.player_loc -> Arena.move array val gen_models : (string * ContinuousRule.rule) list -> Structure.structure -> - float -> move array -> move array * Arena.game_state array + float -> Arena.move array -> Arena.move array * Arena.game_state array val list_moves : Arena.game -> Arena.game_state -> - (int * move * Arena.game_state) array + (int * Arena.move * Arena.game_state) array Modified: trunk/Toss/Play/MoveTest.ml =================================================================== --- trunk/Toss/Play/MoveTest.ml 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Play/MoveTest.ml 2011-08-09 06:21:46 UTC (rev 1530) @@ -4,11 +4,11 @@ "move to string" >:: (fun () -> let mv = { - Move.mv_time = 0.; - Move.parameters = []; - Move.rule = "rule"; - Move.next_loc = 1; - Move.embedding = [(1, 1)]; + Arena.mv_time = 0.; + parameters = []; + rule = "rule"; + next_loc = 1; + embedding = [(1, 1)]; } in let s = Structure.empty_structure () in assert_equal ~printer:(fun x -> x) (Move.move_str_short s mv) Modified: trunk/Toss/Play/Play.mli =================================================================== --- trunk/Toss/Play/Play.mli 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Play/Play.mli 2011-08-09 06:21:46 UTC (rev 1530) @@ -16,10 +16,10 @@ (** Maximax unfolding upto depth, keep previous moves for stability. *) val unfold_maximax_upto : ?ab:bool -> int -> Arena.game -> Formula.real_expr array array -> - int GameTree.game_tree * (Move.move * Arena.game_state) list list -> - int GameTree.game_tree * (Move.move * Arena.game_state) list list + int GameTree.game_tree * (Arena.move * Arena.game_state) list list -> + int GameTree.game_tree * (Arena.move * Arena.game_state) list list (** Maximax unfold upto depth and choose move. *) val maximax_unfold_choose : ?check_stable:int -> int -> Arena.game -> Arena.game_state -> Formula.real_expr array array -> - (Move.move * Arena.game_state) list + (Arena.move * Arena.game_state) list Modified: trunk/Toss/Server/ReqHandler.ml =================================================================== --- trunk/Toss/Server/ReqHandler.ml 2011-08-08 20:58:36 UTC (rev 1529) +++ trunk/Toss/Server/ReqHandler.ml 2011-08-09 06:21:46 UTC (rev 1530) @@ -64,15 +64,15 @@ try for i = 0 to Array.length moves - 1 do let mov = moves.(i) in - if r_name = mov.Move.rule && List.for_all - (fun (e, f) -> f = List.assoc e mov.Move.embedding) mtch then + if r_name = mov.Arena.rule && List.for_all + (fun (e, f) -> f = List.assoc e mov.Arena.embedding) mtch then raise (Found i) done; failwith "GDL Play request: action mismatched with play state" with Found pos -> pos) in let req = Arena.ApplyRuleInt (r_name, mtch, 0.1, []) in let (new_state_noloc, resp) = Arena.handle_request state req in - let new_loc = moves.(pos).Move.next_loc in + let new_loc = moves.(pos).Arena.next_loc in (fst new_state_noloc, {snd new_state_noloc with Arena.cur_loc = new_loc}) ) else state @@ -147,7 +147,7 @@ Aux.random_elem (Play.maximax_unfold_choose 5500 (fst state) (snd state) heur) in TranslateGame.translate_outgoing_move gdl_transl state - move.Move.rule move.Move.embedding + move.Arena.rule move.Arena.embedding ) else ( Gc.compact (); TranslateGame.noop_move gdl_transl (snd state) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-08 20:58:42
|
Revision: 1529 http://toss.svn.sourceforge.net/toss/?rev=1529&view=rev Author: lukstafi Date: 2011-08-08 20:58:36 +0000 (Mon, 08 Aug 2011) Log Message: ----------- GDL translation specification: (1) default paths for defined relation translation, (2) eliminating variables at fluent paths, (3) eliminating ground arguments of relations. (1) and (2) implemented. Not tested (tests do not pass yet). Modified Paths: -------------- trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/TranslateFormula.ml trunk/Toss/GGP/TranslateFormula.mli trunk/Toss/GGP/TranslateFormulaTest.ml trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGame.mli trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/GGP/GDL.ml 2011-08-08 20:58:36 UTC (rev 1529) @@ -723,6 +723,7 @@ | _ -> None ) clauses in let exp_clause clause = + (* TODO: remove "role" atoms *) (* determine variables standing for players *) let plvars = player_vars_of (List.map rel_of_atom (atoms_of_clause clause)) in @@ -978,3 +979,27 @@ (** A "blank" term. *) let blank = Const "_BLANK_" + + +(* [expand_path_vars_by p ts clauses] expands variables that have + occurrences at path [p] in some state term of a clause, by terms + [ts]. *) +let expand_path_vars_by p ts clauses = + let exp_clause ((h_rel, h_args), body as clause) = + (* determine variables standing for players *) + let pstates = state_terms (Pos (Rel (h_rel, h_args))::body) in + let pvars = Aux.map_try + (fun s -> term_vars (at_path s p)) pstates in + let pvars = Aux.Strings.elements + (List.fold_left Aux.Strings.union Aux.Strings.empty pvars) in + if pvars = [] then [clause] + else + let sbs = Aux.power pvars ts in + List.map (fun sb -> subst_clause sb clause) sbs in + Aux.concat_map exp_clause clauses + + +let ground_vars_at_paths ps_sterms clauses = + List.fold_left (fun clauses (p, ts) -> + expand_path_vars_by p ts clauses + ) clauses ps_sterms Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/GGP/GDL.mli 2011-08-08 20:58:36 UTC (rev 1529) @@ -182,3 +182,9 @@ val paths_to_list : path_set -> path list val path_str : path -> string + +(** Expand variables that have occurrences at given paths in some + state term of a clause, by subterms at those paths in the list of + ground terms. *) +val ground_vars_at_paths : + (path * term list) list -> clause list -> clause list Modified: trunk/Toss/GGP/TranslateFormula.ml =================================================================== --- trunk/Toss/GGP/TranslateFormula.ml 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/GGP/TranslateFormula.ml 2011-08-08 20:58:36 UTC (rev 1529) @@ -62,6 +62,7 @@ defrel_arg_type : (string * defrel_arg_type) list ref; (* late binding to store $ArgType# data *) term_arities : (string * int) list; + rel_default_path : (string * path option array) list; } let empty_transl_data = { @@ -72,6 +73,7 @@ defined_rels = []; defrel_arg_type = ref []; term_arities = []; + rel_default_path = []; } let blank_out data t = @@ -217,7 +219,6 @@ (* {3 Build and use defined relations.} *) let build_defrels data clauses = - (* let data = !data_ref in *) let all_branches = Aux.concat_map (fun ((rel,args),body) -> List.map (fun phi -> rel, (args, phi)) (separate_disj [body])) @@ -283,13 +284,20 @@ (fun i -> function Some _ -> None | None -> callside_for_arg i) p_defside in - let arg_paths = Aux.array_map2 - (fun defside callside -> + let arg_paths = Array.mapi + (fun i defside -> + let callside = p_callside.(i) in match defside, callside with | Some p, _ | None, Some p -> p - | None, None -> (* find a good path *) - failwith "GGP/TranslateFormula: finding path for defined relation argument undetermined by state terms not implemented yet") - p_defside p_callside in + | None, None -> + (* the ArgType(R,i) = NoSide,p variant is precomputed *) + match (List.assoc rel data.rel_default_path).(i) with + | Some p -> p + | None -> failwith + (Printf.sprintf + "TranslateFormula.build_defrels: could not \ + determine path for relation %s argument %d" rel i) + ) p_defside in (* now building the translation *) let defvars = Array.mapi (fun i _ -> "v"^string_of_int i) arg_paths in Modified: trunk/Toss/GGP/TranslateFormula.mli =================================================================== --- trunk/Toss/GGP/TranslateFormula.mli 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/GGP/TranslateFormula.mli 2011-08-08 20:58:36 UTC (rev 1529) @@ -11,6 +11,7 @@ defrel_arg_type : (string * defrel_arg_type) list ref; (** late binding to store $ArgType$ data *) term_arities : (string * int) list; + rel_default_path : (string * GDL.path option array) list; } val blank_out : transl_data -> GDL.term -> GDL.term Modified: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-08 20:58:36 UTC (rev 1529) @@ -27,7 +27,8 @@ let connect5_data = let term_arities = - ["control", 1; "cell", 3; "x", 0; "o", 0; "b", 0; "mark", 2] in + ["control", 1; "cell", 3; "x", 0; "o", 0; "b", 0; "mark", 2; + "a", 0; "b", 0; "c", 0; "d", 0; "e", 0; "f", 0; "g", 0; "h", 0] in let arities f = List.assoc f term_arities in let f_paths = List.fold_right (GDL.add_path arities) [["cell", 2]; ["control", 0]] GDL.empty_path_set in @@ -37,10 +38,18 @@ let mask_reps = [GDL.Func ("control", [|GDL.blank|]); GDL.Func ("cell", [|GDL.blank; GDL.blank; GDL.blank|])] in - let defined_rels = [ - "adjacent_cell"; "col"; "conn5"; "diag1"; "diag2"; - "exists_empty_cell"; "exists_line_of_five"; "goal"; "legal"; "next"; - "row"; "terminal"] in + let defrel_arities = [ + "adjacent_cell", 4; + "col__x", 0; "col__o", 0; "col__b", 0; + "conn5__x", 0; "conn5__o", 0; "conn5__b", 0; + "diag1__x", 0; "diag1__o", 0; "diag1__b", 0; + "diag2__x", 0; "diag2__o", 0; "diag2__b", 0; + "exists_empty_cell", 0; "exists_line_of_five", 0; + "row__x", 0; "row__o", 0; "row__b", 0] in + let defined_rels = List.map fst defrel_arities in + let default_path = Some ["cell", 0] in + let rel_default_path = List.map + (fun (rel, ar) -> rel, Array.make ar default_path) defrel_arities in { f_paths = f_paths; m_paths = m_paths; @@ -49,6 +58,7 @@ defined_rels = defined_rels; defrel_arg_type = ref []; term_arities = term_arities; + rel_default_path = rel_default_path; } let tests = "TranslateFormula" >::: [ Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-08 20:58:36 UTC (rev 1529) @@ -264,24 +264,17 @@ (List.map GDL.path_str (GDL.paths_to_list f_paths))) ); (* }}} *) - let next_clauses = - List.map (function - | (_,[|s_C|]),body_C -> s_C, true, body_C - | _ -> assert false) frame_clauses - @ List.map (function - | (_,[|s_C|]),body_C -> s_C, false, body_C - | _ -> assert false) move_clauses in let arities = ("EQ_", 2):: Aux.unique_sorted (List.map (fun ((rel, args),_) -> rel, Array.length args) clauses) in - let element_terms = + let ground_state_terms = List.fold_left (fun acc st -> Aux.unique_sorted (st @ acc)) [] agg_states in let element_reps = Aux.unique_sorted (List.map (fun t -> - simult_subst f_paths blank t) element_terms) in + simult_subst f_paths blank t) ground_state_terms) in (* {{{ log entry *) if !debug_level > 2 then ( Printf.printf @@ -368,7 +361,7 @@ let fluents = ref Aux.Strings.empty in let struc = add_pred false stable_rels struc m_pathl element_reps in let struc = add_pred false fluents struc f_pathl init_state in - let struc = add_pred true fluents struc f_pathl element_terms in + let struc = add_pred true fluents struc f_pathl ground_state_terms in (* adding mask predicates *) let all_paths = paths_union m_paths f_paths in let struc = @@ -397,9 +390,9 @@ (List.map (fun e -> Structure.find_elem struc (term_to_name e), e) element_reps) in players, rules, - next_clauses, f_paths, m_paths, mask_reps, defined_rels, + frame_clauses, move_clauses, f_paths, m_paths, mask_reps, defined_rels, Aux.Strings.elements !stable_rels, Aux.Strings.elements !fluents, - static_base, init_state, struc, agg_actions, elem_term_map + static_base, init_state, struc, ground_state_terms, elem_term_map (* substitute a "next" clause with frame info *) let subst_fnextcl sb (head, frame, body) = @@ -1097,16 +1090,62 @@ payoffs +let transl_arg_type_no_side defined_rels static_base init_state + ground_at_m_paths = + assert (ground_at_m_paths <> []); + List.map (fun (rel, ar) -> + let rel_graph = Aux.assoc_all rel static_base in + match rel_graph with + (* empty graph, take any path *) + | [] -> rel, Array.make ar None + | tup::tups -> + let projs = + List.fold_left + (fun agg_tup tup -> + Aux.array_map2 (fun x y->x::y) tup agg_tup) + (Array.map (fun t->[t]) tup) tups in + let intersects = Array.map + (fun rel_proj -> + let rel_proj = Aux.unique_sorted rel_proj in + List.sort (fun (i,_) (j,_) -> j-i) ( + List.map + (fun (p, pts) -> + List.length (Aux.list_inter rel_proj pts), p) + ground_at_m_paths)) projs in + rel, + Array.map (function (_, p)::_ -> Some p | [] -> None) + intersects + ) defined_rels + + (* [playing_as] is only used for building move translation data, the translation is independent of the selected player. *) let translate_game ~playing_as clauses = let clauses = expand_players clauses in let used_vars, clauses = rename_clauses clauses in let players, rules, - next_cls, f_paths, m_paths, mask_reps, defined_rels, - stable_rels, fluents, - static_base, init_state, struc, agg_actions, elem_term_map = + frame_clauses, move_clauses, f_paths, m_paths, + mask_reps, defined_rels, stable_rels, fluents, + static_base, init_state, struc, ground_state_terms, elem_term_map = create_init_struc clauses in + let ground_at paths = List.map + (fun p -> + p, Aux.map_try (fun s -> at_path s p) ground_state_terms) + (paths_to_list paths) in + let ground_at_f_paths = ground_at f_paths in + let clauses = + ground_vars_at_paths ground_at_f_paths clauses in + let frame_clauses = + ground_vars_at_paths ground_at_f_paths frame_clauses in + let move_clauses = + ground_vars_at_paths ground_at_f_paths move_clauses in + let next_cls = + List.map (function + | (_,[|s_C|]),body_C -> s_C, true, body_C + | _ -> assert false) frame_clauses + @ List.map (function + | (_,[|s_C|]),body_C -> s_C, false, body_C + | _ -> assert false) move_clauses in let turn_data = try Some (check_turn_based players rules) with Not_turn_based -> None in @@ -1114,10 +1153,13 @@ create_rule_cands (turn_data <> None) used_vars next_cls clauses in let rule_cands = filter_rule_cands static_base defined_rels rule_cands in - let all_state_terms = - Aux.concat_map state_terms (List.map snd clauses) in let term_arities = Aux.unique_sorted - (Aux.concat_map term_arities all_state_terms) in + (Aux.concat_map term_arities ground_state_terms) in + let defined_rel_arities = List.map + (fun rel -> + let args = List.assoc rel (List.map fst clauses) in + rel, Array.length args) + defined_rels in let transl_data = { TranslateFormula.f_paths = f_paths; m_paths = m_paths; @@ -1126,6 +1168,9 @@ defined_rels = defined_rels; defrel_arg_type = ref []; (* built in TranslateFormula *) term_arities = term_arities; + rel_default_path = + transl_arg_type_no_side defined_rel_arities static_base init_state + (ground_at m_paths); } in let defined_rels = TranslateFormula.build_defrels transl_data clauses in let player_names = Array.to_list Modified: trunk/Toss/GGP/TranslateGame.mli =================================================================== --- trunk/Toss/GGP/TranslateGame.mli 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/GGP/TranslateGame.mli 2011-08-08 20:58:36 UTC (rev 1529) @@ -51,16 +51,16 @@ (* Create the initial structure and assorted data. Exposed for testing purposes. - [players, rules, next_cls, f_paths, m_paths, mask_reps, + [players, rules, frame_cls, move_cls, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, stable_base, init_state, - struc, agg_actions, elem_term_map = create_init_struc clauses] *) + struc, ground_state_terms, elem_term_map = create_init_struc clauses] *) val create_init_struc : GDL.clause list -> GDL.term array * GDL.gdl_rule list * - (GDL.term * bool * GDL.literal list) list * GDL.path_set * + GDL.clause list * GDL.clause list * GDL.path_set * GDL.path_set * GDL.term list * string list * string list * string list * GDL.rel_atom list * GDL.term list * - Structure.structure * GDL.term array list list * + Structure.structure * GDL.term list * GDL.term Aux.IntMap.t Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-08 20:58:36 UTC (rev 1529) @@ -117,13 +117,12 @@ "connect5 translation data" >:: (fun () -> - (* perhaps should be a small test, takes mediocrily long *) let descr = load_rules ("./GGP/examples/connect5.gdl") in let clauses = GDL.expand_players descr in let players, rules, - next_cls, f_paths, m_paths, mask_reps, defined_rels, + frame_cls, move_cls, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, - stable_base, init_state, struc, agg_actions, elem_term_map = + stable_base, init_state, struc, ground_state_terms, elem_term_map = TranslateGame.create_init_struc clauses in assert_equal ~msg:"f_paths" ~printer:(fun x->x) @@ -141,6 +140,8 @@ (String.concat "; " (List.map GDL.term_str mask_reps)); + (* adjacent_cell is a defined relation only because it has + large arity: see {!TranslateGame.defined_arity_above}. *) assert_equal ~msg:"defined_rels" ~printer:(fun x->x) "adjacent_cell, col, conn5, diag1, diag2, exists_empty_cell, exists_line_of_five, goal, legal, next, row, terminal" (String.concat ", " (List.sort String.compare defined_rels)); @@ -222,6 +223,7 @@ (* DiscreteRule.debug_level := 4; *) () + let a () = game_test_case ~game_name:"connect5" ~player:"x" ~own_plnum:0 ~opponent_plnum:1 @@ -263,7 +265,7 @@ (* regen_with_debug ~game_name:"connect4" ~player:"white" *) *) -let exec = +let exec () = Aux.run_test_if_target "TranslateGameTest" ("TranslateGame" >::: [tests; bigtests]) Modified: trunk/Toss/www/reference/reference.tex =================================================================== --- trunk/Toss/www/reference/reference.tex 2011-08-08 05:20:23 UTC (rev 1528) +++ trunk/Toss/www/reference/reference.tex 2011-08-08 20:58:36 UTC (rev 1529) @@ -1306,11 +1306,15 @@ clearly referring to players (\ie arguments of positive \texttt{role} atoms, first arguments to positive \texttt{does} atoms and to \texttt{legal}) by substituting them by players of $G$ (\ie arguments -of \texttt{role} facts), duplicating the clauses. From this transformed -specification, we derive the elements of the Toss structure -(Section~\ref{subsec-elems}), the relations (Section~\ref{subsec-rels}), -the rewriting rules (Section~\ref{subsec-rules}) and finally the move -translation function (Section~\ref{subsec-move-tr}). +of \texttt{role} facts), duplicating the clauses. From this +specification, we derive the elements (Section~\ref{subsec-elems}) and +the stable relations and initial fluents (Section~\ref{subsec-rels}) +of the Toss structure. Having separated the fluent from the stable +part of state terms, we further transform the definition $G$ by +expanding variables corresponding to fluents, and use the transformed +specification to derive the defined relations in Toss, the rewriting +rules (Section~\ref{subsec-rules}) and finally the move translation +function (Section~\ref{subsec-move-tr}). \subsection{Elements of the Toss Structure} \label{subsec-elems} @@ -1624,6 +1628,42 @@ % formulas. %\end{definition} +\subsection{Expanding the GDL Game Definition} + +Prior to further processing, we modify the wave clauses of the +game. Let $\calN \in \mathrm{Next}_{W}$, we add to the body of $\calN$ +a \texttt{true} atom $(\mathtt{true} \ BL(s_\calN)$ (where +$\mathtt{BL}(t)=t\big[\calP_f \ot \mathtt{BLANK}\big]$). The added +state term will be the corresponding LHS element of the RHS element +introduced by the clause. + +Now we discuss transformations of the game $G$ that result in a longer +(having more clauses) but simpler definition. \emph{Eliminating a GDL + variable $x \in FV(\calC)$ by a set of terms $T$} means replacing +the clause $C$ the variable occurs in, with a set of clauses $\calC_t += \calC[v \ot t]$ for $t \in T$. First such transformation initiated +the translation process: we eliminated variables ranging over players +(by virtue of occurring in \texttt{does}, \texttt{legal} or +\texttt{goal} atoms), by the players of the game. + +Before generating Toss formulas we also transform the definition $G$ +by grounding all variables that have occurrences at fluent paths, \ie +eliminating these variables by constants that occur at these paths in +ground state terms $\calS$. + +After eliminating variables, we eliminate arguments of a defined +relation that are ground in the head of each clause defining the +relation. We generate a new relation name for each value of the +argument. We replace all atoms of the old relation by those new +relations to which the eliminated argument of the atom can be +instantiated, if necessary duplicating the clause containing the atom +(if some variables need to be eliminated by the instantiation). + +As an optimization, instead of duplicating the clause, if a variable +is local to an atom (in all cases of eliminating a variable), we can +replace the atom by a disjunction of corresponding atoms, or if it is +a negative literal, by a conjunction of negated atoms. + \subsection{Structure Rewriting Rules} To create the structure rewriting rule for the Toss game, @@ -1632,13 +1672,6 @@ be the players in $G$, \ie let there be \texttt{(role $p_1$)} up to \texttt{(role $p_n$)} facts in $G$, in this order. -Prior to further processing, we modify the wave clauses of the -game. Let $\calN \in \mathrm{Next}_{W}$, we add to the body of $\calN$ -a \texttt{true} atom $(\mathtt{true} \ BL(s_\calN)$ (where -$\mathtt{BL}(t)=t\big[\calP_f \ot \mathtt{BLANK}\big]$). The added -state term will be the corresponding LHS element of the RHS element -introduced by the clause. - \subsubsection{Move Clauses} By GDL specification, a legal joint move of the players is a tuple of @@ -2011,7 +2044,7 @@ \ldots, \mathtt{(<= (R \ t^k_1 \ldots t^k_n) \ b_k)}.\] For the $i$th argument of $R$ ($i \in \{1,\ldots,n\}$) we will find $\mathtt{ArgType}(R,i)$ with possible values -$(\mathtt{DefSide},\calS_i,p_i)$ and $(\mathtt{CallSide},p_i)$, with a mapping $\calS_i$ into state terms +$(\mathtt{DefSide},\calS_i,p_i)$, $(\mathtt{CallSide},p_i)$ and $(\mathtt{NoSide},p_i)$, with a mapping $\calS_i$ into state terms corresponding to the argument in a given context and a path $p_i \in \calP_m$ corresponding to the subterm position selected to ``transfer'' the argument. @@ -2034,21 +2067,30 @@ the domain of $\calS_i(p_i)$ is maximal. Set $\mathtt{ArgType}(R,i) = (\mathtt{CallSide},p_i)$. -The specific definition of $\mathtt{ArgType}(R,i) = -(\mathtt{CallSide},p_i)$ is not relevant for correctness, but (for -correctness) $p_i \in \calP_m$ should be a path whose domain, \ie the -set $\big\{t \big| s\tpos_{p_i} = t, s \in \calS\big\}$, contains the -domain of the $i$th argument of $R$, \ie the sum of projections of $R$ -on $i$th argument for all possible game states. The current definition -above does not guarantee this; the exact implementation may further -evolve as $\mathtt{ArgType}$ is relevant for the quality of -translation (\ie how many simplifications can be applied, see -Section~\ref{sec-game-simpl}). +In case neither $\mathtt{DefSide}$ nor $\mathtt{CallSide}$ approach is +satisfactory, we set $\mathtt{ArgType}(R,i) = (\mathtt{NoSide},p_i)$, +where the path $p_i \in \calP_m$ is selected so that the intersection +of the projection of the graph of $R$ for the initial game state +$g_{R,i} = \{s | G \vdash R(t_1,\ldots,t_n) \textit{ for any } +\ol{t} \textit{ s.t. } t_i = s\}$, and the set of subterms of state +terms at path $p_i$, $g_{p_i} = \{s \tpos_{p_i} | s \in \calS\}$, is +maximal w.r.t. cardinality ($p_i = \arg \max_{p \in \calP_m} \left| + g_{R,i} \cap g_p \right|$). +For correctness, $p_i \in \calP_m$ should be a path whose domain, \ie +the set $\big\{t \big| s\tpos_{p_i} = t, s \in \calS\big\}$, contains +the domain of the $i$th argument of $R$, \ie the sum of projections of +$R$ on $i$th argument for all possible game states. The current +definition above does not guarantee this; the exact implementation may +further evolve as $\mathtt{ArgType}$ is relevant for the quality of +translation (\ie both for correctness and how many simplifications can +be applied, see Section~\ref{sec-game-simpl}). + We are ready to provide the translated definition $R_{def}$. Let $v_1,\ldots,v_n$ be fresh Toss variables, let $\calI_R = \big\{i \big| \mathtt{ArgType}(R,i) = -(\mathtt{DefSide},\calS_i,p_i)\big\}$ and $p_{R,i}$ be such that $\mathtt{ArgType}(R,i) = +(\mathtt{DefSide},\calS_i,p_i)\big\}$ and $p_{R,i}$ be such that +$\mathtt{ArgType}(R,i) = (\mathtt{DefSide},\calS_i,p_{R,i})$ or $\mathtt{ArgType}(R,i) = (\mathtt{CallSide},p_{R,i})$. Let $\mathtt{BL}(p \ot t)$ for a path $p$ and term $t$ be a state term containing $t$ at path $p$, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-08 05:20:33
|
Revision: 1528 http://toss.svn.sourceforge.net/toss/?rev=1528&view=rev Author: lukaszkaiser Date: 2011-08-08 05:20:23 +0000 (Mon, 08 Aug 2011) Log Message: ----------- Toss website update - recent presentations. Modified Paths: -------------- trunk/Toss/www/Publications/all.bib Added Paths: ----------- trunk/Toss/www/pub/agi11_demo_slides.pdf trunk/Toss/www/pub/agi11_poster.pdf trunk/Toss/www/pub/giga11_slides.pdf Modified: trunk/Toss/www/Publications/all.bib =================================================================== --- trunk/Toss/www/Publications/all.bib 2011-08-05 18:35:09 UTC (rev 1527) +++ trunk/Toss/www/Publications/all.bib 2011-08-08 05:20:23 UTC (rev 1528) @@ -4,6 +4,30 @@ # TALKS +@inproceedings{KAGI11, + author={Toss}, + title={Artificial General Game Intelligence}, + url = {/pub/agi11_demo_slides.pdf}, + booktitle= {AGI, Mountain View}, + year={2011 Talk} +} + +@inproceedings{KAGI11POSTER, + author={Toss}, + title={Artificial General Game Intelligence - Poster}, + url = {/pub/agi11_poster.pdf}, + booktitle= {AGI, Mountain View}, + year={2011 Talk} +} + +@inproceedings{KGIGA11, + author={Toss}, + title={First Order Logic with Counting for General Game Playing}, + url = {/pub/giga11_slides.pdf}, + booktitle= {GIGA Workshop, Barcelona}, + year={2011 Talk} +} + @inproceedings{KGTJ10, author={Toss}, title={Playing Games when States have Rich Structure}, Added: trunk/Toss/www/pub/agi11_demo_slides.pdf =================================================================== (Binary files differ) Property changes on: trunk/Toss/www/pub/agi11_demo_slides.pdf ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/www/pub/agi11_poster.pdf =================================================================== --- trunk/Toss/www/pub/agi11_poster.pdf (rev 0) +++ trunk/Toss/www/pub/agi11_poster.pdf 2011-08-08 05:20:23 UTC (rev 1528) @@ -0,0 +1,49359 @@ +%PDF-1.4 +%\xD0\xD4\xC5\xD8 +3 0 obj +<< /pgfprgb [/Pattern /DeviceRGB] >> +endobj +1 0 obj +<<>> +endobj +2 0 obj +<<>> +endobj +19 0 obj << +/Length 56224 +/Filter /FlateDecode +>> +stream +x\xDA\xEC\xBD]\x93%\xC7q%\xF8\x8E_Q\xFB\xD8ν\xCC\xEF\x8F1\x9B\x87\xC5P\x84I\xB3c6$a\xA6J\xB3\xD6 \xB2\xA5\xEE\x86\x80\xC3\xD1\xFE\xFAu\xCF\xCC\xF0s<\xC2\xF3fUU\xB6\xBBC\xA1\xDA\xCB\xCB3\xFCx|\xCF\xF0\x88\xAC\x9E\xFE\xF0T=}\xF5Y\x95\xFD\xB7\x96\xFF[=\xD5Os{\xED\xBB\xF6\xA9\x99\xDA\xE1Z5\xF5\xD37?\xFBӓh}\xF5\xB4\xA8~V]\xDBy\xEA\x9F\xFE\xF2\xA4b\xF9\x97\xBE\xBD\xAE\xAE\x9F\xBA\xB9\xBEN\xFD4\xF6OO\x88빻6\xF5X7O\x9E>k\x9An\xBC\xCEU[w\xBBr\x98\xF9w\xFED\x9E\xF0\xF7O\x9F}z2o\xEAj\x9E\xAE];\xF7\xF5S۵ת\xE7V\z\xFA\xAC\xAE\xF5P5͢\xD7_\xE7qh\xFB\xA7\xEAZ-\xFFS\xFD\xAF\xB4\xF5\xE9RoB\xFE\xA5\xBAnϸ\xF4\xD5\xF2?A\xEA\xBF\xFAX?\xFD\xF2\xFB\xCF~\xFDٯ\x9F\xF4\xFF\xBDa|\x96\xFA\xAD\xC1\xE3`>\xBA\xBFۓ7}\xED\xC6~h\x9Fj\x91^\xA7\xA1\x86\xA7z\xEA\xAF\xCDЋ2\xF9`\xB2o\xE4yu\xDB\xAEg\xD6m\xDAn\xBEJtڙ̲\x94\xA2&6\xE8][]\x87\xAAjD\x96\xFB\xAA\xBAN\xD5<\xF7\xD4 +\xC8\xC4\xB5r\x86Ѭ\x86@|\xB3`\xBB\x9D\xEFy\x91\x92\x{19DE79}\xB6M\xD5\xF5\x8B\xDApm\xDB~j~\x96\x81\xD9p\xCF[;\x9F\xFCU\xD5\xCEj\xBE\xABƩ\x93\xFF\x8E2\x9E~\xF8\xC3\xD3\xCEo~\xF39wiF\x9D,\xA5\xE5\x8D~\xD1M\xD7zj\xAB:\xEB\x9E7cƊ\xAE\xCB&O\xFA\xA7'\x9B\xCE\xCD\xC7\xF5\xFF$\x9D\xC2+]~\xBE2\x8B2\xE3\xFF\x9F.\xE9X\xF2T5\xC5?\xEB\xF1Y\xDD\xE3\xF2\xAFFb\x99Ŀ\xF8[\xF0ڜԊ\xB5j\x855\xB7\xD6\xE7\xD5\xCB\xF3\xF8\xBFv^\xF4\xB5\xCCNU/=\xA7\xB9\xF6\xC3t\xC2 +X2$\x86J\x9E\xDEMO\x97\xB6\xA7k?\xCDj\xE6˯\xA5\xAB\xE8@\xA95\xF0\xCD\xD3\xD7\xFF\xF4\x94\xF4L\xED\xEBo\x9F~\xF7\xF9\xFF\xF5\xC3O\xEF\xFF\xA1j\xBBo\xFB\xF0ť\xC6Ͽ\xFA\xEE\xD3w?\xD8?\xDE}\xFCN>\xFF\xDBO?}\xF7\xE1\xC3\xFB?|\xF7\xE9\x9B\xEF\xBE\xF8ǯ\xFF\xF9\xDA\xDAP\x98^\x91\xA0!\xB2\xFAy!G\xEFC\xAA\xAE&\xED<\xCDS#\xE3jl\xEFB\x8A[bv.0\xC4#\xE9\xE1\xC1t\xDF\xEC\x9F +\xED\xD5}SU\xD3\xFE/\xF2\xF9?\xFE\x93b]:Ե\xEDS?\xD7i\x9E\x9BuH7ӵ톡\xAAeB\x9B\xAAT\xFC\xDBb\xB8\x89^ݍ\x8BV\xDF\xDC5ܞ'\xFAv/,m\xD0` +\x83\xB4\xBF\xB6\xAE-ͧ\xAE=\xD5ҪQ\xFAF\xDB_U\xA2\xFB\xA7\xEF\xFC\xF1\xFA\xE3?]?}\xF7\xD3\xD2]\xDCmW\xEBl\x9C\xFA\xCA\xE6\xF2>\xAF\xBD\x84\xA0l\xBBk;N\xD2\xE6\x8F,\xAE;\xF9\x83y^\xD7\xE1J\xD1k\xBBn\xD1z\x96fCf\xADyVX$\x98]\x8D/v\xFB\xEE:β\xEC,\xE3Љ\x9E¢\xCBf\xBF\xE2\xF2M\xDD\xFC\xF9_\xBEh\xEB\xCF\xDF\xFD\xF8\xFF~qi\xAA\xFE\xF3\xFF\xF6\xEE\x8B\xFA\xF3\xF7?~\xF7\xC3\xFA\xCFw\x9F\xBE\xD5\xBAR\xB5\xFB\xFC\xB7?\xBD\xD3\xD9\xE2\xD3\xFBw\xFF\x92Ok\x9B\xB8I\xE6\xE6\xF4\x85\xBC\xDEЬ\xFB\xEA\xDAH\xA7\x9D<\x9CMӶ\xCBY:z= ];\xC6x6u]_\x99Ke-\xE9\xDB;W\x82\xFA\xDAN\xC22VS\xF4\xF3\xB2L\xD3\xF2\xF3\xF6\x9Fuh\x82U\xE0\x92\x9ApA\xB29\xE5OO\x90|r3\x92\xAC\xEC\xB2 + +?9NP֑\xDE\xE8\x82#q[!GO\x88%\xF8S_\xAD\xF3HS\xCF\xF2\xAFq\xEB=1\x8Cl\x8Bt\xF0\xFBG\xF9\xAB\xB9\x91n-0\xB6\xD38\xAC任\xCEC7\xF7\xBE2\xE7\xFD<\xB9I[R\xA0\x88$h[&Yï\xC3\xD8=o\x9CՕx\xA0Du\x9C\xA6\xEB4 +\xBC\xB4\xCA\3\xCCuh\x9B\x9Ai\xAD+\xAB\x9C\xAF\xBE\xFA\xDBm!\xFD\xFE݇\xFF\xFCť\x9B\xE6Ͽ\xFD\xEE\xE3\xF7\x9F~\xFC\xE9\x87w?}\xB7\xFE\xEEݧ[\xD7\xD8\xDF\xCB\xEAϿ\xA7\xF9÷\xEB/\xFF\xB0\xAD\xC0\xA3\xCCh\xABֻ\xF5\x9F?|\xBF\xA9\xFF\xB4\x89?m\xF1\xC7w\xFFk\xFB\x8B?\xBE\xFF\xB8\xFE\xEE_?\x88\xCD\xEA\xF3[\xC5﷿\xF8\x8B\xCAdQ\xCFGr\xEEN\xB6\x9Ao\xB0^\xD7,k\xDF\xCB˻z\xBA6\xBD\xCE\xE9ʞ\xC6\xE6v\xBF\xFFu\xF1\xB3ٴ\x96e\xA0Us\xFACӏwN |
From: <luk...@us...> - 2011-08-05 18:35:16
|
Revision: 1527 http://toss.svn.sourceforge.net/toss/?rev=1527&view=rev Author: lukstafi Date: 2011-08-05 18:35:09 +0000 (Fri, 05 Aug 2011) Log Message: ----------- GDL translation fixing: initial structure generation bug (wrong terms as elements); setting up formula translation testing. Modified Paths: -------------- trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/Server/Tests.ml Added Paths: ----------- trunk/Toss/GGP/TranslateFormulaTest.ml Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-05 12:09:48 UTC (rev 1526) +++ trunk/Toss/GGP/GDL.mli 2011-08-05 18:35:09 UTC (rev 1527) @@ -174,6 +174,8 @@ val at_paths : ?fail_at_missing:bool -> path_set -> term -> term list val empty_path_set : path_set +(** Add path to a set. First argument gives term arities. *) +val add_path : (string -> int) -> path -> path_set -> path_set val paths_union : path_set -> path_set -> path_set (** List the paths in a set. *) Added: trunk/Toss/GGP/TranslateFormulaTest.ml =================================================================== --- trunk/Toss/GGP/TranslateFormulaTest.ml (rev 0) +++ trunk/Toss/GGP/TranslateFormulaTest.ml 2011-08-05 18:35:09 UTC (rev 1527) @@ -0,0 +1,74 @@ +open OUnit +open TranslateFormula + +let parse_game_descr s = + GDLParser.parse_game_description KIFLexer.lex + (Lexing.from_string s) + +let parse_term s = + GDLParser.parse_term KIFLexer.lex + (Lexing.from_string s) + +let pte = parse_term + +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 = + GDLParser.parse_game_description KIFLexer.lex + (Lexing.from_channel f) in + descr + +let connect5_data = + let term_arities = + ["control", 1; "cell", 3; "x", 0; "o", 0; "b", 0; "mark", 2] in + let arities f = List.assoc f term_arities in + let f_paths = List.fold_right (GDL.add_path arities) + [["cell", 2]; ["control", 0]] GDL.empty_path_set in + let m_paths = List.fold_right (GDL.add_path arities) + [["cell", 0]; ["cell", 1]] GDL.empty_path_set in + let all_paths = GDL.paths_union f_paths m_paths in + let mask_reps = + [GDL.Func ("control", [|GDL.blank|]); + GDL.Func ("cell", [|GDL.blank; GDL.blank; GDL.blank|])] in + let defined_rels = [ + "adjacent_cell"; "col"; "conn5"; "diag1"; "diag2"; + "exists_empty_cell"; "exists_line_of_five"; "goal"; "legal"; "next"; + "row"; "terminal"] in + { + f_paths = f_paths; + m_paths = m_paths; + all_paths = all_paths; + mask_reps = mask_reps; + defined_rels = defined_rels; + defrel_arg_type = ref []; + term_arities = term_arities; + } + +let tests = "TranslateFormula" >::: [ + + "defined relations connect5" >:: + (fun () -> + let descr = load_rules ("./GGP/examples/connect5.gdl") in + let clauses = GDL.expand_players descr in + let transl_data = connect5_data in + let defined_rels = + TranslateFormula.build_defrels transl_data clauses in + let res = String.concat "\n" + (List.map (fun (rel,(args,body)) -> + rel^"("^String.concat ", " args^ + ") = "^Formula.str body) defined_rels) in + assert_equal ~msg:"connect5 noop moves by players" + ~printer:(fun x->x) + "" res; + ); + +] + +let exec = Aux.run_test_if_target "TranslateFormulaTest" tests Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-05 12:09:48 UTC (rev 1526) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-05 18:35:09 UTC (rev 1527) @@ -327,6 +327,7 @@ (String.concat ", " struc_rels) (String.concat ", " defined_rels) ); (* }}} *) + let stable_rels = ref Aux.Strings.empty in let struc = List.fold_left (fun struc rel -> let arity = List.assoc rel arities in @@ -338,37 +339,42 @@ let tup = Array.of_list (List.map2 at_path etup ptup) in if rel = "EQ_" && arity = 2 && tup.(0) = tup.(1) || List.mem (rel, tup) static_base - then + then ( + stable_rels := Aux.Strings.add fact_rel !stable_rels; Structure.add_rel_named_elems struc fact_rel - (Array.map term_to_name tup) + (* we add the element repr. tuple if subterms at ptup + are in relation *) + (Aux.array_map_of_list term_to_name etup)) else struc ) struc elem_tups ) struc path_tups ) (Structure.empty_structure ()) struc_rels in (* adding anchor and fluent predicates *) - let add_pred rels struc paths elements = + let add_pred sig_only rels struc paths elements = List.fold_left (fun struc path -> Aux.fold_left_try (fun struc elem -> let pred = pred_on_path_subterm path (at_path elem path) in - if List.mem pred !rels then struc - else ( - rels := pred :: !rels; - let tup = [|elem|] in - Structure.add_rel_named_elems struc pred - (Array.map term_to_name tup)) + rels := Aux.Strings.add pred !rels; + if sig_only + then Structure.add_rel_name pred 1 struc + else + (* in case the state term is not element repr. yet *) + let elem = simult_subst f_paths blank elem in + let tup = [|term_to_name elem|] in + Structure.add_rel_named_elems struc pred tup ) struc elements ) struc paths in - let stable_rels = ref [] in - let fluents = ref [] in - let struc = add_pred stable_rels struc m_pathl element_reps in - let struc = add_pred fluents struc f_pathl init_state in + let fluents = ref Aux.Strings.empty in + let struc = add_pred false stable_rels struc m_pathl element_reps in + let struc = add_pred false fluents struc f_pathl init_state in + let struc = add_pred true fluents struc f_pathl element_terms in (* adding mask predicates *) let all_paths = paths_union m_paths f_paths in let struc = List.fold_left (fun struc m -> let pred = term_to_name m in - stable_rels := pred :: !stable_rels; + stable_rels := Aux.Strings.add pred !stable_rels; List.fold_left (fun struc elem -> if simult_subst all_paths blank elem = m then ( @@ -378,7 +384,7 @@ ) struc element_reps ) struc mask_reps in (* {{{ log entry *) - if !debug_level > 2 then ( + if !debug_level > 4 then ( Printf.printf "create_init_struc: resulting struc=\n%s\n%!" (Structure.str struc) ); @@ -392,7 +398,7 @@ Structure.find_elem struc (term_to_name e), e) element_reps) in players, rules, next_clauses, f_paths, m_paths, mask_reps, defined_rels, - !stable_rels, !fluents, + Aux.Strings.elements !stable_rels, Aux.Strings.elements !fluents, static_base, init_state, struc, agg_actions, elem_term_map (* substitute a "next" clause with frame info *) Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-05 12:09:48 UTC (rev 1526) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-05 18:35:09 UTC (rev 1527) @@ -143,18 +143,18 @@ assert_equal ~msg:"defined_rels" ~printer:(fun x->x) "adjacent_cell, col, conn5, diag1, diag2, exists_empty_cell, exists_line_of_five, goal, legal, next, row, terminal" - (String.concat ", " defined_rels); + (String.concat ", " (List.sort String.compare defined_rels)); assert_equal ~msg:"fluents" ~printer:(fun x->x) - "control_0x, control_0o, cell_2b, cell_2x, cell_2o" + "cell_2b, cell_2o, cell_2x, control_0o, control_0x" (String.concat ", " fluents); assert_equal ~msg:"stable_rels" ~printer:(fun x->x) - "A LOT OF THEM" + "EQ___cell_0__cell_0, EQ___cell_0__cell_1, EQ___cell_1__cell_0, EQ___cell_1__cell_1, adjacent__cell_0__cell_0, adjacent__cell_0__cell_1, adjacent__cell_1__cell_0, adjacent__cell_1__cell_1, cell_0a, cell_0b, cell_0c, cell_0d, cell_0e, cell_0f, cell_0g, cell_0h, cell_1a, cell_1b, cell_1c, cell_1d, cell_1e, cell_1f, cell_1g, cell_1h, cell__BLANK___BLANK___BLANK_, control__BLANK_, coordinate__cell_0, coordinate__cell_1, nextcol__cell_0__cell_0, nextcol__cell_0__cell_1, nextcol__cell_1__cell_0, nextcol__cell_1__cell_1" (String.concat ", " stable_rels); assert_equal ~msg:"structure elements" ~printer:(fun x->x) - "cell_a_a__BLANK_, cell_a_b__BLANK_, cell_a_c__BLANK_, cell_a_d__BLANK_, cell_a_e__BLANK_, cell_a_f__BLANK_, cell_a_g__BLANK_, cell_a_h__BLANK_, cell_b_a__BLANK_, cell_b_b__BLANK_, cell_b_c__BLANK_, cell_b_d__BLANK_, cell_b_e__BLANK_, cell_b_f__BLANK_, cell_b_g__BLANK_, cell_b_h__BLANK_, cell_c_a__BLANK_, cell_c_b__BLANK_, cell_c_c__BLANK_, cell_c_d__BLANK_, cell_c_e__BLANK_, cell_c_f__BLANK_, cell_c_g__BLANK_, cell_c_h__BLANK_, cell_d_a__BLANK_, cell_d_b__BLANK_, cell_d_c__BLANK_, cell_d_d__BLANK_, cell_d_e__BLANK_, cell_d_f__BLANK_, cell_d_g__BLANK_, cell_d_h__BLANK_, cell_e_a__BLANK_, cell_e_b__BLANK_, cell_e_c__BLANK_, cell_e_d__BLANK_, cell_e_e__BLANK_, cell_e_f__BLANK_, cell_e_g__BLANK_, cell_e_h__BLANK_, cell_f_a__BLANK_, cell_f_b__BLANK_, cell_f_c__BLANK_, cell_f_d__BLANK_, cell_f_e__BLANK_, cell_f_f__BLANK_, cell_f_g__BLANK_, cell_f_h__BLANK_, cell_g_a__BLANK_, cell_g_b__BLANK_, cell_g_c__BLANK_, cell_g_d__BLANK_, cell_g_e__BLANK_, cell_g_f__BLANK_, cell_g_g__BLANK_, cell_g_h__BLANK_, cell_h_a__BLANK_, cell_h_b__BLANK_, cell_h_c__BLANK_, cell_h_d__BLANK_, cell_h_e__BLANK_, cell_h_f__BLANK_, cell_h_g__BLANK_, cell_h_h__BLANK_" + "cell_a_a__BLANK_, cell_a_b__BLANK_, cell_a_c__BLANK_, cell_a_d__BLANK_, cell_a_e__BLANK_, cell_a_f__BLANK_, cell_a_g__BLANK_, cell_a_h__BLANK_, cell_b_a__BLANK_, cell_b_b__BLANK_, cell_b_c__BLANK_, cell_b_d__BLANK_, cell_b_e__BLANK_, cell_b_f__BLANK_, cell_b_g__BLANK_, cell_b_h__BLANK_, cell_c_a__BLANK_, cell_c_b__BLANK_, cell_c_c__BLANK_, cell_c_d__BLANK_, cell_c_e__BLANK_, cell_c_f__BLANK_, cell_c_g__BLANK_, cell_c_h__BLANK_, cell_d_a__BLANK_, cell_d_b__BLANK_, cell_d_c__BLANK_, cell_d_d__BLANK_, cell_d_e__BLANK_, cell_d_f__BLANK_, cell_d_g__BLANK_, cell_d_h__BLANK_, cell_e_a__BLANK_, cell_e_b__BLANK_, cell_e_c__BLANK_, cell_e_d__BLANK_, cell_e_e__BLANK_, cell_e_f__BLANK_, cell_e_g__BLANK_, cell_e_h__BLANK_, cell_f_a__BLANK_, cell_f_b__BLANK_, cell_f_c__BLANK_, cell_f_d__BLANK_, cell_f_e__BLANK_, cell_f_f__BLANK_, cell_f_g__BLANK_, cell_f_h__BLANK_, cell_g_a__BLANK_, cell_g_b__BLANK_, cell_g_c__BLANK_, cell_g_d__BLANK_, cell_g_e__BLANK_, cell_g_f__BLANK_, cell_g_g__BLANK_, cell_g_h__BLANK_, cell_h_a__BLANK_, cell_h_b__BLANK_, cell_h_c__BLANK_, cell_h_d__BLANK_, cell_h_e__BLANK_, cell_h_f__BLANK_, cell_h_g__BLANK_, cell_h_h__BLANK_, control__BLANK_" (String.concat ", " (List.map (Structure.elem_name struc) (Structure.elements struc))) ); @@ -236,48 +236,7 @@ "control__blank_", "control_MV1"] ~loc1_noop:"noop" ~loc1_move:"(mark f g)" -let a () = - let descr = load_rules ("./GGP/examples/connect5.gdl") in - let clauses = GDL.expand_players descr in - let players, rules, - next_cls, f_paths, m_paths, mask_reps, defined_rels, - stable_rels, fluents, - stable_base, init_state, struc, agg_actions, elem_term_map = - TranslateGame.create_init_struc clauses in - assert_equal ~msg:"f_paths" ~printer:(fun x->x) - "cell_2; control_0" - (String.concat "; " - (List.map GDL.path_str (GDL.paths_to_list f_paths))); - - assert_equal ~msg:"m_paths" ~printer:(fun x->x) - "cell_0; cell_1" - (String.concat "; " - (List.map GDL.path_str (GDL.paths_to_list m_paths))); - - assert_equal ~msg:"mask_reps" ~printer:(fun x->x) - "(cell _BLANK_ _BLANK_ _BLANK_); (control _BLANK_)" - (String.concat "; " - (List.map GDL.term_str mask_reps)); - - assert_equal ~msg:"defined_rels" ~printer:(fun x->x) - "adjacent_cell, col, conn5, diag1, diag2, exists_empty_cell, exists_line_of_five, goal, legal, next, row, terminal" - (String.concat ", " defined_rels); - - assert_equal ~msg:"fluents" ~printer:(fun x->x) - "control_0x, control_0o, cell_2b, cell_2x, cell_2o" - (String.concat ", " fluents); - - assert_equal ~msg:"stable_rels" ~printer:(fun x->x) - "A LOT OF THEM" - (String.concat ", " stable_rels); - - assert_equal ~msg:"structure elements" ~printer:(fun x->x) - "cell_a_a__BLANK_, cell_a_b__BLANK_, cell_a_c__BLANK_, cell_a_d__BLANK_, cell_a_e__BLANK_, cell_a_f__BLANK_, cell_a_g__BLANK_, cell_a_h__BLANK_, cell_b_a__BLANK_, cell_b_b__BLANK_, cell_b_c__BLANK_, cell_b_d__BLANK_, cell_b_e__BLANK_, cell_b_f__BLANK_, cell_b_g__BLANK_, cell_b_h__BLANK_, cell_c_a__BLANK_, cell_c_b__BLANK_, cell_c_c__BLANK_, cell_c_d__BLANK_, cell_c_e__BLANK_, cell_c_f__BLANK_, cell_c_g__BLANK_, cell_c_h__BLANK_, cell_d_a__BLANK_, cell_d_b__BLANK_, cell_d_c__BLANK_, cell_d_d__BLANK_, cell_d_e__BLANK_, cell_d_f__BLANK_, cell_d_g__BLANK_, cell_d_h__BLANK_, cell_e_a__BLANK_, cell_e_b__BLANK_, cell_e_c__BLANK_, cell_e_d__BLANK_, cell_e_e__BLANK_, cell_e_f__BLANK_, cell_e_g__BLANK_, cell_e_h__BLANK_, cell_f_a__BLANK_, cell_f_b__BLANK_, cell_f_c__BLANK_, cell_f_d__BLANK_, cell_f_e__BLANK_, cell_f_f__BLANK_, cell_f_g__BLANK_, cell_f_h__BLANK_, cell_g_a__BLANK_, cell_g_b__BLANK_, cell_g_c__BLANK_, cell_g_d__BLANK_, cell_g_e__BLANK_, cell_g_f__BLANK_, cell_g_g__BLANK_, cell_g_h__BLANK_, cell_h_a__BLANK_, cell_h_b__BLANK_, cell_h_c__BLANK_, cell_h_d__BLANK_, cell_h_e__BLANK_, cell_h_f__BLANK_, cell_h_g__BLANK_, cell_h_h__BLANK_" - (String.concat ", " - (List.map (Structure.elem_name struc) (Structure.elements struc))) - - let a () = match test_filter [(* "GDLBig:1:breakthrough" *) "GDLBig:0:connect5"] @@ -303,3 +262,8 @@ (* regenerate ~debug:true ~game_name:"pawn_whopping" ~player:"x"; *) (* regen_with_debug ~game_name:"connect4" ~player:"white" *) *) + +let exec = + Aux.run_test_if_target "TranslateGameTest" + ("TranslateGame" >::: [tests; bigtests]) + Modified: trunk/Toss/Server/Tests.ml =================================================================== --- trunk/Toss/Server/Tests.ml 2011-08-05 12:09:48 UTC (rev 1526) +++ trunk/Toss/Server/Tests.ml 2011-08-05 18:35:09 UTC (rev 1527) @@ -35,6 +35,7 @@ "GameSimplTest", [GameSimplTest.tests]; "GDLTest", [GDLTest.tests]; "TranslateGameTest", [TranslateGameTest.tests; TranslateGameTest.bigtests]; + "TranslateFormulaTest", [TranslateFormulaTest.tests]; ] let server_tests = "Server", [ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-05 12:10:01
|
Revision: 1526 http://toss.svn.sourceforge.net/toss/?rev=1526&view=rev Author: lukstafi Date: 2011-08-05 12:09:48 +0000 (Fri, 05 Aug 2011) Log Message: ----------- GDL translation fixing: fluent paths bug, initial structure generation test. Modified Paths: -------------- trunk/Toss/GGP/GDL.ml trunk/Toss/GGP/GDL.mli trunk/Toss/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGame.mli trunk/Toss/GGP/TranslateGameTest.ml Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-04 16:40:12 UTC (rev 1525) +++ trunk/Toss/GGP/GDL.ml 2011-08-05 12:09:48 UTC (rev 1526) @@ -436,12 +436,11 @@ used_vars := Aux.add_strings (List.map snd sb) !used_vars; let sb = List.map (fun (v,t) -> v, Var t) sb in List.map (subst_br sb) brs in - (* FIXME: make sure it's OK!!! *) let expand_atom (rel, args as atom) (sb, (head, r_body, r_neg_body)) = (let try def_brs = freshen_brs (List.assoc rel defs) in let args = Array.map (subst sb) args in - List.map (fun (params,d_body,d_neg_body) -> + Aux.map_try (fun (params,d_body,d_neg_body) -> let sb = unify sb (Array.to_list params) (Array.to_list args) in let r_br = head, d_body @ r_body, d_neg_body @ r_neg_body in @@ -733,21 +732,21 @@ List.map (fun sb -> subst_clause sb clause) sbs in Aux.concat_map exp_clause clauses -(** Partition relations into stable (not depending, even indirectly, +(** Partition relations into static (not depending, even indirectly, on "true") and remaining ones. *) -let stable_rels defs = - let rec aux nonstable remaining = +let static_rels defs = + let rec aux nonstatic remaining = let more = Aux.map_some (fun (rel, branches) -> if List.exists (fun (_, body, neg_body) -> let called = List.map fst (body @ neg_body) in List.exists (fun rel -> rel = "true" || - List.mem rel nonstable) called + List.mem rel nonstatic) called ) branches then Some rel else None ) remaining in - if more = [] then List.map fst remaining, nonstable - else aux (more @ nonstable) + if more = [] then List.map fst remaining, nonstatic + else aux (more @ nonstatic) (List.filter (fun (rel,_) -> not (List.mem rel more)) remaining) in aux [] defs Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-04 16:40:12 UTC (rev 1525) +++ trunk/Toss/GGP/GDL.mli 2011-08-05 12:09:48 UTC (rev 1526) @@ -110,9 +110,9 @@ Aggregate and random playout, player-denoting variable elimination. *) -(** Partition relations into stable (not depending, even indirectly, +(** Partition relations into static (not depending, even indirectly, on "true") and remaining ones. *) -val stable_rels : gdl_defs -> string list * string list +val static_rels : gdl_defs -> string list * string list (** Besides the aggregate playout, also return the separation of rules @@ -178,3 +178,5 @@ (** List the paths in a set. *) val paths_to_list : path_set -> path list + +val path_str : path -> string Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-04 16:40:12 UTC (rev 1525) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-05 12:09:48 UTC (rev 1526) @@ -1,5 +1,21 @@ (** {2 Translating GDL definition: Toss rules and initial structure.} + Some terminology -- try to comply. + + static relation: GDL relation not even indirectly depending on + "true" nor "does" + + dynamic relation: GDL relation depending on "true" (a relation + that is not static) + + stable relation: a Toss structure relation that is not changed by + any rewrite + + fluent relation: a Toss structure relation that is changed by + rewriting + + defined relation: a Toss defined relation (i.e. does not normally + occur in the structure) *) open GDL @@ -8,7 +24,7 @@ (** Local level of logging. *) let debug_level = ref 0 -(** Translate stable relations that otherwise would be translated as +(** Translate static relations that otherwise would be translated as structure relations, but have arity above the threshold, as defined relations. *) let defined_arity_above = ref 2 @@ -101,6 +117,7 @@ not (siz1 > siz2) && pn2 >= pn1 in let best = Aux.maximal cmp gens in (* avoid "frame wave" if possible *) + (* FIXME: TODO: handle frame waves as in updated reference spec *) let t, (ps, _, _) = if !nonerasing_frame_wave then @@ -123,9 +140,18 @@ let fluent_paths_and_frames clauses = let defs = defs_of_rules (Aux.concat_map rules_of_clause clauses) in - let stable, nonstable = stable_rels defs in + let static, nonstatic = static_rels defs in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "fluent_paths_and_frames: static=%s; nonstatic=%s\n%!" + (String.concat ", " static) (String.concat ", " nonstatic) + ); + (* }}} *) let inline_defs = - List.filter (fun (rel,_) -> List.mem rel nonstable) defs in + List.filter (fun (rel,_) -> List.mem rel nonstatic) defs in + let inline_defs = + ("does", List.assoc "legal" defs)::inline_defs in (* To determine whether a clause is a frame, we need to know its expansion, so we expand clauses separately. A proper frame clause must have *all* expansions being proper frame clauses. But a @@ -133,12 +159,30 @@ regarded as "frame wave". *) let next_clauses = List.filter (fun ((rel,_),_) -> rel="next") clauses in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "fluent_paths_and_frames: initial next_clauses=\n%s\n\n" + (String.concat "\n" + (List.map GDL.def_str + (GDL.defs_of_rules + (Aux.concat_map GDL.rules_of_clause next_clauses)))) + ); + (* }}} *) let next_e = List.map (fun c -> (* it should actually be a single element association *) let brs_c = List.assoc "next" (defs_of_rules (rules_of_clause c)) in c, expand_positive_lits inline_defs brs_c) next_clauses in + (* {{{ log entry *) + if !debug_level > 2 then ( + let next_exp = Aux.concat_map snd next_e in + Printf.printf + "fluent_paths_and_frames: expanded next_e=\n%s\n\n" + (GDL.def_str ("next", next_exp)) + ); + (* }}} *) let find_br_fluents s_C (_,body,neg_body) = let true_args body = List.map (function [|t|] -> t | _ -> assert false) @@ -147,12 +191,22 @@ let n_ts = true_args neg_body in let t_C, ps = most_similar s_C (p_ts @ n_ts) in (* "negative true" check *) - t_C, ps, List.mem t_C p_ts in + t_C, ps, List.mem t_C n_ts in let is_frame s_C (t_C, _, neg_true) = not neg_true && s_C = t_C in let find_fluents (c, c_e) = let s_C = (snd (fst c)).(0) in - let res = List.map (find_br_fluents s_C) c_e in + (* discarding frame waves *) + (* FIXME: TODO: handle frame waves as in updated reference spec *) + let res = Aux.map_try (find_br_fluents s_C) c_e in + (* {{{ log entry *) + if !debug_level > 3 then ( + Printf.printf + "find_fluents: most_similar for s_C=%s expansions t_C=%s\n" + (term_str s_C) (String.concat ", " + (List.map (fun (t,_,_)->term_str t) res)) + ); + (* }}} *) if List.for_all (is_frame s_C) res then Aux.Left c else @@ -163,7 +217,7 @@ term_paths (function Const _ -> true | _ -> false) t_C else ps) res in Aux.Right (c, List.fold_left paths_union empty_path_set f_paths) in - let res = Aux.map_try find_fluents next_e in + let res = List.map find_fluents next_e in let frames, fluents = Aux.partition_choice res in let move_clauses, f_paths = List.split fluents in frames, move_clauses, @@ -186,15 +240,30 @@ ) clauses in let players = Array.of_list players in let rules = Aux.concat_map rules_of_clause clauses in - let stable_rel_defs, nonstable_rel_defs, - stable_base, init_state, (agg_actions, agg_states) = + let static_rel_defs, nonstatic_rel_defs, + static_base, init_state, (agg_actions, agg_states) = playout ~aggregate:true players !playout_horizon rules in - let stable_rels = Aux.unique_sorted - (List.map (fun ((rel,_),_,_)->rel) stable_rel_defs) in - let nonstable_rels = Aux.unique_sorted - (List.map (fun ((rel,_),_,_)->rel) nonstable_rel_defs) in + let static_rels = Aux.unique_sorted + (List.map (fun ((rel,_),_,_)->rel) static_rel_defs) in + let nonstatic_rels = Aux.unique_sorted + (List.map (fun ((rel,_),_,_)->rel) nonstatic_rel_defs) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "create_init_struc: static_rels=%s; nonstatic_rels=%s\n%!" + (String.concat ", " static_rels) (String.concat ", " nonstatic_rels) + ); + (* }}} *) let frame_clauses, move_clauses, f_paths = fluent_paths_and_frames clauses in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "create_init_struc: f_paths=%s\n%!" + (String.concat "; " + (List.map GDL.path_str (GDL.paths_to_list f_paths))) + ); + (* }}} *) let next_clauses = List.map (function | (_,[|s_C|]),body_C -> s_C, true, body_C @@ -213,21 +282,51 @@ let element_reps = Aux.unique_sorted (List.map (fun t -> simult_subst f_paths blank t) element_terms) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "create_init_struc: element_reps=\n%s\n%!" + (String.concat ", " (List.map term_str element_reps)) + ); + (* }}} *) + let m_paths = List.map (term_paths ~prefix_only:true (Aux.neg contains_blank)) element_reps in let m_paths = List.fold_left paths_union empty_path_set m_paths in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "create_init_struc: m_paths=%s\n%!" + (String.concat "; " + (List.map GDL.path_str (GDL.paths_to_list m_paths))) + ); + (* }}} *) let mask_reps = Aux.unique_sorted (List.map (fun t -> simult_subst m_paths blank t) element_reps) in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "create_init_struc: mask_reps=\n%s\n%!" + (String.concat ", " (List.map term_str mask_reps)) + ); + (* }}} *) let m_pathl = paths_to_list m_paths in let f_pathl = paths_to_list f_paths in (* adding subterm equality relations and fact relations *) let struc_rels, defined_rels = List.partition (fun rel -> - List.assoc rel arities <= !defined_arity_above) stable_rels in + List.assoc rel arities <= !defined_arity_above) static_rels in let struc_rels = "EQ_"::struc_rels in - let defined_rels = defined_rels @ nonstable_rels in + let defined_rels = defined_rels @ nonstatic_rels in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf + "create_init_struc: struc_rels=%s; defined_rels=%s\n%!" + (String.concat ", " struc_rels) (String.concat ", " defined_rels) + ); + (* }}} *) let struc = List.fold_left (fun struc rel -> let arity = List.assoc rel arities in @@ -238,7 +337,7 @@ Aux.fold_left_try (fun struc etup -> let tup = Array.of_list (List.map2 at_path etup ptup) in if rel = "EQ_" && arity = 2 && tup.(0) = tup.(1) - || List.mem (rel, tup) stable_base + || List.mem (rel, tup) static_base then Structure.add_rel_named_elems struc fact_rel (Array.map term_to_name tup) @@ -252,10 +351,12 @@ Aux.fold_left_try (fun struc elem -> let pred = pred_on_path_subterm path (at_path elem path) in - rels := pred :: !rels; - let tup = [|elem|] in - Structure.add_rel_named_elems struc pred - (Array.map term_to_name tup) + if List.mem pred !rels then struc + else ( + rels := pred :: !rels; + let tup = [|elem|] in + Structure.add_rel_named_elems struc pred + (Array.map term_to_name tup)) ) struc elements ) struc paths in let stable_rels = ref [] in @@ -267,15 +368,21 @@ let struc = List.fold_left (fun struc m -> let pred = term_to_name m in + stable_rels := pred :: !stable_rels; List.fold_left (fun struc elem -> if simult_subst all_paths blank elem = m then ( - stable_rels := pred :: !stable_rels; Structure.add_rel_named_elems struc pred [|term_to_name elem|]) else struc ) struc element_reps ) struc mask_reps in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "create_init_struc: resulting struc=\n%s\n%!" + (Structure.str struc) + ); + (* }}} *) (* let elem_term_map = Aux.strmap_of_assoc (List.map (fun e -> term_to_name e, e) element_reps) in @@ -286,7 +393,7 @@ players, rules, next_clauses, f_paths, m_paths, mask_reps, defined_rels, !stable_rels, !fluents, - stable_base, init_state, struc, agg_actions, elem_term_map + static_base, init_state, struc, agg_actions, elem_term_map (* substitute a "next" clause with frame info *) let subst_fnextcl sb (head, frame, body) = @@ -607,14 +714,14 @@ result, is_concurrent -let filter_rule_cands stable_base defined_rels rule_cands = +let filter_rule_cands static_base defined_rels rule_cands = let check_atom = function | Pos (Rel (rel, _ as a)) -> List.mem rel defined_rels || - List.exists (rels_unify a) stable_base + List.exists (rels_unify a) static_base | Neg (Rel (rel, _ as a)) -> List.mem rel defined_rels || - not (List.exists (rels_unify a) stable_base) + not (List.exists (rels_unify a) static_base) | _ -> true in let check_cands cands = List.filter (fun (_, _, case_conds) -> @@ -992,7 +1099,7 @@ let players, rules, next_cls, f_paths, m_paths, mask_reps, defined_rels, stable_rels, fluents, - stable_base, init_state, struc, agg_actions, elem_term_map = + static_base, init_state, struc, agg_actions, elem_term_map = create_init_struc clauses in let turn_data = try Some (check_turn_based players rules) @@ -1000,7 +1107,7 @@ let rule_cands, is_concurrent = create_rule_cands (turn_data <> None) used_vars next_cls clauses in let rule_cands = - filter_rule_cands stable_base defined_rels rule_cands in + filter_rule_cands static_base defined_rels rule_cands in let all_state_terms = Aux.concat_map state_terms (List.map snd clauses) in let term_arities = Aux.unique_sorted Modified: trunk/Toss/GGP/TranslateGame.mli =================================================================== --- trunk/Toss/GGP/TranslateGame.mli 2011-08-04 16:40:12 UTC (rev 1525) +++ trunk/Toss/GGP/TranslateGame.mli 2011-08-05 12:09:48 UTC (rev 1526) @@ -48,6 +48,22 @@ val empty_gdl_translation : gdl_translation +(* Create the initial structure and assorted data. Exposed for testing + purposes. + + [players, rules, next_cls, f_paths, m_paths, mask_reps, + defined_rels, stable_rels, fluents, stable_base, init_state, + struc, agg_actions, elem_term_map = create_init_struc clauses] *) +val create_init_struc : + GDL.clause list -> + GDL.term array * GDL.gdl_rule list * + (GDL.term * bool * GDL.literal list) list * GDL.path_set * + GDL.path_set * GDL.term list * string list * string list * + string list * GDL.rel_atom list * GDL.term list * + Structure.structure * GDL.term array list list * + GDL.term Aux.IntMap.t + + (* [playing_as] is only used for building move translation data, the game translation is independent of the selected player (a dummy term can be provided). *) Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-04 16:40:12 UTC (rev 1525) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-05 12:09:48 UTC (rev 1526) @@ -98,7 +98,7 @@ "tictactoe" >:: (fun () -> game_test_case ~game_name:"tictactoe" ~player:"xplayer" - ~own_plnum:0 ~opponent_plnum:1 + ~own_plnum:0 ~opponent_plnum:1 ~loc0_rule_name:"mark_x64_y19_0" ~loc0_emb:[ "cell_x64_y19__blank_", "cell_2_2_MV1"; @@ -110,9 +110,54 @@ "control__blank_", "control_MV1"] ~loc1_noop:"noop" ~loc1_move:"(mark 1 1)" ); + ] let bigtests = "TranslateGameBig" >::: [ + + "connect5 translation data" >:: + (fun () -> + (* perhaps should be a small test, takes mediocrily long *) + let descr = load_rules ("./GGP/examples/connect5.gdl") in + let clauses = GDL.expand_players descr in + let players, rules, + next_cls, f_paths, m_paths, mask_reps, defined_rels, + stable_rels, fluents, + stable_base, init_state, struc, agg_actions, elem_term_map = + TranslateGame.create_init_struc clauses in + + assert_equal ~msg:"f_paths" ~printer:(fun x->x) + "cell_2; control_0" + (String.concat "; " + (List.map GDL.path_str (GDL.paths_to_list f_paths))); + + assert_equal ~msg:"m_paths" ~printer:(fun x->x) + "cell_0; cell_1" + (String.concat "; " + (List.map GDL.path_str (GDL.paths_to_list m_paths))); + + assert_equal ~msg:"mask_reps" ~printer:(fun x->x) + "(cell _BLANK_ _BLANK_ _BLANK_); (control _BLANK_)" + (String.concat "; " + (List.map GDL.term_str mask_reps)); + + assert_equal ~msg:"defined_rels" ~printer:(fun x->x) + "adjacent_cell, col, conn5, diag1, diag2, exists_empty_cell, exists_line_of_five, goal, legal, next, row, terminal" + (String.concat ", " defined_rels); + + assert_equal ~msg:"fluents" ~printer:(fun x->x) + "control_0x, control_0o, cell_2b, cell_2x, cell_2o" + (String.concat ", " fluents); + + assert_equal ~msg:"stable_rels" ~printer:(fun x->x) + "A LOT OF THEM" + (String.concat ", " stable_rels); + + assert_equal ~msg:"structure elements" ~printer:(fun x->x) + "cell_a_a__BLANK_, cell_a_b__BLANK_, cell_a_c__BLANK_, cell_a_d__BLANK_, cell_a_e__BLANK_, cell_a_f__BLANK_, cell_a_g__BLANK_, cell_a_h__BLANK_, cell_b_a__BLANK_, cell_b_b__BLANK_, cell_b_c__BLANK_, cell_b_d__BLANK_, cell_b_e__BLANK_, cell_b_f__BLANK_, cell_b_g__BLANK_, cell_b_h__BLANK_, cell_c_a__BLANK_, cell_c_b__BLANK_, cell_c_c__BLANK_, cell_c_d__BLANK_, cell_c_e__BLANK_, cell_c_f__BLANK_, cell_c_g__BLANK_, cell_c_h__BLANK_, cell_d_a__BLANK_, cell_d_b__BLANK_, cell_d_c__BLANK_, cell_d_d__BLANK_, cell_d_e__BLANK_, cell_d_f__BLANK_, cell_d_g__BLANK_, cell_d_h__BLANK_, cell_e_a__BLANK_, cell_e_b__BLANK_, cell_e_c__BLANK_, cell_e_d__BLANK_, cell_e_e__BLANK_, cell_e_f__BLANK_, cell_e_g__BLANK_, cell_e_h__BLANK_, cell_f_a__BLANK_, cell_f_b__BLANK_, cell_f_c__BLANK_, cell_f_d__BLANK_, cell_f_e__BLANK_, cell_f_f__BLANK_, cell_f_g__BLANK_, cell_f_h__BLANK_, cell_g_a__BLANK_, cell_g_b__BLANK_, cell_g_c__BLANK_, cell_g_d__BLANK_, cell_g_e__BLANK_, cell_g_f__BLANK_, cell_g_g__BLANK_, cell_g_h__BLANK_, cell_h_a__BLANK_, cell_h_b__BLANK_, cell_h_c__BLANK_, cell_h_d__BLANK_, cell_h_e__BLANK_, cell_h_f__BLANK_, cell_h_g__BLANK_, cell_h_h__BLANK_" + (String.concat ", " + (List.map (Structure.elem_name struc) (Structure.elements struc))) + ); "connect5" >:: (fun () -> @@ -171,7 +216,7 @@ ] let a () = - GDL.debug_level := 2; + (* GDL.debug_level := 2; *) TranslateGame.debug_level := 4; GameSimpl.debug_level := 4; (* DiscreteRule.debug_level := 4; *) @@ -191,7 +236,48 @@ "control__blank_", "control_MV1"] ~loc1_noop:"noop" ~loc1_move:"(mark f g)" +let a () = + let descr = load_rules ("./GGP/examples/connect5.gdl") in + let clauses = GDL.expand_players descr in + let players, rules, + next_cls, f_paths, m_paths, mask_reps, defined_rels, + stable_rels, fluents, + stable_base, init_state, struc, agg_actions, elem_term_map = + TranslateGame.create_init_struc clauses in + assert_equal ~msg:"f_paths" ~printer:(fun x->x) + "cell_2; control_0" + (String.concat "; " + (List.map GDL.path_str (GDL.paths_to_list f_paths))); + + assert_equal ~msg:"m_paths" ~printer:(fun x->x) + "cell_0; cell_1" + (String.concat "; " + (List.map GDL.path_str (GDL.paths_to_list m_paths))); + + assert_equal ~msg:"mask_reps" ~printer:(fun x->x) + "(cell _BLANK_ _BLANK_ _BLANK_); (control _BLANK_)" + (String.concat "; " + (List.map GDL.term_str mask_reps)); + + assert_equal ~msg:"defined_rels" ~printer:(fun x->x) + "adjacent_cell, col, conn5, diag1, diag2, exists_empty_cell, exists_line_of_five, goal, legal, next, row, terminal" + (String.concat ", " defined_rels); + + assert_equal ~msg:"fluents" ~printer:(fun x->x) + "control_0x, control_0o, cell_2b, cell_2x, cell_2o" + (String.concat ", " fluents); + + assert_equal ~msg:"stable_rels" ~printer:(fun x->x) + "A LOT OF THEM" + (String.concat ", " stable_rels); + + assert_equal ~msg:"structure elements" ~printer:(fun x->x) + "cell_a_a__BLANK_, cell_a_b__BLANK_, cell_a_c__BLANK_, cell_a_d__BLANK_, cell_a_e__BLANK_, cell_a_f__BLANK_, cell_a_g__BLANK_, cell_a_h__BLANK_, cell_b_a__BLANK_, cell_b_b__BLANK_, cell_b_c__BLANK_, cell_b_d__BLANK_, cell_b_e__BLANK_, cell_b_f__BLANK_, cell_b_g__BLANK_, cell_b_h__BLANK_, cell_c_a__BLANK_, cell_c_b__BLANK_, cell_c_c__BLANK_, cell_c_d__BLANK_, cell_c_e__BLANK_, cell_c_f__BLANK_, cell_c_g__BLANK_, cell_c_h__BLANK_, cell_d_a__BLANK_, cell_d_b__BLANK_, cell_d_c__BLANK_, cell_d_d__BLANK_, cell_d_e__BLANK_, cell_d_f__BLANK_, cell_d_g__BLANK_, cell_d_h__BLANK_, cell_e_a__BLANK_, cell_e_b__BLANK_, cell_e_c__BLANK_, cell_e_d__BLANK_, cell_e_e__BLANK_, cell_e_f__BLANK_, cell_e_g__BLANK_, cell_e_h__BLANK_, cell_f_a__BLANK_, cell_f_b__BLANK_, cell_f_c__BLANK_, cell_f_d__BLANK_, cell_f_e__BLANK_, cell_f_f__BLANK_, cell_f_g__BLANK_, cell_f_h__BLANK_, cell_g_a__BLANK_, cell_g_b__BLANK_, cell_g_c__BLANK_, cell_g_d__BLANK_, cell_g_e__BLANK_, cell_g_f__BLANK_, cell_g_g__BLANK_, cell_g_h__BLANK_, cell_h_a__BLANK_, cell_h_b__BLANK_, cell_h_c__BLANK_, cell_h_d__BLANK_, cell_h_e__BLANK_, cell_h_f__BLANK_, cell_h_g__BLANK_, cell_h_h__BLANK_" + (String.concat ", " + (List.map (Structure.elem_name struc) (Structure.elements struc))) + + let a () = match test_filter [(* "GDLBig:1:breakthrough" *) "GDLBig:0:connect5"] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2011-08-04 16:40:19
|
Revision: 1525 http://toss.svn.sourceforge.net/toss/?rev=1525&view=rev Author: lukstafi Date: 2011-08-04 16:40:12 +0000 (Thu, 04 Aug 2011) Log Message: ----------- GDL translation fixing: bug expanding player variables. Modified Paths: -------------- 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/GGP/TranslateGame.ml trunk/Toss/GGP/TranslateGame.mli trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/www/reference/reference.tex Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/Formula/Aux.ml 2011-08-04 16:40:12 UTC (rev 1525) @@ -193,6 +193,11 @@ fold_left_try f (f accu a) l with Not_found -> fold_left_try f accu l +let rec power dom img = + List.fold_right (fun v sbs -> + concat_map (fun e -> List.map (fun sb -> (v,e)::sb) sbs) img) + dom [[]] + let product l = List.fold_right (fun set prod -> concat_map (fun el -> List.map (fun tup -> el::tup) prod) set) Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/Formula/Aux.mli 2011-08-04 16:40:12 UTC (rev 1525) @@ -125,6 +125,10 @@ [Not_found]. *) val fold_left_try : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a +(** [power dom img] generates all functions with domain [dom] and + image [img], as graphs. *) +val power : 'a list -> 'b list -> ('a * 'b) list list + (** Cartesian product of lists. Not tail recursive. *) val product : 'a list list -> 'a list list Modified: trunk/Toss/GGP/GDL.ml =================================================================== --- trunk/Toss/GGP/GDL.ml 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/GGP/GDL.ml 2011-08-04 16:40:12 UTC (rev 1525) @@ -313,10 +313,7 @@ " " ^ neg_rel_atoms_str neg_body ^ ")" let def_str (rel, branches) = - String.concat "\n" (List.map (fun (args, body, neg_body) -> - "("^ rel_atom_str (rel, args) ^ " <= " ^ rel_atoms_str body ^ - " " ^ neg_rel_atoms_str neg_body) - branches) + String.concat "\n" (List.map (branch_str rel) branches) let sb_str sb = String.concat ", " (List.map (fun (v,t)->v^":="^term_str t) sb) @@ -718,7 +715,8 @@ | "legal", [|Var v; _|] -> Some v | _ -> None) rels - +(* Expand players, and also remove the "role" atoms since they become + redundant. *) let expand_players clauses = let players = Aux.map_some (function @@ -731,8 +729,7 @@ player_vars_of (List.map rel_of_atom (atoms_of_clause clause)) in if plvars = [] then [clause] else - let sbs = List.map (fun v -> - List.map (fun pl -> v, pl) players) plvars in + let sbs = Aux.power plvars players in List.map (fun sb -> subst_clause sb clause) sbs in Aux.concat_map exp_clause clauses Modified: trunk/Toss/GGP/GDL.mli =================================================================== --- trunk/Toss/GGP/GDL.mli 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/GGP/GDL.mli 2011-08-04 16:40:12 UTC (rev 1525) @@ -104,6 +104,7 @@ val term_arities : term -> (string * int) list val rel_atom_str : rel_atom -> string +val def_str : string * def_branch list -> string (** {3 GDL whole-game operations.} Modified: trunk/Toss/GGP/GDLTest.ml =================================================================== --- trunk/Toss/GGP/GDLTest.ml 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/GGP/GDLTest.ml 2011-08-04 16:40:12 UTC (rev 1525) @@ -156,13 +156,28 @@ (does o (mark b a)) (does x noop)"]) ); + "expand players connect5" >:: + (fun () -> + let descr = load_rules ("./GGP/examples/connect5.gdl") in + let clauses = expand_players descr in + let legal_def = List.assoc "legal" + (GDL.defs_of_rules + (Aux.concat_map GDL.rules_of_clause clauses)) in + assert_equal ~msg:"expanded legal branches" ~printer:(fun x->x) + "((legal x (mark ?x ?y)) <= (true (control x)) (true (cell ?x ?y b)) ) +((legal o (mark ?x ?y)) <= (true (control o)) (true (cell ?x ?y b)) ) +((legal x noop) <= (role x) (not (true (control x)))) +((legal o noop) <= (role o) (not (true (control o))))" + (GDL.def_str ("legal", legal_def)); + ); + "playout connect5" >:: (fun () -> let descr = load_rules ("./GGP/examples/connect5.gdl") in - + let clauses = expand_players descr in let _, _, _, _, (rand_actions, _) = GDL.playout ~aggregate:false [|GDL.Const "x"; GDL.Const "o"|] - 10 (Aux.concat_map GDL.rules_of_clause descr) in + 10 (Aux.concat_map GDL.rules_of_clause clauses) in let noop_actions = Aux.take_n 9 (List.map (Aux.map_some Modified: trunk/Toss/GGP/TranslateGame.ml =================================================================== --- trunk/Toss/GGP/TranslateGame.ml 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/GGP/TranslateGame.ml 2011-08-04 16:40:12 UTC (rev 1525) @@ -20,8 +20,8 @@ [nonerasing_frame_wave] is set to [true].) *) let nonerasing_frame_wave = ref true -(** Limit on the number of steps for aggregate playout. *) -let agg_playout_horizon = ref 30 +(** Limit on the number of steps for aggregate and random playouts. *) +let playout_horizon = ref 30 (** Use "true" atoms while computing rule cases. *) let split_on_state_atoms = ref false @@ -188,7 +188,7 @@ let rules = Aux.concat_map rules_of_clause clauses in let stable_rel_defs, nonstable_rel_defs, stable_base, init_state, (agg_actions, agg_states) = - playout ~aggregate:true players !agg_playout_horizon rules in + playout ~aggregate:true players !playout_horizon rules in let stable_rels = Aux.unique_sorted (List.map (fun ((rel,_),_,_)->rel) stable_rel_defs) in let nonstable_rels = Aux.unique_sorted @@ -632,8 +632,25 @@ for players in the locations. *) let check_turn_based players rules = let check_one_playout () = - let _, _, _, _, (playout_actions, _) = - playout ~aggregate:false players !agg_playout_horizon rules in + (* {{{ log entry *) + if !debug_level > 2 then ( + Printf.printf "check_turn_based: starting check_one_playout\n" + ); + (* }}} *) + let _, _, _, _, (playout_actions, playout_states) = + playout ~aggregate:false players !playout_horizon rules in + (* {{{ log entry *) + if !debug_level > 3 then ( + let actions = List.map + (List.map (fun a->"does", a)) playout_actions in + let res = + String.concat ";\n" (List.map (fun step -> String.concat " " + (List.map GDL.rel_atom_str step)) actions) in + Printf.printf + "check_turn_based: no of states: %d, playout actions:\n%s\n%!" + (List.length playout_states) res + ); + (* }}} *) let noop_cands = List.map (fun actions -> let actions = Aux.map_reduce (function [|player; action|] -> player, action @@ -648,8 +665,16 @@ if accu = None then Some player else raise Not_turn_based | _, Some _ -> accu) None noop_cands) noop_cands in + (* {{{ log entry *) + if !debug_level > 1 then ( + Printf.printf "check_turn_based: control player pre-cands:\n%s\n%!" + (String.concat " " + (List.map (function Some t->term_str t | None->"None") + control_cands)) + ); + (* }}} *) let noop_cands = List.map Aux.collect noop_cands in - (* throw in players with (multiple) constant actions *) + (* throw in players with (multiple) constant actions *) let control_noop_cands = List.map2 (fun ccand noops -> let nccands, noops = Aux.partition_map (function player, [] -> assert false @@ -664,29 +689,29 @@ List.split control_noop_cands in (* {{{ log entry *) if !debug_level > 1 then ( - Printf.printf "check_turn_based: control player cands %s\n%!" + Printf.printf "check_turn_based: control player cands:\n%s\n%!" (String.concat " " (List.map (function Some t->term_str t | None->"None") control_cands)) ); (* }}} *) - (* 2b *) + (* 2b *) let loc_players = find_cycle control_cands in - (* {{{ log entry *) + (* {{{ log entry *) if !debug_level > 0 then ( Printf.printf "check_turn_based: location players %s\n%!" (String.concat " " (List.map (function Some t->term_str t | None->"None") loc_players)) ); - (* }}} *) + (* }}} *) let loc_players = Array.of_list (List.map (function Some p -> p | None -> players.(0)) loc_players) in let loc_n = Array.length loc_players in let players_n = Array.length players in let find_player p = Aux.array_argfind (fun x -> x = p) players in - (* noop actions of a player in a location *) + (* noop actions of a player in a location *) let loc_noops = let i = ref 0 in let noops = ref noop_cands in @@ -698,9 +723,9 @@ if loc_noops.(!i).(p_i) = None then loc_noops.(!i).(p_i) <- noop else if loc_noops.(!i).(p_i) <> noop - (* moves are not simultaneous, but different [noop] actions - are used by the same player -- can be resolved by - introducing separate locations for each noop case *) + (* moves are not simultaneous, but different [noop] actions + are used by the same player -- can be resolved by + introducing separate locations for each noop case *) then raise Not_turn_based) (List.hd !noops); incr i; if !i = loc_n then i := 0; Modified: trunk/Toss/GGP/TranslateGame.mli =================================================================== --- trunk/Toss/GGP/TranslateGame.mli 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/GGP/TranslateGame.mli 2011-08-04 16:40:12 UTC (rev 1525) @@ -1,6 +1,9 @@ (** Local level of logging. *) val debug_level : int ref +(** Limit on plys for both aggregate and random playouts. *) +val playout_horizon : int ref + type tossrule_data = { legal_tuple : GDL.term array; (* the "legal"/"does" term of the player that performs the move Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/GGP/TranslateGameTest.ml 2011-08-04 16:40:12 UTC (rev 1525) @@ -171,7 +171,7 @@ ] let a () = - (* GDL.debug_level := 2; *) + GDL.debug_level := 2; TranslateGame.debug_level := 4; GameSimpl.debug_level := 4; (* DiscreteRule.debug_level := 4; *) Modified: trunk/Toss/www/reference/reference.tex =================================================================== --- trunk/Toss/www/reference/reference.tex 2011-08-04 03:58:35 UTC (rev 1524) +++ trunk/Toss/www/reference/reference.tex 2011-08-04 16:40:12 UTC (rev 1525) @@ -1764,11 +1764,13 @@ We determine which clauses are frame clauses prior to partitioning into the rule clauses and computing the substitution $\sigma_{\ol{\calC},\ol{\calN}}$ -- at the point where fluent paths -are computed. It is unclear which wave clauses should be considered -frame clauses -- we optimistically assume that all wave clauses not -depending on player actions (\ie not containing \texttt{does}) are -frame clauses (and in the current implementation we ignore frame-wave -clauses as they do not provide useful erasure clauses). +are computed. It is difficult to establish which wave clauses should +be considered frame clauses. In the current implementation, we +optimistically assume that all wave clauses not depending on player +actions (\ie not containing \texttt{does}) are frame clauses (and +currently we ignore frame-wave clauses as they do not provide useful +erasure clauses). In the future, we might perform deeper checking as +to which wave clauses are frame clauses. From the frame clauses in $\sigma_{\ol{\calC}, \ol{\calN}}(\calN_1), \dots, \sigma_{\ol{\calC}, \ol{\calN}}(\calN_m)$, we select subsets $J$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |