toss-devel-svn Mailing List for Toss (Page 4)
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...> - 2012-02-11 22:41:05
|
Revision: 1674 http://toss.svn.sourceforge.net/toss/?rev=1674&view=rev Author: lukaszkaiser Date: 2012-02-11 22:40:58 +0000 (Sat, 11 Feb 2012) Log Message: ----------- Cleanup in Client. Modified Paths: -------------- trunk/Toss/Client/.cvsignore trunk/Toss/Client/clientTest.js trunk/Toss/Client/index.html Added Paths: ----------- trunk/Toss/Client/img/toss.png Removed Paths: ------------- trunk/Toss/Client/JsHandler.js trunk/Toss/Client/Login.js trunk/Toss/Client/profile.html trunk/Toss/Client/register.html trunk/Toss/Client/support.html trunk/Toss/Client/toss.png Property Changed: ---------------- trunk/Toss/Client/ Property changes on: trunk/Toss/Client ___________________________________________________________________ Modified: svn:ignore - # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . *.ttf *.eot *.svg *.woff *~ + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . JsHandler.js clientTestRender*.png *~ Modified: trunk/Toss/Client/.cvsignore =================================================================== --- trunk/Toss/Client/.cvsignore 2012-02-11 22:16:36 UTC (rev 1673) +++ trunk/Toss/Client/.cvsignore 2012-02-11 22:40:58 UTC (rev 1674) @@ -2,8 +2,6 @@ # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . -*.ttf -*.eot -*.svg -*.woff +JsHandler.js +clientTestRender*.png *~ Deleted: trunk/Toss/Client/JsHandler.js =================================================================== --- trunk/Toss/Client/JsHandler.js 2012-02-11 22:16:36 UTC (rev 1673) +++ trunk/Toss/Client/JsHandler.js 2012-02-11 22:40:58 UTC (rev 1674) @@ -1,979 +0,0 @@ -// A bug in js_of_ocaml: it sometimes omits the functions below, which -// belong to its runtmie. - -// Applies to code below this line: -// Js_of_ocaml runtime support -// http://www.ocsigen.org/js_of_ocaml/ -// Copyright (C) 2010 Jérôme Vouillon -// Laboratoire PPS - CNRS Université Paris Diderot -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, with linking exception; -// either version 2.1 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -// Provides: caml_int64_bits_of_float const -function caml_int64_bits_of_float (x) { - if (!isFinite(x)) { - if (isNaN(x)) return [255, 1, 0, 0xfff0]; - return (x > 0)?[255,0,0,0x7ff0]:[255,0,0,0xfff0]; - } - var sign = (x>=0)?0:0x8000; - if (sign) x = -x; - var exp = Math.floor(Math.LOG2E*Math.log(x)) + 1023; - if (exp <= 0) { - exp = 0; - x /= Math.pow(2,-1026); - } else { - x /= Math.pow(2,exp-1027); - if (x < 16) { x *= 2; exp -=1; } - if (exp == 0) { x /= 2; } - } - var k = Math.pow(2,24); - var r3 = x|0; - x = (x - r3) * k; - var r2 = x|0; - x = (x - r2) * k; - var r1 = x|0; - r3 = (r3 &0xf) | sign | exp << 4; - return [255, r1, r2, r3]; -} -//Provides: caml_int64_to_bytes -function caml_int64_to_bytes(x) { - return [x[3] >> 8, x[3] & 0xff, x[2] >> 16, (x[2] >> 8) & 0xff, x[2] & 0xff, - x[1] >> 16, (x[1] >> 8) & 0xff, x[1] & 0xff]; -} -// This program was compiled from OCaml by js_of_ocaml 1.0 -function caml_raise_with_arg (tag, arg) { throw [0, tag, arg]; } -function caml_raise_with_string (tag, msg) { - caml_raise_with_arg (tag, new MlWrappedString (msg)); -} -function caml_invalid_argument (msg) { - caml_raise_with_string(caml_global_data[4], msg); -} -function caml_array_bound_error () { - caml_invalid_argument("index out of bounds"); -} -function caml_str_repeat(n, s) { - if (!n) { return ""; } - if (n & 1) { return caml_str_repeat(n - 1, s) + s; } - var r = caml_str_repeat(n >> 1, s); - return r + r; -} -function MlString(param) { - if (param != null) { - this.bytes = this.fullBytes = param; - this.last = this.len = param.length; - } -} -MlString.prototype = { - string:null, - bytes:null, - fullBytes:null, - array:null, - len:null, - last:0, - toJsString:function() { - return this.string = decodeURIComponent (escape(this.getFullBytes())); - }, - toBytes:function() { - if (this.string != null) - var b = unescape (encodeURIComponent (this.string)); - else { - var b = "", a = this.array, l = a.length; - for (var i = 0; i < l; i ++) b += String.fromCharCode (a[i]); - } - this.bytes = this.fullBytes = b; - this.last = this.len = b.length; - return b; - }, - getBytes:function() { - var b = this.bytes; - if (b == null) b = this.toBytes(); - return b; - }, - getFullBytes:function() { - var b = this.fullBytes; - if (b !== null) return b; - b = this.bytes; - if (b == null) b = this.toBytes (); - if (this.last < this.len) { - this.bytes = (b += caml_str_repeat(this.len - this.last, '\0')); - this.last = this.len; - } - this.fullBytes = b; - return b; - }, - toArray:function() { - var b = this.bytes; - if (b == null) b = this.toBytes (); - var a = [], l = this.last; - for (var i = 0; i < l; i++) a[i] = b.charCodeAt(i); - for (l = this.len; i < l; i++) a[i] = 0; - this.string = this.bytes = this.fullBytes = null; - this.last = this.len; - this.array = a; - return a; - }, - getArray:function() { - var a = this.array; - if (!a) a = this.toArray(); - return a; - }, - getLen:function() { - var len = this.len; - if (len !== null) return len; - this.toBytes(); - return this.len; - }, - toString:function() { var s = this.string; return s?s:this.toJsString(); }, - valueOf:function() { var s = this.string; return s?s:this.toJsString(); }, - blitToArray:function(i1, a2, i2, l) { - var a1 = this.array; - if (a1) - for (var i = 0; i < l; i++) a2 [i2 + i] = a1 [i1 + i]; - else { - var b = this.bytes; - if (b == null) b = this.toBytes(); - var l1 = this.last - i1; - if (l <= l1) - for (var i = 0; i < l; i++) a2 [i2 + i] = b.charCodeAt(i1 + i); - else { - for (var i = 0; i < l1; i++) a2 [i2 + i] = b.charCodeAt(i1 + i); - for (; i < l; i++) a2 [i2 + i] = 0; - } - } - }, - get:function (i) { - var a = this.array; - if (a) return a[i]; - var b = this.bytes; - if (b == null) b = this.toBytes(); - return (i<this.last)?b.charCodeAt(i):0; - }, - safeGet:function (i) { - if (!this.len) this.toBytes(); - if ((i < 0) || (i >= this.len)) caml_array_bound_error (); - return this.get(i); - }, - set:function (i, c) { - var a = this.array; - if (!a) { - if (this.last == i) { - this.bytes += String.fromCharCode (c & 0xff); - this.last ++; - return 0; - } - a = this.toArray(); - } else if (this.bytes != null) { - this.bytes = this.fullBytes = this.string = null; - } - a[i] = c & 0xff; - return 0; - }, - safeSet:function (i, c) { - if (this.len == null) this.toBytes (); - if ((i < 0) || (i >= this.len)) caml_array_bound_error (); - this.set(i, c); - }, - fill:function (ofs, len, c) { - if (ofs >= this.last && this.last && c == 0) return; - var a = this.array; - if (!a) a = this.toArray(); - else if (this.bytes != null) { - this.bytes = this.fullBytes = this.string = null; - } - var l = ofs + len; - for (var i = ofs; i < l; i++) a[i] = c; - }, - compare:function (s2) { - if (this.string != null && s2.string != null) { - if (this.string < s2.string) return -1; - if (this.string > s2.string) return 1; - return 0; - } - var b1 = this.getFullBytes (); - var b2 = s2.getFullBytes (); - if (b1 < b2) return -1; - if (b1 > b2) return 1; - return 0; - }, - equal:function (s2) { - if (this.string != null && s2.string != null) - return this.string == s2.string; - return this.getFullBytes () == s2.getFullBytes (); - }, - lessThan:function (s2) { - if (this.string != null && s2.string != null) - return this.string < s2.string; - return this.getFullBytes () < s2.getFullBytes (); - }, - lessEqual:function (s2) { - if (this.string != null && s2.string != null) - return this.string <= s2.string; - return this.getFullBytes () <= s2.getFullBytes (); - } -} -function MlWrappedString (s) { this.string = s; } -MlWrappedString.prototype = new MlString(); -function MlMakeString (l) { this.bytes = ""; this.len = l; } -MlMakeString.prototype = new MlString (); -function caml_array_get (array, index) { - if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error(); - return array[index+1]; -} -function caml_array_set (array, index, newval) { - if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error(); - array[index+1]=newval; return 0; -} -function caml_blit_string(s1, i1, s2, i2, len) { - if (len === 0) return; - if (i2 === s2.last && s2.bytes != null) { - var b = s1.bytes; - if (b == null) b = s1.toBytes (); - if (i1 > 0 || s1.last > len) b = b.slice(i1, i1 + len); - s2.bytes += b; - s2.last += b.length; - return; - } - var a = s2.array; - if (!a) a = s2.toArray(); else { s2.bytes = s2.string = null; } - s1.blitToArray (i1, a, i2, len); -} -function caml_call_gen(f, args) { - if(f.fun) - return caml_call_gen(f.fun, args); - var n = f.length; - var d = n - args.length; - if (d == 0) - return f.apply(null, args); - else if (d < 0) - return caml_call_gen(f.apply(null, args.slice(0,n)), args.slice(n)); - else - return function (x){ return caml_call_gen(f, args.concat([x])); }; -} -function caml_classify_float (x) { - if (isFinite (x)) { - if (Math.abs(x) >= 2.2250738585072014e-308) return 0; - if (x != 0) return 1; - return 2; - } - return isNaN(x)?4:3; -} -function caml_int64_compare(x,y) { - var x3 = x[3] << 16; - var y3 = y[3] << 16; - if (x3 > y3) return 1; - if (x3 < y3) return -1; - if (x[2] > y[2]) return 1; - if (x[2] < y[2]) return -1; - if (x[1] > y[1]) return 1; - if (x[1] < y[1]) return -1; - return 0; -} -function caml_int_compare (a, b) { - if (a < b) return (-1); if (a == b) return 0; return 1; -} -function caml_compare_val (a, b, total) { - var stack = []; - for(;;) { - if (!(total && a === b)) { - if (a instanceof MlString) { - if (b instanceof MlString) { - if (a != b) { - var x = a.compare(b); - if (x != 0) return x; - } - } else - return 1; - } else if (a instanceof Array && a[0] === (a[0]|0)) { - var ta = a[0]; - if (ta === 250) { - a = a[1]; - continue; - } else if (b instanceof Array && b[0] === (b[0]|0)) { - var tb = b[0]; - if (tb === 250) { - b = b[1]; - continue; - } else if (ta != tb) { - return (ta < tb)?-1:1; - } else { - switch (ta) { - case 248: { - var x = caml_int_compare(a[2], b[2]); - if (x != 0) return x; - break; - } - case 255: { - var x = caml_int64_compare(a, b); - if (x != 0) return x; - break; - } - default: - if (a.length != b.length) return (a.length < b.length)?-1:1; - if (a.length > 1) stack.push(a, b, 1); - } - } - } else - return 1; - } else if (b instanceof MlString || - (b instanceof Array && b[0] === (b[0]|0))) { - return -1; - } else { - if (a < b) return -1; - if (a > b) return 1; - if (total && a != b) { - if (a == a) return 1; - if (b == b) return -1; - } - } - } - if (stack.length == 0) return 0; - var i = stack.pop(); - b = stack.pop(); - a = stack.pop(); - if (i + 1 < a.length) stack.push(a, b, i + 1); - a = a[i]; - b = b[i]; - } -} -function caml_compare (a, b) { return caml_compare_val (a, b, true); } -function caml_create_string(len) { - if (len < 0) caml_invalid_argument("String.create"); - return new MlMakeString(len); -} -function caml_raise_constant (tag) { throw [0, tag]; } -var caml_global_data = [0]; -function caml_raise_zero_divide () { - caml_raise_constant(caml_global_data[6]); -} -function caml_div(x,y) { - if (y == 0) caml_raise_zero_divide (); - return (x/y)|0; -} -function caml_equal (x, y) { return +(caml_compare_val(x,y,false) == 0); } -function caml_fill_string(s, i, l, c) { s.fill (i, l, c); } -function caml_float_compare (x, y) { - if (x === y) return 0; - if (x < y) return -1; - if (x > y) return 1; - if (x === x) return 1; - if (y === y) return -1; - return 0; -} -function caml_parse_format (fmt) { - fmt = fmt.toString (); - var len = fmt.length; - if (len > 31) caml_invalid_argument("format_int: format too long"); - var f = - { justify:'+', signstyle:'-', filler:' ', alternate:false, - base:0, signedconv:false, width:0, uppercase:false, - sign:1, prec:6, conv:'f' }; - for (var i = 0; i < len; i++) { - var c = fmt.charAt(i); - switch (c) { - case '-': - f.justify = '-'; break; - case '+': case ' ': - f.signstyle = c; break; - case '0': - f.filler = '0'; break; - case '#': - f.alternate = true; break; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - f.width = 0; - while (c=fmt.charCodeAt(i) - 48, c >= 0 && c <= 9) { - f.width = f.width * 10 + c; i++ - } - i--; - break; - case '.': - f.prec = 0; - i++; - while (c=fmt.charCodeAt(i) - 48, c >= 0 && c <= 9) { - f.prec = f.prec * 10 + c; i++ - } - i--; - case 'd': case 'i': - f.signedconv = true; /* fallthrough */ - case 'u': - f.base = 10; break; - case 'x': - f.base = 16; break; - case 'X': - f.base = 16; f.uppercase = true; break; - case 'o': - f.base = 8; break; - case 'e': case 'f': case 'g': - f.signedconv = true; f.conv = c; break; - case 'E': case 'F': case 'G': - f.signedconv = true; f.uppercase = true; - f.conv = c.toLowerCase (); break; - } - } - return f; -} -function caml_finish_formatting(f, rawbuffer) { - if (f.uppercase) rawbuffer = rawbuffer.toUpperCase(); - var len = rawbuffer.length; - if (f.signedconv && (f.sign < 0 || f.signstyle != '-')) len++; - if (f.alternate) { - if (f.base == 8) len += 1; - if (f.base == 16) len += 2; - } - var buffer = ""; - if (f.justify == '+' && f.filler == ' ') - for (var i = len; i < f.width; i++) buffer += ' '; - if (f.signedconv) { - if (f.sign < 0) buffer += '-'; - else if (f.signstyle != '-') buffer += f.signstyle; - } - if (f.alternate && f.base == 8) buffer += '0'; - if (f.alternate && f.base == 16) buffer += "0x"; - if (f.justify == '+' && f.filler == '0') - for (var i = len; i < f.width; i++) buffer += '0'; - buffer += rawbuffer; - if (f.justify == '-') - for (var i = len; i < f.width; i++) buffer += ' '; - return new MlWrappedString (buffer); -} -function caml_format_float (fmt, x) { - var s, f = caml_parse_format(fmt); - if (x < 0) { f.sign = -1; x = -x; } - if (isNaN(x)) { s = "nan"; f.filler = ' '; } - else if (!isFinite(x)) { s = "inf"; f.filler = ' '; } - else - switch (f.conv) { - case 'e': - var s = x.toExponential(f.prec); - var i = s.length; - if (s.charAt(i - 3) == 'e') - s = s.slice (0, i - 1) + '0' + s.slice (i - 1); - break; - case 'f': - s = x.toFixed(f.prec); break; - case 'g': - var prec = f.prec?f.prec:1; - s = x.toExponential(prec - 1); - var j = s.indexOf('e'); - var exp = +s.slice(j + 1); - if (exp < -4 || x.toFixed(0).length > prec) { - var i = j - 1; while (s.charAt(i) == '0') i--; - if (s.charAt(i) == '.') i--; - s = s.slice(0, i + 1) + s.slice(j); - i = s.length; - if (s.charAt(i - 3) == 'e') - s = s.slice (0, i - 1) + '0' + s.slice (i - 1); - break; - } else { - var p = prec; - if (exp < 0) { p -= exp + 1; s = x.toFixed(p); } - else while (s = x.toFixed(p), s.length > prec + 1) p--; - if (p) { - var i = s.length - 1; while (s.charAt(i) == '0') i--; - if (s.charAt(i) == '.') i--; - s = s.slice(0, i + 1); - } - } - break; - } - return caml_finish_formatting(f, s); -} -function caml_format_int(fmt, i) { - if (fmt.toString() == "%d") return new MlWrappedString(""+i); - var f = caml_parse_format(fmt); - if (i < 0) { if (f.signedconv) { f.sign = -1; i = -i; } else i >>>= 0; } - var s = i.toString(f.base); - return caml_finish_formatting(f, s); -} -function caml_get_public_method (obj, tag) { - var meths = obj[1]; - var li = 3, hi = meths[1] * 2 + 1, mi; - while (li < hi) { - mi = ((li+hi) >> 1) | 1; - if (tag < meths[mi+1]) hi = mi-2; - else li = mi; - } - return (tag == meths[li+1] ? meths[li] : 0); -} -function caml_greaterequal (x, y) { return +(caml_compare(x,y,false) >= 0); } -function caml_greaterthan (x, y) { return +(caml_compare(x,y,false) > 0); } -function caml_int64_to_bytes(x) { - return [x[3] >> 8, x[3] & 0xff, x[2] >> 16, (x[2] >> 8) & 0xff, x[2] & 0xff, - x[1] >> 16, (x[1] >> 8) & 0xff, x[1] & 0xff]; -} -function caml_int64_bits_of_float (x) { - if (!isFinite(x)) { - if (isNaN(x)) return [255, 1, 0, 0xfff0]; - return (x > 0)?[255,0,0,0x7ff0]:[255,0,0,0xfff0]; - } - var sign = (x>=0)?0:0x8000; - if (sign) x = -x; - var exp = Math.floor(Math.LOG2E*Math.log(x)) + 1023; - if (exp <= 0) { - exp = 0; - x /= Math.pow(2,-1026); - } else { - x /= Math.pow(2,exp-1027); - if (x < 16) { x *= 2; exp -=1; } - if (exp == 0) { x /= 2; } - } - var k = Math.pow(2,24); - var r3 = x|0; - x = (x - r3) * k; - var r2 = x|0; - x = (x - r2) * k; - var r1 = x|0; - r3 = (r3 &0xf) | sign | exp << 4; - return [255, r1, r2, r3]; -} -function caml_hash_univ_param (count, limit, obj) { - var hash_accu = 0; - function hash_aux (obj) { - limit --; - if (count < 0 || limit < 0) return; - if (obj instanceof Array && obj[0] === (obj[0]|0)) { - switch (obj[0]) { - case 248: - count --; - hash_accu = (hash_accu * 65599 + obj[2]) | 0; - break - case 250: - limit++; hash_aux(obj); break; - case 255: - count --; - hash_accu = (hash_accu * 65599 + obj[1] + (obj[2] << 24)) | 0; - break; - default: - count --; - hash_accu = (hash_accu * 19 + obj[0]) | 0; - for (var i = obj.length - 1; i > 0; i--) hash_aux (obj[i]); - } - } else if (obj instanceof MlString) { - count --; - var a = obj.array, l = obj.getLen (); - if (a) { - for (var i = 0; i < l; i++) hash_accu = (hash_accu * 19 + a[i]) | 0; - } else { - var b = obj.getFullBytes (); - for (var i = 0; i < l; i++) - hash_accu = (hash_accu * 19 + b.charCodeAt(i)) | 0; - } - } else if (obj === (obj|0)) { - count --; - hash_accu = (hash_accu * 65599 + obj) | 0; - } else if (obj === +obj) { - count--; - var p = caml_int64_to_bytes (caml_int64_bits_of_float (obj)); - for (var i = 7; i >= 0; i--) hash_accu = (hash_accu * 19 + p[i]) | 0; - } - } - hash_aux (obj); - return hash_accu & 0x3FFFFFFF; -} -function caml_int64_float_of_bits (x) { - var exp = (x[3] & 0x7fff) >> 4; - if (exp == 2047) { - if ((x[1]|x[2]|(x[3]&0xf)) == 0) - return (x[3] & 0x8000)?(-Infinity):Infinity; - else - return NaN; - } - var k = Math.pow(2,-24); - var res = (x[1]*k+x[2])*k+(x[3]&0xf); - if (exp > 0) { - res += 16 - res *= Math.pow(2,exp-1027); - } else - res *= Math.pow(2,-1026); - if (x[3] & 0x8000) res = - res; - return res; -} -function caml_int64_is_negative(x) { - return (x[3] << 16) < 0; -} -function caml_int64_neg (x) { - var y1 = - x[1]; - var y2 = - x[2] + (y1 >> 24); - var y3 = - x[3] + (y2 >> 24); - return [255, y1 & 0xffffff, y2 & 0xffffff, y3 & 0xffff]; -} -function caml_int64_of_int32 (x) { - return [255, x & 0xffffff, (x >> 24) & 0xffffff, (x >> 31) & 0xffff] -} -function caml_int64_ucompare(x,y) { - if (x[3] > y[3]) return 1; - if (x[3] < y[3]) return -1; - if (x[2] > y[2]) return 1; - if (x[2] < y[2]) return -1; - if (x[1] > y[1]) return 1; - if (x[1] < y[1]) return -1; - return 0; -} -function caml_int64_lsl1 (x) { - x[3] = (x[3] << 1) | (x[2] >> 23); - x[2] = ((x[2] << 1) | (x[1] >> 23)) & 0xffffff; - x[1] = (x[1] << 1) & 0xffffff; -} -function caml_int64_lsr1 (x) { - x[1] = ((x[1] >>> 1) | (x[2] << 23)) & 0xffffff; - x[2] = ((x[2] >>> 1) | (x[3] << 23)) & 0xffffff; - x[3] = x[3] >>> 1; -} -function caml_int64_sub (x, y) { - var z1 = x[1] - y[1]; - var z2 = x[2] - y[2] + (z1 >> 24); - var z3 = x[3] - y[3] + (z2 >> 24); - return [255, z1 & 0xffffff, z2 & 0xffffff, z3 & 0xffff]; -} -function caml_int64_udivmod (x, y) { - var offset = 0; - var modulus = x.slice (); - var divisor = y.slice (); - var quotient = [255, 0, 0, 0]; - while (caml_int64_ucompare (modulus, divisor) > 0) { - offset++; - caml_int64_lsl1 (divisor); - } - while (offset >= 0) { - offset --; - caml_int64_lsl1 (quotient); - if (caml_int64_ucompare (modulus, divisor) >= 0) { - quotient[1] ++; - modulus = caml_int64_sub (modulus, divisor); - } - caml_int64_lsr1 (divisor); - } - return [0,quotient, modulus]; -} -function caml_int64_to_int32 (x) { - return x[1] | (x[2] << 24); -} -function caml_int64_is_zero(x) { - return (x[3]|x[2]|x[1]) == 0; -} -function caml_int64_format (fmt, x) { - var f = caml_parse_format(fmt); - if (f.signedconv && caml_int64_is_negative(x)) { - f.sign = -1; x = caml_int64_neg(x); - } - var buffer = ""; - var wbase = caml_int64_of_int32(f.base); - var cvtbl = "0123456789abcdef"; - do { - var p = caml_int64_udivmod(x, wbase); - x = p[1]; - buffer = cvtbl.charAt(caml_int64_to_int32(p[2])) + buffer; - } while (! caml_int64_is_zero(x)); - return caml_finish_formatting(f, buffer); -} -function caml_parse_sign_and_base (s) { - var i = 0, base = 10, sign = s.get(0) == 45?(i++,-1):1; - if (s.get(i) == 48) - switch (s.get(i + 1)) { - case 120: case 88: base = 16; i += 2; break; - case 111: case 79: base = 8; i += 2; break; - case 98: case 66: base = 2; i += 2; break; - } - return [i, sign, base]; -} -function caml_parse_digit(c) { - if (c >= 48 && c <= 57) return c - 48; - if (c >= 65 && c <= 90) return c - 55; - if (c >= 97 && c <= 122) return c - 87; - return -1; -} -function caml_failwith (msg) { - caml_raise_with_string(caml_global_data[3], msg); -} -function caml_int_of_string (s) { - var r = caml_parse_sign_and_base (s); - var i = r[0], sign = r[1], base = r[2]; - var threshold = -1 >>> 0; - var c = s.get(i); - var d = caml_parse_digit(c); - if (d < 0 || d >= base) caml_failwith("int_of_string"); - var res = d; - for (;;) { - i++; - c = s.get(i); - if (c == 95) continue; - d = caml_parse_digit(c); - if (d < 0 || d >= base) break; - res = base * res + d; - if (res > threshold) caml_failwith("int_of_string"); - } - if (i != s.getLen()) caml_failwith("int_of_string"); - res = sign * res; - if ((res | 0) != res) caml_failwith("int_of_string"); - return res; -} -function caml_is_printable(c) { return +(c > 31 && c < 127); } -function caml_js_eval_string () {return eval(arguments[0].toString());} -function caml_js_from_array(a) { return a.slice(1); } -function caml_js_fun_call(f, args) { return f.apply(null, args.slice(1)); } -function caml_js_to_array(a) { return [0].concat(a); } -function caml_js_wrap_callback(f) { - var toArray = Array.prototype.slice; - return function () { - var args = (arguments.length > 0)?toArray.call (arguments):[undefined]; - return caml_call_gen(f, args); - } -} -function caml_lessequal (x, y) { return +(caml_compare(x,y,false) <= 0); } -function caml_lessthan (x, y) { return +(caml_compare(x,y,false) < 0); } -function caml_lex_array(s) { - s = s.getFullBytes(); - var a = [], l = s.length / 2; - for (var i = 0; i < l; i++) - a[i] = (s.charCodeAt(2 * i) | (s.charCodeAt(2 * i + 1) << 8)) << 16 >> 16; - return a; -} -function caml_lex_engine(tbl, start_state, lexbuf) { - var lex_buffer = 2; - var lex_buffer_len = 3; - var lex_start_pos = 5; - var lex_curr_pos = 6; - var lex_last_pos = 7; - var lex_last_action = 8; - var lex_eof_reached = 9; - var lex_base = 1; - var lex_backtrk = 2; - var lex_default = 3; - var lex_trans = 4; - var lex_check = 5; - if (!tbl.lex_default) { - tbl.lex_base = caml_lex_array (tbl[lex_base]); - tbl.lex_backtrk = caml_lex_array (tbl[lex_backtrk]); - tbl.lex_check = caml_lex_array (tbl[lex_check]); - tbl.lex_trans = caml_lex_array (tbl[lex_trans]); - tbl.lex_default = caml_lex_array (tbl[lex_default]); - } - var c, state = start_state; - var buffer = lexbuf[lex_buffer].getArray(); - if (state >= 0) { - lexbuf[lex_last_pos] = lexbuf[lex_start_pos] = lexbuf[lex_curr_pos]; - lexbuf[lex_last_action] = -1; - } else { - state = -state - 1; - } - for(;;) { - var base = tbl.lex_base[state]; - if (base < 0) return -base-1; - var backtrk = tbl.lex_backtrk[state]; - if (backtrk >= 0) { - lexbuf[lex_last_pos] = lexbuf[lex_curr_pos]; - lexbuf[lex_last_action] = backtrk; - } - if (lexbuf[lex_curr_pos] >= lexbuf[lex_buffer_len]){ - if (lexbuf[lex_eof_reached] == 0) - return -state - 1; - else - c = 256; - }else{ - c = buffer[lexbuf[lex_curr_pos]]; - lexbuf[lex_curr_pos] ++; - } - if (tbl.lex_check[base + c] == state) - state = tbl.lex_trans[base + c]; - else - state = tbl.lex_default[state]; - if (state < 0) { - lexbuf[lex_curr_pos] = lexbuf[lex_last_pos]; - if (lexbuf[lex_last_action] == -1) - caml_failwith("lexing: empty token"); - else - return lexbuf[lex_last_action]; - }else{ - /* Erase the EOF condition only if the EOF pseudo-character was - consumed by the automaton (i.e. there was no backtrack above) - */ - if (c == 256) lexbuf[lex_eof_reached] = 0; - } - } -} -function caml_make_vect (len, init) { - var b = [0]; for (var i = 1; i <= len; i++) b[i] = init; return b; -} -function MlStringFromArray (a) { - var len = a.length; this.array = a; this.len = this.last = len; -} -MlStringFromArray.prototype = new MlString (); -var caml_md5_string = -function () { - function add (x, y) { return (x + y) | 0; } - function xx(q,a,b,x,s,t) { - a = add(add(a, q), add(x, t)); - return add((a << s) | (a >>> (32 - s)), b); - } - function ff(a,b,c,d,x,s,t) { - return xx((b & c) | ((~b) & d), a, b, x, s, t); - } - function gg(a,b,c,d,x,s,t) { - return xx((b & d) | (c & (~d)), a, b, x, s, t); - } - function hh(a,b,c,d,x,s,t) { return xx(b ^ c ^ d, a, b, x, s, t); } - function ii(a,b,c,d,x,s,t) { return xx(c ^ (b | (~d)), a, b, x, s, t); } - function md5(buffer, length) { - var i = length; - buffer[i >> 2] |= 0x80 << (8 * (i & 3)); - for (i = (i & ~0x3) + 4;(i & 0x3F) < 56 ;i += 4) - buffer[i >> 2] = 0; - buffer[i >> 2] = length << 3; - i += 4; - buffer[i >> 2] = (length >> 29) & 0x1FFFFFFF; - var w = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476]; - for(i = 0; i < buffer.length; i += 16) { - var a = w[0], b = w[1], c = w[2], d = w[3]; - a = ff(a, b, c, d, buffer[i+ 0], 7, 0xD76AA478); - d = ff(d, a, b, c, buffer[i+ 1], 12, 0xE8C7B756); - c = ff(c, d, a, b, buffer[i+ 2], 17, 0x242070DB); - b = ff(b, c, d, a, buffer[i+ 3], 22, 0xC1BDCEEE); - a = ff(a, b, c, d, buffer[i+ 4], 7, 0xF57C0FAF); - d = ff(d, a, b, c, buffer[i+ 5], 12, 0x4787C62A); - c = ff(c, d, a, b, buffer[i+ 6], 17, 0xA8304613); - b = ff(b, c, d, a, buffer[i+ 7], 22, 0xFD469501); - a = ff(a, b, c, d, buffer[i+ 8], 7, 0x698098D8); - d = ff(d, a, b, c, buffer[i+ 9], 12, 0x8B44F7AF); - c = ff(c, d, a, b, buffer[i+10], 17, 0xFFFF5BB1); - b = ff(b, c, d, a, buffer[i+11], 22, 0x895CD7BE); - a = ff(a, b, c, d, buffer[i+12], 7, 0x6B901122); - d = ff(d, a, b, c, buffer[i+13], 12, 0xFD987193); - c = ff(c, d, a, b, buffer[i+14], 17, 0xA679438E); - b = ff(b, c, d, a, buffer[i+15], 22, 0x49B40821); - a = gg(a, b, c, d, buffer[i+ 1], 5, 0xF61E2562); - d = gg(d, a, b, c, buffer[i+ 6], 9, 0xC040B340); - c = gg(c, d, a, b, buffer[i+11], 14, 0x265E5A51); - b = gg(b, c, d, a, buffer[i+ 0], 20, 0xE9B6C7AA); - a = gg(a, b, c, d, buffer[i+ 5], 5, 0xD62F105D); - d = gg(d, a, b, c, buffer[i+10], 9, 0x02441453); - c = gg(c, d, a, b, buffer[i+15], 14, 0xD8A1E681); - b = gg(b, c, d, a, buffer[i+ 4], 20, 0xE7D3FBC8); - a = gg(a, b, c, d, buffer[i+ 9], 5, 0x21E1CDE6); - d = gg(d, a, b, c, buffer[i+14], 9, 0xC33707D6); - c = gg(c, d, a, b, buffer[i+ 3], 14, 0xF4D50D87); - b = gg(b, c, d, a, buffer[i+ 8], 20, 0x455A14ED); - a = gg(a, b, c, d, buffer[i+13], 5, 0xA9E3E905); - d = gg(d, a, b, c, buffer[i+ 2], 9, 0xFCEFA3F8); - c = gg(c, d, a, b, buffer[i+ 7], 14, 0x676F02D9); - b = gg(b, c, d, a, buffer[i+12], 20, 0x8D2A4C8A); - a = hh(a, b, c, d, buffer[i+ 5], 4, 0xFFFA3942); - d = hh(d, a, b, c, buffer[i+ 8], 11, 0x8771F681); - c = hh(c, d, a, b, buffer[i+11], 16, 0x6D9D6122); - b = hh(b, c, d, a, buffer[i+14], 23, 0xFDE5380C); - a = hh(a, b, c, d, buffer[i+ 1], 4, 0xA4BEEA44); - d = hh(d, a, b, c, buffer[i+ 4], 11, 0x4BDECFA9); - c = hh(c, d, a, b, buffer[i+ 7], 16, 0xF6BB4B60); - b = hh(b, c, d, a, buffer[i+10], 23, 0xBEBFBC70); - a = hh(a, b, c, d, buffer[i+13], 4, 0x289B7EC6); - d = hh(d, a, b, c, buffer[i+ 0], 11, 0xEAA127FA); - c = hh(c, d, a, b, buffer[i+ 3], 16, 0xD4EF3085); - b = hh(b, c, d, a, buffer[i+ 6], 23, 0x04881D05); - a = hh(a, b, c, d, buffer[i+ 9], 4, 0xD9D4D039); - d = hh(d, a, b, c, buffer[i+12], 11, 0xE6DB99E5); - c = hh(c, d, a, b, buffer[i+15], 16, 0x1FA27CF8); - b = hh(b, c, d, a, buffer[i+ 2], 23, 0xC4AC5665); - a = ii(a, b, c, d, buffer[i+ 0], 6, 0xF4292244); - d = ii(d, a, b, c, buffer[i+ 7], 10, 0x432AFF97); - c = ii(c, d, a, b, buffer[i+14], 15, 0xAB9423A7); - b = ii(b, c, d, a, buffer[i+ 5], 21, 0xFC93A039); - a = ii(a, b, c, d, buffer[i+12], 6, 0x655B59C3); - d = ii(d, a, b, c, buffer[i+ 3], 10, 0x8F0CCC92); - c = ii(c, d, a, b, buffer[i+10], 15, 0xFFEFF47D); - b = ii(b, c, d, a, buffer[i+ 1], 21, 0x85845DD1); - a = ii(a, b, c, d, buffer[i+ 8], 6, 0x6FA87E4F); - d = ii(d, a, b, c, buffer[i+15], 10, 0xFE2CE6E0); - c = ii(c, d, a, b, buffer[i+ 6], 15, 0xA3014314); - b = ii(b, c, d, a, buffer[i+13], 21, 0x4E0811A1); - a = ii(a, b, c, d, buffer[i+ 4], 6, 0xF7537E82); - d = ii(d, a, b, c, buffer[i+11], 10, 0xBD3AF235); - c = ii(c, d, a, b, buffer[i+ 2], 15, 0x2AD7D2BB); - b = ii(b, c, d, a, buffer[i+ 9], 21, 0xEB86D391); - w[0] = add(a, w[0]); - w[1] = add(b, w[1]); - w[2] = add(c, w[2]); - w[3] = add(d, w[3]); - } - var t = []; - for (var i = 0; i < 4; i++) - for (var j = 0; j < 4; j++) - t[i * 4 + j] = (w[i] >> (8 * j)) & 0xFF; - return t; - } - return function (s, ofs, len) { - var buf = []; - if (s.array) { - var a = s.array; - for (var i = 0; i < len; i+=4) { - var j = i + ofs; - buf[i>>2] = a[j] | (a[j+1] << 8) | (a[j+2] << 16) | (a[j+3] << 24); - } - for (; i < len; i++) buf[i>>2] |= a[i + ofs] << (8 * (i & 3)); - } else { - var b = s.getFullBytes(); - for (var i = 0; i < len; i+=4) { - var j = i + ofs; - buf[i>>2] = - b.charCodeAt(j) | (b.charCodeAt(j+1) << 8) | - (b.charCodeAt(j+2) << 16) | (b.charCodeAt(j+3) << 24); - } - for (; i < len; i++) buf[i>>2] |= b.charCodeAt(i + ofs) << (8 * (i & 3)); - } - return new MlStringFromArray(md5(buf, len)); - } -} (); -function caml_ml_flush () { return 0; } -function caml_ml_open_descriptor_out () { return 0; } -function caml_ml_out_channels_list () { return 0; } -function caml_ml_output () { return 0; } -function caml_mod(x,y) { - if (y == 0) caml_raise_zero_divide (); - return x%y; -} -function caml_mul(x,y) { - return ((((x >> 16) * y) << 16) + (x & 0xffff) * y)|0; -} -function caml_notequal (x, y) { return +(caml_compare_val(x,y,false) != 0); } -function caml_obj_block (tag, size) { - var o = [tag]; - for (var i = 1; i <= size; i++) o[i] = 0; - return o; -} -function caml_obj_set_tag (x, tag) { x[0] = tag; return 0; } -function caml_obj_tag (x) { return (x instanceof Array)?x[0]:1000; } -function caml_register_global (n, v) { caml_global_data[n + 1] = v; } -var caml_named_values = {}; -function caml_register_named_value(nm,v) { - caml_named_values[nm] = v; return 0; -} -function caml_string_compare(s1, s2) { return s1.compare(s2); } -function caml_string_equal(s1, s2) { - var b1 = s1.fullBytes; - var b2 = s2.fullBytes; - if (b1 != null && b2 != null) return (b1 == b2)?1:0; - return (s1.getFullBytes () == s2.getFullBytes ())?1:0; -} -function caml_string_notequal(s1, s2) { return 1-caml_string_equal(s1, s2); } -function caml_sys_get_config () { - return [0, new MlWrappedString("Unix"), 32]; -} -function caml_sys_random_seed () { - return new Date()^0xffffffff*Math.random(); -} -function caml_update_dummy (x, y) { - if( typeof y==="function" ) { x.fun = y; return 0; } - if( y.fun ) { x.fun = y.fun; return 0; } - var i = y.length; while (i--) x[i] = y[i]; return 0; -} @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-11 22:16:44
|
Revision: 1673 http://toss.svn.sourceforge.net/toss/?rev=1673&view=rev Author: lukaszkaiser Date: 2012-02-11 22:16:36 +0000 (Sat, 11 Feb 2012) Log Message: ----------- Moving WebClient to Client, first JS unit test with phantomjs, correcting Client bug for WebKit, describing compilation on OSX. Modified Paths: -------------- trunk/Toss/.cvsignore trunk/Toss/Client/JsHandler.js trunk/Toss/Client/Local.js trunk/Toss/Client/State.js trunk/Toss/Client/index.html trunk/Toss/Makefile trunk/Toss/README trunk/Toss/www/develop.xml Added Paths: ----------- trunk/Toss/Client/ trunk/Toss/Client/GameSelection.ml trunk/Toss/Client/JsHandler.ml trunk/Toss/Client/Makefile trunk/Toss/Client/clientTest.js Removed Paths: ------------- trunk/Toss/Server/GameSelection.ml trunk/Toss/Server/JsHandler.ml trunk/Toss/WebClient/ Property Changed: ---------------- trunk/Toss/ Property changes on: trunk/Toss ___________________________________________________________________ Modified: svn:ignore - # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . Toss.docdir _build TossServer *.native *Profile.log gmon.out *~ *.annot *.cmx *.cmi *.o *.cmo *.a *.cmxa log.* + # We are still using .cvsignore files as we find them easier to manage # than svn properties. Therefore if you change .cvsignore do the following. # svn propset svn:ignore -F .cvsignore . Toss.docdir _build TossServer *.native *.byte *Profile.log gmon.out *~ *.annot *.cmx *.cmi *.o *.cmo *.a *.cmxa log.* Modified: trunk/Toss/.cvsignore =================================================================== --- trunk/Toss/.cvsignore 2012-02-10 02:21:07 UTC (rev 1672) +++ trunk/Toss/.cvsignore 2012-02-11 22:16:36 UTC (rev 1673) @@ -6,6 +6,7 @@ _build TossServer *.native +*.byte *Profile.log gmon.out *~ Copied: trunk/Toss/Client/GameSelection.ml (from rev 1672, trunk/Toss/Server/GameSelection.ml) =================================================================== --- trunk/Toss/Client/GameSelection.ml (rev 0) +++ trunk/Toss/Client/GameSelection.ml 2012-02-11 22:16:36 UTC (rev 1673) @@ -0,0 +1,1065 @@ +(* In-source definitions of several games, loading games from strings. *) + +type game_state_data = { + heuristic : Formula.real_expr array array; (** heuristic *) + game_state : (Arena.game * Arena.game_state); (** game and state *) + playclock : int; (** playclock *) + game_str : string; (** game representation *) +} + +let compute_heuristic advr (game, state) = + let pat_arr = Array.of_list game.Arena.patterns in + let pl_heur l = + let len = List.length l.Arena.heur in + if len = 0 || len > Array.length pat_arr then raise Not_found else + let add_pat (i, h) pw = + let pat = Formula.Times (Formula.Const pw, pat_arr.(i)) in + (i+1, Formula.Plus (pat, h)) in + snd (List.fold_left add_pat (0, Formula.Const 0.) l.Arena.heur) in + try + let res = Array.map (fun a-> Array.map pl_heur a) game.Arena.graph in + res + with Not_found -> + Heuristic.default_heuristic ~struc:state.Arena.struc ?advr game + +let compile_game_data game_name game_str = + let (game, game_state as game_with_state) = + ArenaParser.parse_game_state Lexer.lex (Lexing.from_string game_str) in + let adv_ratio = + try Some (float_of_string (List.assoc "adv_ratio" game.Arena.data)) + with Not_found -> None in + let heuristic = compute_heuristic adv_ratio game_with_state in + game_name, + {heuristic = heuristic; + game_state = game_with_state; + playclock = 30; (* game clock from where? *) + game_str = game_str; + } + + +let chess_str = (" +PLAYERS 1, 2 +DATA depth: 0, adv_ratio: 1 +SET Sum (x | wP(x) : 1) +SET Sum (x | wR(x) : 1) +SET Sum (x | wN(x) : 1) +SET Sum (x | wB(x) : 1) +SET Sum (x | wQ(x) : 1) +SET Sum (x | bP(x) : 1) +SET Sum (x | bR(x) : 1) +SET Sum (x | bN(x) : 1) +SET Sum (x | bB(x) : 1) +SET Sum (x | bQ(x) : 1) +SET Sum (x | wBeats(x) : 1 + :(b(x)) + 3 * :(bK(x))) +SET Sum (x | bBeats(x) : 1 + :(w(x)) + 3 * :(wK(x))) +REL w(x) = wP(x) or wR(x) or wN(x) or wB(x) or wQ(x) or wK(x) +REL b(x) = bP(x) or bR(x) or bN(x) or bB(x) or bQ(x) or bK(x) +REL DoubleC(x, y) = ex z ((C(x, z) and C(z, y)) or (C(y, z) and C(z, x))) +REL DoubleR(x, y) = ex z ((R(x, z) and R(z, y)) or (R(y, z) and R(z, x))) +REL KnightRCC(x, y) = ex z ((R(x, z) or R(z, x)) and DoubleC(z, y)) +REL KnightCRR(x, y) = ex z ((C(x, z) or C(z, x)) and DoubleR(z, y)) +REL Knight(x, y) = KnightRCC(x, y) or KnightCRR(x, y) +REL FreeD1 (x, y) = tc x, y (D1 (x, y) and not w(y) and not b(y)) +REL FreeD2 (x, y) = tc x, y (D2 (x, y) and not w(y) and not b(y)) +REL Diag1 (x, y) = ex z (FreeD1 (x, z) and (z = y or D1 (z, y))) +REL Diag2 (x, y) = ex z (FreeD2 (x, z) and (z = y or D2 (z, y))) +REL Diag (x, y) = Diag1 (x, y) or Diag2 (x, y) +REL FreeC (x, y) = tc x, y ((C(x, y) or C(y, x)) and not w(y) and not b(y)) +REL FreeR (x, y) = tc x, y ((R(x, y) or R(y, x)) and not w(y) and not b(y)) +REL Col (x, y) = ex z (FreeC (x, z) and (z = y or (C(z, y) or C(y, z)))) +REL Row (x, y) = ex z (FreeR (x, z) and (z = y or (R(z, y) or R(y, z)))) +REL Line (x, y) = Col (x, y) or Row (x, y) +REL Near (x, y) = C(x,y) or C(y,x) or R(x,y) or R(y,x) or D1(x, y) or D2(x, y) +REL wPBeats (x) = ex y (wP(y) and ex z ((R(y, z) or R(z, y)) and C(z, x))) +REL bPBeats (x) = ex y (bP(y) and ex z ((R(y, z) or R(z, y)) and C(x, z))) +REL wDiagBeats (x) = ex y ((wQ(y) or wB(y)) and Diag(y, x)) +REL bDiagBeats (x) = ex y ((bQ(y) or bB(y)) and Diag(y, x)) +REL wLineBeats (x) = ex y ((wQ(y) or wR(y)) and Line(y, x)) +REL bLineBeats (x) = ex y ((bQ(y) or bR(y)) and Line(y, x)) +REL wFigBeats(x) = wDiagBeats(x) or wLineBeats(x) or ex y(wN(y) and Knight(y,x)) +REL bFigBeats(x) = bDiagBeats(x) or bLineBeats(x) or ex y(bN(y) and Knight(y,x)) +REL wBeats(x) = wFigBeats(x) or wPBeats(x) or ex y (wK(y) and Near(y, x)) +REL bBeats(x) = bFigBeats(x) or bPBeats(x) or ex y (bK(y) and Near(y, x)) +REL CheckW() = ex x (wK(x) and bBeats(x)) +REL CheckB() = ex x (bK(x) and wBeats(x)) +RULE WhitePawnMove: + [ | | ] \" + ... + ... + + wP +\" -> [ | | ] \" + ... + wP + + . +\" emb w, b pre not IsEight(a2) post not CheckW() +RULE BlackPawnMove: + [ | | ] \" + ... + bP. + + . +\" -> [ | | ] \" + ... + ... + + bP +\" emb w, b pre not IsFirst(a1) post not CheckB() +RULE WhitePawnMoveDbl: + [ | | ] \" + + . + ... + ... + + wP +\" -> [ | | ] \" + ... + wP + + . + ... + ... +\" emb w, b pre IsSecond(a1) post not CheckW() +RULE BlackPawnMoveDbl: + [ | | ] \" + ... + bP. + + . + ... + ... +\" -> [ | | ] \" + + + ... + ... + + bP +\" emb w, b pre IsSeventh(a3) post not CheckB() +RULE WhitePawnBeat: + [ a, b | wP { a }; b { b } | - ] + -> + [ a, b | wP { b } | - ] + emb w, b + pre not IsEight(b) and ex z (C(a, z) and (R(z, b) or R(b, z))) + post not CheckW() +RULE WhitePawnBeatPromote: + [ a, b | wP { a }; b { b } | - ] + -> + [ a, b | wQ { b } | - ] + emb w, b + pre IsEight(b) and ex z (C(a, z) and (R(z, b) or R(b, z))) + post not CheckW() +RULE WhitePawnBeatRDbl: + [ | | ] \" + ... + ?..-bP + ... + ? ... + ... + wP.bP +\" -> [ | | ] \" + ... + ?... + ... + ? wP. + ... + .... +\" emb w, b post not CheckW() +RULE WhitePawnBeatLDbl: + [ | | ] \" + ... + -bP? + ... + . ?.. + ... + bP.wP +\" -> [ | | ] \" + ... + ...? + ... + wP ?.. + ... + .... +\" emb w, b post not CheckW() +RULE BlackPawnBeat: + [ a, b | bP { a }; w { b } | - ] + -> + [ a, b | bP { b } | - ] + emb w, b + pre not IsFirst(b) and ex z (C(z, a) and (R(z, b) or R(b, z))) + post not CheckB() +RULE BlackPawnBeatPromote: + [ a, b | bP { a }; w { b } | - ] + -> + [ a, b | bQ { b } | - ] + emb w, b + pre IsFirst(b) and ex z (C(z, a) and (R(z, b) or R(b, z))) + post not CheckB() +RULE BlackPawnBeatRDbl: + [ | | ] \" + ... + bP.wP + ... + ? ... + ... + ?..-wP +\" -> [ | | ] \" + ... + .... + ... + ? bP. + ... + ?... +\" emb w, b post not CheckB() +RULE BlackPawnBeatLDbl: + [ | | ] \" + ... + wP.bP + ... + . ?.. + ... + -wP? +\" -> [ | | ] \" + ... + .... + ... + bP ?.. + ... + ...? +\" emb w, b post not CheckB() +RULE WhitePawnPromote: + [ | | ] \" + ... + ... + + wP +\" -> [ | | ] \" + ... + wQ. + + . +\" emb w, b pre IsEight(a2) post not CheckW() +RULE BlackPawnPromote: + [ | | ] \" + ... + bP. + + . +\" -> [ | | ] \" + ... + ... + + bQ +\" emb w, b pre IsFirst(a1) post not CheckB() +RULE WhiteKnight: + [ a, b | wN { a }; _opt_b { b } | - ] + -> + [ a, b | wN { b } | - ] + emb w, b pre Knight(a, b) post not CheckW() +RULE BlackKnight: + [ a, b | bN { a }; _opt_w { b } | - ] + -> + [ a, b | bN { b } | - ] + emb w, b pre Knight(a, b) post not CheckB() +RULE WhiteBishop: + [ a, b | wB { a }; _opt_b { b } | - ] + -> + [ a, b | wB { b } | - ] + emb w, b pre Diag(a, b) post not CheckW() +RULE BlackBishop: + [ a, b | bB { a }; _opt_w { b } | - ] + -> + [ a, b | bB { b } | - ] + emb w, b pre Diag(a, b) post not CheckB() +RULE WhiteRook: + [ a, b | wR { a }; _opt_b { b } | - ] + -> + [ a, b | wR { b } | - ] + emb w, b pre not IsA1(a) and not IsH1(a) and Line(a, b) post not CheckW() +RULE WhiteRookA1: + [ a, b | wR { a }; _opt_b { b } | - ] + -> + [ a, b | wR { b } | - ] + emb w, b pre IsA1(a) and Line(a, b) post not CheckW() +RULE WhiteRookH1: + [ a, b | wR { a }; _opt_b { b } | - ] + -> + [ a, b | wR { b } | - ] + emb w, b pre IsH1(a) and Line(a, b) post not CheckW() +RULE BlackRook: + [ a, b | bR { a }; _opt_w { b } | - ] + -> + [ a, b | bR { b } | - ] + emb w, b pre not IsA8(a) and not IsH8(a) and Line(a, b) post not CheckB() +RULE BlackRookA8: + [ a, b | bR { a }; _opt_w { b } | - ] + -> + [ a, b | bR { b } | - ] + emb w, b pre IsA8(a) and Line(a, b) post not CheckB() +RULE BlackRookH8: + [ a, b | bR { a }; _opt_w { b } | - ] + -> + [ a, b | bR { b } | - ] + emb w, b pre IsH8(a) and Line(a, b) post not CheckB() +RULE WhiteQueen: + [ a, b | wQ { a }; _opt_b { b } | - ] + -> + [ a, b | wQ { b } | - ] + emb w, b pre (Line(a, b) or Diag(a, b)) post not CheckW() +RULE BlackQueen: + [ a, b | bQ { a }; _opt_w { b } | - ] + -> + [ a, b | bQ { b } | - ] + emb w, b pre (Line(a, b) or Diag(a, b)) post not CheckB() +RULE WhiteKing: + [ a, b | wK { a }; _opt_b { b } | - ] + -> + [ a, b | wK { b } | - ] + emb w, b pre Near(a, b) post not CheckW() +RULE BlackKing: + [ a, b | bK { a }; _opt_w { b } | - ] + -> + [ a, b | bK { b } | - ] + emb w, b pre Near(a, b) post not CheckB() +RULE WhiteLeftCastle: + [ | | ] \" + ... ... ... + wR. ... wK. +\" -> [ | | ] \" + ... ... ... + ... wK.wR ... +\" emb w,b pre not(bBeats(c1) or bBeats(d1) or bBeats(e1)) and before + not WhiteRookA1, not WhiteKing, not WhiteLeftCastle, not WhiteRightCastle +RULE WhiteRightCastle: + [ | | ] \" + ... ... + wK. ...wR +\" -> [ | | ] \" + ... ... + ...wR wK. +\" emb w,b pre not (bBeats(a1) or bBeats(b1) or bBeats(c1)) and before + not WhiteRookH1, not WhiteKing, not WhiteLeftCastle, not WhiteRightCastle +RULE BlackLeftCastle: + [ | | ] \" + ... ... ... + bR. ... bK. +\" -> [ | | ] \" + ... ... ... + ... bK.bR ... +\" emb w,b pre not(wBeats(c1) or wBeats(d1) or wBeats(e1)) and before + not BlackRookA8, not BlackKing, not BlackLeftCastle, not BlackRightCastle +RULE BlackRightCastle: + [ | | ] \" + ... ... + bK. ...bR +\" -> [ | | ] \" + ... ... + ...bR bK. +\" emb w,b pre not (wBeats(a1) or wBeats(b1) or wBeats(c1)) and before + not BlackRookH8, not BlackKing, not BlackLeftCastle, not BlackRightCastle +LOC 0 { + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 1]; + [WhitePawnMoveDbl -> 1]; + [WhitePawnBeat -> 1]; + [WhitePawnBeatPromote -> 1]; + [WhitePawnBeatLDbl -> 1]; + [WhitePawnBeatRDbl -> 1]; + [WhitePawnPromote -> 1]; + [WhiteKnight -> 1]; + [WhiteBishop -> 1]; + [WhiteRook -> 1]; + [WhiteRookA1 -> 1]; + [WhiteRookH1 -> 1]; + [WhiteQueen -> 1]; + [WhiteLeftCastle -> 1]; + [WhiteRightCastle -> 1]; + [WhiteKing -> 1] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 1 { + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 0]; + [BlackPawnMoveDbl -> 0]; + [BlackPawnBeat -> 0]; + [BlackPawnBeatPromote -> 0]; + [BlackPawnBeatLDbl -> 0]; + [BlackPawnBeatRDbl -> 0]; + [BlackPawnPromote -> 0]; + [BlackKnight -> 0]; + [BlackBishop -> 0]; + [BlackRook -> 0]; + [BlackRookA8 -> 0]; + [BlackRookH8 -> 0]; + [BlackQueen -> 0]; + [BlackLeftCastle -> 0]; + [BlackRightCastle -> 0]; + [BlackKing -> 0] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +MODEL [ | | ] \" + ... ... ... ... + bR bN.bB bQ.bK bB.bN bR. + ... ... ... ... + bP.bP bP.bP bP.bP bP.bP + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + wP wP.wP wP.wP wP.wP wP. + ... ... ... ... + wR.wN wB.wQ wK.wB wN.wR +\" with +D1(x, y) = ex z ( (R(x, z) and C(z, y)) or (R(y, z) and C(z, x)) ) ; +D2(x, y) = ex z ( (R(x, z) and C(y, z)) or (R(y, z) and C(x, z)) ) ; +IsFirst(x) = not ex z C(z, x) ; +IsSecond(x) = ex y (C(y, x) and IsFirst(y)) ; +IsEight(x) = not ex z C(x, z) ; +IsSeventh(x) = ex y (C(x, y) and IsEight(y)) ; +IsA1(x) = not ex z R(z, x) and IsFirst(x) ; +IsH1(x) = not ex z R(x, z) and IsFirst(x) ; +IsA8(x) = not ex z R(z, x) and IsEight(x) ; +IsH8(x) = not ex z R(x, z) and IsEight(x) +") + +let connect4_str = ("PLAYERS 1, 2 +DATA r1: circle, r2: line, adv_ratio: 4, depth: 6 +REL Row4 (x, y, z, v) = R(x, y) and R(y, z) and R(z, v) +REL Col4 (x, y, z, v) = C(x, y) and C(y, z) and C(z, v) +REL DiagA4 (x, y, z, v) = DiagA(x, y) and DiagA(y, z) and DiagA(z, v) +REL DiagB4 (x, y, z, v) = DiagB(x, y) and DiagB(y, z) and DiagB(z, v) +REL Conn4 (x, y, z, v) = + Row4(x,y,z,v) or Col4(x,y,z,v) or DiagA4(x,y,z,v) or DiagB4(x,y,z,v) +REL WinQ() = + ex x,y,z,v (Q(x) and Q(y) and Q(z) and Q(v) and Conn4(x, y, z, v)) +REL WinP() = + ex x,y,z,v (P(x) and P(y) and P(z) and P(v) and Conn4(x, y, z, v)) +REL EmptyUnder (x) = ex y (C(y, x) and not P(y) and not Q(y)) +RULE Cross: + [a | P:1 {} | - ] -> [a | P (a) | - ] emb Q, P + pre not EmptyUnder (a) and not WinQ() +RULE Circle: + [a | Q:1 {} | - ] -> [a | Q (a) | - ] emb Q, P + pre not EmptyUnder (a) and not WinP() +LOC 0 { + PLAYER 1 { + PAYOFF :(WinP()) - :(WinQ()) + MOVES [Cross -> 1] + } + PLAYER 2 { + PAYOFF :(WinQ()) - :(WinP()) + } +} +LOC 1 { + PLAYER 1 { + PAYOFF :(WinP()) - :(WinQ()) + } + PLAYER 2 { + PAYOFF :(WinQ()) - :(WinP()) + MOVES [Circle -> 0] + } +} +MODEL [ | P:1 {}; Q:1 {} | ] \" + ... ... ... + ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... + ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... + ... ... ... + ... ... ... ... + ... ... ... ... +\" with DiagA (x, y) = ex u (R(x, u) and C(u, y)) ; + DiagB (x, y) = ex u (R(x, u) and C(y, u)) +") + +let pawn_whopping_str = (" +PLAYERS 1, 2 +DATA depth: 4, adv_ratio: 2 +REL DiagW (x, y) = ex z (C(x, z) and (R(y, z) or R(z, y))) +REL DiagB (x, y) = ex z (C(z, x) and (R(y, z) or R(z, y))) +REL IsFirst(x) = not ex z C(z, x) +REL IsSecond(x) = ex y (C(y, x) and IsFirst(y)) +REL IsEight(x) = not ex z C(x, z) +REL IsSeventh(x) = ex y (C(x, y) and IsEight(y)) +REL WhiteEnds() = (ex x (wP(x) and not ex y C(x, y))) or (not ex z bP(z)) +REL BlackEnds() = (ex x (bP(x) and not ex y C(y, x))) or (not ex z wP(z)) +RULE WhiteBeat: + [ a, b | wP { a }; bP { b } | - ] -> [ a, b | wP { b } | - ] emb wP, bP + pre DiagW(a, b) and not BlackEnds() +RULE WhiteMove: + [ | bP:1 {}; R:2 {} | ] \" + + . + + wP +\" -> [ | bP:1 {}; R:2 {} | ] \" + + wP + + . +\" emb wP, bP pre not BlackEnds() +RULE WhiteMoveTwo: + [ | bP:1 {}; R:2 {} | ] \" + + . + + . + + wP +\" -> [ | bP:1 {}; R:2 {} | ] \" + + wP + + . + + . +\" emb wP, bP pre IsSecond(a1) and not BlackEnds() +RULE WhiteRightPassant: + [ | | ] \" + ... + ?..-bP + ... + ? ... + ... + wP.bP +\" -> [ | | ] \" + ... + ?... + ... + ? wP. + ... + .... +\" emb wP, bP pre not BlackEnds() +RULE WhiteLeftPassant: + [ | | ] \" + ... + -bP? + ... + . ?.. + ... + bP.wP +\" -> [ | | ] \" + ... + ...? + ... + wP ?.. + ... + .... +\" emb wP, bP pre not BlackEnds() +RULE BlackBeat: + [ a, b | bP { a }; wP { b } | - ] -> [ a, b | bP { b } | - ] emb wP, bP + pre DiagB(a, b) and not WhiteEnds() +RULE BlackMove: + [ | R:2 {}; wP:1 {} | ] \" + + bP + + . +\" -> [ | R:2 {}; wP:1 {} | ] \" + + . + + bP +\" emb wP, bP pre not WhiteEnds() +RULE BlackMoveTwo: + [ | R:2 {}; wP:1 {} | ] \" + + bP + + . + + . +\" -> [ | R:2 {}; wP:1 {} | ] \" + + . + + . + + bP +\" emb wP, bP pre IsSeventh(a3) and not WhiteEnds() +RULE BlackRightPassant: + [ | | ] \" + ... + bP.wP + ... + ? ... + ... + ?..-wP +\" -> [ | | ] \" + ... + .... + ... + ? bP. + ... + ?... +\" emb wP, bP pre not WhiteEnds() +RULE BlackLeftPassant: + [ | | ] \" + ... + wP.bP + ... + . ?.. + ... + -wP? +\" -> [ | | ] \" + ... + .... + ... + bP ?.. + ... + ...? +\" emb wP, bP pre not WhiteEnds() +LOC 0 { + PLAYER 1 { + PAYOFF :(WhiteEnds()) - :(BlackEnds()) + MOVES + [WhiteBeat -> 1]; [WhiteMove -> 1]; [WhiteMoveTwo -> 1]; + [WhiteRightPassant -> 1]; [WhiteLeftPassant -> 1] + } + PLAYER 2 { PAYOFF :(BlackEnds()) - :(WhiteEnds()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(WhiteEnds()) - :(BlackEnds()) } + PLAYER 2 { + PAYOFF :(BlackEnds()) - :(WhiteEnds()) + MOVES + [BlackBeat -> 0]; [BlackMove -> 0]; [BlackMoveTwo -> 0]; + [BlackRightPassant -> 0]; [BlackLeftPassant -> 0] + } +} +MODEL [ | | ] \" + ... ... ... ... + ... ... ... ... + ... ... ... ... + bP.bP bP.bP bP.bP bP.bP + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + wP wP.wP wP.wP wP.wP wP. + ... ... ... ... + ... ... ... ... +\" +") + +let breakthrough_str = (" +PLAYERS 1, 2 +DATA depth: 2, adv_ratio: 2 +REL DiagW (x, y) = ex z (C(x, z) and (R(y, z) or R(z, y))) +REL DiagB (x, y) = ex z (C(z, x) and (R(y, z) or R(z, y))) +RULE WhiteDiag: + [ a, b | W { a }; _opt_B { b } | - ] + -> + [ a, b | W { b } | - ] + emb W, B pre DiagW(a, b) and not ex x (B(x) and not ex y C(y, x)) +RULE WhiteStraight: + [ | B:1 {}; R:2 {} | ] \" + + . + + W +\" -> [ | B:1 {}; R:2 {} | + ] \" + + W + + . +\" emb W, B pre not ex x (B(x) and not ex y C(y, x)) +RULE BlackDiag: + [ a, b | B { a }; _opt_W { b } | - ] + -> + [ a, b | B { b } | - ] + emb W, B pre DiagB(a, b) and not ex x (W(x) and not ex y C(x, y)) +RULE BlackStraight: + [ | R:2 {}; W:1 {} | ] \" + + B + + . +\" -> [ | R:2 {}; W:1 {} | + ] \" + + . + + B +\" emb W, B pre not ex x (W(x) and not ex y C(x, y)) +LOC 0 { + PLAYER 1 { + PAYOFF + :(ex x (W(x) and not ex y C(x, y))) - :(ex x (B(x) and not ex y C(y, x))) + MOVES + [WhiteDiag -> 1]; [WhiteStraight -> 1] + } + PLAYER 2 { + PAYOFF + :(ex x (B(x) and not ex y C(y, x))) - :(ex x (W(x) and not ex y C(x, y))) + } +} +LOC 1 { + PLAYER 1 { + PAYOFF + :(ex x (W(x) and not ex y C(x, y))) - :(ex x (B(x) and not ex y C(y, x))) + } + PLAYER 2 { + PAYOFF + :(ex x (B(x) and not ex y C(y, x))) - :(ex x (W(x) and not ex y C(x, y))) + MOVES + [BlackDiag -> 0]; [BlackStraight -> 0] + } +} +MODEL [ | | ] \" + ... ... ... ... + B B..B B..B B..B B.. + ... ... ... ... + B..B B..B B..B B..B + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + W W..W W..W W..W W.. + ... ... ... ... + W..W W..W W..W W..W +\" +") + + +let checkers_str = (" +PLAYERS 1, 2 +DATA depth: 4, adv_ratio: 2 +REL w(x) = W(x) or Wq(x) +REL b(x) = B(x) or Bq(x) +REL AnyDiag (x, y) = + DiagWa (x, y) or DiagWb (x, y) or DiagBa (x, y) or DiagBb (x, y) +REL Diag2 (x, y, z) = DiagW2 (x, y, z) or DiagB2 (x, y, z) +REL BeatsW (x, y) = ex z (b(z) and not b(y) and not w(y) and DiagW2 (x, z, y)) +REL BeatsWX (x, y) = ex z (b(z) and not b(y) and not w(y) and Diag2 (x, z, y)) +REL BeatsB (x, y) = ex z (w(z) and not b(y) and not w(y) and DiagB2 (x, z, y)) +REL BeatsBX (x, y) = ex z (w(z) and not b(y) and not w(y) and Diag2 (x, z, y)) +REL BJumps() = ex x, y ((B(x) and BeatsB (x, y)) or (Bq(x) and BeatsBX (x, y))) +REL WJumps() = ex x, y ((W(x) and BeatsW (x, y)) or (Wq(x) and BeatsWX (x, y))) +RULE RedMove: + [ a, b | W { a } | - ] -> [ a, b | W { b } | - ] emb w, b + pre (not IsEight(b)) and (DiagWa(a, b) or DiagWb(a, b)) and not WJumps() +RULE WhiteMove: + [ a, b | B { a } | - ] -> [ a, b | B { b } | - ] emb w, b + pre (not IsFirst(b)) and (DiagBa(a, b) or DiagBb(a, b)) and not BJumps() +RULE RedPromote: + [ a, b | W { a } | - ] -> [ a, b | Wq { b } | - ] emb w, b + pre (IsEight(b)) and (DiagWa(a, b) or DiagWb(a, b)) and not WJumps() +RULE WhitePromote: + [ a, b | B { a } | - ] -> [ a, b | Bq { b } | - ] emb w, b + pre (IsFirst(b)) and (DiagBa(a, b) or DiagBb(a, b)) and not BJumps() +RULE RedQMove: + [ a, b | Wq { a } | - ] -> [ a, b | Wq { b } | - ] emb w, b + pre AnyDiag (a, b) and not WJumps() +RULE WhiteQMove: + [ a, b | Bq { a } | - ] -> [ a, b | Bq { b } | - ] emb w, b + pre AnyDiag (a, b) and not BJumps() +RULE RedBeat: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | W { c } | - ] emb w, b + pre DiagW2 (a, b, c) and not IsEight(c) + post not ex x, y (_new_W(x) and BeatsWX (x, y)) +RULE WhiteBeat: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | B { c } | - ] emb w, b + pre DiagB2 (a, b, c) and not IsFirst(c) + post not ex x, y (_new_B(x) and BeatsBX (x, y)) +RULE RedBeatBoth: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | W { c } | - ] emb w, b + pre _new_W(a) and Diag2 (a, b, c) and not IsEight(c) + post not ex x, y (_new_W(x) and BeatsWX (x, y)) +RULE WhiteBeatBoth: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | B { c } | - ] emb w, b + pre _new_B(a) and Diag2 (a, b, c) and not IsFirst(c) + post not ex x, y (_new_B(x) and BeatsBX (x, y)) +RULE RedBeatPromote: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | Wq { c } | - ] emb w, b + pre DiagW2 (a, b, c) and IsEight(c) +RULE WhiteBeatPromote: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | Bq { c } | - ] emb w, b + pre DiagB2 (a, b, c) and IsFirst(c) +RULE RedBeatCont: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | W { c } | - ] emb w, b + pre DiagW2 (a, b, c) and not IsEight(c) + post ex x, y (_new_W(x) and BeatsWX (x, y)) +RULE WhiteBeatCont: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | B { c } | - ] emb w, b + pre DiagB2 (a, b, c) and not IsFirst(c) + post ex x, y (_new_B(x) and BeatsBX (x, y)) +RULE RedBeatBothCont: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | W { c } | - ] emb w, b + pre _new_W(a) and Diag2 (a, b, c) and not IsEight(c) + post ex x, y (_new_W(x) and BeatsWX (x, y)) +RULE WhiteBeatBothCont: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | B { c } | - ] emb w, b + pre _new_B(a) and Diag2 (a, b, c) and not IsFirst(c) + post ex x, y (_new_B(x) and BeatsBX (x, y)) +RULE RedQBeat: + [ a, b, c | Wq { a }; b { b } | - ] -> [ a, b, c | Wq { c } | - ] emb w, b + pre Diag2 (a, b, c) +RULE WhiteQBeat: + [ a, b, c | Bq { a }; w { b } | - ] -> [ a, b, c | Bq { c } | - ] emb w, b + pre Diag2 (a, b, c) +LOC 0 { + PLAYER 1 { + PAYOFF :(ex x w(x)) - :(ex x b(x)) + MOVES + [RedMove -> 1]; [RedPromote -> 1]; [RedQMove -> 1]; + [RedBeat -> 1]; [RedBeatPromote -> 1]; [RedQBeat -> 1]; + [RedBeatCont -> 2] + } + PLAYER 2 { + PAYOFF :(ex x b(x)) - :(ex x w(x)) + } +} +LOC 1 { + PLAYER 1 { + PAYOFF :(ex x w(x)) - :(ex x b(x)) + } + PLAYER 2 { + PAYOFF :(ex x b(x)) - :(ex x w(x)) + MOVES + [WhiteMove -> 0]; [WhitePromote -> 0]; [WhiteQMove -> 0]; + [WhiteBeat -> 0]; [WhiteBeatPromote -> 0]; [WhiteQBeat -> 0]; + [WhiteBeatCont -> 3] + } +} +LOC 2 { + PLAYER 1 { + PAYOFF :(ex x w(x)) - :(ex x b(x)) + MOVES [RedBeatBoth -> 1]; [RedBeatPromote -> 1]; [RedBeatBothCont -> 2] + } + PLAYER 2 { + PAYOFF :(ex x b(x)) - :(ex x w(x)) + } +} +LOC 3 { + PLAYER 1 { + PAYOFF :(ex x w(x)) - :(ex x b(x)) + } + PLAYER 2 { + PAYOFF :(ex x b(x)) - :(ex x w(x)) + MOVES + [WhiteBeatBoth -> 0]; [WhiteBeatPromote -> 0]; [WhiteBeatBothCont -> 3] + } +} +MODEL [ | Wq:1 { }; Bq:1 { } | + ] \" + ... ... ... ... + B.. B.. B.. B.. + ... ... ... ... + B.. B.. B.. B.. + ... ... ... ... + B.. B.. B.. B.. + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + W.. W.. W.. W.. + ... ... ... ... + W.. W.. W.. W.. + ... ... ... ... + W.. W.. W.. W.. +\" with +IsFirst(x) = not ex z C(z, x) ; +IsEight(x) = not ex z C(x, z) ; +DiagWa (x, y) = ex z (C(x, z) and R(y, z)) ; +DiagBa (x, y) = ex z (C(z, x) and R(z, y)) ; +DiagWb (x, y) = ex z (C(x, z) and R(z, y)) ; +DiagBb (x, y) = ex z (C(z, x) and R(y, z)) ; +DiagW2 (x, y, z) = + (DiagWa (x, y) and DiagWa (y, z)) or (DiagWb (x, y) and DiagWb (y, z)) ; +DiagB2 (x, y, z) = + (DiagBa (x, y) and DiagBa (y, z)) or (DiagBb (x, y) and DiagBb (y, z)) +") + +let gomoku_str = (" +PLAYERS 1, 2 +DATA rCircle: circle, rCross: line, adv_ratio: 5, depth: 2 +REL Row5 (x, y, z, v, w) = R(x, y) and R(y, z) and R(z, v) and R(v, w) +REL Col5 (x, y, z, v, w) = C(x, y) and C(y, z) and C(z, v) and C(v, w) +REL DiagA5 (x, y, z, v, w) = + DiagA(x, y) and DiagA(y, z) and DiagA(z, v) and DiagA(v, w) +REL DiagB5 (x, y, z, v, w) = + DiagB(x, y) and DiagB(y, z) and DiagB(z, v) and DiagB(v, w) +REL Conn5 (x, y, z, v, w) = + Row5(x,y,z,v,w) or Col5(x,y,z,v,w) or DiagA5(x,y,z,v,w) or DiagB5(x,y,z,v,w) +REL WinQ() = + ex x,y,z,v,w (Q(x) and Q(y) and Q(z) and Q(v) and Q(w) and Conn5(x,y,z,v,w)) +REL WinP() = + ex x,y,z,v,w (P(x) and P(y) and P(z) and P(v) and P(w) and Conn5(x,y,z,v,w)) +RULE Cross: + [a1 | P:1 {}; Q:1 {} | - ] + -> + [a1 | P (a1); Q:1 {} | - ] + emb Q, P pre not WinQ() +RULE Circle: + [a1 | P:1 {}; Q:1 {} | - ] + -> + [a1 | P:1 {}; Q (a1) | - ] + emb Q, P pre not WinP() +LOC 0 { + PLAYER 1 { + PAYOFF :(WinP()) - :(WinQ()) + MOVES [Cross -> 1] + } + PLAYER 2 { PAYOFF :(WinQ()) - :(WinP()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(WinP()) - :(WinQ()) } + PLAYER 2 { + PAYOFF :(WinQ()) - :(WinP()) + MOVES [Circle -> 0] + } +} +MODEL [ | P:1 {}; Q:1 {} | ] \" + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... +\" with DiagA (x, y) = ex u (R(x, u) and C(u, y)); + DiagB (x, y) = ex u (R(x, u) and C(y, u)) +") + +let entanglement_str = (" +PLAYERS 1, 2 +RULE Follow: + [ a1, a2 | C { (a2) }; R { (a1) } | + vx { a1->0., a2->0. }; vy { a1->0., a2->0. }; + x { a1->-10., a2->-10. }; y { a1->-10., a2->10. } ] + -> + [ a1, a2 | C { (a1) }; R { (a1) } | + vx { a1->0., a2->0. }; vy { a1->0., a2->0. }; + x { a1->-10., a2->-10. }; y { a1->-10., a2->10. } ] +emb R, C +RULE Wait: + [ a1 | R { (a1) } | + vx { a1->0. }; vy { a1->0. }; x { a1->-10. }; y { a1->-10. } ] + -> + [ a1 | R { (a1) } | + vx { a1->0. }; vy { a1->0. }; x { a1->-10. }; y { a1->-10. } ] +emb R, C +RULE Run: + [ a1, a2 | C:1 { }; E { (a1, a2) }; R { (a1) }; _opt_C { (a1) } | + vx { a1->0., a2->0. }; vy { a1->0., a2->0. }; + x { a1->-10., a2->10. }; y { a1->-10., a2->-10. } ] + -> + [ a1, a2 | C:1 { }; E { (a1, a2) }; R { (a2) }; _opt_C { (a1) } | + vx { a1->0., a2->0. }; vy { a1->0., a2->0. }; + x { a1->-10., a2->10. }; y { a1->-10., a2->-10. } ] +emb R, C +LOC 0 { + PLAYER 1 { + PAYOFF 0. + MOVES [Follow -> 1]; [Wait -> 1] + } + PLAYER 2 { PAYOFF 0. } +} +LOC 1 { + PLAYER 1 { PAYOFF 1. } + PLAYER 2 { + PAYOFF -1. + MOVES [Run -> 0] + } + } +MODEL [ d4, a2, a1, b1, b2, e4, c2, c1, f4, d2, d1, f1, f2, g1, g2, h1, h2, e1, e2, i1, i2 | C { (d4); (e4); (f4) }; E { (a2, a1); (a2, b2); (a1, a2); (a1, b1); (b1, a1); (b1, b2); (b1, c1); (b2, a2); (b2, b1); (b2, c2); (c2, b2); (c2, c1); (c2, d2); (c1, b1); (c1, c2); (c1, d1); (d2, c2); (d2, d1); (d2, e1); (d1, c1); (d1, d2); (d1, e2); (f1, f2); (f1, g1); (f1, e1); (f2, f1); (f2, g2); (f2, e2); (g1, f1); (g1, g2); (g1, h1); (g2, f2); (g2, g1); (g2, h2); (h1, g1); (h1, h2); (h1, i1); (h2, g2); (h2, h1); (h2, i2); (e1, d2); (e1, f1); (e1, e2); (e2, d1); (e2, f2); (e2, e1); (i1, h1); (i1, i2); (i2, h2); (i2, i1) }; R { (e1) }; _opt_C:1 { } | vx { d4->0., a2->0., a1->0., b1->0., b2->0., e4->0., c2->0., c1->0., f4->0., d2->0., d1->0., f1->0., f2->0., g1->0., g2->0., h1->0., h2->0., e1->0., e2->0., i1->0., i2->0. }; vy { d4->0., a2->0., a1->0., b1->0., b2->0., e4->0., c2->0., c1->0., f4->0., d2->0., d1->0., f1->0., f2->0., g1->0., g2->0., h1->0., h2->0., e1->0., e2->0., i1->0., i2->0. }; x { d4->100., a2->-50., a1->-50., b1->0., b2->0., e4->150., c2->50., c1->50., f4->200., d2->100., d1->100., f1->200., f2->200., g1->250., g2->250., h1->300., h2->300., e1->150., e2->150., i1->350., i2->350. }; y { d4->-150., a2->-100., a1->-50., b1->-50., b2->-100., e4->0., c2->-100., c1->-50., f4->-150., d2->-100., d1->-50., f1->-100., f2->-50., g1->-100., g2->-50., h1->-100., h2->-50., e1->-100., e2->-50., i1->-100., i2->-50. } ] +") + +let tictactoe_str = (" +PLAYERS 1, 2 +DATA r1: circle, r2: line, adv_ratio: 5, depth: 3 +REL DiagA (x, y) = ex u (R(x, u) and C(u, y)) +REL DiagB (x, y) = ex u (R(x, u) and C(y, u)) +REL Row3 (x, y, z) = R(x, y) and R(y, z) +REL Col3 (x, y, z) = C(x, y) and C(y, z) +REL DiagA3 (x, y, z) = DiagA(x, y) and DiagA(y, z) +REL DiagB3 (x, y, z) = DiagB(x, y) and DiagB(y, z) +REL Conn3 (x, y, z) = + Row3(x, y, z) or Col3(x, y, z) or DiagA3(x, y, z) or DiagB3(x, y, z) +REL WinQ() = ex x, y, z (Q(x) and Q(y) and Q(z) and Conn3(x, y, z)) +REL WinP() = ex x, y, z (P(x) and P(y) and P(z) and Conn3(x, y, z)) +RULE Cross: + [a | P:1 {} | - ] -> [a | P (a) | - ] emb Q, P pre not WinQ() +RULE Circle: + [a | Q:1 {} | - ] -> [a | Q (a) | - ] emb Q, P pre not WinP() +LOC 0 { + PLAYER 1 { PAYOFF :(WinP()) - :(WinQ()) + MOVES [Cross -> 1] } + PLAYER 2 { PAYOFF :(WinQ()) - :(WinP()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(WinP()) - :(WinQ()) } + PLAYER 2 { PAYOFF :(WinQ()) - :(WinP()) + MOVES [Circle -> 0] } +} +MODEL [ | P:1 {}; Q:1 {} | ] \" + + . . . + + . . . + + . . . +\" +") + +let predef_games = + [ + "Breakthrough", breakthrough_str; + "Checkers", checkers_str; + "Chess", chess_str; + "Connect4", connect4_str; + "Entanglement", entanglement_str; + "Gomoku", gomoku_str; + "Pawn-Whopping", pawn_whopping_str; + "Tic-Tac-Toe", tictactoe_str; + ] + +let games = ref [compile_game_data "Tic-Tac-Toe" tictactoe_str] Modified: trunk/Toss/Client/JsHandler.js =================================================================== --- trunk/Toss/WebClient/JsHandler.js 2012-02-10 02:21:07 UTC (rev 1672) +++ trunk/Toss/Client/JsHandler.js 2012-02-11 22:16:36 UTC (rev 1673) @@ -237,13 +237,12 @@ } function caml_blit_string(s1, i1, s2, i2, len) { if (len === 0) return; - if (i2 === s2.last && i1 === 0 && s1.last == len) { - var s = s1.bytes; - if (s !== null) - s2.bytes += s1.bytes; - else - s2.bytes += s1.getBytes(); - s2.last += len; + if (i2 === s2.last && s2.bytes != null) { + var b = s1.bytes; + if (b == null) b = s1.toBytes (); + if (i1 > 0 || s1.last > len) b = b.slice(i1, i1 + len); + s2.bytes += b; + s2.last += b.length; return; } var a = s2.array; @@ -296,12 +295,12 @@ } } else return 1; - } else if (a instanceof Array && a[0] == (a[0]|0)) { + } else if (a instanceof Array && a[0] === (a[0]|0)) { var ta = a[0]; if (ta === 250) { a = a[1]; continue; - } else if (b instanceof Array && b[0] == (b[0]|0)) { + } else if (b instanceof Array && b[0] === (b[0]|0)) { var tb = b[0]; if (tb === 250) { b = b[1]; @@ -328,7 +327,7 @@ } else return 1; } else if (b instanceof MlString || - (b instanceof Array && b[0] == (b[0]|0))) { + (b instanceof Array && b[0] === (b[0]|0))) { return -1; } else { if (a < b) return -1; @@ -510,12 +509,41 @@ } function caml_greaterequal (x, y) { return +(caml_compare(x,y,false) >= 0); } function caml_greaterthan (x, y) { return +(caml_compare(x,y,false) > 0); } +function caml_int64_to_bytes(x) { + return [x[3] >> 8, x[3] & 0xff, x[2] >> 16, (x[2] >> 8) & 0xff, x[2] & 0xff, + x[1] >> 16, (x[1] >> 8) & 0xff, x[1] & 0xff]; +} +function caml_int64_bits_of_float (x) { + if (!isFinite(x)) { + if (isNaN(x)) return [255, 1, 0, 0xfff0]; + return (x > 0)?[255,0,0,0x7ff0]:[255,0,0,0xfff0]; + } + var sign = (x>=0)?0:0x8000; + if (sign) x = -x; + var exp = Math.floor(Math.LOG2E*Math.log(x)) + 1023; + if (exp <= 0) { + exp = 0; + x /= Math.pow(2,-1026); + } else { + x /= Math.pow(2,exp-1027); + if (x < 16) { x *= 2; exp -=1; } + if (exp == 0) { x /= 2; } + } + var k = Math.pow(2,24); + var r3 = x|0; + x = (x - r3) * k; + var r2 = x|0; + x = (x - r2) * k; + var r1 = x|0; + r3 = (r3 &0xf) | sign | exp << 4; + return [255, r1, r2, r3]; +} function caml_hash_univ_param (count, limit, obj) { var hash_accu = 0; function hash_aux (obj) { limit --; if (count < 0 || limit < 0) return; - if (obj instanceof Array && obj[0] == (obj[0]|0)) { + if (obj instanceof Array && obj[0] === (obj[0]|0)) { switch (obj[0]) { case 248: count --; @@ -542,10 +570,10 @@ for (var i = 0; i < l; i++) hash_accu = (hash_accu * 19 + b.charCodeAt(i)) | 0; } - } else if (obj == (obj|0)) { + } else if (obj === (obj|0)) { count --; hash_accu = (hash_accu * 65599 + obj) | 0; - } else if (obj == +obj) { + } else if (obj === +obj) { count--; var p = caml_int64_to_bytes (caml_int64_bits_of_float (obj)); for (var i = 7; i >= 0; i--) hash_accu = (hash_accu * 19 + p[i]) | 0; @@ -948,4 +976,4 @@ if( y.fun ) { x.fun = y.fun; return 0; } var i = y.length; while (i--) x[i] = y[i]; return 0; } @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-10 02:21:15
|
Revision: 1672 http://toss.svn.sourceforge.net/toss/?rev=1672&view=rev Author: lukaszkaiser Date: 2012-02-10 02:21:07 +0000 (Fri, 10 Feb 2012) Log Message: ----------- Work on optimizing local webclient. Modified Paths: -------------- trunk/Toss/Arena/ContinuousRule.ml trunk/Toss/Arena/DiscreteRule.ml trunk/Toss/Formula/AuxIO.ml trunk/Toss/Learn/Distinguish.ml trunk/Toss/Server/GameSelection.ml trunk/Toss/Server/JsHandler.ml trunk/Toss/Solver/AssignmentSet.ml trunk/Toss/Solver/AssignmentSet.mli trunk/Toss/Solver/Assignments.ml trunk/Toss/Solver/Assignments.mli trunk/Toss/Solver/AssignmentsTest.ml trunk/Toss/Solver/Solver.ml trunk/Toss/WebClient/JsHandler.js trunk/Toss/WebClient/State.js trunk/Toss/examples/Checkers.toss Modified: trunk/Toss/Arena/ContinuousRule.ml =================================================================== --- trunk/Toss/Arena/ContinuousRule.ml 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Arena/ContinuousRule.ml 2012-02-10 02:21:07 UTC (rev 1672) @@ -176,8 +176,7 @@ (lhs, FormulaSubst.subst_real ["t", Formula.Const !time] rhs)) upd in (* we don't need to use val_map because !last_struc contains the evolved values *) - let asg = AssignmentSet.fo_assgn_of_list - (List.map (fun (v, a) -> `FO v, a) m) in + let asg = AssignmentSet.fo_assgn_of_list m in let upd_vals = List.map (fun (lhs,expr) -> lhs, Solver.M.get_real_val ~asg expr !last_struc) upd in Modified: trunk/Toss/Arena/DiscreteRule.ml =================================================================== --- trunk/Toss/Arena/DiscreteRule.ml 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Arena/DiscreteRule.ml 2012-02-10 02:21:07 UTC (rev 1672) @@ -330,14 +330,14 @@ List.map (fun tp->List.map2 (fun v e->v,e) vars tp) tuples | AssignmentSet.Empty -> [] - | AssignmentSet.FO (`FO v, els) -> - let vars = list_remove v vars in - concat_map (fun (e,sub)-> - List.map (fun tl->(v,e)::tl) - (enumerate_asgns all_elems vars sub)) els + | AssignmentSet.FO (v, els) -> + let vars = list_remove v vars in + concat_map (fun (e,sub)-> + List.map (fun tl -> (v,e)::tl) + (enumerate_asgns all_elems vars sub)) els | AssignmentSet.MSO (_, els) -> - concat_map (fun (e,sub)-> - enumerate_asgns all_elems vars sub) els + concat_map (fun (e,sub)-> + enumerate_asgns all_elems vars sub) els | AssignmentSet.Real _ -> failwith "real matches unsupported" (* Enumerate matchings returned by {!find_matchings} for the same Modified: trunk/Toss/Formula/AuxIO.ml =================================================================== --- trunk/Toss/Formula/AuxIO.ml 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Formula/AuxIO.ml 2012-02-10 02:21:07 UTC (rev 1672) @@ -145,14 +145,14 @@ ENDIF -let default_debug_level = ref 1 -let debug_levels = ref [] +let default_debug_level = ref 0 +let debug_levels = Hashtbl.create 7 let set_debug_level module_name debug_lev = - debug_levels := Aux.replace_assoc module_name debug_lev !debug_levels + Hashtbl.replace debug_levels module_name debug_lev let debug_level_for module_name = - try List.assoc module_name !debug_levels + try Hashtbl.find debug_levels module_name with Not_found -> !default_debug_level let log module_name debug_lev s = @@ -162,4 +162,3 @@ ) ELSE ( print_endline s; flush stdout ) ENDIF - Modified: trunk/Toss/Learn/Distinguish.ml =================================================================== --- trunk/Toss/Learn/Distinguish.ml 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Learn/Distinguish.ml 2012-02-10 02:21:07 UTC (rev 1672) @@ -17,7 +17,7 @@ let eval structure phi assignment = (Solver.M.evaluate_partial structure assignment phi) in let elems = Assignments.set_to_set_list (Structure.elems structure) in - let vars =Array.map fo_var (Array.of_list (Aux.range (Array.length tuple))) in + let vars=Array.map varname (Array.of_list (Aux.range (Array.length tuple))) in let assignment = if tuple = [||] then AssignmentSet.Any else Assignments.assignments_of_list elems vars [tuple] in eval structure formula assignment <> AssignmentSet.Empty Modified: trunk/Toss/Server/GameSelection.ml =================================================================== --- trunk/Toss/Server/GameSelection.ml 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Server/GameSelection.ml 2012-02-10 02:21:07 UTC (rev 1672) @@ -52,14 +52,6 @@ SET Sum (x | bQ(x) : 1) SET Sum (x | wBeats(x) : 1 + :(b(x)) + 3 * :(bK(x))) SET Sum (x | bBeats(x) : 1 + :(w(x)) + 3 * :(wK(x))) -REL IsFirst(x) = not ex z C(z, x) -REL IsSecond(x) = ex y (C(y, x) and IsFirst(y)) -REL IsEight(x) = not ex z C(x, z) -REL IsSeventh(x) = ex y (C(x, y) and IsEight(y)) -REL IsA1(x) = not ex z R(z, x) and IsFirst(x) -REL IsH1(x) = not ex z R(x, z) and IsFirst(x) -REL IsA8(x) = not ex z R(z, x) and IsEight(x) -REL IsH8(x) = not ex z R(x, z) and IsEight(x) REL w(x) = wP(x) or wR(x) or wN(x) or wB(x) or wQ(x) or wK(x) REL b(x) = bP(x) or bR(x) or bN(x) or bB(x) or bQ(x) or bK(x) REL DoubleC(x, y) = ex z ((C(x, z) and C(z, y)) or (C(y, z) and C(z, x))) @@ -339,7 +331,8 @@ \" -> [ | | ] \" ... ... ... ... wK.wR ... -\" emb w,b pre not(bBeats(c1) or bBeats(d1) or bBeats(e1)) post true +\" emb w,b pre not(bBeats(c1) or bBeats(d1) or bBeats(e1)) and before + not WhiteRookA1, not WhiteKing, not WhiteLeftCastle, not WhiteRightCastle RULE WhiteRightCastle: [ | | ] \" ... ... @@ -347,7 +340,8 @@ \" -> [ | | ] \" ... ... ...wR wK. -\" emb w,b pre not (bBeats(a1) or bBeats(b1) or bBeats(c1)) post true +\" emb w,b pre not (bBeats(a1) or bBeats(b1) or bBeats(c1)) and before + not WhiteRookH1, not WhiteKing, not WhiteLeftCastle, not WhiteRightCastle RULE BlackLeftCastle: [ | | ] \" ... ... ... @@ -355,7 +349,8 @@ \" -> [ | | ] \" ... ... ... ... bK.bR ... -\" emb w,b pre not(wBeats(c1) or wBeats(d1) or wBeats(e1)) post true +\" emb w,b pre not(wBeats(c1) or wBeats(d1) or wBeats(e1)) and before + not BlackRookA8, not BlackKing, not BlackLeftCastle, not BlackRightCastle RULE BlackRightCastle: [ | | ] \" ... ... @@ -363,8 +358,9 @@ \" -> [ | | ] \" ... ... ...bR bK. -\" emb w,b pre not (wBeats(a1) or wBeats(b1) or wBeats(c1)) post true -LOC 0 { // both can castle +\" emb w,b pre not (wBeats(a1) or wBeats(b1) or wBeats(c1)) and before + not BlackRookH8, not BlackKing, not BlackLeftCastle, not BlackRightCastle +LOC 0 { PLAYER 1 { COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 PAYOFF :(CheckB()) - :(CheckW()) @@ -379,19 +375,19 @@ [WhiteKnight -> 1]; [WhiteBishop -> 1]; [WhiteRook -> 1]; - [WhiteRookA1 -> 5]; - [WhiteRookH1 -> 3]; + [WhiteRookA1 -> 1]; + [WhiteRookH1 -> 1]; [WhiteQueen -> 1]; - [WhiteLeftCastle -> 7]; - [WhiteRightCastle -> 7]; - [WhiteKing -> 7] + [WhiteLeftCastle -> 1]; + [WhiteRightCastle -> 1]; + [WhiteKing -> 1] } PLAYER 2 { COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 PAYOFF :(CheckW()) - :(CheckB()) } } -LOC 1 { // both can castle +LOC 1 { PLAYER 2 { COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 PAYOFF :(CheckW()) - :(CheckB()) @@ -406,796 +402,18 @@ [BlackKnight -> 0]; [BlackBishop -> 0]; [BlackRook -> 0]; - [BlackRookA8 -> 16]; - [BlackRookH8 -> 8]; + [BlackRookA8 -> 0]; + [BlackRookH8 -> 0]; [BlackQueen -> 0]; - [BlackLeftCastle -> 24]; - [BlackRightCastle -> 24]; - [BlackKing -> 24] + [BlackLeftCastle -> 0]; + [BlackRightCastle -> 0]; + [BlackKing -> 0] } PLAYER 1 { COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 PAYOFF :(CheckB()) - :(CheckW()) } } -LOC 2 { // w left, b can castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 3]; - [WhitePawnMoveDbl -> 3]; - [WhitePawnBeat -> 3]; - [WhitePawnBeatPromote -> 3]; - [WhitePawnBeatLDbl -> 3]; - [WhitePawnBeatRDbl -> 3]; - [WhitePawnPromote -> 3]; - [WhiteKnight -> 3]; - [WhiteBishop -> 3]; - [WhiteRook -> 3]; - [WhiteRookA1 -> 7]; - [WhiteRookH1 -> 3]; - [WhiteQueen -> 3]; - [WhiteLeftCastle -> 7]; - [WhiteKing -> 7] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 3 { // w left, b can castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 2]; - [BlackPawnMoveDbl -> 2]; - [BlackPawnBeat -> 2]; - [BlackPawnBeatPromote -> 2]; - [BlackPawnBeatLDbl -> 2]; - [BlackPawnBeatRDbl -> 2]; - [BlackPawnPromote -> 2]; - [BlackKnight -> 2]; - [BlackBishop -> 2]; - [BlackRook -> 2]; - [BlackRookA8 -> 18]; - [BlackRookH8 -> 10]; - [BlackQueen -> 2]; - [BlackLeftCastle -> 26]; - [BlackRightCastle -> 26]; - [BlackKing -> 26] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 4 { // w right, b can castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 5]; - [WhitePawnMoveDbl -> 5]; - [WhitePawnBeat -> 5]; - [WhitePawnBeatPromote -> 5]; - [WhitePawnBeatLDbl -> 5]; - [WhitePawnBeatRDbl -> 5]; - [WhitePawnPromote -> 5]; - [WhiteKnight -> 5]; - [WhiteBishop -> 5]; - [WhiteRook -> 5]; - [WhiteRookA1 -> 5]; - [WhiteRookH1 -> 7]; - [WhiteQueen -> 5]; - [WhiteRightCastle -> 7]; - [WhiteKing -> 7] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 5 { // w right, b can castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 4]; - [BlackPawnMoveDbl -> 4]; - [BlackPawnBeat -> 4]; - [BlackPawnBeatPromote -> 4]; - [BlackPawnBeatLDbl -> 4]; - [BlackPawnBeatRDbl -> 4]; - [BlackPawnPromote -> 4]; - [BlackKnight -> 4]; - [BlackBishop -> 4]; - [BlackRook -> 4]; - [BlackRookA8 -> 20]; - [BlackRookH8 -> 12]; - [BlackQueen -> 4]; - [BlackLeftCastle -> 28]; - [BlackRightCastle -> 28]; - [BlackKing -> 28] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 6 { // w no, b can castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 7]; - [WhitePawnMoveDbl -> 7]; - [WhitePawnBeat -> 7]; - [WhitePawnBeatPromote -> 7]; - [WhitePawnBeatLDbl -> 7]; - [WhitePawnBeatRDbl -> 7]; - [WhitePawnPromote -> 7]; - [WhiteKnight -> 7]; - [WhiteBishop -> 7]; - [WhiteRook -> 7]; - [WhiteRookA1 -> 7]; - [WhiteRookH1 -> 7]; - [WhiteQueen -> 7]; - [WhiteKing -> 7] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 7 { // w no, b can castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 6]; - [BlackPawnMoveDbl -> 6]; - [BlackPawnBeat -> 6]; - [BlackPawnBeatPromote -> 6]; - [BlackPawnBeatLDbl -> 6]; - [BlackPawnBeatRDbl -> 6]; - [BlackPawnPromote -> 6]; - [BlackKnight -> 6]; - [BlackBishop -> 6]; - [BlackRook -> 6]; - [BlackRookA8 -> 22]; - [BlackRookH8 -> 14]; - [BlackQueen -> 6]; - [BlackLeftCastle -> 30]; - [BlackRightCastle -> 30]; - [BlackKing -> 30] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 8 { // w can, b left castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 9]; - [WhitePawnMoveDbl -> 9]; - [WhitePawnBeat -> 9]; - [WhitePawnBeatPromote -> 9]; - [WhitePawnBeatLDbl -> 9]; - [WhitePawnBeatRDbl -> 9]; - [WhitePawnPromote -> 9]; - [WhiteKnight -> 9]; - [WhiteBishop -> 9]; - [WhiteRook -> 9]; - [WhiteRookA1 -> 13]; - [WhiteRookH1 -> 11]; - [WhiteQueen -> 9]; - [WhiteLeftCastle -> 15]; - [WhiteRightCastle -> 15]; - [WhiteKing -> 15] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 9 { // w can, b left castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 8]; - [BlackPawnMoveDbl -> 8]; - [BlackPawnBeat -> 8]; - [BlackPawnBeatPromote -> 8]; - [BlackPawnBeatLDbl -> 8]; - [BlackPawnBeatRDbl -> 8]; - [BlackPawnPromote -> 8]; - [BlackKnight -> 8]; - [BlackBishop -> 8]; - [BlackRook -> 8]; - [BlackRookA8 -> 24]; - [BlackRookH8 -> 8]; - [BlackQueen -> 8]; - [BlackLeftCastle -> 24]; - [BlackKing -> 24] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 10 { // w left, b left castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 11]; - [WhitePawnMoveDbl -> 11]; - [WhitePawnBeat -> 11]; - [WhitePawnBeatPromote -> 11]; - [WhitePawnBeatLDbl -> 11]; - [WhitePawnBeatRDbl -> 11]; - [WhitePawnPromote -> 11]; - [WhiteKnight -> 11]; - [WhiteBishop -> 11]; - [WhiteRook -> 11]; - [WhiteRookA1 -> 15]; - [WhiteRookH1 -> 11]; - [WhiteQueen -> 11]; - [WhiteLeftCastle -> 15]; - [WhiteKing -> 15] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 11 { // w left, b left castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 10]; - [BlackPawnMoveDbl -> 10]; - [BlackPawnBeat -> 10]; - [BlackPawnBeatPromote -> 10]; - [BlackPawnBeatLDbl -> 10]; - [BlackPawnBeatRDbl -> 10]; - [BlackPawnPromote -> 10]; - [BlackKnight -> 10]; - [BlackBishop -> 10]; - [BlackRook -> 10]; - [BlackRookA8 -> 26]; - [BlackRookH8 -> 10]; - [BlackQueen -> 10]; - [BlackLeftCastle -> 26]; - [BlackKing -> 26] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 12 { // w right, b left castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 13]; - [WhitePawnMoveDbl -> 13]; - [WhitePawnBeat -> 13]; - [WhitePawnBeatPromote -> 13]; - [WhitePawnBeatLDbl -> 13]; - [WhitePawnBeatRDbl -> 13]; - [WhitePawnPromote -> 13]; - [WhiteKnight -> 13]; - [WhiteBishop -> 13]; - [WhiteRook -> 13]; - [WhiteRookA1 -> 13]; - [WhiteRookH1 -> 15]; - [WhiteQueen -> 13]; - [WhiteRightCastle -> 15]; - [WhiteKing -> 15] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 13 { // w right, b left castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 12]; - [BlackPawnMoveDbl -> 12]; - [BlackPawnBeat -> 12]; - [BlackPawnBeatPromote -> 12]; - [BlackPawnBeatLDbl -> 12]; - [BlackPawnBeatRDbl -> 12]; - [BlackPawnPromote -> 12]; - [BlackKnight -> 12]; - [BlackBishop -> 12]; - [BlackRook -> 12]; - [BlackRookA8 -> 28]; - [BlackRookH8 -> 12]; - [BlackQueen -> 12]; - [BlackLeftCastle -> 28]; - [BlackKing -> 28] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 14 { // w no, b left castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 15]; - [WhitePawnMoveDbl -> 15]; - [WhitePawnBeat -> 15]; - [WhitePawnBeatPromote -> 15]; - [WhitePawnBeatLDbl -> 15]; - [WhitePawnBeatRDbl -> 15]; - [WhitePawnPromote -> 15]; - [WhiteKnight -> 15]; - [WhiteBishop -> 15]; - [WhiteRook -> 15]; - [WhiteRookA1 -> 15]; - [WhiteRookH1 -> 15]; - [WhiteQueen -> 15]; - [WhiteKing -> 15] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 15 { // w no, b left castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 14]; - [BlackPawnMoveDbl -> 14]; - [BlackPawnBeat -> 14]; - [BlackPawnBeatPromote -> 14]; - [BlackPawnBeatLDbl -> 14]; - [BlackPawnBeatRDbl -> 14]; - [BlackPawnPromote -> 14]; - [BlackKnight -> 14]; - [BlackBishop -> 14]; - [BlackRook -> 14]; - [BlackRookA8 -> 30]; - [BlackRookH8 -> 14]; - [BlackQueen -> 14]; - [BlackLeftCastle -> 30]; - [BlackKing -> 30] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 16 { // w can, b right castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 17]; - [WhitePawnMoveDbl -> 17]; - [WhitePawnBeat -> 17]; - [WhitePawnBeatPromote -> 17]; - [WhitePawnBeatLDbl -> 17]; - [WhitePawnBeatRDbl -> 17]; - [WhitePawnPromote -> 17]; - [WhiteKnight -> 17]; - [WhiteBishop -> 17]; - [WhiteRook -> 17]; - [WhiteRookA1 -> 21]; - [WhiteRookH1 -> 19]; - [WhiteQueen -> 17]; - [WhiteLeftCastle -> 23]; - [WhiteRightCastle -> 23]; - [WhiteKing -> 23] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 17 { // w can, b right castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 16]; - [BlackPawnMoveDbl -> 16]; - [BlackPawnBeat -> 16]; - [BlackPawnBeatPromote -> 16]; - [BlackPawnBeatLDbl -> 16]; - [BlackPawnBeatRDbl -> 16]; - [BlackPawnPromote -> 16]; - [BlackKnight -> 16]; - [BlackBishop -> 16]; - [BlackRook -> 16]; - [BlackRookA8 -> 16]; - [BlackRookH8 -> 24]; - [BlackQueen -> 16]; - [BlackRightCastle -> 24]; - [BlackKing -> 24] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 18 { // w left, b right castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 19]; - [WhitePawnMoveDbl -> 19]; - [WhitePawnBeat -> 19]; - [WhitePawnBeatPromote -> 19]; - [WhitePawnBeatLDbl -> 19]; - [WhitePawnBeatRDbl -> 19]; - [WhitePawnPromote -> 19]; - [WhiteKnight -> 19]; - [WhiteBishop -> 19]; - [WhiteRook -> 19]; - [WhiteRookA1 -> 23]; - [WhiteRookH1 -> 19]; - [WhiteQueen -> 19]; - [WhiteLeftCastle -> 23]; - [WhiteKing -> 23] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 19 { // w left, b right castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 18]; - [BlackPawnMoveDbl -> 18]; - [BlackPawnBeat -> 18]; - [BlackPawnBeatPromote -> 18]; - [BlackPawnBeatLDbl -> 18]; - [BlackPawnBeatRDbl -> 18]; - [BlackPawnPromote -> 18]; - [BlackKnight -> 18]; - [BlackBishop -> 18]; - [BlackRook -> 18]; - [BlackRookA8 -> 18]; - [BlackRookH8 -> 26]; - [BlackQueen -> 18]; - [BlackRightCastle -> 26]; - [BlackKing -> 26] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 20 { // w right, b right castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 21]; - [WhitePawnMoveDbl -> 21]; - [WhitePawnBeat -> 21]; - [WhitePawnBeatPromote -> 21]; - [WhitePawnBeatLDbl -> 21]; - [WhitePawnBeatRDbl -> 21]; - [WhitePawnPromote -> 21]; - [WhiteKnight -> 21]; - [WhiteBishop -> 21]; - [WhiteRook -> 21]; - [WhiteRookA1 -> 21]; - [WhiteRookH1 -> 23]; - [WhiteQueen -> 21]; - [WhiteRightCastle -> 23]; - [WhiteKing -> 23] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 21 { // w right, b right castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 20]; - [BlackPawnMoveDbl -> 20]; - [BlackPawnBeat -> 20]; - [BlackPawnBeatPromote -> 20]; - [BlackPawnBeatLDbl -> 20]; - [BlackPawnBeatRDbl -> 20]; - [BlackPawnPromote -> 20]; - [BlackKnight -> 20]; - [BlackBishop -> 20]; - [BlackRook -> 20]; - [BlackRookA8 -> 20]; - [BlackRookH8 -> 28]; - [BlackQueen -> 20]; - [BlackRightCastle -> 28]; - [BlackKing -> 28] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 22 { // w no, b right castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 23]; - [WhitePawnMoveDbl -> 23]; - [WhitePawnBeat -> 23]; - [WhitePawnBeatPromote -> 23]; - [WhitePawnBeatLDbl -> 23]; - [WhitePawnBeatRDbl -> 23]; - [WhitePawnPromote -> 23]; - [WhiteKnight -> 23]; - [WhiteBishop -> 23]; - [WhiteRook -> 23]; - [WhiteRookA1 -> 23]; - [WhiteRookH1 -> 23]; - [WhiteQueen -> 23]; - [WhiteKing -> 23] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 23 { // w no, b right castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 22]; - [BlackPawnMoveDbl -> 22]; - [BlackPawnBeat -> 22]; - [BlackPawnBeatPromote -> 22]; - [BlackPawnBeatLDbl -> 22]; - [BlackPawnBeatRDbl -> 22]; - [BlackPawnPromote -> 22]; - [BlackKnight -> 22]; - [BlackBishop -> 22]; - [BlackRook -> 22]; - [BlackRookA8 -> 22]; - [BlackRookH8 -> 30]; - [BlackQueen -> 22]; - [BlackRightCastle -> 30]; - [BlackKing -> 30] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 24 { // w can, b no castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 25]; - [WhitePawnMoveDbl -> 25]; - [WhitePawnBeat -> 25]; - [WhitePawnBeatPromote -> 25]; - [WhitePawnBeatLDbl -> 25]; - [WhitePawnBeatRDbl -> 25]; - [WhitePawnPromote -> 25]; - [WhiteKnight -> 25]; - [WhiteBishop -> 25]; - [WhiteRook -> 25]; - [WhiteRookA1 -> 29]; - [WhiteRookH1 -> 27]; - [WhiteQueen -> 25]; - [WhiteLeftCastle -> 31]; - [WhiteRightCastle -> 31]; - [WhiteKing -> 31] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 25 { // w can, b no castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 24]; - [BlackPawnMoveDbl -> 24]; - [BlackPawnBeat -> 24]; - [BlackPawnBeatPromote -> 24]; - [BlackPawnBeatLDbl -> 24]; - [BlackPawnBeatRDbl -> 24]; - [BlackPawnPromote -> 24]; - [BlackKnight -> 24]; - [BlackBishop -> 24]; - [BlackRook -> 24]; - [BlackRookA8 -> 24]; - [BlackRookH8 -> 24]; - [BlackQueen -> 24]; - [BlackKing -> 24] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 26 { // w left, b no castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 27]; - [WhitePawnMoveDbl -> 27]; - [WhitePawnBeat -> 27]; - [WhitePawnBeatPromote -> 27]; - [WhitePawnBeatLDbl -> 27]; - [WhitePawnBeatRDbl -> 27]; - [WhitePawnPromote -> 27]; - [WhiteKnight -> 27]; - [WhiteBishop -> 27]; - [WhiteRook -> 27]; - [WhiteRookA1 -> 31]; - [WhiteRookH1 -> 27]; - [WhiteQueen -> 27]; - [WhiteLeftCastle -> 31]; - [WhiteKing -> 31] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 27 { // w left, b no castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 26]; - [BlackPawnMoveDbl -> 26]; - [BlackPawnBeat -> 26]; - [BlackPawnBeatPromote -> 26]; - [BlackPawnBeatLDbl -> 26]; - [BlackPawnBeatRDbl -> 26]; - [BlackPawnPromote -> 26]; - [BlackKnight -> 26]; - [BlackBishop -> 26]; - [BlackRook -> 26]; - [BlackRookA8 -> 26]; - [BlackRookH8 -> 26]; - [BlackQueen -> 26]; - [BlackKing -> 26] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 28 { // w right, b no castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 29]; - [WhitePawnMoveDbl -> 29]; - [WhitePawnBeat -> 29]; - [WhitePawnBeatPromote -> 29]; - [WhitePawnBeatLDbl -> 29]; - [WhitePawnBeatRDbl -> 29]; - [WhitePawnPromote -> 29]; - [WhiteKnight -> 29]; - [WhiteBishop -> 29]; - [WhiteRook -> 29]; - [WhiteRookA1 -> 29]; - [WhiteRookH1 -> 31]; - [WhiteQueen -> 29]; - [WhiteRightCastle -> 31]; - [WhiteKing -> 31] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 29 { // w right, b no castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 28]; - [BlackPawnMoveDbl -> 28]; - [BlackPawnBeat -> 28]; - [BlackPawnBeatPromote -> 28]; - [BlackPawnBeatLDbl -> 28]; - [BlackPawnBeatRDbl -> 28]; - [BlackPawnPromote -> 28]; - [BlackKnight -> 28]; - [BlackBishop -> 28]; - [BlackRook -> 28]; - [BlackRookA8 -> 28]; - [BlackRookH8 -> 28]; - [BlackQueen -> 28]; - [BlackKing -> 28] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 30 { // w no, b no castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 31]; - [WhitePawnMoveDbl -> 31]; - [WhitePawnBeat -> 31]; - [WhitePawnBeatPromote -> 31]; - [WhitePawnBeatLDbl -> 31]; - [WhitePawnBeatRDbl -> 31]; - [WhitePawnPromote -> 31]; - [WhiteKnight -> 31]; - [WhiteBishop -> 31]; - [WhiteRook -> 31]; - [WhiteRookA1 -> 31]; - [WhiteRookH1 -> 31]; - [WhiteQueen -> 31]; - [WhiteKing -> 31] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 31 { // w no, b no castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 30]; - [BlackPawnMoveDbl -> 30]; - [BlackPawnBeat -> 30]; - [BlackPawnBeatPromote -> 30]; - [BlackPawnBeatLDbl -> 30]; - [BlackPawnBeatRDbl -> 30]; - [BlackPawnPromote -> 30]; - [BlackKnight -> 30]; - [BlackBishop -> 30]; - [BlackRook -> 30]; - [BlackRookA8 -> 30]; - [BlackRookH8 -> 30]; - [BlackQueen -> 30]; - [BlackKing -> 30] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} MODEL [ | | ] \" ... ... ... ... bR bN.bB bQ.bK bB.bN bR. @@ -1215,7 +433,15 @@ wR.wN wB.wQ wK.wB wN.wR \" with D1(x, y) = ex z ( (R(x, z) and C(z, y)) or (R(y, z) and C(z, x)) ) ; -D2(x, y) = ex z ( (R(x, z) and C(y, z)) or (R(y, z) and C(x, z)) ) +D2(x, y) = ex z ( (R(x, z) and C(y, z)) or (R(y, z) and C(x, z)) ) ; +IsFirst(x) = not ex z C(z, x) ; +IsSecond(x) = ex y (C(y, x) and IsFirst(y)) ; +IsEight(x) = not ex z C(x, z) ; +IsSeventh(x) = ex y (C(x, y) and IsEight(y)) ; +IsA1(x) = not ex z R(z, x) and IsFirst(x) ; +IsH1(x) = not ex z R(x, z) and IsFirst(x) ; +IsA8(x) = not ex z R(z, x) and IsEight(x) ; +IsH8(x) = not ex z R(x, z) and IsEight(x) ") let connect4_str = ("PLAYERS 1, 2 @@ -1536,20 +762,10 @@ let checkers_str = (" PLAYERS 1, 2 DATA depth: 4, adv_ratio: 2 -REL IsFirst(x) = not ex z C(z, x) -REL IsEight(x) = not ex z C(x, z) REL w(x) = W(x) or Wq(x) REL b(x) = B(x) or Bq(x) -REL DiagWa (x, y) = ex z (C(x, z) and R(y, z)) -REL DiagBa (x, y) = ex z (C(z, x) and R(z, y)) -REL DiagWb (x, y) = ex z (C(x, z) and R(z, y)) -REL DiagBb (x, y) = ex z (C(z, x) and R(y, z)) REL AnyDiag (x, y) = DiagWa (x, y) or DiagWb (x, y) or DiagBa (x, y) or DiagBb (x, y) -REL DiagW2 (x, y, z) = - (DiagWa (x, y) and DiagWa (y, z)) or (DiagWb (x, y) and DiagWb (y, z)) -REL DiagB2 (x, y, z) = - (DiagBa (x, y) and DiagBa (y, z)) or (DiagBb (x, y) and DiagBb (y, z)) REL Diag2 (x, y, z) = DiagW2 (x, y, z) or DiagB2 (x, y, z) REL BeatsW (x, y) = ex z (b(z) and not b(y) and not w(y) and DiagW2 (x, z, y)) REL BeatsWX (x, y) = ex z (b(z) and not b(y) and not w(y) and Diag2 (x, z, y)) @@ -1680,7 +896,17 @@ W.. W.. W.. W.. ... ... ... ... W.. W.. W.. W.. -\" +\" with +IsFirst(x) = not ex z C(z, x) ; +IsEight(x) = not ex z C(x, z) ; +DiagWa (x, y) = ex z (C(x, z) and R(y, z)) ; +DiagBa (x, y) = ex z (C(z, x) and R(z, y)) ; +DiagWb (x, y) = ex z (C(x, z) and R(z, y)) ; +DiagBb (x, y) = ex z (C(z, x) and R(y, z)) ; +DiagW2 (x, y, z) = + (DiagWa (x, y) and DiagWa (y, z)) or (DiagWb (x, y) and DiagWb (y, z)) ; +DiagB2 (x, y, z) = + (DiagBa (x, y) and DiagBa (y, z)) or (DiagBb (x, y) and DiagBb (y, z)) ") let gomoku_str = (" Modified: trunk/Toss/Server/JsHandler.ml =================================================================== --- trunk/Toss/Server/JsHandler.ml 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Server/JsHandler.ml 2012-02-10 02:21:07 UTC (rev 1672) @@ -145,7 +145,7 @@ Js.Unsafe.set result (js player_name) (Js.float payoff)) payoffs; Js.Unsafe.set info_obj (js"result") result); - AuxIO.log "js_of_game_state: Game prepared. Sending..."; + LOG 0 "%s" "js_of_game_state: Game prepared. Sending..."; info_obj let new_play game_name pl1 pl2 = Modified: trunk/Toss/Solver/AssignmentSet.ml =================================================================== --- trunk/Toss/Solver/AssignmentSet.ml 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Solver/AssignmentSet.ml 2012-02-10 02:21:07 UTC (rev 1672) @@ -13,10 +13,10 @@ disjunctions of polynomials. If an assignment set is not Empty, then it cannot contain Empty leafs. *) type assignment_set = - Empty + | Empty | Any - | FO of Formula.fo_var * (int * assignment_set) list - | MSO of Formula.mso_var * ((Elems.t * Elems.t) * assignment_set) list + | FO of string * (int * assignment_set) list + | MSO of string * ((Elems.t * Elems.t) * assignment_set) list | Real of (Poly.polynomial * Formula.sign_op) list list @@ -29,9 +29,9 @@ let rec assigned_vars acc = function | Empty | Any -> acc - | FO (v, l) -> assigned_vars_list assigned_vars ((v :> Formula.var) :: acc) l - | MSO (v, l) -> assigned_vars_list assigned_vars ((v :> Formula.var) :: acc) l - | _ -> acc + | FO (v, l) -> assigned_vars_list assigned_vars ((`FO v) :: acc) l + | MSO (v, l) -> assigned_vars_list assigned_vars ((`MSO v) :: acc) l + | _ -> failwith "AssignmentSet:assigned vars not implemented for reals" (* From {!RealQuantElim}: Print a case, i.e. a list of polynomials and their signs, as string. *) @@ -48,53 +48,46 @@ (* Print the given assignment as string. *) let rec str = function - Empty -> "{}" + | Empty -> "{}" | Any -> "T" | FO (v, map) -> - let vn = Formula.var_str v in - let estr (e, a) = - if a = Any then vn ^ "->" ^ (string_of_int e) else - vn ^ "->" ^ (string_of_int e) ^ (str a) ^ " " in - "{ " ^ (String.concat ", " (List.map estr map)) ^ " }" + let estr (e, a) = + if a = Any then v ^ "->" ^ (string_of_int e) else + v ^ "->" ^ (string_of_int e) ^ (str a) ^ " " in + "{ " ^ (String.concat ", " (List.map estr map)) ^ " }" | MSO (v, map) -> - let vn = Formula.var_str v in - let estr ((pos, neg), a) = - let (posl, negl) = (Elems.elements pos, Elems.elements neg) in - let pos_str = String.concat ", " (List.map string_of_int posl) in - let neg_str = String.concat ", " (List.map string_of_int negl) in - let a_s = if a = Any then "" else str a in - if a = Empty then "{}" else - vn ^ "->(inc {" ^ pos_str ^ "} excl {" ^ neg_str ^ "})" ^ a_s - in - "{ " ^ (String.concat ", " (List.map estr map)) ^ " }" + let estr ((pos, neg), a) = + let (posl, negl) = (Elems.elements pos, Elems.elements neg) in + let pos_str = String.concat ", " (List.map string_of_int posl) in + let neg_str = String.concat ", " (List.map string_of_int negl) in + let a_s = if a = Any then "" else str a in + if a = Empty then "{}" else + v ^ "->(inc {" ^ pos_str ^ "} excl {" ^ neg_str ^ "})" ^ a_s in + "{ " ^ (String.concat ", " (List.map estr map)) ^ " }" | Real poly_dnf -> - "{ " ^ (cases_str "" poly_dnf) ^ " }" + "{ " ^ (cases_str "" poly_dnf) ^ " }" let rec named_str struc = function - Empty -> "{}" + | Empty -> "{}" | Any -> "T" | FO (v, map) -> - let vn = Formula.var_str v in - let estr (e, a) = - if a = Any then vn ^ "->" ^ (Structure.elem_str struc e) else - vn ^ "->" ^ - (Structure.elem_str struc e) ^ (named_str struc a) ^ " " in - "{ " ^ (String.concat ", " (List.map estr map)) ^ " }" + let estr (e, a) = + if a = Any then v ^ "->" ^ (Structure.elem_str struc e) else + v ^ "->" ^ (Structure.elem_str struc e) ^ (named_str struc a) ^ " " in + "{ " ^ (String.concat ", " (List.map estr map)) ^ " }" | MSO (v, map) -> - let vn = Formula.var_str v in - let estr ((pos, neg), a) = - let (posl, negl) = (Elems.elements pos, Elems.elements neg) in - let pos_str = - String.concat ", " (List.map (Structure.elem_str struc) posl) in - let neg_str = - String.concat ", " (List.map (Structure.elem_str struc) negl) in - let a_s = if a = Any then "" else named_str struc a in - if a = Empty then "{}" else - vn ^ "->(inc {" ^ pos_str ^ "} excl {" ^ neg_str ^ "})" ^ a_s - in - "{ " ^ (String.concat ", " (List.map estr map)) ^ " }" - | Real poly_dnf -> - "{ " ^ (cases_str "" poly_dnf) ^ " }" + let estr ((pos, neg), a) = + let (posl, negl) = (Elems.elements pos, Elems.elements neg) in + let pos_str = + String.concat ", " (List.map (Structure.elem_str struc) posl) in + let neg_str = + String.concat ", " (List.map (Structure.elem_str struc) negl) in + let a_s = if a = Any then "" else named_str struc a in + if a = Empty then failwith "empty assg under MSO" else + v ^ "->(inc {" ^ pos_str ^ "} excl {" ^ neg_str ^ "})" ^ a_s in + "{ " ^ (String.concat ", " (List.map estr map)) ^ " }" + | Real poly_dnf -> + "{ " ^ (cases_str "" poly_dnf) ^ " }" (* Select an arbitrary assignment for first-order variables with the given names and default values. Raise [Not_found] if the assignment @@ -102,12 +95,11 @@ let rec choose_fo default = function | Empty -> raise Not_found | Any -> default - | FO (`FO v, []) when List.mem_assoc v default -> raise Not_found - | FO (`FO v, (e, sub)::_) when e < 0 && List.mem_assoc v default -> - (v, List.assoc v default) - ::choose_fo (List.remove_assoc v default) sub - | FO (`FO v, (e, sub)::_) when List.mem_assoc v default -> - (v, e)::choose_fo (List.remove_assoc v default) sub + | FO (v, []) when List.mem_assoc v default -> raise Not_found + | FO (v, (e, sub)::_) when e < 0 && List.mem_assoc v default -> + (v, List.assoc v default) :: choose_fo (List.remove_assoc v default) sub + | FO (v, (e, sub)::_) when List.mem_assoc v default -> + (v, e) :: choose_fo (List.remove_assoc v default) sub | FO (_, (_, sub)::_) | MSO (_, (_,sub)::_) -> if default = [] then [] else choose_fo default sub | _ -> raise Not_found @@ -121,43 +113,29 @@ List.rev_map Array.of_list (Aux.product (List.rev_map (fun _ -> Structure.Elems.elements elems) vars)) - | FO (`FO v, (e,other_aset)::asg_list) when e < 0 -> + | FO (v, (e,other_aset)::asg_list) when e < 0 -> let asg_list = List.map (fun e -> e, try List.assoc e asg_list with Not_found -> other_aset) (Structure.Elems.elements elems) in let (idx, vs) = - try - (Aux.find_index v vars, Aux.remove_one v vars) - with Not_found -> - failwith ("assigned var "^ v ^ " not in "^ (String.concat "," vars)) in + try (Aux.find_index v vars, Aux.remove_one v vars) + with Not_found -> failwith ("assigned var " ^ v ^ " not in " ^ + (String.concat "," vars)) in let prolong e asg = Array.of_list (Aux.insert_nth idx e (Array.to_list asg)) in List.concat (List.rev_map (fun (e, asg) -> List.rev_map (prolong e) (tuples elems vs asg)) asg_list) - | FO (`FO v, asg_list) -> + | FO (v, asg_list) -> let (idx, vs) = - try - (Aux.find_index v vars, Aux.remove_one v vars) - with Not_found -> - failwith ("assigned var "^ v ^ " not in "^ (String.concat "," vars)) in + try (Aux.find_index v vars, Aux.remove_one v vars) + with Not_found -> failwith ("assigned var " ^ v ^ " not in " ^ + (String.concat "," vars)) in let prolong e asg = Array.of_list (Aux.insert_nth idx e (Array.to_list asg)) in List.concat (List.rev_map (fun (e, asg) -> List.rev_map (prolong e) (tuples elems vs asg)) asg_list) | _ -> failwith "listing tuples in non first-order assignment set" - -(* Check if a variable is actually present in the assignments - tree. TODO: handle the real case. *) -let rec mem_assoc v = function - | Empty | Any -> false - | FO (v1, _) when (v1 :> Formula.var) = (v :> Formula.var) -> true - | MSO (v1, _) when (v1 :> Formula.var) = (v :> Formula.var) -> true - | Real _ -> false - | FO (_, assgns) -> - List.exists (fun (_,aset) -> mem_assoc v aset) assgns - | MSO (_, assgns) -> - List.exists (fun (_,aset) -> mem_assoc v aset) assgns - + (* Convert the FO part of an assignment set to a set of assignments. *) let rec fo_assgn_to_list all_elems vars = function | Any -> @@ -166,20 +144,20 @@ List.map (List.combine vars) tuples | Empty -> [] | FO (v, (e,other_aset)::els) when e < 0 -> - let vars = Aux.list_remove v vars in - let other_res = - fo_assgn_to_list all_elems vars other_aset in - Aux.concat_map (fun e-> - List.map (fun tl->(v,e)::tl) - (try fo_assgn_to_list all_elems vars (List.assoc e els) - with Not_found -> other_res)) all_elems + let vars = Aux.list_remove (`FO v) vars in + let other_res = + fo_assgn_to_list all_elems vars other_aset in + Aux.concat_map (fun e-> + List.map (fun tl -> (`FO v, e)::tl) + (try fo_assgn_to_list all_elems vars (List.assoc e els) + with Not_found -> other_res)) all_elems | FO (v, els) -> - let vars = Aux.list_remove v vars in + let vars = Aux.list_remove (`FO v) vars in Aux.concat_map (fun (e,sub)-> - List.map (fun tl->(v,e)::tl) + List.map (fun tl -> (`FO v, e)::tl) (fo_assgn_to_list all_elems vars sub)) els | MSO (_, els) -> - Aux.concat_map (fun (e,sub)-> + Aux.concat_map (fun (e, sub)-> fo_assgn_to_list all_elems vars sub) els | Real _ -> failwith "AssignmentSet.assgn_to_list: Reals not implemented yet." Modified: trunk/Toss/Solver/AssignmentSet.mli =================================================================== --- trunk/Toss/Solver/AssignmentSet.mli 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Solver/AssignmentSet.mli 2012-02-10 02:21:07 UTC (rev 1672) @@ -9,10 +9,10 @@ disjunctions of polynomials. If an assignment set is not Empty, then it cannot contain Empty leafs. *) type assignment_set = - Empty + | Empty | Any - | FO of Formula.fo_var * (int * assignment_set) list - | MSO of Formula.mso_var * + | FO of string * (int * assignment_set) list + | MSO of string * ((Structure.Elems.t * Structure.Elems.t) * assignment_set) list | Real of (Poly.polynomial * Formula.sign_op) list list @@ -38,10 +38,6 @@ in order in which [vars] are given. [elems] are are all elements. *) val tuples : Structure.Elems.t -> string list -> assignment_set -> int array list -(** Check if a variable is actually present in the assignments tree. *) -val mem_assoc : [< Formula.var ] -> assignment_set -> bool - - (** Convert the FO part of an assingment set into a list of substitutions. *) val fo_assgn_to_list : int list -> Formula.fo_var list -> assignment_set -> @@ -49,4 +45,4 @@ (** Convert an association list into an assignment for FO variables. *) val fo_assgn_of_list : - (Formula.fo_var * int) list -> assignment_set + (string * int) list -> assignment_set Modified: trunk/Toss/Solver/Assignments.ml =================================================================== --- trunk/Toss/Solver/Assignments.ml 2012-02-09 18:30:51 UTC (rev 1671) +++ trunk/Toss/Solver/Assignments.ml 2012-02-10 02:21:07 UTC (rev 1672) @@ -27,7 +27,7 @@ (* We need order on variables and elements. We assume FO < MSO < Real! *) -let compare_vars x y = -1 * Formula.compare_vars x y +let compare_vars x y = -1 * String.compare x y let compare_elems = Structure.compare_elems (* Helper function: mapping on second position in a list of pairs. *) @@ -49,10 +49,17 @@ (* List a set or list ref; changes from set to list if required. *) let slist slr = match !slr with + | List (i, l) -> List.rev l + | Set (i, s) -> + if !debug_level>1 then print_endline " converting set to list (slist)"; + let l = Elems.elements s in (slr := List (i, List.rev l); l) + +let slist_rev slr = + match !slr with | List (i, l) -> l | Set (i, s) -> - if !debug_level>1 then print_endline " converting set to list (slist)"; - let l = Elems.elements s in (slr := List (i, l); l) + if !debug_level>1 then print_endline " rconverting set to list (slist)"; + let l = List.rev (Elems.elements s) in (slr := List (i, l); l) (* Set from a set or list ref; changes from list to set if required. *) let sset slr = @@ -94,7 +101,7 @@ | (Any, a) -> a | (a, Any) -> a | (FO (v1, map1), FO (v2, map2)) -> ( - match compare_vars (v1 :> Formula.var) (v2 :> Formula.var) with + match compare_vars v1 v2 with 0 -> let res_map = List.rev (join_maps_rev [] (map1, map2)) in if res_map = [] then Empty else FO (v1, res_map) @@ -106,7 +113,7 @@ | (MSO _, FO (v, map)) -> fo_map v (join aset1) map | (Real _, FO (v, map)) -> fo_map v (join aset1) map | (MSO (v1, disj1), MSO (v2, disj2)) -> ( - match compare_vars (v1 :> Formula.var) (v2 :> Formula.var) with + match compare_vars (v1) (v2) with 0 -> let res_disj = small_simp (join_disj [] disj1 disj2) in if res_disj = [] then Empty else MSO (v1, res_disj) @@ -149,43 +156,56 @@ (* ------------------------------ EQUAL -------------------------------- *) (* Enforce [aset] and additionally that the FO variable [v] is set to [e]. *) -let rec set_equal v e = function +let rec set_equal uneq els v e = function | Empty -> Empty | FO (u, map) as aset -> ( - match compare_vars (u :> Formula.var) (v :> Formula.var) with - 0 -> + match compare_vars u v with + | 0 -> + if uneq then + let nmap = List.filter (fun (el,_) -> el <> e) map in + if nmap = [] then Empty else FO (u, nmap) + else (try FO (u, [(e, List.assoc e map)]) with Not_found -> Empty) | x when x < 0 -> - let rmap = List.rev_map (fun (i, a) -> (i, set_equal v e a)) map in - let nmap = List.rev (List.filter (fun (_, a) -> a <> Empty) rmap) in - if nmap = [] then Empty else FO (u, nmap) + let rmap = List.rev_map (fun (i, a) -> + (i, set_equal uneq els v e a)) map in + let nmap = List.rev (List.filter (fun (_, a) -> a <> Empty) rmap) in + if nmap = [] then Empty else FO (u, nmap) | _ -> FO (v, [(e, aset)]) - ) - | aset -> FO (v, [(e, aset)]) + ) + | aset -> + if uneq then + FO (v, List.rev_map (fun e -> (e, aset)) + (List.filter (fun el -> el<>e) (slist_rev els))) + else + FO (v, [(e, aset)]) (* Enforce that in [aset] the variable [u] is equal to [w]; assumes u < w. *) -let rec eq_vars els u w = function +let rec eq_vars uneq els u w = function | Empty -> Empty | FO (v, map) as aset -> ( - match compare_vars (v :> Formula.var) (u :> Formula.var) with - 0 -> - let rmap = List.rev_map (fun (e, a) -> (e, set_equal w e a)) map in - let nmap = List.rev (List.filter (fun (_, a) -> a <> Empty) rmap) in - if nmap = [] then Empty else FO (v, nmap) - | x when x < 0 -> - let rmap = List.rev_map (fun (i,a) -> (i, eq_vars els u w a)) map in - let nmap = List.rev (List.filter (fun (_, a) -> a <> Empty) rmap) in - if nmap = [] then Empty else FO (v, nmap) - | _ -> eq_vars els u w (FO(u, List.map (fun e -> (e,aset)) (slist els))) - ) - | aset -> eq_vars els u w (FO(u, List.map (fun e -> (e,aset)) (slist els))) - + match compare_vars v u with + | 0 -> + let rmap = List.rev_map (fun (e, a) -> + (e, set_equal uneq els w e a)) map in + let nmap = List.rev (List.filter (fun (_, a) -> a <> Empty) rmap) in + if nmap = [] then Empty else FO (v, nmap) + | x when x < 0 -> + let rmap = List.rev_map (fun (i,a)-> (i, eq_vars uneq els u w a)) map in + let nmap = List.rev (List.filter (fun (_, a) -> a <> Empty) rmap) in + if nmap = [] then Empty else FO (v, nmap) + | _ -> eq_vars uneq els u w ( + FO (u, List.rev_map (fun e -> (e,aset)) (slist_rev els))) + ) + | aset -> eq_vars uneq els u w ( + FO (u, List.rev_map (fun e -> (e,aset)) (slist_rev els))) + (* Enforce that in [aset] the variable [u] is equal to [w]. *) -let equal_vars elems u w aset = - match compare_vars (u :> Formula.var) (w :> Formula.var) with +let equal_vars ?(unequal=false) elems u w aset = + match compare_vars u w with | 0 -> aset (* TODO: with one var is assigned, we could be more efficient *) - | x when x < 0 -> eq_vars elems u w aset - | _ -> eq_vars elems w u aset + | x when x < 0 -> eq_vars unequal elems u w aset + | _ -> eq_vars unequal elems w u aset (* ------------------------------- SUM ---------------------------------- *) @@ -210,61 +230,64 @@ | (Empty, a) -> a | (a, Empty) -> a | (FO (v1, map1), FO (v2, map2)) -> ( - match compare_vars (v1 :> Formula.var) (v2 :> Formula.var) with + match compare_vars v1 v2 with | 0 -> - let res_map = List.rev (sum_maps_rev elems [] (map1, map2)) in - if is_full elems res_map then Any else FO (v1, res_map) + let res_map = List.rev (sum_maps_rev elems [] (map1, map2)) in + if is_full elems res_map then Any else FO (v1, res_map) | x when x < 0 -> - let elems_map2 = List.map (fun e -> (e, aset2)) (slist elems) in - let res = List.rev (sum_maps_rev elems [] (map1, elems_map2)) in - if is_full elems res then Any else FO (v1, res) + let elems_map2 = + List.rev_map (fun e -> (e, aset2)) (slist_rev elems) in + let res = List.rev (sum_maps_rev elems [] (map1, elems_map2)) in + if is_full elems res then Any else FO (v1, res) | x -> - let elems_map1 = List.map (fun e -> (e, aset1)) (slist elems) in - let res = List.rev (sum_maps_rev elems [] (elems_map1, map2)) in - if is_full elems res then Any else FO (v2, res) + let elems_map1 = + List.rev_map (fun e -> (e, aset1)) (slist_rev elems) in + let res = List.rev (sum_maps_rev elems [] (elems_map1, map2)) in + if is_full elems res then Any else FO (v2, res) ) - | (FO (v, map), _) -> - sum elems aset1 (FO (v, List.map (fun e -> (e, aset2)) (slist elems))) - | (_, FO (v, map)) -> - sum elems (FO (v, List.map (fun e -> (e, aset1)) (slist elems))) aset2 + | (FO (v, map), _) -> sum elems aset1 ( + FO (v, List.rev_map (fun e -> (e, aset2)) (slist_rev elems))) + | (_, FO (v, map)) -> sum elems ( + FO (v, List.rev_map (fun e -> (e, aset1)) (slist_rev elems))) aset2 | (MSO (v1, disj1), MSO (v2, disj2)) -> ( - let subs ((i1, o1), a1) ((i2, o2), a2) = - a1 = a2 && (Elems.subset i2 i1) && (Elems.subset o2 o1) in - let rec append_subs acc l1 = function - [] -> - let is_not_subs x = not (List.exists (subs x) acc) in - List.rev_append (List.filter is_not_subs l1) acc - | x :: xs -> - if List.exists (subs x) l1 then append_subs acc l1 xs else - append_subs (x::acc) l1 xs in - match compare_vars (v1 :> Formula.var) (v2 :> Formula.var) with - 0 -> - let sd1 = List.fold_left (sum_subsumed elems disj2) [] disj1 in - let sd2 = List.fold_left (sum_subsumed elems disj1) [] disj2 in - let res_disj = append_subs [] sd1 sd2 in - if is_full_mso res_disj then Any else MSO (v1, List.sort Pervasives.compare res_disj) - | x when x < 0 -> - sum elems aset1 (MSO (v1, [((Elems.empty, Elems.empty), aset2)])) - | x -> - sum elems (MSO (v2, [((Elems.empty, Elems.empty), aset1)])) aset2 - ) + let subs ((i1, o1), a1) ((i2, o2), a2) = + a1 = a2 && (Elems.subset i2 i1) && (Elems.subset o2 o1) in + let rec append_subs acc l1 = function + | [] -> + let is_not_subs x = not (List.exists (subs x) acc) in + List.rev_append (List.filter is_not_subs l1) acc + | x :: xs -> + if List.exists (subs x) l1 then append_subs acc l1 xs else + append_subs (x::acc) l1 xs in + match compare_vars (v1) (v2) with + | 0 -> + let sd1 = List.fold_left (sum_subsumed elems disj2) [] disj1 in + let sd2 = List.fold_left (sum_subsumed elems disj1) [] disj2 in + let res_disj = append_subs [] sd1 sd2 in + if is_full_mso res_disj then Any else + MSO (v1, List.sort Pervasives.compare res_disj) + | x when x < 0 -> + sum elems aset1 (MSO (v1, [((Elems.empty, Elems.empty), aset2)])) + | x -> + sum elems (MSO (v2, [((Elems.empty, Elems.empty), aset1)])) aset2 + ) | (MSO (v, disj), Real _) -> - sum elems aset1 (MSO (v, [((Elems.empty, Elems.empty), aset2)])) + sum elems aset1 (MSO (v, [((Elems.empty, Elems.empty), aset2)])) | (Real _, MSO (v, disj)) -> - sum elems (MSO (v, [((Elems.empty, Elems.empty), aset1)])) aset2 + sum elems (MSO (v, [((Elems.empty, Elems.empty), aset1)])) aset2 | (Real poly_disj1, Real poly_disj2) -> - (* FIXME fullness check for reals here (use reals solver). *) - Real (List.rev_append poly_disj1 poly_disj2) + (* FIXME fullness check for reals here (use reals solver). *) + Real (List.rev_append poly_disj1 poly_disj2) and sum_maps_rev elems acc = function | ([], m) -> List.rev_append m acc | (m, []) -> List.rev_append m acc | ((e1, a1) :: r1, (e2, a2) :: r2) -> - match compare_elems e1 e2 with - 0 -> sum_maps_rev elems ((e1, sum elems a1 a2) :: acc) (r1, r2) - | x when x < 0 -> - sum_maps_rev elems ((e1, a1) :: acc) (r1, ((e2, a2) :: r2)) - | x -> sum_maps_rev elems ((e2, a2) :: acc) (((e1, a1) :: r1), r2) + match compare_elems e1 e2 with + | 0 -> sum_maps_rev elems ((e1, sum elems a1 a2) :: acc) (r1, r2) + | x when x < 0 -> + sum_maps_rev elems ((e1, a1) :: acc) (r1, ((e2, a2) :: r2)) + | x -> sum_maps_rev elems ((e2, a2) :: acc) (((e1, a1) :: r1), r2) and sum_subsumed elems disj1 acc ((inel, outel), asg) = let subsumes ((i, o), _) = (Elems.subset i inel) && (Elems.subset o outel) in @@ -280,28 +303,29 @@ (* Project assignments on a given variable. We assume that [elems] are all elements and are sorted. Corresponds to the existential quantifier. *) let rec project elems v = function - | Empty -> Empty - | Any -> Any - | FO (u, m) when (u :> Formula.var) = v -> (* Sum the assignments below *) + | Empty -> Empty + | Any -> Any + | FO (u, m) when u = v -> (* Sum the assignments below *) List.fold_left (fun s (_, a) -> sum elems s a) Empty m - | FO (u, m) -> + | FO (u, m) -> let res_map = map_snd (project elems v) m in - if is_full elems res_map then Any else FO (u, res_map) - | MSO (u, d) when (u :> Formula.var) = v -> + if is_full elems res_map then Any else FO (u, res_map) + | MSO (u, d) when u = v -> List.fold_left (fun s (_, a) -> sum elems s a) Empty d - | MSO (u, d) -> + | MSO (u, d) -> let res_disj = map_snd (project elems v) d in - if is_full_mso res_disj then Any else MSO (u, res_disj) - | Real poly_disj -> - let simp p = RealQuantElim.simplify_sat [Formula.var_str v] p in - let app l p = if l = [[]] then [[]] else let q = simp p in - if q = [[]] then [[]] else List.rev_append q l in + if is_full_mso res_disj then Any else MSO (u, res_disj) + | Real poly_disj -> + let simp p = RealQuantElim.simplify_sat [v] p in + let app l p = if l = [[]] then [[]] else + let q = simp p in + if q = [[]] then [[]] else List.rev_append q l in let res_poly = List.fold_left app [] poly_disj in - if res_poly = [[]] then Any else Real res_poly - + if res_poly = [[]] then Any else Real res_poly + let rec project_list elems aset var_list = (* bigger (e.g. MSO > FO) first *) - let vars = List.sort (fun x y -> -1 * Formula.compare_vars x y) var_list in - List.fold_left (fun a v -> project elems v a) aset vars + let vars = List.sort (fun x y -> compare_vars x y) var_list in + List.fold_left (fun a v -> project elems v a) aset vars (* ---------------------- UNIVERSAL PROJECTION ------------------------------ *) @@ -323,43 +347,43 @@ let rec universal elems v = function | Empty -> Empty | Any -> Any - | FO (u, m) when (u :> Formula.var) = v -> (* Join the assignments below *) - if List.length m < sllen elems then Empty else - List.fold_left (fun s (_, a) -> join s a) Any m + | FO (u, m) when u = v -> (* Join the assignments below *) + if List.length m < sllen elems then Empty else + List.fold_left (fun s (_, a) -> join s a) Any m | FO (u, m) -> - let res_map = map_snd (universal elems v) m in - let res_filtered = List.filter (fun (_, a) -> a <> Empty) res_map in - if res_filtered = [] then Empty else FO (u, res_filtered) - | MSO (u, disj) when (u :> Formula.var) <> v -> - let res_disj = map_snd (universal elems v) disj in - let res_filtered = List.filter (fun (_, a) -> a <> Empty) res_disj in - if res_filtered = [] then Empty else MSO (u, res_filtered) + let res_map = map_snd (universal elems v) m in + let res_filtered = List.filter (fun (_, a) -> a <> Empty) res_map in + if res_filtered = [] then Empty else FO (u, res_filtered) + | MSO (u, disj) when u <> v -> + let res_disj = map_snd (universal elems v) disj in + let res_filtered = List.filter (fun (_, a) -> a <> Empty) res_disj in + if res_filtered = [] then Empty else MSO (u, res_filtered) | MSO (u, disj) -> - let max_elem = List.fold_left (fun i e -> max i e) 0 (slist elems) in - let disj_arr = let (_, asgs) = List.split disj in Array.of_list asgs in - let nclause_i (i, l) (x, a) = (* TODO: memoize a's + unsat hint *) - if a = Any then (i, (neg_clause x) :: l) else - (i+1, ((i + max_elem)::(neg_clause x)):: l) in - let (_, cnf) = List.fold_left nclause_i (1, []) disj in - let assgn_of_conj conj = - let (assgs, _) = List.partition (fun x-> x > max_elem) conj in - List.fold_left (fun s i -> sum elems s disj_arr.(i - max_elem - 1)) - Empty assgs in - let dnf = convert cnf in - List.fold_left (fun s c -> join s (assgn_of_conj c)) Any dnf + let max_elem = List.fold_left (fun i e -> max i e) 0 (slist elems) in + let disj_arr = let (_, asgs) = List.split disj in Array.of_list asgs in + let nclause_i (i, l) (x, a) = (* TODO: memoize a's + unsat hint *) + if a = Any then (i, (neg_clause x) :: l) else + (i+1, ((i + max_elem)::(neg_clause x)):: l) in + let (_, cnf) = List.fold_left nclause_i (1, []) disj in + let assgn_of_conj conj = + let (assgs, _) = List.partition (fun x-> x > max_elem) conj in + List.fold_left (fun s i -> sum elems s disj_arr.(i - max_elem - 1)) + Empty assgs in + let dnf = convert cnf in + List.fold_left (fun s c -> join s (assgn_of_conj c)) Any dnf | Real poly_disj -> - let neg_disj = negate_real_disj poly_disj in - if neg_disj = [] then Any else - match project elems v (Real (neg_disj)) with - | Any -> Empty - | Real disj -> - let nd = negate_real_disj disj in - if nd = [] then Empty else Real nd - | _ -> failwith "non real assignment after projecting one" + let neg_disj = negate_real_disj poly_disj in + if neg_disj = [] then Any else + match project elems v (Real (neg_disj)) with + | Any -> Empty + | Real disj -> + let nd = negate_real_disj disj in + if nd = [] then Empty else Real nd + | _ -> failwith "non real assignment after projecting one" let rec universal_list elems aset var_list = (* bigger (e.g. MSO) first *) - let vars = List.sort (fun x y -> -1 * Formula.compare_vars x y) var_list in - List.fold_left (fun a v -> universal elems v a) aset vars + let vars = List.sort (fun x y -> compare_vars x y) var_list in + List.fold_left (fun a v -> universal elems v a) aset vars (* ----------------------------- COMPLEMENT -------------------------------- *) @@ -393,7 +417,7 @@ | _ -> failwith "assigned element not in the set of all elements" and complement_disj elems disj = - let max_elem = List.fold_left (fun i e -> max i e) 0 (slist elems) in + let max_elem = List.fold_left (fun i e -> max i e) 0 (slist_rev elems) in let disj_arr = let (_, asgs) = List.split disj in Array.of_list asgs in let nclause_i (i, l) (x, a) = (* TODO: better unsat_hint and memoize a's. *) if a = Any then (i+1, (neg_clause x) :: l) else @@ -426,9 +450,9 @@ | (Empty, _) | (_, Any) -> Empty | (Any, a) -> complement elems a | (a, Empty) -> a - | (FO (`FO v1, map1), FO (`FO v2, map2)) when String.compare v1 v2 = 0 -> + | (FO (v1, map1), FO (v2, map2)) when v1 = v2 -> let resm = List.rev (complement_join_map_rev elems [] (map1, map2)) in - if resm = [] then Empty else FO (`FO v1, resm) + if resm = [] then Empty else FO (v1, resm) | (FO _, FO _) -> join aset (complement elems a) (* TODO: improve! *) | _ -> join aset (complement elems a) @@ -456,7 +480,7 @@ let make_assign vl tuple = if Array.length vl <> Array.length tuple then failwith "make_assign <>length"; let compare_asvs (v1, e1) (v2, e2) = - let c = compare_vars (v1 :> Formula.var) (v2 :> Formula.var) in + let c = compare_vars v1 v2 in if c != 0 then -c else compare_elems e1 e2 in List.sort compare_asvs (Array.to_list (Aux.array_combine vl tuple)) @@ -480,15 +504,6 @@ | (v, e) :: rest -> FO (v, [(e, set_of_single rest)]) in List.fold_left (fun s t -> sum elems s (set_of_single t)) Empty asgn_list -(* Create an assignment out of a list of variables and a tuple. - WRONG THIS WAY -let assignment_of_list vl t = - let rec set_of_single = function - | [] -> Empty - | [(v, e)] -> FO (v, [(e, ... [truncated message content] |
From: <luk...@us...> - 2012-02-09 18:31:00
|
Revision: 1671 http://toss.svn.sourceforge.net/toss/?rev=1671&view=rev Author: lukstafi Date: 2012-02-09 18:30:51 +0000 (Thu, 09 Feb 2012) Log Message: ----------- Logging syntax extension: [LOG debug_level format arg1 ... argN] where [format] is a string logs a [Printf.sprintf format arg1 ... argN] if [debug_level] is bigger than the logging level for the module/file. Modified Paths: -------------- trunk/Toss/Formula/AuxIO.ml trunk/Toss/Formula/AuxIO.mli trunk/Toss/Makefile trunk/Toss/Server/JsHandler.ml trunk/Toss/WebClient/JsHandler.js Added Paths: ----------- trunk/Toss/caml_extensions/pa_log.ml Modified: trunk/Toss/Formula/AuxIO.ml =================================================================== --- trunk/Toss/Formula/AuxIO.ml 2012-02-07 20:07:13 UTC (rev 1670) +++ trunk/Toss/Formula/AuxIO.ml 2012-02-09 18:30:51 UTC (rev 1671) @@ -145,7 +145,18 @@ ENDIF -let log s = +let default_debug_level = ref 1 +let debug_levels = ref [] + +let set_debug_level module_name debug_lev = + debug_levels := Aux.replace_assoc module_name debug_lev !debug_levels + +let debug_level_for module_name = + try List.assoc module_name !debug_levels + with Not_found -> !default_debug_level + +let log module_name debug_lev s = + let s = "["^string_of_int debug_lev^"@"^module_name^"] "^s in IFDEF JAVASCRIPT THEN ( if is_worker then worker_log s else console_log s ) ELSE ( Modified: trunk/Toss/Formula/AuxIO.mli =================================================================== --- trunk/Toss/Formula/AuxIO.mli 2012-02-07 20:07:13 UTC (rev 1670) +++ trunk/Toss/Formula/AuxIO.mli 2012-02-09 18:30:51 UTC (rev 1671) @@ -38,6 +38,20 @@ you have to collect the results, even on Exception in caller *) val toss_call : int * string -> ('a -> 'b) -> 'a -> (unit -> 'b) +(** Default logging level when a level is not set using + {!AuxIO.set_debug_level} for a module. See {!Pa_log}. *) +val default_debug_level : int ref + +(** Set logging level for a module. Logging levels are used by the + [pa_log] syntax extension (the [LOG] syntax). See {!Pa_log}. *) +val set_debug_level : string -> int -> unit + +val debug_level_for : string -> int + (** Output a string in a manner visible to the programmer but not - obtrusive to the GUI user. *) -val log : string -> unit + obtrusive to the GUI user. First argument should be the module + name, or file name with extension stripped, from which the + function is called. Second argument is the logging level, but + serves only informative purposes. Calling this function directly + outputs the message unconditionally. *) +val log : string -> int -> string -> unit Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2012-02-07 20:07:13 UTC (rev 1670) +++ trunk/Toss/Makefile 2012-02-09 18:30:51 UTC (rev 1671) @@ -33,9 +33,9 @@ # ------ NON OCAMLBUILD DEPENDENCIES -------- -caml_extensions/pa_let_try.cmo: caml_extensions/pa_let_try.ml +caml_extensions/%.cmo: caml_extensions/%.ml ocamlc -I +camlp4 -pp "camlp4o pa_extend.cmo q_MLast.cmo" \ - -c caml_extensions/pa_let_try.ml + -c $< # -------- MAIN OCAMLBUILD PART -------- @@ -45,8 +45,8 @@ OCB_CFLAG=-cflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+js_of_ocaml,-I,+site-lib/oUnit,-I,+site-lib/js_of_ocaml,-g OCB_LIB=-libs str,nums,unix,oUnit OCB_LIBJS=-libs str,js_of_ocaml -OCB_PP=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 -I /opt/local/lib/ocaml/site-lib ../caml_extensions/pa_let_try.cmo pa_macro.cmo js_of_ocaml/pa_js.cmo" -OCB_PPJS=-pp "camlp4o -unsafe -I /usr/local/lib/ocaml/3.12.0 -I /opt/local/lib/ocaml/site-lib ../caml_extensions/pa_let_try.cmo pa_macro.cmo -DJAVASCRIPT js_of_ocaml/pa_js.cmo" +OCB_PP=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 -I /opt/local/lib/ocaml/site-lib ../caml_extensions/pa_let_try.cmo ../caml_extensions/pa_log.cmo pa_macro.cmo js_of_ocaml/pa_js.cmo" +OCB_PPJS=-pp "camlp4o -unsafe -I /usr/local/lib/ocaml/3.12.0 -I /opt/local/lib/ocaml/site-lib ../caml_extensions/pa_let_try.cmo ../caml_extensions/pa_log.cmo pa_macro.cmo -DJAVASCRIPT js_of_ocaml/pa_js.cmo" OCAMLBUILD=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf \ -ocamlopt "ocamlopt -inline 10" $(OCB_PP) \ $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) @@ -63,19 +63,19 @@ ServerINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena,Play,GGP,Learn .INC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena,Play,GGP,Learn,Server -%.native: %.ml caml_extensions/pa_let_try.cmo +%.native: %.ml caml_extensions/pa_let_try.cmo caml_extensions/pa_log.cmo $(OCAMLBUILD) -Is $($(subst /,INC,$(dir $@))) $@ -%.p.native: %.ml caml_extensions/pa_let_try.cmo +%.p.native: %.ml caml_extensions/pa_let_try.cmo caml_extensions/pa_log.cmo $(OCAMLBUILD) -Is $($(subst /,INC,$(dir $@))) $@ -%.byte: %.ml caml_extensions/pa_let_try.cmo +%.byte: %.ml caml_extensions/pa_let_try.cmo caml_extensions/pa_log.cmo $(OCAMLBUILDJS) -Is $($(subst /,INC,$(dir $@))) $@ -%.d.byte: %.ml caml_extensions/pa_let_try.cmo +%.d.byte: %.ml caml_extensions/pa_let_try.cmo caml_extensions/pa_log.cmo $(OCAMLBUILD) -Is $($(subst /,INC,$(dir $@))) $@ -doc: caml_extensions/pa_let_try.cmo +doc: caml_extensions/pa_let_try.cmo caml_extensions/pa_log.cmo $(OCAMLBUILD) -Is +oUnit,$(.INC) Toss.docdir/index.html make -C www code_doc_link Modified: trunk/Toss/Server/JsHandler.ml =================================================================== --- trunk/Toss/Server/JsHandler.ml 2012-02-07 20:07:13 UTC (rev 1670) +++ trunk/Toss/Server/JsHandler.ml 2012-02-09 18:30:51 UTC (rev 1671) @@ -57,9 +57,7 @@ record let onmessage event = - AuxIO.log ("worker received "^of_js event##data##fname); - (*Firebug.console##log_4 ("worker received fname=", event##data##fname, - "; args=", event##data##args);*) + LOG 1 "worker received %s" (of_js event##data##fname); let fname = event##data##fname in let args = event##data##args in let handle = Js.Unsafe.get js_handler fname in @@ -72,7 +70,7 @@ let _ = Js.Unsafe.set self (js"onmessage") onmessage let test_handle s = - AuxIO.log ("Testing "^of_js s); + LOG 1 "Testing %s" (of_js s); js ("Now " ^ of_js s ^ " tested") let _ = set_handle "test_handle" test_handle @@ -94,7 +92,7 @@ let struc = state.Arena.struc in let get_pos e = Structure.fun_val struc "x" e, Structure.fun_val struc "y" e in - AuxIO.log "js_of_game_state: Preparing game elements..."; + LOG 1 "js_of_game_state: Preparing game elements..."; let elems = Structure.elements struc in let (posx, posy) = List.split (List.map get_pos elems) in let mkfl f l = List.fold_left f (List.hd l) (List.tl l) in @@ -110,7 +108,7 @@ elems) in (* rels are arrays of element names, with additional "name" field *) let num = Js.number_of_float in - AuxIO.log "js_of_game_state: Preparing game relations..."; + LOG 1 "js_of_game_state: Preparing game relations..."; let rels = Array.of_list (Aux.concat_map (fun (rel, _) -> @@ -131,7 +129,7 @@ Js.Unsafe.set info_obj (js"miny") (num miny); Js.Unsafe.set info_obj (js"elems") (Js.array elems); Js.Unsafe.set info_obj (js"rels") (Js.array rels); - AuxIO.log "js_of_game_state: Preparing game moves..."; + LOG 1 "js_of_game_state: Preparing game moves..."; if !cur_all_moves <> [||] then Js.Unsafe.set info_obj (js"moves") (Js.array (Array.mapi (js_of_move game state) !cur_all_moves)) @@ -155,8 +153,8 @@ let game_name = of_js game_name in let game_loaded = List.mem_assoc game_name !GameSelection.games in if game_loaded - then AuxIO.log ("new_play: "^game_name^" already loaded.") - else AuxIO.log ("new_play: loading "^game_name^"..."); + then LOG 1 "new_play: %s already loaded." game_name + else LOG 1 "new_play: loading %s..." game_name; let game_data = try List.assoc game_name !GameSelection.games with Not_found -> @@ -165,13 +163,13 @@ games := game_data :: !games; snd game_data in if not game_loaded then - AuxIO.log ("new_play: "^game_name^" loaded."); + LOG 1 "new_play: %s loaded." game_name; let game, state = game_data.game_state in cur_game := game_data; play_states := [state]; cur_all_moves := Move.list_moves game state; cur_move := 0; - AuxIO.log ("new_play ("^game_name^"): calling js_of_game_state."); + LOG 1 "new_play (%s): calling js_of_game_state." game_name; js_of_game_state game state let _ = set_handle "new_play" new_play @@ -188,7 +186,7 @@ let make_move move_id = let move_id = int_of_float (Js.to_float move_id) in - AuxIO.log ("make_move: move_id="^string_of_int move_id); + LOG 1 "make_move: move_id=%d" move_id; if !play_states = [] then Js.null else let (p, m, n_state) = !cur_all_moves.(move_id) in Modified: trunk/Toss/WebClient/JsHandler.js =================================================================== --- trunk/Toss/WebClient/JsHandler.js 2012-02-07 20:07:13 UTC (rev 1670) +++ trunk/Toss/WebClient/JsHandler.js 2012-02-09 18:30:51 UTC (rev 1671) @@ -948,4 +948,4 @@ if( y.fun ) { x.fun = y.fun; return 0; } var i = y.length; while (i--) x[i] = y[i]; return 0; } @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-07 20:07:24
|
Revision: 1670 http://toss.svn.sourceforge.net/toss/?rev=1670&view=rev Author: lukaszkaiser Date: 2012-02-07 20:07:13 +0000 (Tue, 07 Feb 2012) Log Message: ----------- Compilation corrections for OSX. Modified Paths: -------------- trunk/Toss/Makefile Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2012-02-07 02:10:47 UTC (rev 1669) +++ trunk/Toss/Makefile 2012-02-07 20:07:13 UTC (rev 1670) @@ -41,12 +41,12 @@ # -------- MAIN OCAMLBUILD PART -------- # TODO: Hard-coded path to js_of_ocaml. -OCB_LFLAG=-lflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+js_of_ocaml,-I,+site-lib/oUnit -OCB_CFLAG=-cflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+js_of_ocaml,-I,+site-lib/oUnit,-g +OCB_LFLAG=-lflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+js_of_ocaml,-I,+site-lib/oUnit,-I,+site-lib/js_of_ocaml +OCB_CFLAG=-cflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+js_of_ocaml,-I,+site-lib/oUnit,-I,+site-lib/js_of_ocaml,-g OCB_LIB=-libs str,nums,unix,oUnit OCB_LIBJS=-libs str,js_of_ocaml -OCB_PP=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo js_of_ocaml/pa_js.cmo" -OCB_PPJS=-pp "camlp4o -unsafe -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo -DJAVASCRIPT js_of_ocaml/pa_js.cmo" +OCB_PP=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 -I /opt/local/lib/ocaml/site-lib ../caml_extensions/pa_let_try.cmo pa_macro.cmo js_of_ocaml/pa_js.cmo" +OCB_PPJS=-pp "camlp4o -unsafe -I /usr/local/lib/ocaml/3.12.0 -I /opt/local/lib/ocaml/site-lib ../caml_extensions/pa_let_try.cmo pa_macro.cmo -DJAVASCRIPT js_of_ocaml/pa_js.cmo" OCAMLBUILD=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf \ -ocamlopt "ocamlopt -inline 10" $(OCB_PP) \ $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-07 02:10:57
|
Revision: 1669 http://toss.svn.sourceforge.net/toss/?rev=1669&view=rev Author: lukaszkaiser Date: 2012-02-07 02:10:47 +0000 (Tue, 07 Feb 2012) Log Message: ----------- Make local the default client, remove dependency on sqlite3 and many requests from ReqHandler and Arena. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/Arena/ArenaParser.mly trunk/Toss/Arena/ArenaTest.ml trunk/Toss/GGP/TranslateGameTest.ml trunk/Toss/Makefile trunk/Toss/README trunk/Toss/Server/ReqHandler.ml trunk/Toss/Server/ReqHandler.mli trunk/Toss/Server/ReqHandlerTest.ml trunk/Toss/Server/Server.ml trunk/Toss/Toss.odocl trunk/Toss/WebClient/JsHandler.js trunk/Toss/WebClient/index.html trunk/Toss/www/develop.xml Removed Paths: ------------- trunk/Toss/Server/DB.ml trunk/Toss/Server/DB.mli trunk/Toss/Server/ServerTest.in trunk/Toss/Server/ServerTest.out trunk/Toss/WebClient/crypto-sha256.js trunk/Toss/WebClient/local.html Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/Arena/Arena.ml 2012-02-07 02:10:47 UTC (rev 1669) @@ -599,75 +599,10 @@ (* Requests which we handle. *) type request = - AddElem of struct_loc (* Add element to location *) - | AddRel of struct_loc * string * string list (* Add relation tuple *) - | DelElem of struct_loc * string (* Del element at location *) - | DelRel of struct_loc * string * string list (* Del relation tuple *) - | GetRelSignature of struct_loc (* List rel names and arities *) - | GetFunSignature of struct_loc (* List function names *) - | GetAllTuples of struct_loc * string (* Get all tuples in relation *) - | GetAllElems of struct_loc (* List all elements *) - | SetFun of struct_loc * string * string * float (* Set function value *) - | GetFun of struct_loc * string * string (* Get function value *) - | SetData of string * string (* Set data under a name *) - | GetData of string (* Get data *) - | SetArity of string * int (* Set arity of a relation *) - | GetArity of string (* Get arity of a relation *) - | RenamePlayer of string * string (* Replace player name *) - | SetLoc of int (* Set current location *) - | GetLoc (* Get current and # locs. *) - | SetLocPlayer of int * string (* Set player at location *) - | GetLocPlayer of int (* Get player at location *) - | SetLocPayoff of int * string * Formula.real_expr(* Set payoff for player *) - | GetLocPayoff of int * string (* Get payoff for player *) - | GetCurPayoffs (* Payoffs in current loc *) - | SetLocMoves of int * (label * int) list (* Set moves at location *) - | GetLocMoves of int (* Get moves at location *) | SuggestLocMoves of int * int * int * string * int option * (string * Formula.real_expr) list array option * float option - (* Suggested moves at loc, with timeout in so many seconds, for so - much computational effort if possible before timeout, using given - search method ("maximax", "alpha_beta", "alpha_beta_ord", - "uct_random_playouts", - "uct_greedy_playouts", "uct_maximax_playouts", - "uct_no_playouts"), with optional horizon for playouts, with - location-dependent heuristics, with advancement ratio for - generating heuristics if they're not given *) - | EvalFormula of Formula.formula (* Evaluate formula *) - | EvalRealExpr of Formula.real_expr (* Evaluate real expr *) - | SetRule of string * - ((string * int) list -> - (string * (string list * Formula.formula)) list -> string -> - ContinuousRule.rule) - (* Set a rule as given *) - | GetRule of string (* Get a rule as string *) - | SetRuleUpd of string * string * string * Formula.real_expr - (* Set a rule update eq *) - | GetRuleUpd of string * string * string (* Get a rule update eq *) - | SetRuleDyn of string*string *string *Term.term (* Set a rule dynamics eq *) - | GetRuleDyn of string * string * string (* Get a rule dynamics eq *) - | SetRuleCond of string * Formula.formula * Formula.formula * Formula.formula - (* Set a rule's precondition, invariant and postconsition *) - | GetRuleCond of string (* Get a rule conditions *) - | SetRuleEmb of string * string list (* Set relations to embed *) - | GetRuleEmb of string (* Get relations to embed *) - | SetRuleAssoc of string * string * string (* Set an association *) - | GetRuleAssoc of string * string (* Get an association *) - | GetRuleMatches of string (* Get matches of a rule *) - | ApplyRule of string * (string * string) list * float * (string * float) list - (* Apply rule at match for given time and with params *) - | ApplyRuleInt of string * (string * int) list * float * (string * float) list - (* Apply rule at match for given time and with params *) - | GetRuleNames (* Get names of all rules *) - | SetTime of float * float (* Set time step and time *) - | GetTime (* Get time step and time *) - | SetState of game * game_state (* Set the full state *) - | GetState (* Return the state *) - | GetModel (* Return model+history *) - | SetModel of Structure.structure * (move * float option) list (* Set above *) - (* --------------------------- REQUEST HANDLER ------------------------------ *) (* Apply function [f] to named structure at location [loc] in [state]. @@ -750,452 +685,21 @@ let sig_str state = Structure.sig_str state.struc -(* Request Handler *) -let handle_request (state_game, state) req = - let struc = state.struc in - let add_new_elem struc = - let struc, e = Structure.add_new_elem struc () in - struc, string_of_int e in - match req with - AddElem loc -> - apply_to_loc add_new_elem loc (state_game, state) "add elem" - | AddRel (loc, rel, tp) -> - let add_rel struc = - let struc, tp = - List.fold_right (fun n (struc, tp) -> - let struc, e = Structure.find_or_new_elem struc n in - struc, e::tp) tp (struc, []) in - let tp = Array.of_list tp in - Structure.add_rel struc rel tp, "REL ADDED" in - apply_to_loc add_rel loc (state_game, state) "add rel" - | DelElem (loc, elem_name) -> - let del_elem struc = - let el = Structure.find_elem struc elem_name in - Structure.del_elem struc el, "ELEM DELETED" in - apply_to_loc del_elem loc (state_game, state) "del elem" - | DelRel (loc, rel, tp) -> - let del_rel struc = - let tp = List.map (fun n -> Structure.find_elem struc n) tp in - Structure.del_rel struc rel (Array.of_list tp), "REL DELETED" in - apply_to_loc del_rel loc (state_game, state) "del rel" - | GetRelSignature loc -> - ((state_game, state), - get_from_loc Structure.sig_str loc (state_game, state) "get signature") - | GetFunSignature loc -> - let fun_signature struc = - let funs = Structure.f_signature struc in - String.concat "; " funs in - ((state_game,state), - get_from_loc fun_signature loc (state_game, state) "get signature") - | GetAllTuples (loc, rel) -> - let tuples struc = - let tps = Structure.rel_graph rel struc in - Structure.rel_str struc rel tps in - ((state_game, state), - get_from_loc tuples loc (state_game, state) "get all tuples") - | GetAllElems loc -> - let elems struc = - let els = Structure.elements struc in - let el_name e = Structure.elem_str struc e in - String.concat "; " (List.map el_name els) in - ((state_game, state), - get_from_loc elems loc (state_game, state) "get all elements") - | SetFun (loc, funct, el_name, v) -> - let set_fun struc = - let el = Structure.find_elem struc el_name in - Structure.add_fun struc funct (el, v), "FUN SET" in - apply_to_loc set_fun loc (state_game, state) "set fun" - | GetFun (loc, funct, el_name) -> - let get_fun struc = - let el = Structure.find_elem struc el_name in - string_of_float (Structure.fun_val struc funct el) in - ((state_game, state), - get_from_loc get_fun loc (state_game, state) "get fun") - | SetData (key, v) -> - let ndata = Aux.replace_assoc key v state_game.data in - (({state_game with data = ndata }, state), "SET DATA") - | GetData (key) -> ( - try ((state_game, state), List.assoc key state_game.data) - with Not_found -> ((state_game, state), "ERR no data") - ) - | SetArity (rel, ar) -> - if (try List.assoc rel (Structure.rel_signature struc) = ar - with Not_found -> false) - then (state_game, state), "SET ARITY" - else - let s = Structure.add_rel_name rel ar struc in - ((state_game, { state with struc = s }), "SET ARITY") - | GetArity (rel) -> ( - if rel = "" then ((state_game, state), sig_str state) else - try ((state_game, state), string_of_int - (List.assoc rel (Structure.rel_signature state.struc))) - with Not_found -> - ((state_game, state), "ERR relation "^rel^" arity not found") - ) - | RenamePlayer (old_name, new_name) -> - let player, player_names = - Aux.pop_assoc old_name state_game.player_names in - ({state_game with player_names = (new_name, player)::player_names}, - state), "PLAYER renamed" - | SetLoc (i) -> - let l = Array.length state_game.graph in - if i < 0 || i > l then (* make new location and set there *) - let a = Array.make (Array.length state_game.graph.(0)) zero_loc in - (({state_game with graph = Array.append state_game.graph [|a|]}, - {state with cur_loc = l }), - "NEW LOC ADDED AND CUR LOC SET TO " ^ (string_of_int l)) - else - ((state_game, { state with cur_loc = i }), "CUR LOC SET") - | GetLoc -> - ((state_game, state), (string_of_int state.cur_loc) ^ " / " ^ - (string_of_int (Array.length state_game.graph))) - | SetLocPlayer (i, player) -> failwith "unsupported for now, concurrency" - (* ((state_game, state), "LOC PLAYER SET") *) - | GetLocPlayer (i) -> - if i < 0 || i > Array.length state_game.graph then - ((state_game, state), "ERR location "^string_of_int i^" not found") - else - let players = - Aux.array_argfind_all (fun l-> l.moves <> []) state_game.graph.(i) in - if List.length players <> 1 then - ((state_game, state), "ERR location " ^ string_of_int i ^ " allows "^ - (string_of_int (List.length players)) ^ " players to move") - else - let pl = List.hd players in - ((state_game, state), Aux.rev_assoc state_game.player_names pl) - | SetLocPayoff (i, player, payoff) -> - let (state_game, state), player = - try (state_game, state), List.assoc player state_game.player_names - with Not_found -> add_new_player (state_game, state) player in - if i < 0 || i > Array.length state_game.graph then - ((state_game, state), "ERR location "^string_of_int i^" not found") - else ( - let simp_payoff = FormulaOps.tnf_re payoff in - state_game.graph.(i).(player) <- - { state_game.graph.(i).(player) with payoff = simp_payoff }; - ((state_game, state), "LOC PAYOFF SET") - ) - | GetLocPayoff (i, player) -> - if i < 0 || i > Array.length state_game.graph then - ((state_game, state), "ERR location "^string_of_int i^" not found") - else ( - try - let pno = List.assoc player state_game.player_names in - ((state_game, state), - Formula.real_str state_game.graph.(i).(pno).payoff) - with Not_found -> ((state_game, state), "0.0") - ) - | GetCurPayoffs -> - let payoffs = Array.to_list - (Array.mapi (fun i v->string_of_int i, v.payoff) - state_game.graph.(state.cur_loc)) in - let ev (p,e) = - p^": "^(string_of_float (Solver.M.get_real_val e struc)) in - ((state_game, state), - String.concat ", " (List.sort compare (List.map ev payoffs))) - | SetLocMoves (i, moves) -> failwith "unsupported for now, concurrency" - (* if i < 0 || i > Array.length state_game.graph then - ((state_game, state), "ERR location "^string_of_int i^" not found") - else ( - state_game.graph.(i) <- { state_game.graph.(i) with moves = moves }; - ((state_game, state), "LOC MOVES SET") - ) *) - | GetLocMoves (i) -> - if i < 0 || i > Array.length state_game.graph then - ((state_game, state), "ERR location "^string_of_int i^" not found") - else - let pl i = Aux.rev_assoc state_game.player_names i in - let all_moves = List.concat (Array.to_list ( - Array.mapi (fun i ploc -> List.map (fun (l, e) -> (pl i, l, e)) - ploc.moves) state_game.graph.(i))) in - ((state_game,state), (String.concat "; " (List.map pmv_str all_moves))) - | SuggestLocMoves _ -> - failwith "handle_req: SuggestLocMoves handled in Server" - | EvalFormula (phi) -> ((state_game, state), "ERR eval not yet implemented") - | EvalRealExpr (rexpr) -> - ((state_game, state), "ERR eval real not yet implemented") - | SetRule (r_name, r) -> ( - try - let signat = Structure.rel_signature state.struc in - let defs = state_game.defined_rels in - let new_rules = - Aux.replace_assoc r_name (r signat defs r_name) - state_game.rules in - (({state_game with rules=new_rules}, state), "SET RULE") - with - Not_found -> ((state_game, state), - "ERR [Not found] setting rule "^r_name^" failed") - ) - | GetRule (r_name) -> - let msg = get_from_rule ContinuousRule.str r_name state_game "get rule" in - ((state_game, state), msg) - | SetRuleUpd (r_name, f, elem_name, expr) -> - let set_upd r = - let new_upd = - Aux.replace_assoc (f,elem_name) expr r.ContinuousRule.update in - { r with ContinuousRule.update = new_upd }, "UPDATE SET" in - apply_to_rule set_upd r_name (state_game, state) "set rule upd" - | GetRuleUpd (r_name, f, elem_name) -> - let get_upd r = - try - let upd = List.assoc (f,elem_name) r.ContinuousRule.update in - Formula.real_str upd - with Not_found -> "0.0" in - ((state_game, state), - get_from_rule get_upd r_name state_game "get rule upd") - | SetRuleDyn (r_name, f, elem_name, term) -> - let set_dyn r = - let new_dyn = - Aux.replace_assoc (f,elem_name) term r.ContinuousRule.dynamics in - { r with ContinuousRule.dynamics = new_dyn },"DYNAMICS SET" in - apply_to_rule set_dyn r_name (state_game, state) "set rule dyn" - | GetRuleDyn (r_name, f, elem_name) -> - let get_dyn r = - try - let dyn = List.assoc (f,elem_name) r.ContinuousRule.dynamics in - Term.str dyn - with Not_found -> "0.0" in - ((state_game, state), - get_from_rule get_dyn r_name state_game "get rule dyn") - | SetRuleCond (r_name, pre, inv, post) -> - let set_cond r = - let d = r.ContinuousRule.discrete in - let (dyn, upd)=(r.ContinuousRule.dynamics, r.ContinuousRule.update) in - let signat = Structure.rel_signature state.struc in - let defs = state_game.defined_rels in - let discr = - match d.DiscreteRule.struc_rule with - | None -> - {d with DiscreteRule.match_formula = pre} - | Some rule_src -> - DiscreteRule.compile_rule signat defs - {rule_src with DiscreteRule.pre = (pre, []) } in - let nr = (* TODO: rename lhs_* relations to be consistent with ln *) - ContinuousRule.make_rule defs discr dyn upd ~inv ~post () in - (nr, "RULE COND SET") in - apply_to_rule set_cond r_name (state_game, state) "set rule cond" - | GetRuleCond (r_name) -> - let get_cond r = - let discr = r.ContinuousRule.discrete in - let pre = - match discr.DiscreteRule.struc_rule with - | None -> discr.DiscreteRule.match_formula - | Some struc_r -> fst struc_r.DiscreteRule.pre in - let (inv, post)=(r.ContinuousRule.inv, r.ContinuousRule.post) in - (Formula.str pre)^"; "^ (Formula.str inv) ^"; "^ (Formula.str post) in - ((state_game, state), - get_from_rule get_cond r_name state_game "get rule cond") - | SetRuleEmb (r_name, emb) -> - let set_emb r = - let struc_r = r.ContinuousRule.discrete.DiscreteRule.struc_rule in - match struc_r with - | None -> - r, - "ERR Set Rule Embedding: formula-based format of " ^ - r_name - | Some struc_r -> - let struc_r = {struc_r with DiscreteRule.emb_rels =emb } in - let (dyn, upd)= - (r.ContinuousRule.dynamics, r.ContinuousRule.update) in - let inv = r.ContinuousRule.inv - and post = r.ContinuousRule.post in - let signat = Structure.rel_signature state.struc in - let defs = state_game.defined_rels in - let discr = DiscreteRule.compile_rule signat defs struc_r in - let nr = - ContinuousRule.make_rule defs discr dyn upd ~inv ~post () in - (nr, "RULE EMB SET") in - apply_to_rule set_emb r_name (state_game, state) "set rule emb" - - | GetRuleEmb (r_name) -> - let get_emb r = - let struc_r = r.ContinuousRule.discrete.DiscreteRule.struc_rule in - match struc_r with - | None -> - "ERR Get Rule Embedding: formula-based format of " ^ - r_name - | Some struc_r -> - String.concat ", " struc_r.DiscreteRule.emb_rels in - ((state_game, state), - get_from_rule get_emb r_name state_game "get rule emb") - - | SetRuleAssoc (r_name, rhs_v, lhs_v) -> - let set_assoc r = - let discr = r.ContinuousRule.discrete in - let signat = Structure.rel_signature state.struc in - let defs = state_game.defined_rels in - let discr = - match discr.DiscreteRule.struc_rule with - | Some struc_r -> - let lhs_e = Structure.find_elem - struc_r.DiscreteRule.lhs_struc lhs_v in - let rhs_e = Structure.find_elem - struc_r.DiscreteRule.rhs_struc rhs_v in - let rule_s = Aux.replace_assoc rhs_e lhs_e - (List.filter (fun (r, l) -> r <> rhs_e) - struc_r.DiscreteRule.rule_s) in - DiscreteRule.compile_rule signat defs - {struc_r with DiscreteRule.rule_s = rule_s} - | None -> - let rlmap = - match discr.DiscreteRule.rlmap with - | None -> - List.map (fun v->v,v) discr.DiscreteRule.lhs_vars - | Some rlmap -> rlmap in - let rlmap = - Aux.replace_assoc rhs_v lhs_v rlmap in - {discr with DiscreteRule.rlmap = Some rlmap} in - let (dyn, upd) = - (r.ContinuousRule.dynamics, r.ContinuousRule.update) in - let inv = r.ContinuousRule.inv - and post = r.ContinuousRule.post in - let nr = - ContinuousRule.make_rule defs discr dyn upd ~inv ~post () in - (nr, "RULE ASSOC SET") - in - apply_to_rule set_assoc r_name (state_game, state) "set rule assoc" - - | GetRuleAssoc (r_name, rhs_v) -> - let get_assoc r = - let assoc = r.ContinuousRule.discrete.DiscreteRule.rlmap in - match assoc with - (* TODO: the RHS variables could have gotten renamed! - Best would be to check if there is struc_rule if - [rlmap = None] *) - | None -> rhs_v - | Some a -> List.assoc rhs_v a in - ((state_game, state), - get_from_rule get_assoc r_name state_game "get rule assoc") - - | GetRuleMatches (r_name) -> ( - let check_history_pre r hist = - match r.ContinuousRule.discrete.DiscreteRule.struc_rule with - | None -> true - | Some sr -> - let prev_list = snd (sr.DiscreteRule.pre) in - let constraint_satisfied (rname, b) = - List.exists (fun (mv, _) -> mv.rule = rname) hist = b in - List.for_all constraint_satisfied prev_list in - try - let r = List.assoc r_name state_game.rules in - let matches = if not (check_history_pre r state.history) then [] else - ContinuousRule.matches_post struc r state.time in - (* matches are from LHS to model *) - ((state_game, state), - String.concat "; " ( - List.map (ContinuousRule.matching_str struc) matches)) - with Not_found -> - ((state_game, state), "ERR getting "^r_name^" matches, rule not found") - ) - - | ApplyRule (r_name, mtch, t, p) -> - (let try r = List.assoc r_name state_game.rules in - let m = List.map (fun (l, s) -> l, - Structure.find_elem state.struc s) mtch in - match ContinuousRule.rewrite_single struc state.time m r t p with - | Some (new_struc, new_time, shifts) -> - let val_str ((f, e), tl) = - let ts t = string_of_float (Term.term_val t) in - (* we've moved to using element names in Term *) - f ^ ", " ^ e ^ ", " ^ (String.concat ", " (List.map ts tl)) in - let shifts_s = String.concat "; " (List.map val_str shifts) in - let newmv = { mv_time = t; parameters = p; rule = r_name; - matching = m; next_loc = -1 (*FIX*) } in - let h = (newmv, None) :: state.history in - ((state_game, - {state with struc = new_struc; time = new_time; history = h}), - shifts_s) - | None -> ((state_game, state), - "ERR applying "^r_name^", postcondition fails") - with Not_found -> - ((state_game, state), "ERR applying "^r_name^", rule not found") - ) - - | ApplyRuleInt (r_name, mtch, t, p) -> - (let try r = List.assoc r_name state_game.rules in - match ContinuousRule.rewrite_single struc state.time mtch r t p with - | Some (new_struc, new_time, shifts) -> - let val_str ((f, e), tl) = - let ts t = string_of_float (Term.term_val t) in - (* we've moved to using element names in Term *) - f ^ ", " ^ e ^ ", " ^ (String.concat ", " (List.map ts tl)) in - let shifts_s = String.concat "; " (List.map val_str shifts) in - ((state_game, {state with struc = new_struc; time = new_time}), - shifts_s) - | None -> ((state_game, state), - "ERR applying " ^ r_name ^ ", postcondition fails") - with Not_found -> - ((state_game, state), "ERR applying " ^ r_name ^ ", rule not found") - ) - - | GetRuleNames -> ((state_game, state), - String.concat "; " (fst (List.split state_game.rules))) - | SetTime (tstep, t) -> - ContinuousRule.set_time_step tstep; - ((state_game, { state with time = t }), "TIME SET") - | GetTime -> - let (ts, t) = (ContinuousRule.get_time_step (), state.time) in - ((state_game, state), string_of_float (ts) ^ " / " ^ string_of_float (t)) - | SetState (g, s) -> - ((g, s), "STATE SET") - | GetState -> ((state_game, state), state_str (state_game, state)) - | GetModel -> - let h_str = if state.history = [] then "" else "\nMOVES\n" ^ - (String.concat ";\n" (List.map sprint_game_move state.history)) in - ((state_game, state), (Structure.sprint state.struc) ^ h_str) - | SetModel (m, h) -> - ((state_game, { state with struc = m; history = h }), "MODEL SET") - - -let can_modify_game = function - | AddElem _ -> true - | AddRel _ -> true - | DelElem _ -> true - | DelRel _ -> true - | GetRelSignature _ -> false - | GetFunSignature _ -> false - | GetAllTuples _ -> false - | GetAllElems _ -> false - | SetFun _ -> false (* TODO: rethink when working on dyns *) - | GetFun _ -> false - | SetData _ -> false - | GetData _ -> false - | SetArity _ -> true - | GetArity _ -> false - | RenamePlayer _ -> false - | SetLoc i -> true - | GetLoc -> false - | SetLocPlayer _ -> true - | GetLocPlayer _ -> false - | SetLocPayoff _ -> true - | GetLocPayoff _ -> false - | GetCurPayoffs -> false - | SetLocMoves _ -> true - | GetLocMoves _ -> false - | SuggestLocMoves _ -> false - | EvalFormula _ -> false - | EvalRealExpr _ -> false - | SetRule _ -> true - | GetRule _ -> false - | SetRuleUpd _ -> true - | GetRuleUpd _ -> false - | SetRuleDyn _ -> true - | GetRuleDyn _ -> false - | SetRuleCond _ -> true - | GetRuleCond _ -> false - | SetRuleEmb _ -> true - | GetRuleEmb _ -> false - | SetRuleAssoc _ -> true - | GetRuleAssoc _ -> false - | GetRuleMatches _ -> false - | ApplyRule _ -> true - | ApplyRuleInt _ -> true - | GetRuleNames -> false - | SetTime _ -> false (* TODO: rethink when working on dyns *) - | GetTime -> false - | SetState _ -> true - | GetState -> false - | SetModel _ -> true - | GetModel -> false - +let apply_rule_int (state_game, state) (r_name, mtch, t, p) = + (let try r = List.assoc r_name state_game.rules in ( + match ContinuousRule.rewrite_single state.struc state.time mtch r t p with + | Some (new_struc, new_time, shifts) -> + let val_str ((f, e), tl) = + let ts t = string_of_float (Term.term_val t) in + (* we've moved to using element names in Term *) + f ^ ", " ^ e ^ ", " ^ (String.concat ", " (List.map ts tl)) in + let shifts_s = String.concat "; " (List.map val_str shifts) in + ((state_game, {state with struc = new_struc; time = new_time}), + shifts_s) + | None -> ((state_game, state), + "ERR applying " ^ r_name ^ ", postcondition fails") + ) + with Not_found -> + ((state_game, state), "ERR applying " ^ r_name ^ ", rule not found") + ) Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/Arena/Arena.mli 2012-02-07 02:10:47 UTC (rev 1669) @@ -170,30 +170,6 @@ (** Requests which we handle. *) type request = - AddElem of struct_loc (** Add element to location *) - | AddRel of struct_loc * string * string list (** Add relation tuple *) - | DelElem of struct_loc * string (** Del element at location *) - | DelRel of struct_loc * string * string list (** Del relation tuple *) - | GetRelSignature of struct_loc (** List rel names and arities *) - | GetFunSignature of struct_loc (** List function names *) - | GetAllTuples of struct_loc * string (** Get all tuples in relation *) - | GetAllElems of struct_loc (** List all elements *) - | SetFun of struct_loc * string * string * float (** Set function value *) - | GetFun of struct_loc * string * string (** Get function value *) - | SetData of string * string (** Set data under a name *) - | GetData of string (** Get data *) - | SetArity of string * int (** Set arity of a relation *) - | GetArity of string (** Get arity of a relation *) - | RenamePlayer of string * string (** Replace player name *) - | SetLoc of int (** Set current location *) - | GetLoc (** Get current and # locs. *) - | SetLocPlayer of int * string (** Set player at location *) - | GetLocPlayer of int (** Get player at location *) - | SetLocPayoff of int * string * Formula.real_expr(** Set payoff for player *) - | GetLocPayoff of int * string (** Get payoff for player *) - | GetCurPayoffs (** Payoffs in current loc *) - | SetLocMoves of int * (label * int) list (** Set moves at location *) - | GetLocMoves of int (** Get moves at location *) | SuggestLocMoves of int * int * int * string * int option * (string * Formula.real_expr) list array option * float option (** Suggested moves at loc, with timeout in so many seconds, for so @@ -204,41 +180,7 @@ "uct_no_playouts"), with optional horizon for playouts, with location-dependent heuristics, with advancement ratio for generating heuristics if they're not given *) - | EvalFormula of Formula.formula (** Evaluate formula *) - | EvalRealExpr of Formula.real_expr (** Evaluate real expr *) - | SetRule of string * - ((string * int) list -> - (string * (string list * Formula.formula)) list -> string -> - ContinuousRule.rule) - (** Set a rule as given *) - | GetRule of string (** Get a rule as string *) - | SetRuleUpd of string * string * string * Formula.real_expr - (** Set a rule update eq *) - | GetRuleUpd of string * string * string (** Get a rule update eq *) - | SetRuleDyn of string*string *string *Term.term (** Set a rule dynamics eq *) - | GetRuleDyn of string * string * string (** Get a rule dynamics eq *) - | SetRuleCond of string * Formula.formula * Formula.formula * Formula.formula - (** Set a rule's precondition, invariant and postconsition *) - | GetRuleCond of string (** Get a rule conditions *) - | SetRuleEmb of string * string list (** Set relations to embed *) - | GetRuleEmb of string (** Get relations to embed *) - | SetRuleAssoc of string * string * string (** Set an r-l rule_s pair *) - | GetRuleAssoc of string * string (** Get an association *) - | GetRuleMatches of string (** Get matches of a rule *) - | ApplyRule of string * (string * string) list * float * (string * float) list - (** Apply rule at match for given time and with params *) - | ApplyRuleInt of string * (string * int) list * float * (string * float) list - | GetRuleNames (** Get names of rules *) - | SetTime of float * float (** Set time step and time *) - | GetTime (** Get time step and time *) - | SetState of game * game_state (** Set the full state *) - | GetState (** Return the state *) - | GetModel (** Return model+history *) - | SetModel of Structure.structure * (move * float option) list - (** Set the model+history *) - -val handle_request : - game * game_state -> request -> (game * game_state) * string - -val can_modify_game : request -> bool +val apply_rule_int : game * game_state -> + string * (string * int) list * float * (string * float) list -> + (game * game_state) * string Modified: trunk/Toss/Arena/ArenaParser.mly =================================================================== --- trunk/Toss/Arena/ArenaParser.mly 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/Arena/ArenaParser.mly 2012-02-07 02:10:47 UTC (rev 1669) @@ -162,57 +162,6 @@ | RULE_SPEC id_int RIGHT_SPEC { Arena.Right ($2) } request: - | SET_CMD SIG_MOD id_int INT { SetArity ($3, $4) } - | GET_CMD SIG_MOD { GetArity ("") } - | GET_CMD SIG_MOD id_int { GetArity ($3) } - | SET_CMD STATE_SPEC gs=game_state { let (g, s) = gs in SetState (g, s) } - | GET_CMD STATE_SPEC { GetState } - | GET_CMD MODEL_SPEC { GetModel } - | SET_CMD MODEL_SPEC model = struct_expr - h = option (preceded (MOVES, separated_list (SEMICOLON, game_move_timed))) - { SetModel (model, match h with None -> [] | Some l -> l) } - | SET_CMD MODEL_SPEC model = struct_expr WITH - defs = separated_list (SEMICOLON, rel_def_simple) - h = option (preceded (MOVES, separated_list (SEMICOLON, game_move_timed))) - { SetModel (Arena.add_def_rels model defs, - match h with None -> [] | Some l -> l) } - | ADD_CMD ELEM_MOD struct_location - { AddElem ($3) } - | ADD_CMD REL_MOD - wh = struct_location - rel = ID - tup = delimited (OPEN, separated_list (COMMA, id_int), CLOSE) - { AddRel (wh, rel, tup) } - | DEL_CMD ELEM_MOD wh=struct_location elem=id_int - { DelElem (wh, elem) } - | DEL_CMD REL_MOD - wh = struct_location - rel = ID - tup = delimited (OPEN, separated_list (COMMA, id_int), CLOSE) - { DelRel (wh, rel, tup) } - | GET_CMD SIG_MOD REL_MOD wh=struct_location - { GetRelSignature wh } - | GET_CMD SIG_MOD FUN_MOD wh=struct_location - { GetFunSignature wh } - | GET_CMD ALLOF_MOD REL_MOD wh=struct_location rel=ID - { GetAllTuples (wh, rel) } - | GET_CMD ALLOF_MOD ELEM_MOD wh=struct_location - { GetAllElems wh } - | SET_CMD FUN_MOD wh=struct_location fn=ID elem=id_int v=FLOAT - { SetFun (wh, fn, elem, v) } - | GET_CMD FUN_MOD wh=struct_location fn=ID elem=id_int - { GetFun (wh, fn, elem) } - | SET_CMD PLAYER_MOD oldn=id_int PLAYER_MOD newn=id_int - { RenamePlayer (oldn, newn) } - | SET_CMD LOC_MOD PAYOFF loc=INT player=id_int poff=real_expr_err - { SetLocPayoff (loc, player, poff) } - | GET_CMD LOC_MOD PAYOFF loc=INT player=id_int - { GetLocPayoff (loc, player) } - | GET_CMD PAYOFF { GetCurPayoffs } - | SET_CMD LOC_MOD MOVES loc=INT - moves = separated_list (SEMICOLON, move) - { SetLocMoves (loc, moves) } - | GET_CMD LOC_MOD MOVES loc=INT { GetLocMoves loc } | EVAL_CMD LOC_MOD MOVES heur_adv_ratio=FLOAT loc=INT TIMEOUT_MOD timer=INT effort=INT algo=ID horizon=INT? @@ -231,51 +180,6 @@ {let heur_adv_ratio = None in SuggestLocMoves (loc, timer, effort, algo, horizon, Some (Array.of_list heuristic), heur_adv_ratio) } - | SET_CMD LOC_MOD PLAYER_MOD loc=INT pl=id_int { SetLocPlayer (loc, pl) } - | SET_CMD LOC_MOD PLAYER_MOD loc=INT { SetLocPlayer (loc, "1") } - | GET_CMD LOC_MOD PLAYER_MOD loc=INT { GetLocPlayer loc } - | SET_CMD LOC_MOD loc=INT { SetLoc loc } - | GET_CMD LOC_MOD { GetLoc } - | EVAL_CMD OPEN phi=formula_expr_err CLOSE { EvalFormula phi } - | EVAL_CMD OPENSQ re=real_expr_err CLOSESQ { EvalRealExpr re } - | SET_CMD DATA_MOD i=ID v=id_int { SetData (i, v) } - | GET_CMD DATA_MOD i=ID { GetData i } - | SET_CMD RULE_SPEC r=id_int rdef=rule_expr { SetRule (r, rdef) } - | GET_CMD RULE_SPEC r=id_int { GetRule r } - | GET_CMD RULE_SPEC { GetRuleNames } - | GET_CMD RULE_SPEC r=id_int MODEL_SPEC { GetRuleMatches r } - | SET_CMD RULE_SPEC - r = id_int MODEL_SPEC - mtch = separated_list ( - COMMA, separated_pair (id_int, COLON, id_int)) - time = FLOAT - params = separated_list (COMMA, separated_pair (ID, COLON, FLOAT)) - { ApplyRule (r, mtch, time, params) } - | SET_CMD RULE_SPEC UPDATE r=id_int fn=ID elem=id_int upd=real_expr - { SetRuleUpd (r, fn, elem, upd) } - | GET_CMD RULE_SPEC UPDATE r=id_int fn=ID elem=id_int - { GetRuleUpd (r, fn, elem) } - | SET_CMD RULE_SPEC DYNAMICS r=id_int fn=ID elem=id_int dyn=term_expr - { SetRuleDyn (r, fn, elem, dyn) } - | GET_CMD RULE_SPEC DYNAMICS r=id_int fn=ID elem=id_int - { GetRuleDyn (r, fn, elem) } - | SET_CMD RULE_SPEC ASSOC - r=id_int rhs_elem=id_int - lhs_elem=id_int - { SetRuleAssoc (r, rhs_elem, lhs_elem) } - | SET_CMD DYNAMICS t0=FLOAT t1=FLOAT { SetTime (t0, t1) } - | GET_CMD DYNAMICS { GetTime } - | GET_CMD RULE_SPEC ASSOC r=id_int rhs_elem=id_int - { GetRuleAssoc (r, rhs_elem) } - | SET_CMD RULE_SPEC EMB - r = id_int - rels = separated_list (COMMA, ID) - { SetRuleEmb (r, rels) } - | GET_CMD RULE_SPEC EMB r=id_int { GetRuleEmb r } - | GET_CMD RULE_SPEC COND r=id_int { GetRuleCond r } - | SET_CMD RULE_SPEC COND r=id_int - pre=formula_expr_err inv=formula_expr_err post=formula_expr_err - { SetRuleCond (r, pre, inv, post) } | error { raise (Lexer.Parsing_error "Syntax error in Server request.") } Modified: trunk/Toss/Arena/ArenaTest.ml =================================================================== --- trunk/Toss/Arena/ArenaTest.ml 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/Arena/ArenaTest.ml 2012-02-07 02:10:47 UTC (rev 1669) @@ -2,21 +2,21 @@ open OUnit -let req_of_str s = - ArenaParser.parse_request Lexer.lex (Lexing.from_string s) +(*let req_of_str s = + ArenaParser.parse_request Lexer.lex (Lexing.from_string s) *) let gs_of_str s = ArenaParser.parse_game_state Lexer.lex (Lexing.from_string s) -let apply_rule gs rname match_str = +(*let apply_rule gs rname match_str = let s = "SET RULE " ^ rname ^ " MODEL " ^ match_str ^ " 0.1" in snd (Arena.handle_request Arena.empty_state (req_of_str s)) +*) - let tests = "Arena" >::: [ "adding rule" >:: - (fun () -> - + (fun () -> assert true); +(* let rule_a = "[a, b | R (a, b) | ] -> [c, d | R (c, d) | ] with [c <- a, d <- b] inv true post true" in let s = "SET RULE rule_a " ^ rule_a in @@ -123,7 +123,7 @@ Arena.handle_request gs (req_of_str "GET STATE") in assert_equal ~msg:("Set "^fname) ~printer:(fun x->x) contents msg; - ); + ); *) ] let a = AuxIO.run_test_if_target "ArenaTest" tests Modified: trunk/Toss/GGP/TranslateGameTest.ml =================================================================== --- trunk/Toss/GGP/TranslateGameTest.ml 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/GGP/TranslateGameTest.ml 2012-02-07 02:10:47 UTC (rev 1669) @@ -79,8 +79,8 @@ let move = List.assoc own_plnum moves in assert_equal ~msg:"own incoming move" ~printer:(emb_str res) (norm_move (rname, emb)) (norm_move move); - let req = Arena.ApplyRuleInt (rname, emb, 0.1, []) in - let ((game,state), _) = Arena.handle_request res req in + let req = (rname, emb, 0.1, []) in + let ((game,state), _) = Arena.apply_rule_int res req in let res = game, {state with Arena.cur_loc = loc1} in let rname = loc1_rule_name in let emb = @@ -137,8 +137,8 @@ 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 gstate req in + let req = (r_name, mtch, 0.1, []) in + let (new_state_noloc, resp) = Arena.apply_rule_int gstate req in let new_loc = moves.(pos).Arena.next_loc in (fst new_state_noloc, {snd new_state_noloc with Arena.cur_loc = new_loc}) Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/Makefile 2012-02-07 02:10:47 UTC (rev 1669) @@ -41,9 +41,9 @@ # -------- MAIN OCAMLBUILD PART -------- # TODO: Hard-coded path to js_of_ocaml. -OCB_LFLAG=-lflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+sqlite3,-I,+js_of_ocaml,-I,+site-lib/oUnit,-I,+site-lib/sqlite3 -OCB_CFLAG=-cflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+sqlite3,-I,+js_of_ocaml,-I,+site-lib/oUnit,-I,+site-lib/sqlite3,-g -OCB_LIB=-libs str,nums,unix,oUnit,sqlite3 +OCB_LFLAG=-lflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+js_of_ocaml,-I,+site-lib/oUnit +OCB_CFLAG=-cflags -I,/usr/local/lib/ocaml/3.12.0/js_of_ocaml,-I,+oUnit,-I,+js_of_ocaml,-I,+site-lib/oUnit,-g +OCB_LIB=-libs str,nums,unix,oUnit OCB_LIBJS=-libs str,js_of_ocaml OCB_PP=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo js_of_ocaml/pa_js.cmo" OCB_PPJS=-pp "camlp4o -unsafe -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo -DJAVASCRIPT js_of_ocaml/pa_js.cmo" @@ -76,7 +76,7 @@ $(OCAMLBUILD) -Is $($(subst /,INC,$(dir $@))) $@ doc: caml_extensions/pa_let_try.cmo - $(OCAMLBUILD) -Is +oUnit,+sqlite3,$(.INC) Toss.docdir/index.html + $(OCAMLBUILD) -Is +oUnit,$(.INC) Toss.docdir/index.html make -C www code_doc_link Modified: trunk/Toss/README =================================================================== --- trunk/Toss/README 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/README 2012-02-07 02:10:47 UTC (rev 1669) @@ -9,7 +9,7 @@ -- Installing dependencies under Ubuntu Run the following in terminal: - sudo apt-get install menhir libounit-ocaml-dev libsqlite3-ocaml-dev libjs-of-ocaml-dev heirloom-mailx + sudo apt-get install menhir libounit-ocaml-dev libjs-of-ocaml-dev heirloom-mailx Finally to compile Toss just type make Deleted: trunk/Toss/Server/DB.ml =================================================================== --- trunk/Toss/Server/DB.ml 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/Server/DB.ml 2012-02-07 02:10:47 UTC (rev 1669) @@ -1,305 +0,0 @@ -(* Wrapper around Toss DB interface. We use sqlite for now, see below. - http://hg.ocaml.info/release/ocaml-sqlite3/file/0e2f7d2cbd12/sqlite3.mli -*) - -let debug_level = ref 0 - - -let tID = ref "toss_id_05174_" - -let dbFILE = ref - ( try (Unix.getenv "HOME") ^ "/.tossdb.sqlite" - with _ -> "/tossdb.sqlite" ) - -let tGAMES = ref ["Breakthrough"; "Checkers"; "Chess"; "Connect4"; - "Entanglement"; "Gomoku"; "Pawn-Whopping"; "Tic-Tac-Toe"; - "Concurrent-Tic-Tac-Toe"] - -let def_gdir = if Sys.file_exists "/usr/share/toss" then - "/usr/share/toss/games" else "./examples" - - -let tSALT = "toss##in$$some167S4lT_-" (* must be as in JavaScript! *) - - -(* ------- Toss DB Creation ------- *) - -let create_db dbfname games_path games = - let db = Sqlite3.db_open dbfname in - let exec s = ignore (Sqlite3.exec_not_null_no_headers db (fun _ -> ()) s) in - exec ("create table users(id string primary key," ^ - " name string, surname string, email string, passwd string)"); - exec ("create table cur_states(playid int primary key," ^ - " game string, player1 string, player2 string," ^ - " move int, toss string, loc string, info string, svg string)"); - exec ("create table old_states(playid int," ^ - " game string, player1 string, player2 string," ^ - " move int, toss string, loc string, info string, svg string)"); - exec ("create table games(game string primary key, toss string)"); - exec ("create table lock(tid int primary key, locked bool)"); - exec ("create table friends(id string, fid string)"); - exec ("insert into lock(tid, locked) values ('" ^ !tID ^ "', 'false')"); - exec ("insert into users(id, name, surname, email, passwd) values " ^ - "('computer', 'Computer', 'tPlay', 'co...@tp...', 'xxx')"); - let insert_game g = - let f = open_in (games_path ^ "/" ^ g ^ ".toss") in - let toss = AuxIO.input_file f in - close_in f; - exec ("insert into games(game, toss) values ('" ^ g ^ "','" ^ toss ^ "')"); - print_endline ("Added " ^ g) in - List.iter insert_game games; - ignore (Sqlite3.db_close db); - Unix.chmod dbfname 0o777 - - -let reload_games dbfname games_path games = - let db = Sqlite3.db_open dbfname in - let exec s = ignore (Sqlite3.exec_not_null_no_headers db (fun _ -> ()) s) in - exec "delete from games"; - print_endline "Deleted old games"; - let reload_game g = - let f = open_in (games_path ^ "/" ^ g ^ ".toss") in - let toss = AuxIO.input_file f in - close_in f; - exec ("insert into games(game, toss) values ('" ^ g ^ "','" ^ toss ^ "')"); - print_endline ("Reloading games: added " ^ g) in - List.iter reload_game games; - ignore (Sqlite3.db_close db) - - -let renew_db ~games_dir = - let nolastslash s = - let l = String.length s in - if s.[l-1] = '/' then String.sub s 0 (l-1) else s in - let gdir = nolastslash games_dir in - if Sys.file_exists !dbFILE then ( - print_endline ("Reloading games into Toss DB (" ^ !dbFILE ^ ")"); - reload_games !dbFILE gdir !tGAMES; - print_endline "Games reloaded"; - ) else ( - print_endline ("Creating empty Toss DB (" ^ !dbFILE ^ ")"); - create_db !dbFILE gdir !tGAMES; - print_endline "Created tossdb.sqlite"; - ) - - - -(* ---------- DB functions wrapper ------------- *) - -exception DBError of string - -let print_row r = Array.iter (fun s -> print_string (s ^ " | ")) r - -let print_rows rs = List.iter (fun r -> print_row r; print_endline "") rs - -let rec apply_cmd ?(retried=0) dbfile select cmd = - let (rows, wh_s) = (ref [], if select = "" then "" else " where " ^ select) in - let select_s = cmd ^ wh_s in - if not (Sys.file_exists !dbFILE) then create_db !dbFILE def_gdir !tGAMES; - let db = Sqlite3.db_open dbfile in - let add_row r = rows := r :: !rows in - let res = Sqlite3.exec_not_null_no_headers db add_row select_s in - let nbr_changed = Sqlite3.changes db in - ignore (Sqlite3.db_close db); - match res with - | Sqlite3.Rc.OK -> (List.rev !rows, nbr_changed) - | Sqlite3.Rc.BUSY | Sqlite3.Rc.LOCKED when retried < 20 -> - if !debug_level > 0 then - Printf.printf "DB busy or locked, retrying %i\n%!" retried; - ignore (Unix.select [] [] [] 0.1); - apply_cmd ~retried:(retried+1) dbfile select cmd - | x -> raise (DBError ((Sqlite3.Rc.to_string x) ^ ":" ^ select_s)) - -let get_table dbfile ?(select="") tbl = - fst (apply_cmd dbfile select ("select * from " ^ tbl)) - -let max_in_table ~field dbfile ?(select="") tbl = - let (rows, _) = - apply_cmd dbfile select ("select max(" ^ field ^ ") from " ^ tbl) in - int_of_string (List.hd rows).(0) - -let insert_table dbfile tbl schm vals = - let vals_s = String.concat ", " (List.map (fun s -> "'" ^ s ^ "'") vals) in - let ins_s = Printf.sprintf "insert into %s(%s) values (%s)" tbl schm vals_s in - ignore (apply_cmd dbfile "" ins_s) - -let update_table dbfile ?(select="") set_s tbl = - snd (apply_cmd dbfile select ("update " ^ tbl ^ " set " ^ set_s)) - - - - - -(* SHA256. Thanks to mbac32768 for providing this implementation online. *) -let sha256_hash s = - let pack64 x = - let b = Buffer.create 8 in - for i = 0 to 7 do - let shft = (7-i)*8 in - Buffer.add_char b (char_of_int (Int64.to_int (Int64.logand (Int64.shift_right x shft) 0xFFL))); - done; - b in - - let pack x n = - if (n mod 8) = 0 then - let n' = n/8 in - let b = Buffer.create n' in - for i = 0 to n'-1 do - let shft = ((n'-1)-i)*8 in - Buffer.add_char b (char_of_int (Int32.to_int (Int32.logand (Int32.shift_right x shft) 0xFFl))); - done; - b - else - raise (Invalid_argument ("pack: " ^ (string_of_int n) ^ " is not a multiple of 8")) in - - let pack32 x = pack x 32 in - - let k = [| - 0x428a2f98l; 0x71374491l; 0xb5c0fbcfl; 0xe9b5dba5l; - 0x3956c25bl; 0x59f111f1l; 0x923f82a4l; 0xab1c5ed5l; - 0xd807aa98l; 0x12835b01l; 0x243185bel; 0x550c7dc3l; - 0x72be5d74l; 0x80deb1fel; 0x9bdc06a7l; 0xc19bf174l; - 0xe49b69c1l; 0xefbe4786l; 0x0fc19dc6l; 0x240ca1ccl; - 0x2de92c6fl; 0x4a7484aal; 0x5cb0a9dcl; 0x76f988dal; - 0x983e5152l; 0xa831c66dl; 0xb00327c8l; 0xbf597fc7l; - 0xc6e00bf3l; 0xd5a79147l; 0x06ca6351l; 0x14292967l; - 0x27b70a85l; 0x2e1b2138l; 0x4d2c6dfcl; 0x53380d13l; - 0x650a7354l; 0x766a0abbl; 0x81c2c92el; 0x92722c85l; - 0xa2bfe8a1l; 0xa81a664bl; 0xc24b8b70l; 0xc76c51a3l; - 0xd192e819l; 0xd6990624l; 0xf40e3585l; 0x106aa070l; - 0x19a4c116l; 0x1e376c08l; 0x2748774cl; 0x34b0bcb5l; - 0x391c0cb3l; 0x4ed8aa4al; 0x5b9cca4fl; 0x682e6ff3l; - 0x748f82eel; 0x78a5636fl; 0x84c87814l; 0x8cc70208l; - 0x90befffal; 0xa4506cebl; 0xbef9a3f7l; 0xc67178f2l |] in - let add_int32 x y = Int32.add x y in - let left_int32 x n = Int32.shift_left x n in - let right_int32 x n = Int32.shift_right_logical x n in - let or_int32 x y = Int32.logor x y in - let xor_int32 x y = Int32.logxor x y in - let and_int32 x y = Int32.logand x y in - let not_int32 x = Int32.lognot x in - - let rotate x n = (or_int32 (right_int32 x n) (left_int32 x (32 - n))) in - let shift x n = right_int32 x n in - let ch x y z = xor_int32 (and_int32 x y) (and_int32 (not_int32 x) z) in - let maj x y z = (xor_int32 (and_int32 x y) (xor_int32 (and_int32 x z) (and_int32 y z))) in - let sum0 x = (xor_int32 (rotate x 2) (xor_int32 (rotate x 13) (rotate x 22))) in - let sum1 x = (xor_int32 (rotate x 6) (xor_int32 (rotate x 11) (rotate x 25))) in - let rh00 x = (xor_int32 (rotate x 7) (xor_int32 (rotate x 18) (shift x 3))) in - let rh01 x = (xor_int32 (rotate x 17) (xor_int32 (rotate x 19) (shift x 10))) in - - let as_bytes bits = - match (bits mod 8) with - | 0 -> (bits / 8) - | _ -> failwith "as_bytes: bits must be multiple of 8" - in - let as_bits bytes = bytes * 8 in - let sha = [| - 0x6a09e667l; - 0xbb67ae85l; - 0x3c6ef372l; - 0xa54ff53al; - 0x510e527fl; - 0x9b05688cl; - 0x1f83d9abl; - 0x5be0cd19l - |] - in - let message = Buffer.create (as_bytes 512) in (* smallest possible buffer is at least 512 bits *) - begin - Buffer.add_string message s; - let original_length = as_bits (Buffer.length message) in - Buffer.add_char message '\x80'; (* append '1' bit *) - let pad_start = as_bits (Buffer.length message) in - let pad_blocks = if (original_length mod 512) < 448 then 1 else 2 in - let message_length = ((original_length / 512) + pad_blocks) * 512 in - begin (* appending k bits of 0 (where message_length-64 is our k) *) - for i = as_bytes pad_start to (as_bytes (message_length - (as_bytes 64)))-8 do - Buffer.add_char message '\x00' - done; - Buffer.add_buffer message (pack64 (Int64.of_int original_length)) - end - end; - let rec process_block i blocks = - let array_of_block i = - let boff = i*(as_bytes 512) in - let to_int32 x = (Int32.of_int (int_of_char x)) in - let w = Array.make (as_bytes 512) 0l in - begin - for t = 0 to 15 do - w.(t) <- (or_int32 (left_int32 (to_int32 (Buffer.nth message (boff + (t*4 )))) 24) - (or_int32 (left_int32 (to_int32 (Buffer.nth message (boff + (t*4+1)))) 16) - (or_int32 (left_int32 (to_int32 (Buffer.nth message (boff + (t*4+2)))) 8) - (to_int32 (Buffer.nth message (boff + (t*4+3)))) ))); - done; - for t = 16 to 63 do - w.(t) <- add_int32 (add_int32 (rh01 w.(t-2)) w.(t-7)) (add_int32 (rh00 w.(t-15)) w.(t-16)) - done; - w - end - in - if i = blocks then - let sha256 = Buffer.create (as_bytes 256) in - let rec pack_sha256 i = - match i with - | 8 -> Buffer.contents sha256 - | _ -> - begin - Buffer.add_buffer sha256 (pack32 sha.(i)); - pack_sha256 (i+1) - end - in pack_sha256 0 - else - begin - let w = array_of_block i in - let tem = [| 0l; 0l |] in - begin - let a = ref sha.(0) in - let b = ref sha.(1) in - let c = ref sha.(2) in - let d = ref sha.(3) in - let e = ref sha.(4) in - let f = ref sha.(5) in - let g = ref sha.(6) in - let h = ref sha.(7) in - for t = 0 to 63 do - begin - tem.(0) <- add_int32 (add_int32 !h (sum1 !e)) (add_int32 (ch !e !f !g) (add_int32 k.(t) w.(t))); - tem.(1) <- add_int32 (sum0 !a) (maj !a !b !c); - h := !g; - g := !f; - f := !e; - e := add_int32 !d tem.(0); - d := !c; - c := !b; - b := !a; - a := add_int32 tem.(0) tem.(1); - end - done; - sha.(0) <- add_int32 sha.(0) !a; - sha.(1) <- add_int32 sha.(1) !b; - sha.(2) <- add_int32 sha.(2) !c; - sha.(3) <- add_int32 sha.(3) !d; - sha.(4) <- add_int32 sha.(4) !e; - sha.(5) <- add_int32 sha.(5) !f; - sha.(6) <- add_int32 sha.(6) !g; - sha.(7) <- add_int32 sha.(7) !h; - - (* good faith attempt to clear memory *) - let z = Int32.of_int 0 in - for i = 0 to 63 do w.(i) <- z done; - tem.(0) <- z; tem.(1) <- z; - a := z; b := z; c := z; d := z; e := z; f := z; g := z; h := z; - end; - process_block (i+1) blocks - end - in - let hexdigits s = - let rec hexdigits_inner hx i = - match i with - | 32 -> hx - | _ -> hexdigits_inner (hx ^ (Printf.sprintf "%02x" (int_of_char s.[i]))) (i+1) - in hexdigits_inner "" 0 in - hexdigits (process_block 0 ((Buffer.length message) / (as_bytes 512))) - -let coded_password s = sha256_hash (tSALT ^ s) Deleted: trunk/Toss/Server/DB.mli =================================================================== --- trunk/Toss/Server/DB.mli 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/Server/DB.mli 2012-02-07 02:10:47 UTC (rev 1669) @@ -1,28 +0,0 @@ -(** Interface to the Toss database through Sqlite. *) - - -exception DBError of string - -val debug_level : int ref - -val tID : string ref -val dbFILE : string ref -val tGAMES : string list ref - -val print_row : string array -> unit - -val print_rows : string array list -> unit - -val get_table : string -> ?select : string -> string -> string array list - -val max_in_table : field:string -> string -> ?select : string -> string -> int - -val insert_table : string -> string -> string -> string list -> unit - -val update_table : string -> ?select : string -> string -> string -> int - -val renew_db : games_dir : string -> unit - -val coded_password : string -> string - -val sha256_hash : string -> string Modified: trunk/Toss/Server/ReqHandler.ml =================================================================== --- trunk/Toss/Server/ReqHandler.ml 2012-02-06 13:55:11 UTC (rev 1668) +++ trunk/Toss/Server/ReqHandler.ml 2012-02-07 02:10:47 UTC (rev 1669) @@ -30,8 +30,6 @@ if List.length locs <> 1 then failwith "too many moves" else if locs = [] then a.(0) else List.hd locs -let possibly_modifies_game = Arena.can_modify_game - let compute_heuristic advr (game, state) = let pat_arr = Array.of_list game.Arena.patterns in let pl_heur l = @@ -51,7 +49,6 @@ exception Found of int - (* Players are indexed from 1 in graph (0 is Environment) *) let apply_rewrite (game,state as gstate) (player, (r_name, mtch)) = if r_name <> "" then ( @@ -90,8 +87,8 @@ 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 gstate req in + let (new_state_noloc, resp) = + Arena.apply_rule_int gstate (r_name, mtch, 0.1, []) in let new_loc = moves.(pos).Arena.next_loc in (fst new_state_noloc, {snd new_state_noloc with Arena.cur_loc = new_loc}) @@ -117,15 +114,6 @@ "ERR: suggest called but no possible moves!" ) - | Aux.Left(Arena.ApplyRule (r_name, mtch, t, p) as req) -> - let (new_state, resp) = Arena.handle_request state req in - (g_heur, game_modified, new_state, gdl_transl, playclock), resp - - | Aux.Left req -> - let (new_state, resp) = Arena.handle_request state req in - (g_heur, game_modified || possibly_modifies_game req, - new_state, gdl_transl, playclock), resp - | Aux.Right (GDL.Start (_, player, game_descr, startcl, playcl)) -> Random.self_init (); let old_force_competitive = !Heuristic.force_competitive in @@ -185,8 +173,6 @@ (* ------------ Old Python Wrapper Client Functions ------------ *) -let client = ref init_state - let lstr ?(sep=",") l = "[" ^ (String.concat sep l) ^ "]" let split_list ?(bound=None) pat s = @@ -204,623 +190,15 @@ let strip_ws = Aux.strip_spaces -let strip_all patl s = - let once str = List.fold_left (fun s p -> strip p s) (strip_ws str) patl in - let rec fp str = let ns = once str in if ns = str then ns else fp ns in fp s -let strip_ws_lst s = strip_all ["]"; "["] s - -let str_find pat s = - try Str.search_forward (Str.regexp_string pat) s 0 with Not_found -> -1 - -let str_replace pat repl s = Str.global_replace (Str.regexp_string pat) repl s - -let client_msg s = - let (new_st, res) = req_handle !client - (Aux.Left (ArenaParser.parse_request Lexer.lex (Lexing.from_string s))) in - client := new_st; - strip_ws res - -let client_get_model () = client_msg "GET MODEL" - -let client_set_model model_s = ignore (client_msg ("SET MODEL " ^ model_s)) - -let client_game_states = Hashtbl.create 7 - -let client_set_game game = - let client_set_state state_s = ignore (client_msg ("SET STATE "^ state_s)) in - let dbtable select tbl = DB.get_table !DB.dbFILE ~select tbl in - try - let game_cl = Hashtbl.find client_game_states game in - client := game_cl - with Not_found -> - let toss = (List.hd (dbtable ("game='" ^ game ^ "'") "games")).(1) in - ignore (client_set_state ("#db#" ^ toss)); - Hashtbl.add client_game_states game !client - -let client_get_cur_loc () = - strip_ws (split "/" (client_msg "GET LOC")).(0) - -let client_set_cur_loc i = ignore (client_msg ("SET LOC " ^ i)) - -let client_get_payoffs () = client_msg "GET PAYOFF" - -let client_get_loc_moves i = - let msg = client_msg ("GET LOC MOVES " ^ i) in - if String.length msg < 1 then [] else - let moves = split_list ";" msg in - let make_itvl v = - let sep = split ":" v in - let d = split "--" sep.(1) in - (strip_ws sep.(0), strip_ws d.(0), strip_ws d.(1)) in - let make_move m = - let gs = split "->" m in - let lab_all = split_list "," gs.(0) in - let (lab_pl, lab) = (List.hd lab_all, List.tl lab_all) in - (strip_ws lab_pl, strip_ws (List.hd lab), - List.map (fun v -> make_itvl (strip_ws v)) (List.tl lab), - strip_ws gs.(1)) in - List.map (fun m -> make_move (strip_ws_lst m)) moves - -let client_query rule_nm = - let msg = client_msg ("GET RULE " ^ rule_nm ^ " MODEL") in - if str_find "->" msg < 0 then [] else - let make_match m_str = - let app_p_assoc dict p = - let p_str = split "->" p in - (strip_ws p_str.(0), strip_ws p_str.(1)) :: dict in - List.fold_left app_p_assoc [] (split_list "," m_str) in - List.map (fun m -> make_match (strip_ws m)) (split_list ";" msg) - -let client_apply_rule rule_nm mtch_s time params = - (*let mt_s = String.concat ", " (List.map (fun (l,r)-> l ^": "^ r) mtch) in*) - let param_s = String.concat ", " (List.map (fun (p,v)-> p ^": "^ v) params) in - let m = client_msg ("SET RULE " ^ rule_nm ^ " MODEL " ^ mtch_s ^ " " ^ - time ^ " " ^ param_s) in - let add_shift shifts seq = - if Array.length seq > 2 then - ((seq.(0), seq.(1)), Array.sub seq 2 ((Array.length seq) - 2)) :: shifts - else shifts in - let add_shift_s sh s = add_shift sh (Array.map strip_ws (split "," s)) in - List.fold_left add_shift_s [] (List.map strip_ws (split_list ";" m)) - -let client_move_str (pl, m, r, e) = - let mstr m = String.concat ", " (List.map (fun (a, b) -> a ^ ": " ^ b) m) in - pl ^ ",({" ^ mstr m ^ "}, " ^ r ^ ", " ^ e ^ ")" - -let client_cur_moves () = - let append_move moves (pl, r, _, endp) = (* currently we ignore itvls *) - (List.map (fun m -> (pl, m, r, endp)) (client_query r)) @ moves in - let cur_loc = client_get_cur_loc () in - let moves = List.fold_left append_move [] (client_get_loc_moves cur_loc) in - String.concat "; " (List.map client_move_str moves) - -let client_make_move m r endp = - let _ = client_apply_rule r m "1.0" [] in - client_set_cur_loc endp - -let client_get_data data_id = - let m = client_msg ("GET DATA " ^ data_id) in - if String.length m > 2 && String.sub m 0 3 = "ERR" then "none" el... [truncated message content] |
From: <luk...@us...> - 2012-02-06 13:55:26
|
Revision: 1668 http://toss.svn.sourceforge.net/toss/?rev=1668&view=rev Author: lukaszkaiser Date: 2012-02-06 13:55:11 +0000 (Mon, 06 Feb 2012) Log Message: ----------- Orders in web, pictures. Modified Paths: -------------- trunk/Toss/WebClient/index.html trunk/Toss/WebClient/local.html trunk/Toss/www/contact.xml trunk/Toss/www/develop.xml Added Paths: ----------- trunk/Toss/WebClient/img/ Removed Paths: ------------- trunk/Toss/WebClient/pics/ trunk/Toss/www/img/Breakthrough.ppm trunk/Toss/www/img/add_rule.png trunk/Toss/www/img/breakthrough_screen.png trunk/Toss/www/img/breakthrough_screen_small.png trunk/Toss/www/img/draw.png trunk/Toss/www/img/erase.png trunk/Toss/www/img/gomoku_screen.png trunk/Toss/www/img/gomoku_screen_small.png trunk/Toss/www/img/match.png trunk/Toss/www/img/move.png trunk/Toss/www/img/redraw.png trunk/Toss/www/img/rewrite.png trunk/Toss/www/img/run_hint.png trunk/Toss/www/img/run_toss.png trunk/Toss/www/img/tic_tac_toe_screen.png trunk/Toss/www/img/tic_tac_toe_screen_small.png Modified: trunk/Toss/WebClient/index.html =================================================================== --- trunk/Toss/WebClient/index.html 2012-02-06 02:18:40 UTC (rev 1667) +++ trunk/Toss/WebClient/index.html 2012-02-06 13:55:11 UTC (rev 1668) @@ -93,7 +93,7 @@ <p id="welcome-top">Enjoy the best games on <span class="logo-in">tPlay</span> for free <span style="float: right;"> <a href="http://itunes.apple.com/us/app/tplay/id438620686" - ><img style="height: 24px;" src="pics/appstore-small.png" /></a> + ><img style="height: 24px;" src="img/appstore-small.png" /></a> <g:plusone></g:plusone> </span> </p> @@ -106,21 +106,21 @@ <p style="width:100%; text-align: justify;"> <button onclick="new_play_guest('Chess')" class="game-picbt" title="Play Chess"> - <img style="max-width:95%" src="pics/Chess.png" alt="Chess Board" /> + <img style="max-width:95%" src="img/Chess.png" alt="Chess Board" /> <span id="pdescChess" class="game-picspan"> <span class="game-pictxt">Chess</span> </span> </button> <button onclick="new_play_guest('Connect4')" class="game-picbt" class="boldobt" title="Play Connect4"> - <img style="max-width:95%" src="pics/Connect4.png" alt="Connect4 Board" /> + <img style="max-width:95%" src="img/Connect4.png" alt="Connect4 Board" /> <span id="pdescConnect4" class="game-picspan"> <span class="game-pictxt">Connect4</span> </span> </button> <button onclick="new_play_guest('Pawn-Whopping')" class="game-picbt" class="boldobt" title="Play Pawn-Whopping"> - <img style="max-width:95%" src="pics/Pawn-Whopping.png" + <img style="max-width:95%" src="img/Pawn-Whopping.png" alt="Pawn-Whopping Board" /> <span id="pdescPawn-Whopping" class="game-picspan"> <span class="game-pictxt">Pawn-Whopping</span> @@ -131,7 +131,7 @@ <p style="width:100%; text-align: justify"> <button onclick="new_play_guest('Breakthrough')" class="game-picbt" class="boldobt" title="Play Breakthrough"> - <img style="max-width:95%" src="pics/Breakthrough.png" + <img style="max-width:95%" src="img/Breakthrough.png" alt="Breakthrough Board" /> <span id="pdescBreakthrough" class="game-picspan"> <span class="game-pictxt">Breakthrough</span> @@ -139,14 +139,14 @@ </button> <button onclick="new_play_guest('Checkers')" class="game-picbt" class="boldobt" title="Play Checkers"> - <img style="max-width:95%" src="pics/Checkers.png" alt="Checkers Board" /> + <img style="max-width:95%" src="img/Checkers.png" alt="Checkers Board" /> <span id="pdescCheckers" class="game-picspan"> <span class="game-pictxt">Checkers</span> </span> </button> <button onclick="new_play_guest('Gomoku')" class="game-picbt" class="boldobt" title="Play Gomoku"> - <img style="max-width:95%" src="pics/Gomoku.png" alt="Gomoku Board" /> + <img style="max-width:95%" src="img/Gomoku.png" alt="Gomoku Board" /> <span id="pdescGomoku" class="game-picspan"> <span class="game-pictxt">Gomoku</span> </span> Modified: trunk/Toss/WebClient/local.html =================================================================== --- trunk/Toss/WebClient/local.html 2012-02-06 02:18:40 UTC (rev 1667) +++ trunk/Toss/WebClient/local.html 2012-02-06 13:55:11 UTC (rev 1668) @@ -40,7 +40,7 @@ <p style="width:100%; text-align: justify;"> <button onclick="new_play_local('Pawn-Whopping')" class="game-picbt" class="boldobt" title="Play Pawn-Whopping"> - <img style="max-width:95%" src="pics/Pawn-Whopping.png" + <img style="max-width:95%" src="img/Pawn-Whopping.png" alt="Pawn-Whopping Board" /> <span id="pdescPawn-Whopping" class="game-picspan"> <span class="game-pictxt">Pawn-Whopping</span> @@ -48,14 +48,14 @@ </button> <button onclick="new_play_local('Connect4')" class="game-picbt" class="boldobt" title="Play Connect4"> - <img style="max-width:95%" src="pics/Connect4.png" alt="Connect4 Board" /> + <img style="max-width:95%" src="img/Connect4.png" alt="Connect4 Board" /> <span id="pdescConnect4" class="game-picspan"> <span class="game-pictxt">Connect4</span> </span> </button> <button onclick="new_play_local('Breakthrough')" class="game-picbt" class="boldobt" title="Play Breakthrough"> - <img style="max-width:95%" src="pics/Breakthrough.png" + <img style="max-width:95%" src="img/Breakthrough.png" alt="Breakthrough Board" /> <span id="pdescBreakthrough" class="game-picspan"> <span class="game-pictxt">Breakthrough</span> @@ -66,7 +66,7 @@ <p style="width:100%; text-align: justify"> <button onclick="new_play_local('Tic-Tac-Toe')" class="game-picbt" class="boldobt" title="Play Tic-Tac-Toe"> - <img style="max-width:95%" src="pics/Tic-Tac-Toe.png" + <img style="max-width:95%" src="img/Tic-Tac-Toe.png" alt="Tic-Tac-Toe Board" /> <span id="pdescTic-Tac-Toe" class="game-picspan"> <span class="game-pictxt">Tic-Tac-Toe</span> @@ -74,14 +74,14 @@ </button> <button onclick="new_play_local('Checkers')" class="game-picbt" class="boldobt" title="Play Checkers"> - <img style="max-width:95%" src="pics/Checkers.png" alt="Checkers Board" /> + <img style="max-width:95%" src="img/Checkers.png" alt="Checkers Board" /> <span id="pdescCheckers" class="game-picspan"> <span class="game-pictxt">Checkers</span> </span> </button> <button onclick="new_play_local('Gomoku')" class="game-picbt" class="boldobt" title="Play Gomoku"> - <img style="max-width:95%" src="pics/Gomoku.png" alt="Gomoku Board" /> + <img style="max-width:95%" src="img/Gomoku.png" alt="Gomoku Board" /> <span id="pdescGomoku" class="game-picspan"> <span class="game-pictxt">Gomoku</span> </span> Modified: trunk/Toss/www/contact.xml =================================================================== --- trunk/Toss/www/contact.xml 2012-02-06 02:18:40 UTC (rev 1667) +++ trunk/Toss/www/contact.xml 2012-02-06 13:55:11 UTC (rev 1668) @@ -279,15 +279,16 @@ Many people contributed, here we name just a few. Current leaders:</par> <itemize> <item>Łukasz Kaiser (<mailto address="luk...@gm..."/>)</item> - <item>Tobias Ganzow</item> <item>Łukasz Stafiniak</item> - <item>Michał Wójcik</item> </itemize> <par>Friends who helped us a lot with discussion and code.</par> <itemize> <item>Dietmar Berwanger</item> <item>Matko Botincan</item> <item>Diana Fischer</item> + <item>Tobias Ganzow</item> + <item>Simon Leßenich</item> + <item>Michał Wójcik</item> </itemize> <par>Yet another group of people, who worked on the oldest version of Toss (around 2004), was lead by:</par> Modified: trunk/Toss/www/develop.xml =================================================================== --- trunk/Toss/www/develop.xml 2012-02-06 02:18:40 UTC (rev 1667) +++ trunk/Toss/www/develop.xml 2012-02-06 13:55:11 UTC (rev 1668) @@ -53,14 +53,14 @@ kompilieren möchte, braucht man Pakete, die mit folgender Zeile installiert werden können.<br/> <em>sudo apt-get install menhir libounit-ocaml-dev libsqlite3-ocaml-dev - heirloom-mailx</em> + libjs-of-ocaml-dev heirloom-mailx</em> </item> <item>Um Toss unter <a href="http://www.apple.com/macosx/">MacOSX</a> zu kompilieren, empfehlen wir <a href="http://www.macports.org/">MacPorts</a> (Xcode nötig). Mit MacPorts muss man folgendes installieren.<br/> - <em>sudo port install ocaml caml-menhir caml-ounit caml-sqlite3 + <em>sudo port install ocaml ocaml-menhir ocaml-ounit ocaml-sqlite3 mailx</em> </item> <item>Folgendes nutzt man, um die @@ -84,13 +84,13 @@ poniższe polecenie zainstaluje pakiety niezbędne do kompilacji Tossa.<br/> <em>sudo apt-get install menhir libounit-ocaml-dev libsqlite3-ocaml-dev - heirloom-mailx</em> + libjs-of-ocaml-dev heirloom-mailx</em> </item> <item>Pod <a href="http://www.apple.com/macosx/">MacOSX</a> polecamy zainstalować <a href="http://www.macports.org/">MacPorts</a> (wymaga Xcode) i wywołać poniższe polecenie.<br/> - <em>sudo port install ocaml caml-menhir caml-ounit caml-sqlite3 + <em>sudo port install ocaml ocaml-menhir ocaml-ounit ocaml-sqlite3 mailx</em> </item> <item>Poniższe polecenie ściągnie @@ -113,12 +113,12 @@ <a href="http://www.ubuntu.com/">Ubuntu</a>, voici une commande avec une liste des paquets à installer.<br/> <em>sudo apt-get install menhir libounit-ocaml-dev libsqlite3-ocaml-dev - heirloom-mailx</em> + libjs-of-ocaml-dev heirloom-mailx</em> </item> <item>Si vous souhaitez développer Toss sur <a href="http://www.apple.com/macosx/">MacOSX</a>, installe <a href="http://www.macports.org/">MacPorts</a> (et Xcode) et faire<br/> - <em>sudo port install ocaml caml-menhir caml-ounit caml-sqlite3 + <em>sudo port install ocaml ocaml-menhir ocaml-ounit ocaml-sqlite3 mailx</em> </item> <item>Cette commande checkout du Deleted: trunk/Toss/www/img/Breakthrough.ppm =================================================================== --- trunk/Toss/www/img/Breakthrough.ppm 2012-02-06 02:18:40 UTC (rev 1667) +++ trunk/Toss/www/img/Breakthrough.ppm 2012-02-06 13:55:11 UTC (rev 1668) @@ -1,120003 +0,0 @@ -P3 -200 200 -255 -0 -0 -0 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -43 -0 -21 -47 -0 -19 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -44 -0 -18 -49 -0 -12 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -40 -0 -13 -41 -0 -16 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -41 -0 -20 -41 -0 -20 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -41 -0 -16 -40 -0 -13 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -49 -0 -12 -44 -0 -18 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -47 -0 -19 -43 -0 -21 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -45 -0 -15 -0 -0 -0 -26 -0 -26 -38 -3 -20 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -40 -6 -21 -43 -8 -24 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -52 -17 -30 -44 -9 -24 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -9 -25 -39 -4 -21 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -40 -5 -21 -41 -7 -22 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -48 -13 -27 -45 -10 -25 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -43 -8 -23 -40 -6 -22 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -49 -14 -27 -44 -8 -23 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -45 -11 -26 -38 -3 -20 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -207 -179 -137 -131 -99 -84 -71 -36 -43 -57 -22 -33 -63 -28 -37 -88 -53 -55 -162 -131 -105 -238 -210 -159 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -249 -222 -166 -177 -147 -116 -100 -65 -62 -66 -29 -39 -57 -22 -33 -67 -32 -40 -113 -80 -71 -189 -160 -125 -253 -226 -169 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -228 -199 -152 -151 -120 -98 -81 -45 -49 -60 -26 -36 -59 -24 -34 -77 -42 -46 -143 -112 -93 -221 -192 -146 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -198 -169 -130 -120 -88 -77 -69 -33 -41 -57 -22 -33 -64 -30 -39 -94 -59 -58 -170 -140 -111 -245 -217 -163 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -244 -216 -162 -170 -140 -111 -93 -58 -58 -64 -29 -38 -57 -22 -33 -69 -33 -41 -122 -90 -79 -199 -170 -131 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -220 -191 -146 -142 -111 -92 -77 -42 -46 -58 -23 -34 -60 -26 -36 -81 -45 -49 -151 -120 -98 -229 -200 -151 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -253 -226 -169 -189 -159 -124 -112 -79 -70 -67 -32 -40 -57 -22 -33 -66 -29 -39 -100 -67 -63 -178 -148 -116 -249 -222 -166 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -238 -210 -159 -161 -130 -106 -87 -52 -54 -63 -28 -37 -57 -22 -33 -71 -36 -43 -131 -99 -84 -208 -180 -137 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -227 -198 -151 -92 -58 -57 -49 -13 -27 -52 -8 -30 -56 -7 -33 -60 -7 -36 -59 -7 -36 -54 -6 -32 -52 -11 -30 -48 -13 -27 -152 -120 -98 -253 -226 -169 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -182 -152 -120 -56 -21 -33 -52 -13 -31 -53 -6 -31 -58 -7 -34 -60 -7 -37 -57 -7 -35 -52 -6 -31 -52 -13 -29 -69 -34 -41 -205 -176 -136 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -247 -220 -165 -127 -95 -80 -47 -11 -26 -53 -10 -30 -56 -6 -33 -59 -8 -35 -59 -7 -36 -56 -7 -33 -52 -9 -30 -48 -12 -26 -114 -80 -72 -241 -214 -160 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -216 -188 -143 -78 -44 -48 -50 -14 -29 -52 -7 -30 -58 -7 -34 -61 -7 -36 -59 -7 -35 -53 -6 -31 -53 -13 -30 -51 -16 -29 -169 -138 -110 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -166 -135 -108 -51 -16 -29 -53 -12 -30 -54 -6 -32 -59 -7 -35 -61 -7 -36 -58 -7 -34 -51 -7 -30 -50 -14 -29 -80 -46 -49 -218 -190 -144 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -241 -213 -160 -111 -79 -71 -47 -12 -26 -51 -9 -30 -56 -7 -33 -59 -7 -36 -60 -8 -35 -55 -6 -33 -53 -10 -30 -47 -11 -26 -128 -96 -82 -248 -221 -166 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -203 -174 -134 -67 -32 -40 -51 -13 -29 -52 -6 -30 -58 -7 -35 -60 -7 -37 -58 -7 -34 -52 -6 -31 -52 -13 -30 -57 -22 -33 -185 -156 -121 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -253 -226 -169 -149 -118 -96 -48 -13 -27 -52 -11 -30 -54 -6 -32 -59 -7 -36 -60 -7 -36 -56 -7 -33 -52 -8 -30 -48 -12 -28 -94 -60 -58 -229 -200 -151 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -207 -179 -137 -52 -16 -29 -54 -8 -32 -64 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -60 -7 -37 -51 -13 -30 -99 -66 -63 -249 -222 -166 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -140 -108 -90 -48 -12 -27 -58 -7 -35 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -6 -33 -46 -11 -26 -173 -142 -112 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -236 -208 -157 -74 -40 -46 -53 -12 -31 -62 -7 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -38 -54 -11 -31 -64 -29 -38 -227 -198 -151 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -190 -161 -125 -47 -12 -27 -54 -7 -32 -63 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -59 -8 -36 -49 -13 -28 -119 -87 -76 -253 -226 -169 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -253 -226 -169 -118 -85 -75 -50 -13 -28 -60 -8 -35 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -55 -7 -32 -48 -13 -27 -193 -164 -127 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -226 -198 -150 -62 -28 -37 -54 -11 -31 -63 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -7 -38 -53 -12 -31 -76 -41 -46 -237 -209 -158 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -171 -140 -112 -46 -11 -26 -55 -6 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -58 -7 -35 -48 -12 -27 -143 -111 -92 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -248 -221 -166 -97 -63 -61 -52 -13 -30 -61 -7 -37 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -38 -55 -9 -32 -52 -16 -29 -208 -180 -137 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -225 -197 -150 -51 -15 -28 -56 -6 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -52 -12 -30 -113 -80 -72 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -105 -49 -13 -28 -62 -7 -37 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -59 -8 -36 -46 -11 -25 -195 -166 -128 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -249 -222 -166 -79 -45 -48 -53 -10 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -53 -8 -32 -66 -32 -40 -243 -215 -162 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -211 -183 -139 -46 -11 -26 -57 -7 -34 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -7 -38 -51 -12 -30 -138 -106 -89 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -134 -102 -87 -51 -13 -30 -62 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -58 -7 -34 -47 -12 -27 -213 -185 -141 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -241 -214 -160 -64 -30 -38 -54 -7 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -52 -11 -31 -83 -48 -50 -250 -223 -166 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -192 -163 -127 -47 -11 -25 -60 -8 -35 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -61 -7 -37 -49 -12 -27 -164 -133 -107 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -254 -227 -169 -109 -76 -70 -53 -12 -30 -63 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -6 -33 -52 -16 -29 -228 -199 -152 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -87 -53 -54 -53 -8 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -8 -38 -50 -14 -28 -189 -160 -125 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -227 -198 -151 -46 -11 -26 -60 -7 -36 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -57 -7 -34 -54 -20 -31 -246 -219 -164 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -149 -118 -98 -53 -13 -31 -63 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -12 -31 -128 -96 -82 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -252 -225 -168 -66 -32 -40 -55 -7 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -61 -7 -37 -48 -12 -26 -212 -183 -140 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -207 -179 -137 -47 -12 -27 -62 -7 -37 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -7 -32 -70 -35 -42 -253 -226 -169 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -123 -91 -79 -53 -11 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -53 -13 -31 -153 -122 -100 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -245 -217 -163 -52 -17 -30 -57 -7 -34 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -59 -7 -36 -46 -11 -26 -229 -201 -152 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -185 -156 -121 -50 -14 -29 -63 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -8 -32 -91 -58 -57 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -204 -175 -135 -49 -13 -28 -63 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -6 -32 -72 -36 -43 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -118 -85 -75 -55 -11 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -14 -32 -158 -127 -103 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -246 -219 -164 -47 -12 -27 -60 -7 -36 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -7 -37 -46 -10 -26 -235 -207 -156 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -180 -150 -118 -53 -15 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -8 -32 -95 -61 -59 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -91 -57 -57 -55 -7 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -53 -15 -30 -183 -153 -120 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -233 -205 -155 -46 -10 -26 -61 -7 -37 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -59 -8 -35 -48 -13 -27 -248 -221 -166 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -155 -124 -101 -55 -14 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -11 -32 -122 -89 -78 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -68 -33 -40 -56 -7 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -50 -13 -28 -206 -178 -136 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -128 -95 -81 -53 -9 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -38 -45 -10 -25 -224 -196 -149 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -252 -224 -167 -48 -14 -28 -60 -7 -36 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -6 -33 -77 -42 -47 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -188 -158 -123 -54 -15 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -14 -32 -167 -137 -109 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -100 -66 -63 -54 -6 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -7 -37 -43 -8 -23 -242 -215 -161 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -241 -213 -160 -43 -8 -23 -62 -7 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -53 -6 -30 -102 -68 -64 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -165 -134 -107 -54 -14 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -15 -31 -190 -161 -125 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -74 -39 -45 -56 -7 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -60 -7 -36 -50 -15 -28 -252 -225 -168 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -222 -193 -147 -46 -10 -25 -63 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -52 -9 -31 -130 -98 -83 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -76 -41 -47 -57 -7 -34 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -16 -33 -178 -149 -117 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -224 -195 -148 -48 -12 -27 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -8 -38 -41 -6 -23 -253 -226 -169 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -142 -111 -91 -52 -8 -30 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -52 -6 -31 -115 -83 -74 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -55 -20 -32 -60 -7 -36 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -53 -16 -31 -201 -173 -133 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -200 -171 -132 -54 -16 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -59 -8 -35 -57 -22 -33 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -113 -80 -71 -53 -6 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -51 -8 -30 -144 -113 -93 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -253 -226 -169 -40 -5 -22 -63 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -47 -12 -26 -225 -197 -150 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -177 -147 -116 -56 -16 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -57 -7 -34 -78 -43 -47 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -23 -33 -59 -8 -35 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -11 -31 -157 -126 -102 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -203 -174 -134 -54 -16 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -43 -8 -24 -237 -209 -158 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -115 -83 -73 -53 -6 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -6 -33 -89 -55 -56 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -41 -6 -23 -62 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -16 -33 -180 -150 -118 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -179 -149 -118 -56 -16 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -7 -38 -42 -7 -22 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -88 -54 -55 -55 -6 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -52 -6 -31 -116 -84 -74 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -235 -207 -157 -43 -8 -24 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -16 -31 -204 -175 -135 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -156 -125 -102 -54 -11 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -60 -8 -35 -58 -23 -34 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -65 -29 -39 -58 -7 -35 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -14 -33 -166 -135 -108 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -212 -183 -140 -52 -15 -30 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -40 -4 -21 -246 -219 -164 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -127 -94 -81 -52 -5 -30 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -6 -32 -100 -66 -63 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -46 -11 -26 -61 -7 -37 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -17 -33 -189 -159 -124 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -188 -158 -123 -56 -16 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -61 -7 -37 -47 -12 -27 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -98 -64 -62 -55 -6 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -52 -5 -29 -129 -97 -83 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -245 -217 -163 -39 -5 -22 -63 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -51 -15 -30 -212 -184 -141 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -165 -134 -107 -55 -13 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -58 -7 -35 -66 -30 -39 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -91 -57 -56 -55 -6 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -16 -31 -194 -165 -128 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -237 -209 -158 -43 -8 -24 -63 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -60 -7 -36 -50 -15 -28 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -157 -126 -102 -54 -12 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -53 -8 -30 -134 -102 -86 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -67 -32 -40 -58 -7 -35 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -49 -13 -28 -217 -189 -144 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -214 -186 -142 -50 -14 -28 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -58 -7 -34 -70 -34 -42 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -130 -98 -84 -53 -8 -30 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -13 -31 -160 -129 -104 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -48 -13 -28 -61 -7 -37 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -43 -8 -23 -239 -211 -158 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -191 -162 -126 -55 -16 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -6 -32 -94 -60 -59 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -162 -132 -105 -55 -13 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -7 -37 -45 -9 -25 -247 -220 -165 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -73 -38 -44 -57 -7 -34 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -53 -6 -31 -111 -78 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -219 -190 -145 -48 -12 -27 -64 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -52 -14 -30 -199 -170 -131 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -136 -104 -88 -53 -10 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -59 -7 -36 -55 -20 -32 -254 -227 -169 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -254 -227 -169 -53 -18 -30 -60 -8 -36 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -53 -10 -31 -139 -108 -89 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -196 -167 -129 -53 -15 -30 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -38 -47 -12 -26 -222 -193 -147 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -108 -75 -68 -54 -6 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -7 -34 -76 -40 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -246 -218 -164 -44 -9 -25 -61 -7 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -14 -31 -166 -135 -108 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -235 -207 -157 -46 -11 -26 -60 -7 -36 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -12 -32 -116 -83 -74 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -163 -133 -106 -53 -14 -30 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -62 -8 -38 -47 -12 -27 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -77 -42 -47 -54 -7 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -7 -33 -60 -25 -35 -252 -224 -167 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -218 -191 -144 -45 -10 -25 -62 -7 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -14 -32 -142 -110 -91 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -137 -106 -89 -54 -14 -31 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -61 -7 -37 -45 -9 -25 -221 -192 -146 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -251 -224 -167 -58 -24 -34 -56 -7 -34 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -7 -32 -79 -44 -49 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -168 -130 -49 -12 -28 -63 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -53 -14 -31 -165 -135 -108 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -112 -79 -71 -54 -11 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -59 -7 -36 -47 -11 -26 -237 -209 -158 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -143 -111 -93 -51 -13 -29 -63 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -57 -7 -35 -47 -12 -27 -229 -201 -152 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -250 -223 -166 -64 -29 -38 -55 -8 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -54 -11 -31 -96 -62 -60 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -201 -173 -133 -47 -11 -26 -60 -7 -37 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -61 -7 -38 -48 -12 -28 -184 -154 -121 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -117 -85 -75 -53 -12 -31 -63 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -7 -34 -53 -18 -30 -242 -215 -161 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -241 -213 -160 -52 -17 -30 -55 -6 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -52 -12 -31 -122 -89 -78 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -49 -14 -27 -224 -195 -148 -255 -228 -170 -255 -228 -170 -255 -228 -170 -180 -150 -118 -49 -13 -27 -62 -7 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -60 -7 -36 -47 -11 -26 -204 -175 -135 -255 -228 -170 -255 -228 -170 -255 -228 -170 -159 -128 -103 -76 -41 -46 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -91 -58 -57 -54 -11 -32 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -55 -8 -32 -67 -32 -40 -251 -224 -167 -255 -228 -170 -255 -228 -170 -255 -228 -170 -72 -38 -43 -166 -136 -109 -255 -228 -170 -255 -228 -170 -255 -228 -170 -227 -198 -151 -47 -12 -27 -58 -7 -35 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -52 -13 -30 -147 -116 -96 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -39 -4 -21 -26 -0 -26 -26 -0 -26 -39 -4 -21 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -252 -225 -168 -93 -59 -58 -53 -12 -30 -63 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -57 -7 -35 -47 -11 -26 -189 -159 -124 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -113 -82 -73 -112 -80 -71 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -221 -192 -146 -49 -14 -27 -55 -8 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -39 -54 -10 -32 -62 -27 -36 -240 -212 -159 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -57 -22 -33 -200 -171 -132 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -153 -121 -99 -49 -13 -28 -60 -7 -36 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -61 -7 -37 -51 -12 -29 -129 -96 -83 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -197 -167 -130 -54 -20 -31 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -246 -219 -164 -74 -40 -46 -53 -11 -31 -63 -8 -38 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -56 -6 -33 -47 -12 -27 -206 -178 -136 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -90 -57 -55 -144 -113 -93 -255 -228 -170 -255 -228 -170 -255 -228 -170 -255 -228 -170 -205 -176 -136 -46 -11 -26 -56 -7 -33 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -64 -8 -39 -63 -8 -38 -54 -11 -30 -76 -42 -47 -247 -220 -165 -255 -228 -... [truncated message content] |
From: <luk...@us...> - 2012-02-06 02:18:47
|
Revision: 1667 http://toss.svn.sourceforge.net/toss/?rev=1667&view=rev Author: lukaszkaiser Date: 2012-02-06 02:18:40 +0000 (Mon, 06 Feb 2012) Log Message: ----------- Final cleanups for 0.7 release. Modified Paths: -------------- trunk/Toss/Makefile trunk/Toss/Play/Move.ml trunk/Toss/README trunk/Toss/Toss.odocl trunk/Toss/WebClient/JsHandler.js trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/Play.js trunk/Toss/WebClient/Style.css trunk/Toss/WebClient/index.html trunk/Toss/WebClient/local.html trunk/Toss/www/Publications/.cvsignore trunk/Toss/www/Publications/Makefile trunk/Toss/www/Publications/all.bib trunk/Toss/www/Publications/index.xml trunk/Toss/www/create.xml trunk/Toss/www/develop.xml trunk/Toss/www/index.xml trunk/Toss/www/learn.xml trunk/Toss/www/navigation.xml trunk/Toss/www/play.xml Added Paths: ----------- trunk/Toss/run_server.sh trunk/Toss/www/pub/aaai11_slides.pdf Removed Paths: ------------- trunk/Toss/toss trunk/Toss/www/examples.xml Property Changed: ---------------- trunk/Toss/www/Publications/ Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2012-02-05 17:05:10 UTC (rev 1666) +++ trunk/Toss/Makefile 2012-02-06 02:18:40 UTC (rev 1667) @@ -10,10 +10,10 @@ %.js: %.byte js_of_ocaml _build/$< -RELEASE=0.6 +RELEASE=0.7 Release: TossServer doc - rm -f *~ Formula/*~ Solver/*~ Arena/*~ Play/*~ GGP/*~ \ - Language/*~ Server/*~ www/*~ WebClient/~ + rm -f *~ MenhirLib/*~ Formula/*~ Solver/*~ Arena/*~ Play/*~ GGP/*~ \ + Learn/*~ Language/*~ Server/*~ www/*~ WebClient/~ make -C www/reference make -C www make -C . @@ -26,6 +26,7 @@ mv toss_$(RELEASE)/_build/Toss.docdir toss_$(RELEASE)/www/code_doc rm -rf toss_$(RELEASE)/_build toss_$(RELEASE)/gmon.out rm -rf toss_$(RELEASE)/www/pub + rm -rf toss_$(RELEASE)/Learn/videos zip -r toss_$(RELEASE).zip toss_$(RELEASE) rm -rf toss_$(RELEASE) @@ -51,8 +52,6 @@ $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) OCAMLBUILDJS=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf $(OCB_PPJS) \ $(OCB_LIBJS) $(OCB_CFLAG) $(OCB_LFLAG) -OCAMLBUILDNOPP=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf \ - $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) FormulaINCSatINC=MenhirLib,Formula FormulaINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll @@ -77,7 +76,7 @@ $(OCAMLBUILD) -Is $($(subst /,INC,$(dir $@))) $@ doc: caml_extensions/pa_let_try.cmo - $(OCAMLBUILDNOPP) -Is +oUnit,+sqlite3,$(.INC) Toss.docdir/index.html + $(OCAMLBUILD) -Is +oUnit,+sqlite3,$(.INC) Toss.docdir/index.html make -C www code_doc_link Modified: trunk/Toss/Play/Move.ml =================================================================== --- trunk/Toss/Play/Move.ml 2012-02-05 17:05:10 UTC (rev 1666) +++ trunk/Toss/Play/Move.ml 2012-02-06 02:18:40 UTC (rev 1667) @@ -39,14 +39,10 @@ Aux.concat_map (fun (label,next_loc) -> let rule = List.assoc label.Arena.lb_rule rules in - AuxIO.log ("gen_moves: matchings for "^label.Arena.lb_rule); List.map (fun emb -> label,next_loc,emb) - (ContinuousRule.matches model rule)) + (ContinuousRule.matches model rule)) loc.Arena.moves in - AuxIO.log ("gen_moves: found "^string_of_int (List.length matchings) - ^" matchings."); - if matchings = [] then [| |] - else ( + if matchings = [] then [| |] else ( (* generating the grid *) Array.concat (List.map (fun (label,next_loc,emb) -> @@ -120,11 +116,7 @@ let loc = game.Arena.graph.(s.Arena.cur_loc) in let moving = select_moving loc in let get_moves pl = - AuxIO.log ("Move.list_moves: before getting moves for player "^ - string_of_int pl); - let m = - gen_moves cGRID_SIZE game.Arena.rules s.Arena.struc loc.(pl) in - AuxIO.log ("Move.list_moves: before generating models for the moves"); + let m = gen_moves cGRID_SIZE game.Arena.rules s.Arena.struc loc.(pl) 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/README =================================================================== --- trunk/Toss/README 2012-02-05 17:05:10 UTC (rev 1666) +++ trunk/Toss/README 2012-02-06 02:18:40 UTC (rev 1667) @@ -9,7 +9,7 @@ -- Installing dependencies under Ubuntu Run the following in terminal: - sudo apt-get install menhir libounit-ocaml-dev libsqlite3-ocaml-dev heirloom-mailx + sudo apt-get install menhir libounit-ocaml-dev libsqlite3-ocaml-dev libjs-of-ocaml-dev heirloom-mailx Finally to compile Toss just type make @@ -44,6 +44,7 @@ The SAT-solver in Formula/Sat/dpll/ is part of the Decision Procedure Toolkit, and it is Copyright to Intel Corporation and distributed under a separate license - the Apache License 2.0. See Formula/Sat/dpll/LICENSE.txt. +The part of menhirLib we use (under MenhirLib/) also has a separate licence. Toss is licensed under the following BSD license. Modified: trunk/Toss/Toss.odocl =================================================================== --- trunk/Toss/Toss.odocl 2012-02-05 17:05:10 UTC (rev 1666) +++ trunk/Toss/Toss.odocl 2012-02-06 02:18:40 UTC (rev 1667) @@ -1,3 +1,4 @@ +Formula/Aux Formula/Formula Formula/FormulaParser Formula/FormulaMap @@ -20,7 +21,6 @@ Solver/Solver Solver/Class Solver/ClassParser -Solver/Distinguish Arena/Term Arena/TermParser Arena/DiscreteRule @@ -38,7 +38,7 @@ GGP/TranslateFormula GGP/TranslateGame GGP/GameSimpl -Server/Picture -Server/LearnGame +Learn/Distinguish +Learn/LearnGame Server/DB Server/ReqHandler Modified: trunk/Toss/WebClient/JsHandler.js =================================================================== --- trunk/Toss/WebClient/JsHandler.js 2012-02-05 17:05:10 UTC (rev 1666) +++ trunk/Toss/WebClient/JsHandler.js 2012-02-06 02:18:40 UTC (rev 1667) @@ -948,4 +948,4 @@ if( y.fun ) { x.fun = y.fun; return 0; } var i = y.length; while (i--) x[i] = y[i]; return 0; } @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-05 17:05:16
|
Revision: 1666 http://toss.svn.sourceforge.net/toss/?rev=1666&view=rev Author: lukstafi Date: 2012-02-05 17:05:10 +0000 (Sun, 05 Feb 2012) Log Message: ----------- Minor change: JsHandler not needed in the main thread. Modified Paths: -------------- trunk/Toss/WebClient/local.html Modified: trunk/Toss/WebClient/local.html =================================================================== --- trunk/Toss/WebClient/local.html 2012-02-05 15:33:16 UTC (rev 1665) +++ trunk/Toss/WebClient/local.html 2012-02-05 17:05:10 UTC (rev 1666) @@ -9,7 +9,6 @@ <link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" /> <link rel="stylesheet" type="text/css" href="Style.css" media="screen" title="Default"/> <script type="text/javascript" src="Local.js"> </script> - <script type="text/javascript" src="JsHandler.js"> </script> <script type="text/javascript" src="State.js"> </script> <script type="text/javascript" src="Play.js"> </script> <script type="text/javascript" src="Main.js"> </script> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-05 15:33:22
|
Revision: 1665 http://toss.svn.sourceforge.net/toss/?rev=1665&view=rev Author: lukstafi Date: 2012-02-05 15:33:16 +0000 (Sun, 05 Feb 2012) Log Message: ----------- Better handling of missing functions (the fix to probable js_of_ocaml bug). Modified Paths: -------------- trunk/Toss/Makefile trunk/Toss/WebClient/JsHandler.js trunk/Toss/WebClient/Local.js Added Paths: ----------- trunk/Toss/WebClient/MissingFunctions.js Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2012-02-05 11:15:29 UTC (rev 1664) +++ trunk/Toss/Makefile 2012-02-05 15:33:16 UTC (rev 1665) @@ -5,7 +5,7 @@ WebClient/JsHandler.js: Server/JsHandler.byte js_of_ocaml _build/$< - cp _build/Server/JsHandler.js WebClient/JsHandler.js + cat WebClient/MissingFunctions.js _build/Server/JsHandler.js > WebClient/JsHandler.js %.js: %.byte js_of_ocaml _build/$< Modified: trunk/Toss/WebClient/JsHandler.js =================================================================== --- trunk/Toss/WebClient/JsHandler.js 2012-02-05 11:15:29 UTC (rev 1664) +++ trunk/Toss/WebClient/JsHandler.js 2012-02-05 15:33:16 UTC (rev 1665) @@ -1,3 +1,57 @@ +// A bug in js_of_ocaml: it sometimes omits the functions below, which +// belong to its runtmie. + +// Applies to code below this line: +// Js_of_ocaml runtime support +// http://www.ocsigen.org/js_of_ocaml/ +// Copyright (C) 2010 Jérôme Vouillon +// Laboratoire PPS - CNRS Université Paris Diderot +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, with linking exception; +// either version 2.1 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Provides: caml_int64_bits_of_float const +function caml_int64_bits_of_float (x) { + if (!isFinite(x)) { + if (isNaN(x)) return [255, 1, 0, 0xfff0]; + return (x > 0)?[255,0,0,0x7ff0]:[255,0,0,0xfff0]; + } + var sign = (x>=0)?0:0x8000; + if (sign) x = -x; + var exp = Math.floor(Math.LOG2E*Math.log(x)) + 1023; + if (exp <= 0) { + exp = 0; + x /= Math.pow(2,-1026); + } else { + x /= Math.pow(2,exp-1027); + if (x < 16) { x *= 2; exp -=1; } + if (exp == 0) { x /= 2; } + } + var k = Math.pow(2,24); + var r3 = x|0; + x = (x - r3) * k; + var r2 = x|0; + x = (x - r2) * k; + var r1 = x|0; + r3 = (r3 &0xf) | sign | exp << 4; + return [255, r1, r2, r3]; +} +//Provides: caml_int64_to_bytes +function caml_int64_to_bytes(x) { + return [x[3] >> 8, x[3] & 0xff, x[2] >> 16, (x[2] >> 8) & 0xff, x[2] & 0xff, + x[1] >> 16, (x[1] >> 8) & 0xff, x[1] & 0xff]; +} // This program was compiled from OCaml by js_of_ocaml 1.0 function caml_raise_with_arg (tag, arg) { throw [0, tag, arg]; } function caml_raise_with_string (tag, msg) { Modified: trunk/Toss/WebClient/Local.js =================================================================== --- trunk/Toss/WebClient/Local.js 2012-02-05 11:15:29 UTC (rev 1664) +++ trunk/Toss/WebClient/Local.js 2012-02-05 15:33:16 UTC (rev 1665) @@ -28,61 +28,6 @@ return (res_arr); } -// A bug in js_of_ocaml: it sometimes omits the functions below, which -// belong to its runtmie. - -// Applies to code below this line: -// Js_of_ocaml runtime support -// http://www.ocsigen.org/js_of_ocaml/ -// Copyright (C) 2010 Jérôme Vouillon -// Laboratoire PPS - CNRS Université Paris Diderot -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, with linking exception; -// either version 2.1 of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -// Provides: caml_int64_bits_of_float const -function caml_int64_bits_of_float (x) { - if (!isFinite(x)) { - if (isNaN(x)) return [255, 1, 0, 0xfff0]; - return (x > 0)?[255,0,0,0x7ff0]:[255,0,0,0xfff0]; - } - var sign = (x>=0)?0:0x8000; - if (sign) x = -x; - var exp = Math.floor(Math.LOG2E*Math.log(x)) + 1023; - if (exp <= 0) { - exp = 0; - x /= Math.pow(2,-1026); - } else { - x /= Math.pow(2,exp-1027); - if (x < 16) { x *= 2; exp -=1; } - if (exp == 0) { x /= 2; } - } - var k = Math.pow(2,24); - var r3 = x|0; - x = (x - r3) * k; - var r2 = x|0; - x = (x - r2) * k; - var r1 = x|0; - r3 = (r3 &0xf) | sign | exp << 4; - return [255, r1, r2, r3]; -} -//Provides: caml_int64_to_bytes -function caml_int64_to_bytes(x) { - return [x[3] >> 8, x[3] & 0xff, x[2] >> 16, (x[2] >> 8) & 0xff, x[2] & 0xff, - x[1] >> 16, (x[1] >> 8) & 0xff, x[1] & 0xff]; -} - // ******************************************************************** // Web-Worker thread Added: trunk/Toss/WebClient/MissingFunctions.js =================================================================== --- trunk/Toss/WebClient/MissingFunctions.js (rev 0) +++ trunk/Toss/WebClient/MissingFunctions.js 2012-02-05 15:33:16 UTC (rev 1665) @@ -0,0 +1,54 @@ +// A bug in js_of_ocaml: it sometimes omits the functions below, which +// belong to its runtmie. + +// Applies to code below this line: +// Js_of_ocaml runtime support +// http://www.ocsigen.org/js_of_ocaml/ +// Copyright (C) 2010 Jérôme Vouillon +// Laboratoire PPS - CNRS Université Paris Diderot +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, with linking exception; +// either version 2.1 of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Provides: caml_int64_bits_of_float const +function caml_int64_bits_of_float (x) { + if (!isFinite(x)) { + if (isNaN(x)) return [255, 1, 0, 0xfff0]; + return (x > 0)?[255,0,0,0x7ff0]:[255,0,0,0xfff0]; + } + var sign = (x>=0)?0:0x8000; + if (sign) x = -x; + var exp = Math.floor(Math.LOG2E*Math.log(x)) + 1023; + if (exp <= 0) { + exp = 0; + x /= Math.pow(2,-1026); + } else { + x /= Math.pow(2,exp-1027); + if (x < 16) { x *= 2; exp -=1; } + if (exp == 0) { x /= 2; } + } + var k = Math.pow(2,24); + var r3 = x|0; + x = (x - r3) * k; + var r2 = x|0; + x = (x - r2) * k; + var r1 = x|0; + r3 = (r3 &0xf) | sign | exp << 4; + return [255, r1, r2, r3]; +} +//Provides: caml_int64_to_bytes +function caml_int64_to_bytes(x) { + return [x[3] >> 8, x[3] & 0xff, x[2] >> 16, (x[2] >> 8) & 0xff, x[2] & 0xff, + x[1] >> 16, (x[1] >> 8) & 0xff, x[1] & 0xff]; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-05 11:15:36
|
Revision: 1664 http://toss.svn.sourceforge.net/toss/?rev=1664&view=rev Author: lukstafi Date: 2012-02-05 11:15:29 +0000 (Sun, 05 Feb 2012) Log Message: ----------- WebClient and JsHandler: worker-side Toss handler in JavaScript. AuxIO: single logging command working on both worker-side and window-side. To try the interface locally, start a browser with --allow-file-access-from-files. Modified Paths: -------------- trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/Formula/AuxIO.ml trunk/Toss/Formula/AuxIO.mli trunk/Toss/Play/Move.ml trunk/Toss/Server/GameSelection.ml trunk/Toss/Server/JsHandler.ml trunk/Toss/WebClient/JsHandler.js trunk/Toss/WebClient/Local.js trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/Play.js Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2012-02-05 01:24:07 UTC (rev 1663) +++ trunk/Toss/Formula/Aux.ml 2012-02-05 11:15:29 UTC (rev 1664) @@ -772,14 +772,3 @@ ) ELSE ( Str.global_replace (Str.regexp regexp) templ s ) ENDIF - -(* Display prominently a message and wait for user - acknowledgement. Intended mostly for diagnostic purposes. *) -let alert s = - IFDEF JAVASCRIPT THEN ( - let js_alert = Js.Unsafe.variable "alert" in - Js.Unsafe.fun_call js_alert [|Js.Unsafe.inject (Js.string s)|] - ) ELSE ( - prerr_endline (s ^ " -- PRESS [ENTER]"); - ignore (read_line ()) - ) ENDIF Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2012-02-05 01:24:07 UTC (rev 1663) +++ trunk/Toss/Formula/Aux.mli 2012-02-05 11:15:29 UTC (rev 1664) @@ -369,7 +369,3 @@ except that all substrings of [s] that match [regexp] have been replaced by [templ]. *) val replace_regexp : regexp:string -> templ:string -> string -> string - -(** Display prominently a message and wait for user - acknowledgement. Intended mostly for diagnostic purposes. *) -val alert : string -> unit Modified: trunk/Toss/Formula/AuxIO.ml =================================================================== --- trunk/Toss/Formula/AuxIO.ml 2012-02-05 01:24:07 UTC (rev 1663) +++ trunk/Toss/Formula/AuxIO.ml 2012-02-05 11:15:29 UTC (rev 1664) @@ -119,3 +119,36 @@ (Unix.error_message e) f s; (fun () -> f_in x) ) ENDIF + +IFDEF JAVASCRIPT THEN +(* For some reason, it is difficult to check if a variable is + defined... *) +let is_worker = + Js.to_bool (Js.Unsafe.eval_string "typeof window == 'undefined'") + +let self = + if is_worker then Js.Unsafe.variable "self" + else Js.Unsafe.variable "window" + +let postMessage = Js.Unsafe.variable "postMessage" + +let worker_log s = + ignore (Js.Unsafe.call postMessage self + [|Js.Unsafe.inject (Js.string s)|]) + +(* [Firebug.console##log (s)] forces unconditional access to the "window" + variable. *) +let console_log s = + let console = Js.Unsafe.get self (Js.string "console") in + let c_log = Js.Unsafe.get console (Js.string "log") in + Js.Unsafe.call c_log console [|Js.Unsafe.inject (Js.string s)|] + +ENDIF + +let log s = + IFDEF JAVASCRIPT THEN ( + if is_worker then worker_log s else console_log s + ) ELSE ( + print_endline s; flush stdout + ) ENDIF + Modified: trunk/Toss/Formula/AuxIO.mli =================================================================== --- trunk/Toss/Formula/AuxIO.mli 2012-02-05 01:24:07 UTC (rev 1663) +++ trunk/Toss/Formula/AuxIO.mli 2012-02-05 11:15:29 UTC (rev 1664) @@ -37,3 +37,7 @@ (2) on single-threaded servers handling calls (older Toss versions), you have to collect the results, even on Exception in caller *) val toss_call : int * string -> ('a -> 'b) -> 'a -> (unit -> 'b) + +(** Output a string in a manner visible to the programmer but not + obtrusive to the GUI user. *) +val log : string -> unit Modified: trunk/Toss/Play/Move.ml =================================================================== --- trunk/Toss/Play/Move.ml 2012-02-05 01:24:07 UTC (rev 1663) +++ trunk/Toss/Play/Move.ml 2012-02-05 11:15:29 UTC (rev 1664) @@ -39,9 +39,12 @@ Aux.concat_map (fun (label,next_loc) -> let rule = List.assoc label.Arena.lb_rule rules in + AuxIO.log ("gen_moves: matchings for "^label.Arena.lb_rule); List.map (fun emb -> label,next_loc,emb) (ContinuousRule.matches model rule)) loc.Arena.moves in + AuxIO.log ("gen_moves: found "^string_of_int (List.length matchings) + ^" matchings."); if matchings = [] then [| |] else ( (* generating the grid *) @@ -117,7 +120,11 @@ let loc = game.Arena.graph.(s.Arena.cur_loc) in 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 + AuxIO.log ("Move.list_moves: before getting moves for player "^ + string_of_int pl); + let m = + gen_moves cGRID_SIZE game.Arena.rules s.Arena.struc loc.(pl) in + AuxIO.log ("Move.list_moves: before generating models for the moves"); (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/Server/GameSelection.ml =================================================================== --- trunk/Toss/Server/GameSelection.ml 2012-02-05 01:24:07 UTC (rev 1663) +++ trunk/Toss/Server/GameSelection.ml 2012-02-05 11:15:29 UTC (rev 1664) @@ -1,3 +1,5 @@ +(* In-source definitions of several games, loading games from strings. *) + type game_state_data = { heuristic : Formula.real_expr array array; (** heuristic *) game_state : (Arena.game * Arena.game_state); (** game and state *) @@ -21,7 +23,6 @@ Heuristic.default_heuristic ~struc:state.Arena.struc ?advr game let compile_game_data game_name game_str = - Aux.alert ("Preparing "^game_name^"..."); let (game, game_state as game_with_state) = ArenaParser.parse_game_state Lexer.lex (Lexing.from_string game_str) in let adv_ratio = @@ -1823,14 +1824,16 @@ \" ") -let games = ref +let predef_games = [ - compile_game_data "Breakthrough" breakthrough_str; - compile_game_data "Checkers" checkers_str; - compile_game_data "Chess" chess_str; - compile_game_data "Connect4" connect4_str; - compile_game_data "Entanglement" entanglement_str; - compile_game_data "Gomoku" gomoku_str; - compile_game_data "Pawn-Whopping" pawn_whopping_str; - compile_game_data "Tic-Tac-Toe" tictactoe_str; + "Breakthrough", breakthrough_str; + "Checkers", checkers_str; + "Chess", chess_str; + "Connect4", connect4_str; + "Entanglement", entanglement_str; + "Gomoku", gomoku_str; + "Pawn-Whopping", pawn_whopping_str; + "Tic-Tac-Toe", tictactoe_str; ] + +let games = ref [compile_game_data "Tic-Tac-Toe" tictactoe_str] Modified: trunk/Toss/Server/JsHandler.ml =================================================================== --- trunk/Toss/Server/JsHandler.ml 2012-02-05 01:24:07 UTC (rev 1663) +++ trunk/Toss/Server/JsHandler.ml 2012-02-05 11:15:29 UTC (rev 1664) @@ -27,11 +27,55 @@ let js_object = Js.Unsafe.variable "Object" let js_any = Js.Unsafe.inject -let js_handler = Js.Unsafe.variable "LOCAL" +(* For some reason, it is difficult to check if a variable is + defined... *) +let is_worker = + Js.to_bool (Js.Unsafe.eval_string "typeof window == 'undefined'") + + +let self = + if is_worker then Js.Unsafe.variable "self" + else Js.Unsafe.variable "window" + +let js_handler = jsnew js_object () let set_handle name f = - Js.Unsafe.set js_handler (js name) (Js.wrap_callback f) + Js.Unsafe.set js_handler (js name) (Js.wrap_callback f) +(* In case the handler is used in the same thread: *) +let _ = + Js.Unsafe.set self (js"LOCAL") js_handler +(* In case the handler is used as Web Worker: *) +let postMessage = Js.Unsafe.variable "postMessage" + +(* TODO: build records directly, using js_of_ocaml in a type safe + manner: probably creating an OCaml object. *) +let build_js_record fields = + let record = jsnew js_object () in + List.iter (fun (field, value) -> + Js.Unsafe.set record (js field) value) fields; + record + +let onmessage event = + AuxIO.log ("worker received "^of_js event##data##fname); + (*Firebug.console##log_4 ("worker received fname=", event##data##fname, + "; args=", event##data##args);*) + let fname = event##data##fname in + let args = event##data##args in + let handle = Js.Unsafe.get js_handler fname in + let result = + Js.Unsafe.fun_call handle (Js.to_array args) in + let response = + build_js_record ["fname", fname; "result", result] in + Js.Unsafe.call postMessage self [|js_any response|] + +let _ = Js.Unsafe.set self (js"onmessage") onmessage + +let test_handle s = + AuxIO.log ("Testing "^of_js s); + js ("Now " ^ of_js s ^ " tested") +let _ = set_handle "test_handle" test_handle + let js_of_move game state move_id (player, move, _) = let struc = state.Arena.struc in let matched = Js.array @@ -50,6 +94,7 @@ let struc = state.Arena.struc in let get_pos e = Structure.fun_val struc "x" e, Structure.fun_val struc "y" e in + AuxIO.log "js_of_game_state: Preparing game elements..."; let elems = Structure.elements struc in let (posx, posy) = List.split (List.map get_pos elems) in let mkfl f l = List.fold_left f (List.hd l) (List.tl l) in @@ -65,6 +110,7 @@ elems) in (* rels are arrays of element names, with additional "name" field *) let num = Js.number_of_float in + AuxIO.log "js_of_game_state: Preparing game relations..."; let rels = Array.of_list (Aux.concat_map (fun (rel, _) -> @@ -85,6 +131,7 @@ Js.Unsafe.set info_obj (js"miny") (num miny); Js.Unsafe.set info_obj (js"elems") (Js.array elems); Js.Unsafe.set info_obj (js"rels") (Js.array rels); + AuxIO.log "js_of_game_state: Preparing game moves..."; if !cur_all_moves <> [||] then Js.Unsafe.set info_obj (js"moves") (Js.array (Array.mapi (js_of_move game state) !cur_all_moves)) @@ -100,16 +147,31 @@ Js.Unsafe.set result (js player_name) (Js.float payoff)) payoffs; Js.Unsafe.set info_obj (js"result") result); + AuxIO.log "js_of_game_state: Game prepared. Sending..."; info_obj let new_play game_name pl1 pl2 = (* players are currently not used by [JsHandler] *) - let game_data = List.assoc (of_js game_name) !GameSelection.games in + let game_name = of_js game_name in + let game_loaded = List.mem_assoc game_name !GameSelection.games in + if game_loaded + then AuxIO.log ("new_play: "^game_name^" already loaded.") + else AuxIO.log ("new_play: loading "^game_name^"..."); + let game_data = + try List.assoc game_name !GameSelection.games + with Not_found -> + let game_data = compile_game_data game_name + (List.assoc game_name GameSelection.predef_games) in + games := game_data :: !games; + snd game_data in + if not game_loaded then + AuxIO.log ("new_play: "^game_name^" loaded."); let game, state = game_data.game_state in cur_game := game_data; play_states := [state]; cur_all_moves := Move.list_moves game state; cur_move := 0; + AuxIO.log ("new_play ("^game_name^"): calling js_of_game_state."); js_of_game_state game state let _ = set_handle "new_play" new_play @@ -124,21 +186,23 @@ let _ = set_handle "prev_move" preview_move -let make_move move_id cont = +let make_move move_id = + let move_id = int_of_float (Js.to_float move_id) in + AuxIO.log ("make_move: move_id="^string_of_int move_id); if !play_states = [] then Js.null else - let (p, m, n_state) = - !cur_all_moves.(int_of_float (Js.to_float move_id)) in + let (p, m, n_state) = !cur_all_moves.(move_id) in let game, _ = !cur_game.game_state in play_states := n_state :: !play_states; cur_all_moves := Move.list_moves game n_state; cur_move := 0; - Js.Unsafe.fun_call cont - [|js_any (js_of_game_state game n_state)|] + Js.some (js_of_game_state game n_state) let _ = set_handle "make_move" make_move -let suggest player_name time cont = +(* When called in a different thread, we can't call continuation. So + arrange to do it from "outside". *) +let suggest player_name time = (* We do not use the player name. *) Random.self_init (); let time = Js.to_float time in @@ -163,7 +227,7 @@ (Js.number_of_float comp_started); Js.Unsafe.set result (js"comp_ended") (Js.number_of_float (Aux.gettimeofday ())); - Js.Unsafe.fun_call cont [|js_any result|] + Js.some result with Not_found -> Js.null let _ = set_handle "suggest" suggest Modified: trunk/Toss/WebClient/JsHandler.js =================================================================== --- trunk/Toss/WebClient/JsHandler.js 2012-02-05 01:24:07 UTC (rev 1663) +++ trunk/Toss/WebClient/JsHandler.js 2012-02-05 11:15:29 UTC (rev 1664) @@ -638,7 +638,9 @@ return res; } function caml_is_printable(c) { return +(c > 31 && c < 127); } +function caml_js_eval_string () {return eval(arguments[0].toString());} function caml_js_from_array(a) { return a.slice(1); } +function caml_js_fun_call(f, args) { return f.apply(null, args.slice(1)); } function caml_js_to_array(a) { return [0].concat(a); } function caml_js_wrap_callback(f) { var toArray = Array.prototype.slice; @@ -892,4 +894,4 @@ if( y.fun ) { x.fun = y.fun; return 0; } var i = y.length; while (i--) x[i] = y[i]; return 0; } @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-05 01:24:15
|
Revision: 1663 http://toss.svn.sourceforge.net/toss/?rev=1663&view=rev Author: lukaszkaiser Date: 2012-02-05 01:24:07 +0000 (Sun, 05 Feb 2012) Log Message: ----------- Pre-release preparations and bugfixes. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/Play/Play.ml trunk/Toss/Server/DB.ml trunk/Toss/Server/DB.mli trunk/Toss/Server/ReqHandler.ml trunk/Toss/Server/Server.ml trunk/Toss/Solver/Assignments.ml trunk/Toss/Solver/Solver.ml trunk/Toss/WebClient/Login.js trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/Style.css trunk/Toss/WebClient/index.html trunk/Toss/WebClient/profile.html trunk/Toss/www/create.xml trunk/Toss/www/develop.xml trunk/Toss/www/docs.xml trunk/Toss/www/examples.xml trunk/Toss/www/img/Breakthrough.png trunk/Toss/www/img/Checkers.png trunk/Toss/www/img/Connect4.png trunk/Toss/www/img/Gomoku.png trunk/Toss/www/img/Pawn-Whopping.png trunk/Toss/www/img/Tic-Tac-Toe.png trunk/Toss/www/index.xml trunk/Toss/www/navigation.xml Removed Paths: ------------- trunk/Toss/www/gui_interface.xml Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Arena/Arena.ml 2012-02-05 01:24:07 UTC (rev 1663) @@ -59,8 +59,6 @@ history : (move * float option) list ; } - - let zero_loc = { payoff = Formula.Const 0. ; view = (Formula.And [], []); heur = []; @@ -81,8 +79,14 @@ cur_loc = 0 ; history = [] ; } - +let equal_state gs1 gs2 = + if gs1 == gs2 then true else + if gs1.time <> gs2.time || gs1.cur_loc <> gs2.cur_loc || + gs1.history <> gs2.history then false else + Structure.equal gs1.struc gs2.struc + + (* -------------------- PARSER HELPER ------------------------------ *) let matching_of_names (game, state) rname match_str = Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Arena/Arena.mli 2012-02-05 01:24:07 UTC (rev 1663) @@ -55,6 +55,7 @@ } val empty_state : game * game_state +val equal_state : game_state -> game_state -> bool (** Make a move in a game. *) val make_move : move -> game * game_state -> game * game_state Modified: trunk/Toss/Play/Play.ml =================================================================== --- trunk/Toss/Play/Play.ml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Play/Play.ml 2012-02-05 01:24:07 UTC (rev 1663) @@ -69,6 +69,11 @@ (Aux.gettimeofday() -. !timeout) msg; (t, mvs) +let equal_moves m1 m2 = + if m1 == m2 then true else + let (mv1, gs1), (mv2, gs2) = m1, m2 in + if mv1 <> mv2 then false else Arena.equal_state gs1 gs2 + (* Maximax unfold upto depth and choose move. *) let maximax_unfold_choose ?(check_stable=3) count game state heur = let ab = Heuristic.is_constant_sum heur in (* TODO: payoffs as well! *) @@ -87,7 +92,7 @@ let rec ord_sub = function | ([], _) -> true | (x :: xs, []) -> false - | (x :: xs, y :: ys) when x = y -> ord_sub (xs, ys) + | (x :: xs, y :: ys) when equal_moves x y -> ord_sub (xs, ys) | (x :: xs, y :: ys) -> ord_sub (x :: xs, ys) in let nbr mv = List.length (List.filter (fun m -> ord_sub (mv,m)) last_mvs) in let mvs_votes = List.map (fun m -> (m, nbr m)) last_mvs in Modified: trunk/Toss/Server/DB.ml =================================================================== --- trunk/Toss/Server/DB.ml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Server/DB.ml 2012-02-05 01:24:07 UTC (rev 1663) @@ -113,8 +113,9 @@ let get_table dbfile ?(select="") tbl = fst (apply_cmd dbfile select ("select * from " ^ tbl)) -let count_table dbfile ?(select="") tbl = - let (rows, _) = apply_cmd dbfile select ("select count(*) from " ^ tbl) in +let max_in_table ~field dbfile ?(select="") tbl = + let (rows, _) = + apply_cmd dbfile select ("select max(" ^ field ^ ") from " ^ tbl) in int_of_string (List.hd rows).(0) let insert_table dbfile tbl schm vals = Modified: trunk/Toss/Server/DB.mli =================================================================== --- trunk/Toss/Server/DB.mli 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Server/DB.mli 2012-02-05 01:24:07 UTC (rev 1663) @@ -15,7 +15,7 @@ val get_table : string -> ?select : string -> string -> string array list -val count_table : string -> ?select : string -> string -> int +val max_in_table : field:string -> string -> ?select : string -> string -> int val insert_table : string -> string -> string -> string list -> unit Modified: trunk/Toss/Server/ReqHandler.ml =================================================================== --- trunk/Toss/Server/ReqHandler.ml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Server/ReqHandler.ml 2012-02-05 01:24:07 UTC (rev 1663) @@ -503,7 +503,7 @@ let app_plays plays g = plays ^ "@" ^ (list_plays g uid) in let plays = List.fold_left app_plays "" !DB.tGAMES in uid ^ "@" ^ name ^ plays in - let get_free_id () = (DB.count_table dbFILE "cur_states") + 1 in + let get_free_id() = (DB.max_in_table ~field:"playid" dbFILE "cur_states")+1 in let db_cur_insert game p1 p2 pid move toss loc info svg_str = DB.insert_table dbFILE "cur_states" "playid, game, player1, player2, move, toss, loc, info, svg" Modified: trunk/Toss/Server/Server.ml =================================================================== --- trunk/Toss/Server/Server.ml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Server/Server.ml 2012-02-05 01:24:07 UTC (rev 1663) @@ -26,7 +26,8 @@ let rec accept_sock n s = if n < 1 then failwith "Accept Sock Failed" else - try Unix.accept s with _ -> accept_sock (n-1) s + try Unix.accept s with _ -> + if n mod 3 = 0 then Unix.sleep 1; accept_sock (n-1) s let start_server f port addr_s = (* Unix.establish_server f (Unix.ADDR_INET (get_inet_addr (addr_s), port)) @@ -39,7 +40,7 @@ Unix.listen sock 9; (* maximally 9 pending requests *) let continue = ref true in while !continue do - let (cl_sock, _) = accept_sock 99 sock in + let (cl_sock, _) = accept_sock 98 sock in continue := f (Unix.in_channel_of_descr cl_sock) (Unix.out_channel_of_descr cl_sock); Unix.close cl_sock; Modified: trunk/Toss/Solver/Assignments.ml =================================================================== --- trunk/Toss/Solver/Assignments.ml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Solver/Assignments.ml 2012-02-05 01:24:07 UTC (rev 1663) @@ -380,7 +380,7 @@ and complement_map_rev elems acc = function | ([], []) -> acc - | ([], _) -> failwith "more assigned elements as elements at all" + | ([], _) -> failwith "more assigned elements than elements at all" | (e::es, []) -> complement_map_rev elems ((e, Any)::acc) (es, []) | (e1 :: es, (e2, a) :: ms) -> match compare_elems e1 e2 with @@ -426,9 +426,9 @@ | (Empty, _) | (_, Any) -> Empty | (Any, a) -> complement elems a | (a, Empty) -> a - | (FO (v1, map1), FO (v2, map2)) when v1 = v2 -> + | (FO (`FO v1, map1), FO (`FO v2, map2)) when String.compare v1 v2 = 0 -> let resm = List.rev (complement_join_map_rev elems [] (map1, map2)) in - if resm = [] then Empty else FO (v1, resm) + if resm = [] then Empty else FO (`FO v1, resm) | (FO _, FO _) -> join aset (complement elems a) (* TODO: improve! *) | _ -> join aset (complement elems a) @@ -454,9 +454,10 @@ (* Helper function for assignment creation below. *) let make_assign vl tuple = + if Array.length vl <> Array.length tuple then failwith "make_assign <>length"; let compare_asvs (v1, e1) (v2, e2) = let c = compare_vars (v1 :> Formula.var) (v2 :> Formula.var) in - if c != 0 then -c else compare_elems e1 e2 in + if c != 0 then -c else compare_elems e1 e2 in List.sort compare_asvs (Array.to_list (Aux.array_combine vl tuple)) (* Create an assignment set out of a list of variables and assigned tuples. *) Modified: trunk/Toss/Solver/Solver.ml =================================================================== --- trunk/Toss/Solver/Solver.ml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/Solver/Solver.ml 2012-02-05 01:24:07 UTC (rev 1663) @@ -303,7 +303,7 @@ let app_re = function Fun _ -> raise Not_found | x -> x in try let _ = FormulaMap.map_to_atoms_full app_rel app_re phi in - let rs = Aux.unique_sorted !rels in + let rs = Aux.unique_sorted ~cmp:String.compare !rels in if !debug_level > 1 then print_endline ("F: " ^ (Formula.str phi) ^" "^ (String.concat ", " rs)); Some rs Modified: trunk/Toss/WebClient/Login.js =================================================================== --- trunk/Toss/WebClient/Login.js 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/WebClient/Login.js 2012-02-05 01:24:07 UTC (rev 1663) @@ -166,8 +166,8 @@ } } -function login_onenter () { - if (window.event && window.event.keyCode == 13) { login() } +function login_onenter (ev) { + if (ev && ev.keyCode == 13) { login() } } // Logout Modified: trunk/Toss/WebClient/Main.js =================================================================== --- trunk/Toss/WebClient/Main.js 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/WebClient/Main.js 2012-02-05 01:24:07 UTC (rev 1663) @@ -202,7 +202,7 @@ par.completed_shown = false; } else { par.closed_play_list.style.display = "block"; - par.learn_button.style.display = "inline"; + //par.learn_button.style.display = "inline"; skip for now par.completed_button.innerHTML = "Completed games (Hide)"; par.completed_shown = true; } Modified: trunk/Toss/WebClient/Style.css =================================================================== --- trunk/Toss/WebClient/Style.css 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/WebClient/Style.css 2012-02-05 01:24:07 UTC (rev 1663) @@ -202,6 +202,7 @@ } .loginput { + font-size: 0.8em; border-color: #fff1d4; border-radius: 4px; -moz-border-radius: 4px; @@ -234,6 +235,7 @@ } .play_select { + display: none; position: relative; top: -0.1em; color: #260314; @@ -249,12 +251,14 @@ } .play_select_opt { + display: none; color: #260314; background-color: #fff1d4; border-width: 0px; } .play_learn { + display: none; color: #260314; font-family: Verdana, 'TeXGyreHerosRegular', sans; font-size: 0.8em; @@ -297,6 +301,7 @@ } #loginbt { + font-size: 0.8em; position: relative; top: -2px; font-weight: bold; @@ -336,13 +341,13 @@ #login2 { position: absolute; top: 0px; - left: 18em; + left: 17em; } #login3 { position: absolute; top: 0.3em; - left: 28em; + left: 27em; } #logo { Modified: trunk/Toss/WebClient/index.html =================================================================== --- trunk/Toss/WebClient/index.html 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/WebClient/index.html 2012-02-05 01:24:07 UTC (rev 1663) @@ -35,12 +35,12 @@ <form id="loginform" style="display: inline;" action=""> <div id="login1"> <p class="loginsmall">Username:</p> -<input class="loginput" type="text" name="username" id="username" size="15" /> +<input class="loginput" type="text" name="username" id="username" size="12" /> </div> <div id="login2"> <p class="loginsmall">Password:</p> -<input class="loginput" type="password" name="password" id="password" size="15" - onkeypress="login_onenter()" /> +<input class="loginput" type="password" name="password" id="password" size="12" + onkeypress="login_onenter(event)" /> </div> <div id="login3"> <p class="loginchk"> @@ -177,6 +177,15 @@ <div id="news"> <h3>News</h3> <ul id="welcome-list-news" class="welcome-list"> +<li><b>04/02/12</b> Definitions use play history: new Chess toss file</li> +<li><b>02/02/12</b> Improved stand-alone JS interface with menhirLib</li> +<li><b>31/01/12</b> First stand-alone JS interface (with js_of_ocaml)</li> +<li><b>22/01/12</b> Learning Connect4 and Gomoku from videos</li> +<li><b>21/01/12</b> Learning Breakthrough and Pawn-Whopping videos</li> +<li><b>17/01/12</b> Integrating game learning logic and video stuff</li> +<li><b>06/01/12</b> Parametrized grid detection for video</li> +<li><b>28/12/11</b> Game video recognition improved with Hough lines</li> +<li><b>10/12/11</b> Starting work on game recognition from video</li> <li><b>24/10/11</b> Learning games from examples in web interface</li> <li><b>19/10/11</b> Games learning engine and first buttons in the UI</li> <li><b>14/09/11</b> Simple editing of games added to web interface</li> Modified: trunk/Toss/WebClient/profile.html =================================================================== --- trunk/Toss/WebClient/profile.html 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/WebClient/profile.html 2012-02-05 01:24:07 UTC (rev 1663) @@ -25,11 +25,11 @@ <form id="loginform" style="display: inline;" action=""> <div id="login1"> <p class="loginsmall">Username:</p> -<input class="loginput" type="text" name="username" id="username" size="15" /> +<input class="loginput" type="text" name="username" id="username" size="12" /> </div> <div id="login2"> <p class="loginsmall">Password:</p> -<input class="loginput" type="password" name="password" id="password" size="15" +<input class="loginput" type="password" name="password" id="password" size="12" onkeypress="login_onenter()" /> </div> <div id="login3"> Modified: trunk/Toss/www/create.xml =================================================================== --- trunk/Toss/www/create.xml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/www/create.xml 2012-02-05 01:24:07 UTC (rev 1663) @@ -12,132 +12,6 @@ <link id="create" href="/create.html">Create</link> </history> - - <section title="Two Ways to Create a New Game" lang="en"> - <par>When you are done playing the games already defined in Toss, it's - time to start the real fun – create your own game! - There are two ways to create a game in Toss.</par> - <itemize> - <item>You can use the GUI to edit and create games.</item> - <item>You can edit the .toss files directly.</item> - </itemize> - <par>If you plan to make small changes or an easy experiment, the GUI might - be the better option. For larger or completely new games, it is more - convenient to edit the files in your favorite text editor.</par> - </section> - - <section title="Zwei Methoden um ein neues Spiel in Toss zu erzeugen" - lang="de"> - <par>Wenn man genug online gespielt hat, kann man mit dem wirklichen - Spass in Toss anfangen und ein neues Spiel erschaffen. Zwei Wege - kann man dazu nutzen.</par> - <itemize> - <item>Die Toss GUI erlaubt es, Spiele zu erzeugen.</item> - <item>Die .toss Files kann man auch direkt editieren.</item> - </itemize> - <par>Um kleine Änderungen zu machen oder ein einfaches Beispiel zu - definieren kann man die GUI benutzen. Um kompliziertere Spiele zu - erzeugen und ganz neue Ideen zu realisieren ist es bequemer, die .toss - Files direkt in einem Editor zu bearbeiten.</par> - </section> - - <section title="Dwa Sposoby Tworzenia Nowych Gier w Tossie" lang="pol"> - <par>Gdy już znudzi Ci się granie online, czas na prawdziwą zabawę - z Tossem – stwórz swoją własną grę! W Tossie są dwa sposoby - na tworzenie własnych gier.</par> - <itemize> - <item>Można użyć interfejsu graficznego Tossa (GUI).</item> - <item>Możliwa jest też bezpośrednia edycja plików .toss.</item> - </itemize> - <par>Do małych zmian i prostych eksperymentów wystarczy użycie GUI, - natomiast dla nowych i bardziej skomplikowanych gier wygodniej jest - bezpośrednio edytować pliki .toss w edytorze tekstu.</par> - </section> - - <section title="Deux Façons de Créer un Nouveau Jeu" lang="fr"> - <par>Si vous avez fini de jouer les jeux déjà définis dans Toss, - il est temps de commencer le vrai plaisir – créez votre propre jeu! - Il y a deux façons de créer un jeu dans Toss.</par> - <itemize> - <item>Vous pouvez utiliser l'interface graphique pour éditer - et créer des jeux.</item> - <item>Vous pouvez éditer les fichiers .toss directement.</item> - </itemize> - <par>Si vous prévoyez de faire de petits changements ou une jeu facile, - l'interface graphique pourrait être la meilleure option. Pour les - grandes ou complètement nouveaux jeux, il est plus commode de modifier - les fichiers dans votre éditeur de texte favori.</par> - </section> - - - <section title="Creating Games the in the Toss GUI" lang="en"> - <par>To start the Toss GUI do the following.</par> - <itemize> - <item><em>Download</em> Toss from the - <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> - SourceForge Download Page</a>.</item> - <item><em>Run Toss</em> by clicking <em>Toss.py</em>. - You can start by opening a file from the <em>examples</em> - directory.</item> - </itemize> - <par>When you have the GUI running, we recommend that you watch the - <a href="http://vimeo.com/10110495">Toss Tutorial</a> below, which - shows all the steps needed to define a simple game in Toss and explains - several other features.<br/></par> - <par><br/><toss-video/></par> - </section> - <section title="Spiele in das Toss GUI Erzeugen" lang="de"> - <par>Um die Toss GUI zu starten, muss man:</par> - <itemize> - <item>Toss <em>runterladen</em> von der - <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> - SourceForge Seite</a>.</item> - <item><em>Toss ausführen</em>, indem man auf <em>Toss.py</em> clickt. - Man kann am Anfang einer der Files im <em>examples</em> Verzeichnis - öffnen.</item> - </itemize> - <par>Wenn die GUI schon läuft, kann man am besten das - <a href="http://vimeo.com/10110495">Toss Tutorial</a> unten angucken, - wo gezeigt wird, wie man ein einfaches Spiel in Toss vollständig - definiert und auch andere Features erklärt sind.<br/></par> - <par><br/><toss-video/></par> - </section> - <section title="Tworzenie Gier w Interfejsie Graficznym Tossa" lang="pol"> - <par>Aby uruchomić interfejs graficzny Tossa:</par> - <itemize> - <item><em>Ściągnij</em> Tossa ze - <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> - strony SourceForge</a>.</item> - <item><em>Uruchom Tossa</em> klikając na <em>Toss.py</em>. - Na początek najlepiej otworzyć przykład z katalogu <em>examples</em>. - </item> - </itemize> - <par>Gdy GUI Tossa już działa, polecamy obejrzeć i wykonać poniższy - <a href="http://vimeo.com/10110495">Toss Tutorial</a>. - Pokazane tam są wszystkie kroki do zdefiniowania prostej gry w Tossie, - a także wyjaśnione niektóre bardziej zaawansowane możliwości.<br/></par> - <par><br/><toss-video/></par> - </section> - <section title="Créer des Jeux dans l'Interface Graphique de Toss" lang="fr"> - <par>Pour démarrer l'interface graphique de Toss, procédez comme suit.</par> - <itemize> - <item><em>Téléchargez</em> Toss sur la - <a href="http://sourceforge.net/project/showfiles.php?group_id=115606"> - SourceForge Télécharger Site</a>.</item> - <item><em>Exécutez Toss</em> en cliquant <em>Toss.py</em>. - Vous pouvez commencer par l'ouverture d'un fichier dans du répertoire - <em>examples</em>.</item> - </itemize> - <par> - Lorsque vous avez le bon GUI, nous vous recommandons de regarder le - <a href="http://vimeo.com/10110495">Toss Tutoriel</a> ci-dessous, - qui montre toutes les étapes nécessaires pour définir un jeu simple - en Toss et explique plusieurs autres fonctions. - <br/></par> - <par><br/><toss-video/></par> - </section> - - <section title="Creating Games in your Text Editor" lang="en"> <par>For larger games, we find it easier to edit them in text form than from the GUI. To understand the meaning of the fields @@ -148,9 +22,9 @@ simply edit the .toss file, maybe starting with one of these. </par> <itemize> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss?revision=1349">Chess</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss?revision=1349">Tic-Tac-Toe</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss">Breakthrough</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss">Chess</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss">Tic-Tac-Toe</a></item> </itemize> </section> <section title="Spiele in Text Form erschaffen" lang="de"> @@ -165,9 +39,9 @@ bearbeiten, mit einer des folgenden kann man gut anfangen. </par> <itemize> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss?revision=1349">Chess</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss?revision=1349">Tic-Tac-Toe</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss">Breakthrough</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss">Chess</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss">Tic-Tac-Toe</a></item> </itemize> </section> <section title="Tworzenie Gier w Edytorze Tekstu" lang="pol"> @@ -181,9 +55,9 @@ edytować pliki .toss, być może zaczynając od jednego z tych. </par> <itemize> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss?revision=1349">Chess</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss?revision=1349">Tic-Tac-Toe</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss">Breakthrough</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss">Chess</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss">Tic-Tac-Toe</a></item> </itemize> </section> <section title="La Création de Jeux dans l'Éditeur de Texte" lang="fr"> @@ -197,9 +71,9 @@ éditer le fichier .toss, peut-être en commençant par l'un de ces. </par> <itemize> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss?revision=1349">Chess</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss?revision=1349">Tic-Tac-Toe</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss">Breakthrough</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss">Chess</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss">Tic-Tac-Toe</a></item> </itemize> </section> Modified: trunk/Toss/www/develop.xml =================================================================== --- trunk/Toss/www/develop.xml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/www/develop.xml 2012-02-05 01:24:07 UTC (rev 1663) @@ -40,10 +40,6 @@ </item> <item>In the Toss directory run <em>make</em> and check that it succeeds.</item> - <item>Go through our <a href="/ocaml.html">Mini OCaml Tutorial</a> to - see how we organise OCaml code in general.</item> - <item>In the <a href="/codebasics.html">Toss Code Basics Tutorial</a> you - will learn to code basic operations with Toss.</item> </itemize> </section> <section title="Vorbereitung" lang="de"> @@ -75,10 +71,6 @@ </item> <item>Führe <em>make</em> aus im Toss Verzeichnis und überprüfe, dass es erfolgreich funktioniert hat.</item> - <item>Unser <a href="/ocaml.html">Mini OCaml Tutorial</a> zeigt, - wie wir OCaml Code organisieren.</item> - <item>Das <a href="/codebasics.html">Toss Code Basics Tutorial</a> zeigt, - wie man einfache Toss-Funktionen ausführt.</item> </itemize> </section> <section title="Przygotowanie" lang="pol"> @@ -109,10 +101,6 @@ </item> <item>W katalogu Toss uruchom <em>make</em> i sprawdź czy dobrze zadziałało.</item> - <item>Nasz <a href="/ocaml.html">Mini OCaml Tutorial</a> pokazuje, - jak organizujemy kod OCamla.</item> - <item><a href="/codebasics.html">Toss Code Basics Tutorial</a> pokazuje - podstawowe wywołania funkcji Tossa.</item> </itemize> </section> <section title="Préparation" lang="fr"> @@ -141,10 +129,48 @@ </item> <item>Dans le répertoire Toss exécuter <em>make</em> et vérifier que c'est bien.</item> + </itemize> + </section> + + + <section title="Tutorials" lang="en"> + <itemize> + <item>Visit <a href="http://try.ocamlpro.com">try.ocamlpro.com</a> + to refresh your basic OCaml skills.</item> + <item>Go through our <a href="/ocaml.html">Mini OCaml Tutorial</a> to + see how we organise OCaml code in general.</item> + <item>In the <a href="/codebasics.html">Toss Code Basics Tutorial</a> you + will learn to code basic operations with Toss.</item> + </itemize> + </section> + <section title="Tutorials" lang="de"> + <itemize> + <item>Besuche <a href="http://try.ocamlpro.com">try.ocamlpro.com</a> + um die Grundlagen von OCaml zu lernen.</item> + <item>Unser <a href="/ocaml.html">Mini OCaml Tutorial</a> zeigt, + wie wir OCaml Code organisieren.</item> + <item>Das <a href="/codebasics.html">Toss Code Basics Tutorial</a> zeigt, + wie man einfache Toss-Funktionen ausführt.</item> + </itemize> + </section> + <section title="Tutoriale" lang="pol"> + <itemize> + <item>Na <a href="http://try.ocamlpro.com">try.ocamlpro.com</a> + możesz szybko nauczyć się OCamla na przykładach.</item> + <item>Nasz <a href="/ocaml.html">Mini OCaml Tutorial</a> pokazuje, + jak organizujemy kod OCamla.</item> + <item><a href="/codebasics.html">Toss Code Basics Tutorial</a> pokazuje + podstawowe wywołania funkcji Tossa.</item> + </itemize> + </section> + <section title="Tutoriaux" lang="fr"> + <itemize> + <item>Visitez <a href="http://try.ocamlpro.com">try.ocamlpro.com</a> + pour actualiser vos compétences en OCaml.</item> <item>Notre <a href="/ocaml.html">Mini OCaml Tutorial</a> montre - comment nous organiser le code OCaml.</item> + comment nous organiser le code OCaml.</item> <item>Le <a href="/codebasics.html">Toss Code Basics Tutorial</a> montre - comment on utilise les fonctions de base Toss.</item> + comment on utilise les fonctions de base Toss.</item> </itemize> </section> Modified: trunk/Toss/www/docs.xml =================================================================== --- trunk/Toss/www/docs.xml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/www/docs.xml 2012-02-05 01:24:07 UTC (rev 1663) @@ -14,28 +14,19 @@ <section title="Using Toss" lang="en"> <par>If you want to learn how to use Toss to create games, - go to the <a href="create.html">Create Games</a> page - or just watch the video tutorial below to get started.<br/></par> - <par><br/><toss-video/></par> + go to the <a href="create.html">Create Games</a> page.</par> </section> <section title="Toss Benutzen" lang="de"> <par>Um zu lernen, wie man Toss benutzt um neue Spiele zu erschaffen, - besuche die <a href="create.html">Neue Spiele Erzeugen</a> Seite oder - fange mit dem Video Tutorial unten an.<br/></par> - <par><br/><toss-video/></par> + besuche die <a href="create.html">Neue Spiele Erzeugen</a> Seite.</par> </section> <section title="Używanie Tossa" lang="pol"> <par>Żeby nauczyć się tworzyć gry w Tossie najlepiej odwiedzić stronę - o <a href="create.html">Tworzeniu Nowych Gier</a> albo szybko obejrzeć - poniższy tutorial.<br/></par> - <par><br/><toss-video/></par> + o <a href="create.html">Tworzeniu Nowych Gier</a>.</par> </section> <section title="Utilisation de Toss" lang="fr"> <par>Si vous voulez apprendre à utiliser Toss pour créer des jeux, - aller à la <a href="create.html">Créez des Jeux</a> site ou - simplement regarder la vidéo tutoriel ci-dessous pour commencer. - <br/></par> - <par><br/><toss-video/></par> + aller à la <a href="create.html">Créez des Jeux</a> site.</par> </section> @@ -43,34 +34,26 @@ <par>The Toss Design and Specification reference is an evolving document in which we try to describe the high-level mathematical model of Toss and the main ideas used in the implementation. The document is best - viewed as <a href="reference/reference.pdf">reference.pdf</a> but - a <a href="reference/">html version</a> is available as well - for fast fact-checking.</par> + viewed as <a href="reference/reference.pdf">reference.pdf</a>.</par> </section> <section title="Referenz" lang="de"> <par><em>Toss Design and Specification</em> ist ein ständig aktuliesiertes Dokument, in dem wir versuchen, eine Übersicht über die mathematische Grundlagen von Toss und die Hauptideen der Algorithmen, die wir implementiert haben, zu geben. Es ist am besten als - <a href="reference/reference.pdf">reference.pdf</a> zu lesen, aber - eine <a href="reference/">html Version</a> mit niedrigerer Qualität - steht auch zur Verfügung, falls man etwas ganz schnell finden muss.</par> + <a href="reference/reference.pdf">reference.pdf</a> zu lesen.</par> </section> <section title="Opis" lang="pol"> <par>"Toss Design and Specification" to ciągle zmieniający się dokument, w którym próbujemy opisać matematyczny model Tossa i najważniejsze idee i algorytmy użyte w implementacji. Najlepiej oglądać ten opis - jako <a href="reference/reference.pdf">reference.pdf</a>, ale wersja - <a href="reference/">html</a> w niższej jakości też jest dostępna gdy - trzeba coś szybko sprawdzić.</par> + jako <a href="reference/reference.pdf">reference.pdf</a>.</par> </section> <section title="Référence" lang="fr"> <par>Le Toss Design et Spécification est un document dans lequel nous essayons de décrire le modèle mathématique de Toss et les idées principales utilisées dans Toss. Le document est le meilleur lire - comme <a href="reference/reference.pdf">Reference.pdf</a>, mais - une <a href="reference/">version html</a> est disponible ainsi, - pour vérifier les faits rapidement.</par> + comme <a href="reference/reference.pdf">Reference.pdf</a>.</par> </section> Modified: trunk/Toss/www/examples.xml =================================================================== --- trunk/Toss/www/examples.xml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/www/examples.xml 2012-02-05 01:24:07 UTC (rev 1663) @@ -158,12 +158,12 @@ <section> <itemize> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss?revision=1349">Breakthrough</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Checkers.toss?revision=1349">Checkers</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss?revision=1349">Chess</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Connect4.toss?revision=1349">Connect4</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Gomoku.toss?revision=1349">Gomoku</a></item> - <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss?revision=1349">Tic-Tac-Toe</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Breakthrough.toss">Breakthrough</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Checkers.toss">Checkers</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Chess.toss">Chess</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Connect4.toss">Connect4</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Gomoku.toss">Gomoku</a></item> + <item><a href="http://toss.svn.sourceforge.net/viewvc/toss/trunk/Toss/examples/Tic-Tac-Toe.toss">Tic-Tac-Toe</a></item> </itemize> </section> Deleted: trunk/Toss/www/gui_interface.xml =================================================================== --- trunk/Toss/www/gui_interface.xml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/www/gui_interface.xml 2012-02-05 01:24:07 UTC (rev 1663) @@ -1,141 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE lecture SYSTEM "xsl/xhtml1-lat1.ent"> - -<?xml-stylesheet type="text/xsl" href="xsl/main.xsl" charset="UTF-8"?> - -<personal> - <title lang="en">GUI Interface Guide</title> - <title lang="de">GUI Interface Guide (auf Englisch)</title> - <title lang="pol">GUI Interface Guide (po angielsku)</title> - <title lang="fr">Guide de Interface Graphique (à anglais)</title> - <history> - <link id="create" href="/create.html">Create New Games</link> - <link id="examples" href="/examples.html">Examples</link> - </history> - - - - <section title="Changing Elements"> - <itemize> - <item> - <image src="move.png" title="hand"/> - <em>The move cursor</em> can shift the whole structure (your view-point) - and give more information about elements when you hover over them - (such as name, position and speed of the element). - </item> - - <item> - <image src="draw.png" title="pointer"/> - <em>The pointer</em> can be used for three things: - <itemize> - <item>adding new elements (click on the desired spot and a circle - appears)</item> - <item>selecting and deselecting existing elements - (circle becomes disc when selected)</item> - <item>moving elements (when these are selected)</item> - </itemize> - </item> - - <item> - <image src="erase.png" title="eraser"/> - <em>The eraser</em> has two functions: - <itemize> - <item>removing an element (click on the desired circle - or disc)</item> - <item>removing a relation between elements (click on the arrow - between two elements).</item> - </itemize> - </item> - - <item> - <image src="redraw.png" title="redraw"/> - <em>The redraw button</em> should be used whenever the picture - becomes garbled. As you can imagine an overcrowded region with - many inter-crossing arrows may easily become messed up. - </item> - </itemize> - </section> - - <section title="Editing Relations"> - <par>In the <em>Relations</em> panel you can create a new relation by - clicking <em>New</em>.</par> - - <par>Establishing relations between existing elements is done - with the pointer:</par> - <itemize> - <item>In order to establish a unary relation, select exactly one element - with the pointer and then click the name of the unary relation.</item> - <item>In order to establish a binary relation, select exactly - two elements with the pointer keeping in mind which of the elements - is selected first (relations are not reflexive by default) and - click the name of the relation.</item> - <item>In a similar way you can create relations with arbitrary - arity.</item> - </itemize> - </section> - - <section title="Adding and Applying Rules"> - <itemize> - <item> - <image src="add_rule.png" title="add rule"/> - <em>The add rule</em> button is used to declare a new rewrite rule. - </item> - - <item>For moving, you can use the - <em>Match</em>, <em>Apply</em>, <em>Hint</em>, and - <em>Toss</em>, <em>Toss Run</em>, and <em>Hint Run</em> buttons. - </item> - - <item><image src="match.png" title="match"/> - <em>The match button</em> - finds an embedding of the left-hand model from a rewrite rule in one - of currently allowed moves into the main model and marks it in red. - There may be many such embeddings. Pressing Match repeatedly switches to - another embedding (similarly to the <em>Find Next</em> function - in text editors). - </item> - - <item><image src="rewrite.png" title="rewrite"/> - <em>The apply button</em> - applies the rewrite rule according to the embedding previously marked - in red. Note that players can also match and apply a rule using mouse - gestures: for this write appropriate shape in the - <em>Matching Shape</em> field of a rule (basic shapes like circle, - line, square, triangle etc. are recognized). - </item> - - <item><image src="move.png" title="hint"/> - <em>The hint button</em> - can be used to get move suggestion from our AI engine. - Increase the number of iterations to improve the quality of hints, - and decrease it if getting a hint takes too much time. - </item> - - <item><image src="toss.png" title="toss"/> - <em>The toss button</em> finds a random move and applies it.</item> - - <item><image src="run_toss.png" title="toss run"/> - <em>The toss run button</em> repeats the function of the toss button - a prescribed number of times.</item> - - <item><image src="run_hint.png" title="hint run"/> - <em>The hint run button</em> repeats taking a hint and applying it - a prescribed number of times.</item> - </itemize> - </section> - - <section title="What happens after a rewrite rule is applied"> - <itemize> - <item>The marked elements move as prescribed by the differential equations - in the rule <em>Dynamics</em> panel.</item> - <item>The elements marked in red are removed.</item> - <item>Elements from the right-hand model are added, preserving their own - relations.</item> - <item>Relations previously going to the left elements are connected to - the new right elements as prescribed by the <em>Correspondence</em> - field of the rule.</item> - <item>Values like position and speed are updated as given by - the <em>Update</em> equations in the rule.</item> - </itemize> - </section> -</personal> Modified: trunk/Toss/www/img/Breakthrough.png =================================================================== (Binary files differ) Modified: trunk/Toss/www/img/Checkers.png =================================================================== (Binary files differ) Modified: trunk/Toss/www/img/Connect4.png =================================================================== (Binary files differ) Modified: trunk/Toss/www/img/Gomoku.png =================================================================== (Binary files differ) Modified: trunk/Toss/www/img/Pawn-Whopping.png =================================================================== (Binary files differ) Modified: trunk/Toss/www/img/Tic-Tac-Toe.png =================================================================== (Binary files differ) Modified: trunk/Toss/www/index.xml =================================================================== --- trunk/Toss/www/index.xml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/www/index.xml 2012-02-05 01:24:07 UTC (rev 1663) @@ -52,57 +52,38 @@ <games-section> <game-div> - <game-link game="Breakthrough"/> - <game-link game="Checkers"/> + <game-link game="Pawn-Whopping"/> <game-link game="Connect4"/> + <game-link game="Breakthrough"/> </game-div> <game-div> <game-link game="Gomoku"/> - <game-link game="Pawn-Whopping"/> + <game-link game="Checkers"/> <game-link game="Tic-Tac-Toe"/> </game-div> </games-section> <section title="Create New Games" lang="en"> - <par>The <a href="http://vimeo.com/10110495">Toss Tutorial</a> below - shows all the steps needed to define a simple game in Toss and explains - several other features. With Toss, you can make your game ideas come - true! Go to the <a href="create.html">Create Games</a> page to learn - how to build new games with Toss. - <br/></par> - <par><br/><toss-video/></par> + <par>Go to the <a href="create.html.en">Create Games</a> page to learn + how to build new games with Toss.</par> </section> <section title="Neue Spiele Erzeugen" lang="de"> - <par>Das <a href="http://vimeo.com/10110495">Toss Tutorial</a> unten - zeigt, wie man in Toss ein einfaches Spiel definieren kann, und - erklärt auch einige andere Features von Toss. Mit Toss ist es möglich, - Deine Spielideen zu realisieren! Lerne wie man mit Toss neue - <a href="create.html">Spiele erzeugt.</a> - <br/></par> - <par><br/><toss-video/></par> + <par> + Lerne wie man mit Toss neue <a href="create.html.de">Spiele erzeugt.</a> + </par> </section> <section title="Stwórz Nową Grę" lang="pol"> - <par><a href="http://vimeo.com/10110495">Tutorial Tossa</a> poniżej - pokazuje, jak zdefiniować prostą grę w Kółko i Krzyżyk w Tossie, - wyjaśnia też inne możliwości Tossa. Dzięki Tossowi możesz zrealizować - swój pomysł na nową grę! Zobacz poniższą stronę i dowiedz się jak - <a href="create.html">stworzyć nową grę</a>. - <br/></par> - <par><br/><toss-video/></par> + <par>Zobacz jak <a href="create.html.pol">stworzyć nową grę</a>.</par> </section> <section title="Créez de Noveaux Jeux" lang="fr"> - <par>Le <a href="http://vimeo.com/10110495">Toss Tutoriel</a> ci-dessous - montre toutes les étapes nécessaires pour définir un jeu simple en Toss, - et il explique plusieurs autres caractéristiques aussi. Avec Toss, - vous pouvez réaliser de vos idées de jeu! - Visitez le site <a href="create.html">Créer des Jeux</a> pour en savoir + <par> + Visitez le site <a href="create.html.fr">Créer des Jeux</a> pour en savoir comment on construit de nouveaux jeux avec Toss. - <br/></par> - <par><br/><toss-video/></par> + </par> </section> Modified: trunk/Toss/www/navigation.xml =================================================================== --- trunk/Toss/www/navigation.xml 2012-02-04 01:07:09 UTC (rev 1662) +++ trunk/Toss/www/navigation.xml 2012-02-05 01:24:07 UTC (rev 1663) @@ -9,14 +9,11 @@ <item href="http://sourceforge.net/project/showfiles.php?group_id=115606" >Download Toss</item> <menu title="Create Games" href="/create.html" id="create"> - <item href="http://vimeo.com/10110495" id="tut">Video Tutorial</item> <item href="/examples.html" id="examples">Examples</item> - <item href="/gui_interface.html" id="gui_interface">GUI Interface Guide</item> </menu> <item href="/play.html" id="play">Watch Toss Play</item> <menu title="Documentation" href="/docs.html" id="docs"> <item href="/reference/reference.pdf" id="refpdf">Reference (pdf)</item> - <item href="/reference/" id="refhtml">Reference (html)</item> </menu> <item href="/Publications/" id="Publications">Papers and Talks</item> <menu title="Develop Toss" href="/develop.html" id="develop"> @@ -35,14 +32,11 @@ <item href="http://sourceforge.net/project/showfiles.php?group_id=115606" >Toss Runterladen</item> <menu title="Spiele Erzeugen" href="/create.html" id="create"> - <item href="http://vimeo.com/10110495" id="tut">Video Tutorial</item> <item href="/examples.html" id="examples">Beispiele</item> - <item href="/gui_interface.html" id="gui_interface">GUI Interface Guide</item> </menu> <item href="/play.html" id="play">Wie Toss Spielt</item> <menu title="Dokumentation" href="/docs.html" id="docs"> <item href="/reference/reference.pdf" id="refpdf">Referenz (pdf)</item> - <item href="/reference/" id="refhtml">Referenz (html)</item> </menu> <item href="/Publications/" id="Publications">Papers und Talks</item> <menu title="Toss Programmieren" href="/develop.html" id="develop"> @@ -61,14 +55,11 @@ <item href="http://sourceforge.net/project/showfiles.php?group_id=115606" >Ściągnij Tossa</item> <menu title="Twórz Nowe Gry" href="/create.html" id="create"> - <item href="http://vimeo.com/10110495" id="tut">Tutorial Video</item> <item href="/examples.html" id="examples">Przykłady</item> - <item href="/gui_interface.html" id="gui_interface">Interfejs GUI</item> </menu> <item href="/play.html" id="play">Jak Toss Gra</item> <menu title="Dokumentacja" href="/docs.html" id="docs"> <item href="/reference/reference.pdf" id="refpdf">Opis (pdf)</item> - <item href="/reference/" id="refhtml">Opis (html)</item> </menu> <item href="/Publications/" id="Publications">Prace i Referaty</item> <menu title="Programuj Tossa" href="/develop.html" id="develop"> @@ -87,15 +78,11 @@ <item href="http://sourceforge.net/project/showfiles.php?group_id=115606" >Téléchargez Toss</item> <menu title="Créez des Jeux" href="/create.html" id="create"> - <item href="http://vimeo.com/10110495" id="tut">Vidéo Tutoriel</item> <item href="/examples.html" id="examples">Exemples</item> - <item href="/gui_interface.html" id="gui_interface"> - Interface Graphique</item> </menu> <item href="/play.html" id="play">Regardez Toss Jouer</item> <menu title="Documentation" href="/docs.html" id="docs"> <item href="/reference/reference.pdf" id="refpdf">Référence (pdf)</item> - <item href="/reference/" id="refhtml">Référence (html)</item> </menu> <item href="/Publications/" id="Publications">Papiers, Entretiens</item> <menu title="Développez Toss" href="/develop.html" id="develop"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-04 01:07:16
|
Revision: 1662 http://toss.svn.sourceforge.net/toss/?rev=1662&view=rev Author: lukaszkaiser Date: 2012-02-04 01:07:09 +0000 (Sat, 04 Feb 2012) Log Message: ----------- Allow play history reference in rule preconditions, shorten chess definition. Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/Arena/Arena.mli trunk/Toss/Arena/ArenaParser.mly trunk/Toss/Arena/ContinuousRule.ml trunk/Toss/Arena/ContinuousRuleParser.mly trunk/Toss/Arena/DiscreteRule.ml trunk/Toss/Arena/DiscreteRule.mli trunk/Toss/Arena/DiscreteRuleParser.mly trunk/Toss/Arena/DiscreteRuleTest.ml trunk/Toss/Formula/Lexer.mll trunk/Toss/Formula/Tokens.mly trunk/Toss/Makefile trunk/Toss/Play/Move.ml trunk/Toss/Server/ReqHandler.ml trunk/Toss/examples/Chess.toss Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/Arena.ml 2012-02-04 01:07:09 UTC (rev 1662) @@ -374,6 +374,24 @@ let equational_def_style = ref true +let fprint_game_move f ({mv_time = t; parameters = pl; rule = rn; + next_loc = l; matching = m}, rtime) = + let m_s = String.concat ", " + (List.map (fun (e, x) -> Printf.sprintf "%s: %i" e x) m) in + let rt = match rtime with None -> "" | Some f -> " " ^ (string_of_float f) in + if (pl = []) then + Format.fprintf f "@[<1>[%s@ %F@ ->@ %i@ emb@ %s]%s@]" rn t l m_s rt + else ( + let p_s = String.concat ", " + (List.map (fun (p, v) -> Printf.sprintf "%s: %F" p v) pl) in + Format.fprintf f "@[<1>[%s@ %F,@ %s@ ->@ %i@ emb@ %s]%s@]" rn t p_s l m_s rt + ) + +let sprint_game_move gm = + ignore (Format.flush_str_formatter ()); + fprint_game_move Format.str_formatter gm; + Format.flush_str_formatter () + let fprint_state_full print_compiled_rules ppf ({rules = rules; graph = graph; @@ -385,6 +403,7 @@ {struc = struc; time = time; cur_loc = cur_loc; + history = hist; }) = Format.fprintf ppf "@[<v>"; List.iter (fun (drel, (args, body)) -> @@ -414,6 +433,9 @@ loc_id (fprint_loc_body struc player_names) loc) graph; Format.fprintf ppf "@[<1>MODEL@ %a@]@ " (Structure.fprint ~show_empty:true) struc; + if (hist <> []) then + Format.fprintf ppf "@[<1>MOVES@ %a@]@ " + (Aux.fprint_sep_list ";\n" fprint_game_move) hist; if cur_loc <> 0 then Format.fprintf ppf "@[<1>STATE LOC@ %d@]@ " cur_loc; if time <> 0. then @@ -637,10 +659,11 @@ | GetTime (* Get time step and time *) | SetState of game * game_state (* Set the full state *) | GetState (* Return the state *) - | SetModel of Structure.structure (* Set the model *) - | GetModel (* Return the current model*) + | GetModel (* Return model+history *) + | SetModel of Structure.structure * (move * float option) list (* Set above *) + (* --------------------------- REQUEST HANDLER ------------------------------ *) (* Apply function [f] to named structure at location [loc] in [state]. @@ -942,7 +965,7 @@ {d with DiscreteRule.match_formula = pre} | Some rule_src -> DiscreteRule.compile_rule signat defs - {rule_src with DiscreteRule.pre = pre} in + {rule_src with DiscreteRule.pre = (pre, []) } in let nr = (* TODO: rename lhs_* relations to be consistent with ln *) ContinuousRule.make_rule defs discr dyn upd ~inv ~post () in (nr, "RULE COND SET") in @@ -953,7 +976,7 @@ let pre = match discr.DiscreteRule.struc_rule with | None -> discr.DiscreteRule.match_formula - | Some struc_r -> struc_r.DiscreteRule.pre in + | Some struc_r -> fst struc_r.DiscreteRule.pre in let (inv, post)=(r.ContinuousRule.inv, r.ContinuousRule.post) in (Formula.str pre)^"; "^ (Formula.str inv) ^"; "^ (Formula.str post) in ((state_game, state), @@ -1042,9 +1065,18 @@ get_from_rule get_assoc r_name state_game "get rule assoc") | GetRuleMatches (r_name) -> ( + let check_history_pre r hist = + match r.ContinuousRule.discrete.DiscreteRule.struc_rule with + | None -> true + | Some sr -> + let prev_list = snd (sr.DiscreteRule.pre) in + let constraint_satisfied (rname, b) = + List.exists (fun (mv, _) -> mv.rule = rname) hist = b in + List.for_all constraint_satisfied prev_list in try let r = List.assoc r_name state_game.rules in - let matches = ContinuousRule.matches_post struc r state.time in + let matches = if not (check_history_pre r state.history) then [] else + ContinuousRule.matches_post struc r state.time in (* matches are from LHS to model *) ((state_game, state), String.concat "; " ( @@ -1064,7 +1096,11 @@ (* we've moved to using element names in Term *) f ^ ", " ^ e ^ ", " ^ (String.concat ", " (List.map ts tl)) in let shifts_s = String.concat "; " (List.map val_str shifts) in - ((state_game, {state with struc = new_struc; time = new_time}), + let newmv = { mv_time = t; parameters = p; rule = r_name; + matching = m; next_loc = -1 (*FIX*) } in + let h = (newmv, None) :: state.history in + ((state_game, + {state with struc = new_struc; time = new_time; history = h}), shifts_s) | None -> ((state_game, state), "ERR applying "^r_name^", postcondition fails") @@ -1100,8 +1136,12 @@ | SetState (g, s) -> ((g, s), "STATE SET") | GetState -> ((state_game, state), state_str (state_game, state)) - | SetModel m -> ((state_game, { state with struc = m }), "MODEL SET") - | GetModel -> ((state_game, state), Structure.sprint state.struc) + | GetModel -> + let h_str = if state.history = [] then "" else "\nMOVES\n" ^ + (String.concat ";\n" (List.map sprint_game_move state.history)) in + ((state_game, state), (Structure.sprint state.struc) ^ h_str) + | SetModel (m, h) -> + ((state_game, { state with struc = m; history = h }), "MODEL SET") let can_modify_game = function Modified: trunk/Toss/Arena/Arena.mli =================================================================== --- trunk/Toss/Arena/Arena.mli 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/Arena.mli 2012-02-04 01:07:09 UTC (rev 1662) @@ -232,8 +232,9 @@ | GetTime (** Get time step and time *) | SetState of game * game_state (** Set the full state *) | GetState (** Return the state *) - | SetModel of Structure.structure (** Set the model *) - | GetModel (** Return the model *) + | GetModel (** Return model+history *) + | SetModel of Structure.structure * (move * float option) list + (** Set the model+history *) val handle_request : Modified: trunk/Toss/Arena/ArenaParser.mly =================================================================== --- trunk/Toss/Arena/ArenaParser.mly 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/ArenaParser.mly 2012-02-04 01:07:09 UTC (rev 1662) @@ -86,17 +86,21 @@ EQ body = formula_expr_err { (rel, args, body) } game_move_timed: - | OPENSQ RULE_SPEC? r = id_int COMMA? t = FLOAT COMMA? + | OPENSQ r = id_int t = FLOAT RARR l = INT EMB + emb = separated_list (COMMA, separated_pair (ID, COLON, INT)) CLOSESQ + { ({mv_time = t; parameters = []; rule = r; next_loc = l; matching = emb;}, + None) } + | OPENSQ r = id_int t = FLOAT COMMA p = separated_list (COMMA, separated_pair (ID, COLON, FLOAT)) - RARR LOC_MOD? l = INT EMB + RARR l = INT EMB emb = separated_list (COMMA, separated_pair (ID, COLON, INT)) CLOSESQ - f = FLOAT? + f = FLOAT { ({mv_time = t; parameters = p; rule = r; next_loc = l; matching = emb;}, - f) } + Some f) } | OPENSQ error - { Lexer.report_parsing_error $startpos $endpos + { Lexer.report_parsing_error $startpos $endpos "Syntax error in timed game move definition." - } + } game_defs: | RULE_SPEC rname = id_int COLON r = rule_expr @@ -149,6 +153,8 @@ | program = nonempty_list (game_defs) { process_definition program } +move_expr: + | ID { Arena.empty_move with rule = $1 } struct_location: | MODEL_SPEC { Struct } @@ -162,10 +168,14 @@ | SET_CMD STATE_SPEC gs=game_state { let (g, s) = gs in SetState (g, s) } | GET_CMD STATE_SPEC { GetState } | GET_CMD MODEL_SPEC { GetModel } - | SET_CMD MODEL_SPEC struct_expr { SetModel $3 } + | SET_CMD MODEL_SPEC model = struct_expr + h = option (preceded (MOVES, separated_list (SEMICOLON, game_move_timed))) + { SetModel (model, match h with None -> [] | Some l -> l) } | SET_CMD MODEL_SPEC model = struct_expr WITH defs = separated_list (SEMICOLON, rel_def_simple) - { SetModel (Arena.add_def_rels model defs) } + h = option (preceded (MOVES, separated_list (SEMICOLON, game_move_timed))) + { SetModel (Arena.add_def_rels model defs, + match h with None -> [] | Some l -> l) } | ADD_CMD ELEM_MOD struct_location { AddElem ($3) } | ADD_CMD REL_MOD Modified: trunk/Toss/Arena/ContinuousRule.ml =================================================================== --- trunk/Toss/Arena/ContinuousRule.ml 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/ContinuousRule.ml 2012-02-04 01:07:09 UTC (rev 1662) @@ -214,9 +214,8 @@ let rewrite_single struc cur_time m r t params = let (res_struc, _, _ as res_struc_n_shifts) = rewrite_single_nocheck struc cur_time m r t params in - if r.post = Formula.And [] || - Solver.M.check res_struc r.post - then Some res_struc_n_shifts + if r.post = Formula.And [] || Solver.M.check res_struc r.post then + Some res_struc_n_shifts else None Modified: trunk/Toss/Arena/ContinuousRuleParser.mly =================================================================== --- trunk/Toss/Arena/ContinuousRuleParser.mly 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/ContinuousRuleParser.mly 2012-02-04 01:07:09 UTC (rev 1662) @@ -14,12 +14,20 @@ %% +constr_expr: + | ID { ($1, true) } + | NOT ID { ($2, false) } +precond_expr: + | formula_expr { ($1, []) } + | f = formula_expr AND BEFORE + l = separated_list (COMMA, constr_expr) { (f, l) } + %public rule_expr: | discr = discrete_rule_expr dyn = loption (preceded (DYNAMICS, eq_sys)) upd = loption (preceded (UPDATE, expr_eq_sys)) - pre = option (preceded (PRE, formula_expr)) + pre = option (preceded (PRE, precond_expr)) inv = option (preceded (INV, formula_expr)) post = option (preceded (POST, formula_expr)) { fun signat defs rname -> Modified: trunk/Toss/Arena/DiscreteRule.ml =================================================================== --- trunk/Toss/Arena/DiscreteRule.ml 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/DiscreteRule.ml 2012-02-04 01:07:09 UTC (rev 1662) @@ -15,7 +15,7 @@ rhs_struc : Structure.structure; (* optional tuples in _opt_R-relations *) emb_rels : string list; (* tau_e-relations, other tau_h *) rule_s : (int * int) list; (* map of [rhs] elements to [lhs] elements *) - pre : Formula.formula; (* Precondition for embedding *) + pre : Formula.formula * (string * bool) list; (* precondition *) } type var_tuples = string array list @@ -237,16 +237,17 @@ let map_to_formulas f r = + let f1 (a, l) = (f a, l) in {r with struc_rule = Aux.map_option - (fun discr -> {discr with pre = f discr.pre}) r.struc_rule; + (fun discr -> {discr with pre = f1 discr.pre}) r.struc_rule; match_formula = f r.match_formula} let fold_over_formulas f r acc = let acc = match r.struc_rule with | None -> acc - | Some r -> f r.pre acc in + | Some r -> f (fst r.pre) acc in let acc = f r.match_formula acc in acc @@ -917,7 +918,7 @@ lhs_neg_tups @ List.map (function [x;y] -> Not (Eq (`FO x, `FO y)) | _ -> assert false) lhs_alldif_tups @ - (FormulaOps.as_conjuncts rule_src.pre) + (FormulaOps.as_conjuncts (fst rule_src.pre)) ) in (* Substitute defined relations, expanding their special variants. *) @@ -1037,7 +1038,7 @@ List.map fst add_elems @ Aux.list_diff lhs_vars del_elems in let match_formula = match pre with | None -> match_formula - | Some pre -> Formula.And [match_formula; pre] in + | Some (pre, _) -> Formula.And [match_formula; pre] in let rlmap = if add_elems = [] && del_elems = [] then None @@ -1226,7 +1227,7 @@ rhs_struc = rhs_struc; emb_rels = emb_rels; rule_s = List.map (fun (_,i) ->i,i) struc_elems; - pre = precond; + pre = (precond, []); } @@ -1263,8 +1264,12 @@ let l_str = Structure.str r.lhs_struc in let r_str = Structure.str r.rhs_struc in let pre_str = - if r.pre = Formula.And [] then "" - else " pre " ^ (Formula.str r.pre) in + if (fst r.pre = Formula.And [] && snd r.pre = []) then "" else + let s = " pre " ^ (Formula.str (fst r.pre)) in + if snd r.pre = [] then s else + let before_str (name, b) = if b then name else "not " ^ name in + let before_s = String.concat ", " (List.map before_str (snd r.pre)) in + s ^ " and before " ^ before_s in l_str ^ " -> " ^ r_str ^ emb_str ^ assoc_str ^ pre_str let fprint_struc_rule f r = @@ -1282,10 +1287,13 @@ Format.fprintf f "@ @[<1>with@ [@,@[<1>%a@]@,]@]" (Aux.fprint_sep_list "," matched) r.rule_s; Format.fprintf f "@]"; - if r.pre <> Formula.And [] then - Format.fprintf f "@ @[<1>pre@ %a@]" Formula.fprint r.pre + if (fst r.pre <> Formula.And [] || snd r.pre <> []) then + Format.fprintf f "@ @[<1>pre@ %a@]" Formula.fprint (fst r.pre); + if (snd r.pre <> []) then + let before_str (name, b) = if b then name else "not " ^ name in + let before_s = String.concat ", " (List.map before_str (snd r.pre)) in + Format.fprintf f "@ @[<1>and before@ %s@]" before_s - let rel_tups_to_atoms rel_tups = Aux.concat_map (fun (rel, tups) -> @@ -1477,8 +1485,15 @@ Structure.compare_diff ~cmp_funs r1.rhs_struc r2.rhs_struc in if not eq then raise (Diff_result ( "Rule RHS structures differ: "^msg)); - let pre1 = Formula.flatten r1.pre in - let pre2 = Formula.flatten r2.pre in + if snd r1.pre <> snd r2.pre then ( + let before_str (name, b) = if b then name else "not " ^ name in + let before_s r = String.concat ", " (List.map before_str (snd r.pre)) in + raise (Diff_result (Printf.sprintf + "Rule preconditions BEFORE differ:\n%s\n =/=\n%s" + (before_s r1) (before_s r2))); + ); + let pre1 = Formula.flatten (fst r1.pre) in + let pre2 = Formula.flatten (fst r2.pre) in if pre1 <> pre2 then raise (Diff_result ( Printf.sprintf "Rule preconditions differ:\n%s\n =/=\n%s" (Formula.sprint pre1) (Formula.sprint pre2))); Modified: trunk/Toss/Arena/DiscreteRule.mli =================================================================== --- trunk/Toss/Arena/DiscreteRule.mli 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/DiscreteRule.mli 2012-02-04 01:07:09 UTC (rev 1662) @@ -19,7 +19,7 @@ rhs_struc : Structure.structure; (** optional tuples in _opt_R-relations *) emb_rels : string list; (** tau_e-relations, other tau_h *) rule_s : (int * int) list; (** map of [rhs] elements to [lhs] elems *) - pre : Formula.formula; (** Precondition for embedding *) + pre : Formula.formula * (string * bool) list; (** precondition *) } type var_tuples = string array list @@ -135,7 +135,7 @@ Formula.formula -> (string list * (string * string list) list) option -> ((string * string option) list * (string * string list) list) option -> - Formula.formula option -> rule + (Formula.formula * (string * bool) list) option -> rule (** Relations that can explicitly change state by rewriting (i.e. not as a result of erasure). (A "symmetric difference" of rule sides.) *) Modified: trunk/Toss/Arena/DiscreteRuleParser.mly =================================================================== --- trunk/Toss/Arena/DiscreteRuleParser.mly 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/DiscreteRuleParser.mly 2012-02-04 01:07:09 UTC (rev 1662) @@ -6,8 +6,8 @@ %start parse_discrete_rule %type <(string * int) list -> (string * (string list * Formula.formula)) list -> - Formula.formula option -> DiscreteRule.rule> - parse_discrete_rule discrete_rule_expr + (Formula.formula * (string * bool) list) option -> DiscreteRule.rule> + parse_discrete_rule discrete_rule_expr %% @@ -47,7 +47,7 @@ let base_struc = Structure.empty_with_signat signat in let lhs = lhs base_struc and rhs = rhs base_struc in let pre = - match pre with None -> Formula.And [] | Some pre -> pre in + match pre with None -> (Formula.And [], []) | Some pre -> pre in let struc_rule = { DiscreteRule.lhs_struc = lhs; rhs_struc = rhs; emb_rels = emb_rels; Modified: trunk/Toss/Arena/DiscreteRuleTest.ml =================================================================== --- trunk/Toss/Arena/DiscreteRuleTest.ml 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Arena/DiscreteRuleTest.ml 2012-02-04 01:07:09 UTC (rev 1662) @@ -132,7 +132,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = []; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -151,7 +151,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P";"Q"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -171,7 +171,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P";"Q"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -190,7 +190,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P";"R"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,2; 3,2]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -215,7 +215,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = []; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -234,7 +234,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P";"Q"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -254,7 +254,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P";"Q"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -273,7 +273,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P";"R"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,2; 3,2]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -298,7 +298,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = []; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -318,7 +318,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P";"Q"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -342,7 +342,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = []; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -361,7 +361,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P";"Q"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -385,7 +385,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = []; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -405,7 +405,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -430,7 +430,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = []; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -454,7 +454,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -474,7 +474,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["C"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,2]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -500,7 +500,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -520,7 +520,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = []; (* C is in $tau_h$ but loses e *) - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,2]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -540,7 +540,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["C"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -564,7 +564,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["R"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1; 2,2]} in let embs = find_matchings model rule_obj in assert_raises @@ -589,7 +589,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P"]; - pre = formula_of_str "not C(a)"; + pre = (formula_of_str "not C(a)", []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in assert_raises @@ -607,7 +607,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P"]; - pre = formula_of_str "not C(a)"; + pre = (formula_of_str "not C(a)", []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -630,7 +630,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["P"]; - pre = formula_of_str "not C(a)"; + pre = (formula_of_str "not C(a)", []); rule_s = [1,1]} in let embs = find_matchings model rule_obj in let emb = choose_match model rule_obj embs in @@ -654,7 +654,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["O"; "D"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in assert_equal ~printer:(fun x->x) ~msg:"one not opt" "not O(e)-> true" @@ -668,7 +668,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["O"; "D"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in assert_equal ~printer:(fun x->x) ~msg:"del one not opt" "O(e)-> not O(e)" @@ -682,7 +682,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["O"; "D"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in assert_one_of ~msg:"match defined" ["P(e) or Q(e)-> O(e)"; "Q(e) or P(e)-> O(e)"] @@ -696,7 +696,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["O"; "D"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in assert_one_of ~msg:"match defined 2" ["P(e) or Q(e)-> (O(e) and not P(e) and not Q(e))"; @@ -715,7 +715,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["O"; "D"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in assert_equal ~printer:(fun x->x) ~msg:"defrel: diffthan P Q" "(not P(e) and not Q(e))-> true" @@ -729,7 +729,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["O"; "D"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in assert_one_of ~msg:"del defrel" ["(O(e) and not P(e) and not Q(e) and (_del_P(e) or _del_Q(e)))-> (P(e) and not O(e))"; @@ -746,7 +746,7 @@ {lhs_struc = lhs_struc; rhs_struc = rhs_struc; emb_rels = ["O"; "D"]; - pre = Formula.And []; + pre = (Formula.And [], []); rule_s = [1,1]} in assert_equal ~printer:(fun x->x) ~msg:"diffthan override" "(not O(e) and not P(e))-> (O(e) and not Q(e))" Modified: trunk/Toss/Formula/Lexer.mll =================================================================== --- trunk/Toss/Formula/Lexer.mll 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Formula/Lexer.mll 2012-02-04 01:07:09 UTC (rev 1662) @@ -50,6 +50,7 @@ | WITH | EMB | PRE + | BEFORE | INV | POST | UPDATE @@ -191,6 +192,7 @@ | "with" { WITH } | "emb" { EMB } | "pre" { PRE } + | "before" { BEFORE } | "inv" { INV } | "post" { POST } | "update" { UPDATE } Modified: trunk/Toss/Formula/Tokens.mly =================================================================== --- trunk/Toss/Formula/Tokens.mly 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Formula/Tokens.mly 2012-02-04 01:07:09 UTC (rev 1662) @@ -8,8 +8,8 @@ %token LARR LDARR RARR RDARR LRARR LRDARR INTERV %token OPENCUR CLOSECUR OPENSQ CLOSESQ OPEN CLOSE %token IN_MOD AND OR XOR NOT EX ALL TC -%token WITH EMB PRE INV POST UPDATE DYNAMICS TRUE FALSE ASSOC COND PAYOFF MOVES -%token MATCH ADD_CMD DEL_CMD GET_CMD SET_CMD LET_CMD EVAL_CMD +%token WITH EMB PRE BEFORE INV POST UPDATE DYNAMICS TRUE FALSE ASSOC COND PAYOFF +%token MOVES MATCH ADD_CMD DEL_CMD GET_CMD SET_CMD LET_CMD EVAL_CMD %token ELEM_MOD ELEMS_MOD REL_MOD RELS_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 Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Makefile 2012-02-04 01:07:09 UTC (rev 1662) @@ -45,8 +45,9 @@ OCB_LIB=-libs str,nums,unix,oUnit,sqlite3 OCB_LIBJS=-libs str,js_of_ocaml OCB_PP=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo js_of_ocaml/pa_js.cmo" -OCB_PPJS=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo -DJAVASCRIPT js_of_ocaml/pa_js.cmo" -OCAMLBUILD=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf $(OCB_PP) \ +OCB_PPJS=-pp "camlp4o -unsafe -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo -DJAVASCRIPT js_of_ocaml/pa_js.cmo" +OCAMLBUILD=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf \ + -ocamlopt "ocamlopt -inline 10" $(OCB_PP) \ $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) OCAMLBUILDJS=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf $(OCB_PPJS) \ $(OCB_LIBJS) $(OCB_CFLAG) $(OCB_LFLAG) Modified: trunk/Toss/Play/Move.ml =================================================================== --- trunk/Toss/Play/Move.ml 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Play/Move.ml 2012-02-04 01:07:09 UTC (rev 1662) @@ -80,20 +80,30 @@ ) grid ) matchings)) +(* Check if the before-part of the precondition of the rule holds on history. *) +let check_history_pre r hist = + match r.DiscreteRule.struc_rule with + | None -> true + | Some sr -> + let prev_list = snd (sr.DiscreteRule.pre) in + let constraint_satisfied (rname, b) = + List.exists (fun (mv, _) -> mv.Arena.rule = rname) hist = b in + List.for_all constraint_satisfied prev_list - 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; - history = (mv, None) :: state.Arena.history; - struc = model; - time = time})) - (ContinuousRule.rewrite_single state.Arena.struc time mv.Arena.matching - rule mv.Arena.mv_time mv.Arena.parameters)) (Array.to_list moves) + if check_history_pre rule.ContinuousRule.discrete state.Arena.history then + Aux.map_option + (fun (model, time, _) -> (* ignoring shifts, i.e. animation steps *) + (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.matching + rule mv.Arena.mv_time mv.Arena.parameters) + else None) (Array.to_list moves) let gen_models rules state time moves = let res = gen_models_list rules state time moves in Modified: trunk/Toss/Server/ReqHandler.ml =================================================================== --- trunk/Toss/Server/ReqHandler.ml 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/Server/ReqHandler.ml 2012-02-04 01:07:09 UTC (rev 1662) @@ -221,8 +221,6 @@ client := new_st; strip_ws res -let client_get_state () = client_msg "GET STATE" - let client_get_model () = client_msg "GET MODEL" let client_set_model model_s = ignore (client_msg ("SET MODEL " ^ model_s)) Modified: trunk/Toss/examples/Chess.toss =================================================================== --- trunk/Toss/examples/Chess.toss 2012-02-02 11:16:52 UTC (rev 1661) +++ trunk/Toss/examples/Chess.toss 2012-02-04 01:07:09 UTC (rev 1662) @@ -299,7 +299,8 @@ " -> [ | | ] " ... ... ... ... wK.wR ... -" emb w,b pre not(bBeats(c1) or bBeats(d1) or bBeats(e1)) post true +" emb w,b pre not(bBeats(c1) or bBeats(d1) or bBeats(e1)) and before + not WhiteRookA1, not WhiteKing, not WhiteLeftCastle, not WhiteRightCastle RULE WhiteRightCastle: [ | | ] " ... ... @@ -307,7 +308,8 @@ " -> [ | | ] " ... ... ...wR wK. -" emb w,b pre not (bBeats(a1) or bBeats(b1) or bBeats(c1)) post true +" emb w,b pre not (bBeats(a1) or bBeats(b1) or bBeats(c1)) and before + not WhiteRookH1, not WhiteKing, not WhiteLeftCastle, not WhiteRightCastle RULE BlackLeftCastle: [ | | ] " ... ... ... @@ -315,7 +317,8 @@ " -> [ | | ] " ... ... ... ... bK.bR ... -" emb w,b pre not(wBeats(c1) or wBeats(d1) or wBeats(e1)) post true +" emb w,b pre not(wBeats(c1) or wBeats(d1) or wBeats(e1)) and before + not BlackRookA8, not BlackKing, not BlackLeftCastle, not BlackRightCastle RULE BlackRightCastle: [ | | ] " ... ... @@ -323,8 +326,9 @@ " -> [ | | ] " ... ... ...bR bK. -" emb w,b pre not (wBeats(a1) or wBeats(b1) or wBeats(c1)) post true -LOC 0 { // both can castle +" emb w,b pre not (wBeats(a1) or wBeats(b1) or wBeats(c1)) and before + not BlackRookH8, not BlackKing, not BlackLeftCastle, not BlackRightCastle +LOC 0 { PLAYER 1 { COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 PAYOFF :(CheckB()) - :(CheckW()) @@ -339,19 +343,19 @@ [WhiteKnight -> 1]; [WhiteBishop -> 1]; [WhiteRook -> 1]; - [WhiteRookA1 -> 5]; - [WhiteRookH1 -> 3]; + [WhiteRookA1 -> 1]; + [WhiteRookH1 -> 1]; [WhiteQueen -> 1]; - [WhiteLeftCastle -> 7]; - [WhiteRightCastle -> 7]; - [WhiteKing -> 7] + [WhiteLeftCastle -> 1]; + [WhiteRightCastle -> 1]; + [WhiteKing -> 1] } PLAYER 2 { COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 PAYOFF :(CheckW()) - :(CheckB()) } } -LOC 1 { // both can castle +LOC 1 { PLAYER 2 { COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 PAYOFF :(CheckW()) - :(CheckB()) @@ -366,796 +370,18 @@ [BlackKnight -> 0]; [BlackBishop -> 0]; [BlackRook -> 0]; - [BlackRookA8 -> 16]; - [BlackRookH8 -> 8]; + [BlackRookA8 -> 0]; + [BlackRookH8 -> 0]; [BlackQueen -> 0]; - [BlackLeftCastle -> 24]; - [BlackRightCastle -> 24]; - [BlackKing -> 24] + [BlackLeftCastle -> 0]; + [BlackRightCastle -> 0]; + [BlackKing -> 0] } PLAYER 1 { COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 PAYOFF :(CheckB()) - :(CheckW()) } } -LOC 2 { // w left, b can castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 3]; - [WhitePawnMoveDbl -> 3]; - [WhitePawnBeat -> 3]; - [WhitePawnBeatPromote -> 3]; - [WhitePawnBeatLDbl -> 3]; - [WhitePawnBeatRDbl -> 3]; - [WhitePawnPromote -> 3]; - [WhiteKnight -> 3]; - [WhiteBishop -> 3]; - [WhiteRook -> 3]; - [WhiteRookA1 -> 7]; - [WhiteRookH1 -> 3]; - [WhiteQueen -> 3]; - [WhiteLeftCastle -> 7]; - [WhiteKing -> 7] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 3 { // w left, b can castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 2]; - [BlackPawnMoveDbl -> 2]; - [BlackPawnBeat -> 2]; - [BlackPawnBeatPromote -> 2]; - [BlackPawnBeatLDbl -> 2]; - [BlackPawnBeatRDbl -> 2]; - [BlackPawnPromote -> 2]; - [BlackKnight -> 2]; - [BlackBishop -> 2]; - [BlackRook -> 2]; - [BlackRookA8 -> 18]; - [BlackRookH8 -> 10]; - [BlackQueen -> 2]; - [BlackLeftCastle -> 26]; - [BlackRightCastle -> 26]; - [BlackKing -> 26] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 4 { // w right, b can castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 5]; - [WhitePawnMoveDbl -> 5]; - [WhitePawnBeat -> 5]; - [WhitePawnBeatPromote -> 5]; - [WhitePawnBeatLDbl -> 5]; - [WhitePawnBeatRDbl -> 5]; - [WhitePawnPromote -> 5]; - [WhiteKnight -> 5]; - [WhiteBishop -> 5]; - [WhiteRook -> 5]; - [WhiteRookA1 -> 5]; - [WhiteRookH1 -> 7]; - [WhiteQueen -> 5]; - [WhiteRightCastle -> 7]; - [WhiteKing -> 7] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 5 { // w right, b can castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 4]; - [BlackPawnMoveDbl -> 4]; - [BlackPawnBeat -> 4]; - [BlackPawnBeatPromote -> 4]; - [BlackPawnBeatLDbl -> 4]; - [BlackPawnBeatRDbl -> 4]; - [BlackPawnPromote -> 4]; - [BlackKnight -> 4]; - [BlackBishop -> 4]; - [BlackRook -> 4]; - [BlackRookA8 -> 20]; - [BlackRookH8 -> 12]; - [BlackQueen -> 4]; - [BlackLeftCastle -> 28]; - [BlackRightCastle -> 28]; - [BlackKing -> 28] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 6 { // w no, b can castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 7]; - [WhitePawnMoveDbl -> 7]; - [WhitePawnBeat -> 7]; - [WhitePawnBeatPromote -> 7]; - [WhitePawnBeatLDbl -> 7]; - [WhitePawnBeatRDbl -> 7]; - [WhitePawnPromote -> 7]; - [WhiteKnight -> 7]; - [WhiteBishop -> 7]; - [WhiteRook -> 7]; - [WhiteRookA1 -> 7]; - [WhiteRookH1 -> 7]; - [WhiteQueen -> 7]; - [WhiteKing -> 7] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 7 { // w no, b can castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 6]; - [BlackPawnMoveDbl -> 6]; - [BlackPawnBeat -> 6]; - [BlackPawnBeatPromote -> 6]; - [BlackPawnBeatLDbl -> 6]; - [BlackPawnBeatRDbl -> 6]; - [BlackPawnPromote -> 6]; - [BlackKnight -> 6]; - [BlackBishop -> 6]; - [BlackRook -> 6]; - [BlackRookA8 -> 22]; - [BlackRookH8 -> 14]; - [BlackQueen -> 6]; - [BlackLeftCastle -> 30]; - [BlackRightCastle -> 30]; - [BlackKing -> 30] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 8 { // w can, b left castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 9]; - [WhitePawnMoveDbl -> 9]; - [WhitePawnBeat -> 9]; - [WhitePawnBeatPromote -> 9]; - [WhitePawnBeatLDbl -> 9]; - [WhitePawnBeatRDbl -> 9]; - [WhitePawnPromote -> 9]; - [WhiteKnight -> 9]; - [WhiteBishop -> 9]; - [WhiteRook -> 9]; - [WhiteRookA1 -> 13]; - [WhiteRookH1 -> 11]; - [WhiteQueen -> 9]; - [WhiteLeftCastle -> 15]; - [WhiteRightCastle -> 15]; - [WhiteKing -> 15] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 9 { // w can, b left castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 8]; - [BlackPawnMoveDbl -> 8]; - [BlackPawnBeat -> 8]; - [BlackPawnBeatPromote -> 8]; - [BlackPawnBeatLDbl -> 8]; - [BlackPawnBeatRDbl -> 8]; - [BlackPawnPromote -> 8]; - [BlackKnight -> 8]; - [BlackBishop -> 8]; - [BlackRook -> 8]; - [BlackRookA8 -> 24]; - [BlackRookH8 -> 8]; - [BlackQueen -> 8]; - [BlackLeftCastle -> 24]; - [BlackKing -> 24] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 10 { // w left, b left castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 11]; - [WhitePawnMoveDbl -> 11]; - [WhitePawnBeat -> 11]; - [WhitePawnBeatPromote -> 11]; - [WhitePawnBeatLDbl -> 11]; - [WhitePawnBeatRDbl -> 11]; - [WhitePawnPromote -> 11]; - [WhiteKnight -> 11]; - [WhiteBishop -> 11]; - [WhiteRook -> 11]; - [WhiteRookA1 -> 15]; - [WhiteRookH1 -> 11]; - [WhiteQueen -> 11]; - [WhiteLeftCastle -> 15]; - [WhiteKing -> 15] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 11 { // w left, b left castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 10]; - [BlackPawnMoveDbl -> 10]; - [BlackPawnBeat -> 10]; - [BlackPawnBeatPromote -> 10]; - [BlackPawnBeatLDbl -> 10]; - [BlackPawnBeatRDbl -> 10]; - [BlackPawnPromote -> 10]; - [BlackKnight -> 10]; - [BlackBishop -> 10]; - [BlackRook -> 10]; - [BlackRookA8 -> 26]; - [BlackRookH8 -> 10]; - [BlackQueen -> 10]; - [BlackLeftCastle -> 26]; - [BlackKing -> 26] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 12 { // w right, b left castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 13]; - [WhitePawnMoveDbl -> 13]; - [WhitePawnBeat -> 13]; - [WhitePawnBeatPromote -> 13]; - [WhitePawnBeatLDbl -> 13]; - [WhitePawnBeatRDbl -> 13]; - [WhitePawnPromote -> 13]; - [WhiteKnight -> 13]; - [WhiteBishop -> 13]; - [WhiteRook -> 13]; - [WhiteRookA1 -> 13]; - [WhiteRookH1 -> 15]; - [WhiteQueen -> 13]; - [WhiteRightCastle -> 15]; - [WhiteKing -> 15] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 13 { // w right, b left castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 12]; - [BlackPawnMoveDbl -> 12]; - [BlackPawnBeat -> 12]; - [BlackPawnBeatPromote -> 12]; - [BlackPawnBeatLDbl -> 12]; - [BlackPawnBeatRDbl -> 12]; - [BlackPawnPromote -> 12]; - [BlackKnight -> 12]; - [BlackBishop -> 12]; - [BlackRook -> 12]; - [BlackRookA8 -> 28]; - [BlackRookH8 -> 12]; - [BlackQueen -> 12]; - [BlackLeftCastle -> 28]; - [BlackKing -> 28] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 14 { // w no, b left castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 15]; - [WhitePawnMoveDbl -> 15]; - [WhitePawnBeat -> 15]; - [WhitePawnBeatPromote -> 15]; - [WhitePawnBeatLDbl -> 15]; - [WhitePawnBeatRDbl -> 15]; - [WhitePawnPromote -> 15]; - [WhiteKnight -> 15]; - [WhiteBishop -> 15]; - [WhiteRook -> 15]; - [WhiteRookA1 -> 15]; - [WhiteRookH1 -> 15]; - [WhiteQueen -> 15]; - [WhiteKing -> 15] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 15 { // w no, b left castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 14]; - [BlackPawnMoveDbl -> 14]; - [BlackPawnBeat -> 14]; - [BlackPawnBeatPromote -> 14]; - [BlackPawnBeatLDbl -> 14]; - [BlackPawnBeatRDbl -> 14]; - [BlackPawnPromote -> 14]; - [BlackKnight -> 14]; - [BlackBishop -> 14]; - [BlackRook -> 14]; - [BlackRookA8 -> 30]; - [BlackRookH8 -> 14]; - [BlackQueen -> 14]; - [BlackLeftCastle -> 30]; - [BlackKing -> 30] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 16 { // w can, b right castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 17]; - [WhitePawnMoveDbl -> 17]; - [WhitePawnBeat -> 17]; - [WhitePawnBeatPromote -> 17]; - [WhitePawnBeatLDbl -> 17]; - [WhitePawnBeatRDbl -> 17]; - [WhitePawnPromote -> 17]; - [WhiteKnight -> 17]; - [WhiteBishop -> 17]; - [WhiteRook -> 17]; - [WhiteRookA1 -> 21]; - [WhiteRookH1 -> 19]; - [WhiteQueen -> 17]; - [WhiteLeftCastle -> 23]; - [WhiteRightCastle -> 23]; - [WhiteKing -> 23] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 17 { // w can, b right castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 16]; - [BlackPawnMoveDbl -> 16]; - [BlackPawnBeat -> 16]; - [BlackPawnBeatPromote -> 16]; - [BlackPawnBeatLDbl -> 16]; - [BlackPawnBeatRDbl -> 16]; - [BlackPawnPromote -> 16]; - [BlackKnight -> 16]; - [BlackBishop -> 16]; - [BlackRook -> 16]; - [BlackRookA8 -> 16]; - [BlackRookH8 -> 24]; - [BlackQueen -> 16]; - [BlackRightCastle -> 24]; - [BlackKing -> 24] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 18 { // w left, b right castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 19]; - [WhitePawnMoveDbl -> 19]; - [WhitePawnBeat -> 19]; - [WhitePawnBeatPromote -> 19]; - [WhitePawnBeatLDbl -> 19]; - [WhitePawnBeatRDbl -> 19]; - [WhitePawnPromote -> 19]; - [WhiteKnight -> 19]; - [WhiteBishop -> 19]; - [WhiteRook -> 19]; - [WhiteRookA1 -> 23]; - [WhiteRookH1 -> 19]; - [WhiteQueen -> 19]; - [WhiteLeftCastle -> 23]; - [WhiteKing -> 23] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 19 { // w left, b right castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 18]; - [BlackPawnMoveDbl -> 18]; - [BlackPawnBeat -> 18]; - [BlackPawnBeatPromote -> 18]; - [BlackPawnBeatLDbl -> 18]; - [BlackPawnBeatRDbl -> 18]; - [BlackPawnPromote -> 18]; - [BlackKnight -> 18]; - [BlackBishop -> 18]; - [BlackRook -> 18]; - [BlackRookA8 -> 18]; - [BlackRookH8 -> 26]; - [BlackQueen -> 18]; - [BlackRightCastle -> 26]; - [BlackKing -> 26] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 20 { // w right, b right castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 21]; - [WhitePawnMoveDbl -> 21]; - [WhitePawnBeat -> 21]; - [WhitePawnBeatPromote -> 21]; - [WhitePawnBeatLDbl -> 21]; - [WhitePawnBeatRDbl -> 21]; - [WhitePawnPromote -> 21]; - [WhiteKnight -> 21]; - [WhiteBishop -> 21]; - [WhiteRook -> 21]; - [WhiteRookA1 -> 21]; - [WhiteRookH1 -> 23]; - [WhiteQueen -> 21]; - [WhiteRightCastle -> 23]; - [WhiteKing -> 23] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 21 { // w right, b right castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 20]; - [BlackPawnMoveDbl -> 20]; - [BlackPawnBeat -> 20]; - [BlackPawnBeatPromote -> 20]; - [BlackPawnBeatLDbl -> 20]; - [BlackPawnBeatRDbl -> 20]; - [BlackPawnPromote -> 20]; - [BlackKnight -> 20]; - [BlackBishop -> 20]; - [BlackRook -> 20]; - [BlackRookA8 -> 20]; - [BlackRookH8 -> 28]; - [BlackQueen -> 20]; - [BlackRightCastle -> 28]; - [BlackKing -> 28] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 22 { // w no, b right castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 23]; - [WhitePawnMoveDbl -> 23]; - [WhitePawnBeat -> 23]; - [WhitePawnBeatPromote -> 23]; - [WhitePawnBeatLDbl -> 23]; - [WhitePawnBeatRDbl -> 23]; - [WhitePawnPromote -> 23]; - [WhiteKnight -> 23]; - [WhiteBishop -> 23]; - [WhiteRook -> 23]; - [WhiteRookA1 -> 23]; - [WhiteRookH1 -> 23]; - [WhiteQueen -> 23]; - [WhiteKing -> 23] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 23 { // w no, b right castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 22]; - [BlackPawnMoveDbl -> 22]; - [BlackPawnBeat -> 22]; - [BlackPawnBeatPromote -> 22]; - [BlackPawnBeatLDbl -> 22]; - [BlackPawnBeatRDbl -> 22]; - [BlackPawnPromote -> 22]; - [BlackKnight -> 22]; - [BlackBishop -> 22]; - [BlackRook -> 22]; - [BlackRookA8 -> 22]; - [BlackRookH8 -> 30]; - [BlackQueen -> 22]; - [BlackRightCastle -> 30]; - [BlackKing -> 30] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 24 { // w can, b no castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 25]; - [WhitePawnMoveDbl -> 25]; - [WhitePawnBeat -> 25]; - [WhitePawnBeatPromote -> 25]; - [WhitePawnBeatLDbl -> 25]; - [WhitePawnBeatRDbl -> 25]; - [WhitePawnPromote -> 25]; - [WhiteKnight -> 25]; - [WhiteBishop -> 25]; - [WhiteRook -> 25]; - [WhiteRookA1 -> 29]; - [WhiteRookH1 -> 27]; - [WhiteQueen -> 25]; - [WhiteLeftCastle -> 31]; - [WhiteRightCastle -> 31]; - [WhiteKing -> 31] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 25 { // w can, b no castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 24]; - [BlackPawnMoveDbl -> 24]; - [BlackPawnBeat -> 24]; - [BlackPawnBeatPromote -> 24]; - [BlackPawnBeatLDbl -> 24]; - [BlackPawnBeatRDbl -> 24]; - [BlackPawnPromote -> 24]; - [BlackKnight -> 24]; - [BlackBishop -> 24]; - [BlackRook -> 24]; - [BlackRookA8 -> 24]; - [BlackRookH8 -> 24]; - [BlackQueen -> 24]; - [BlackKing -> 24] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 26 { // w left, b no castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 27]; - [WhitePawnMoveDbl -> 27]; - [WhitePawnBeat -> 27]; - [WhitePawnBeatPromote -> 27]; - [WhitePawnBeatLDbl -> 27]; - [WhitePawnBeatRDbl -> 27]; - [WhitePawnPromote -> 27]; - [WhiteKnight -> 27]; - [WhiteBishop -> 27]; - [WhiteRook -> 27]; - [WhiteRookA1 -> 31]; - [WhiteRookH1 -> 27]; - [WhiteQueen -> 27]; - [WhiteLeftCastle -> 31]; - [WhiteKing -> 31] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 27 { // w left, b no castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 26]; - [BlackPawnMoveDbl -> 26]; - [BlackPawnBeat -> 26]; - [BlackPawnBeatPromote -> 26]; - [BlackPawnBeatLDbl -> 26]; - [BlackPawnBeatRDbl -> 26]; - [BlackPawnPromote -> 26]; - [BlackKnight -> 26]; - [BlackBishop -> 26]; - [BlackRook -> 26]; - [BlackRookA8 -> 26]; - [BlackRookH8 -> 26]; - [BlackQueen -> 26]; - [BlackKing -> 26] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 28 { // w right, b no castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 29]; - [WhitePawnMoveDbl -> 29]; - [WhitePawnBeat -> 29]; - [WhitePawnBeatPromote -> 29]; - [WhitePawnBeatLDbl -> 29]; - [WhitePawnBeatRDbl -> 29]; - [WhitePawnPromote -> 29]; - [WhiteKnight -> 29]; - [WhiteBishop -> 29]; - [WhiteRook -> 29]; - [WhiteRookA1 -> 29]; - [WhiteRookH1 -> 31]; - [WhiteQueen -> 29]; - [WhiteRightCastle -> 31]; - [WhiteKing -> 31] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 29 { // w right, b no castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 28]; - [BlackPawnMoveDbl -> 28]; - [BlackPawnBeat -> 28]; - [BlackPawnBeatPromote -> 28]; - [BlackPawnBeatLDbl -> 28]; - [BlackPawnBeatRDbl -> 28]; - [BlackPawnPromote -> 28]; - [BlackKnight -> 28]; - [BlackBishop -> 28]; - [BlackRook -> 28]; - [BlackRookA8 -> 28]; - [BlackRookH8 -> 28]; - [BlackQueen -> 28]; - [BlackKing -> 28] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} -LOC 30 { // w no, b no castle - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - MOVES - [WhitePawnMove -> 31]; - [WhitePawnMoveDbl -> 31]; - [WhitePawnBeat -> 31]; - [WhitePawnBeatPromote -> 31]; - [WhitePawnBeatLDbl -> 31]; - [WhitePawnBeatRDbl -> 31]; - [WhitePawnPromote -> 31]; - [WhiteKnight -> 31]; - [WhiteBishop -> 31]; - [WhiteRook -> 31]; - [WhiteRookA1 -> 31]; - [WhiteRookH1 -> 31]; - [WhiteQueen -> 31]; - [WhiteKing -> 31] - } - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - } -} -LOC 31 { // w no, b no castle - PLAYER 2 { - COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 - PAYOFF :(CheckW()) - :(CheckB()) - MOVES - [BlackPawnMove -> 30]; - [BlackPawnMoveDbl -> 30]; - [BlackPawnBeat -> 30]; - [BlackPawnBeatPromote -> 30]; - [BlackPawnBeatLDbl -> 30]; - [BlackPawnBeatRDbl -> 30]; - [BlackPawnPromote -> 30]; - [BlackKnight -> 30]; - [BlackBishop -> 30]; - [BlackRook -> 30]; - [BlackRookA8 -> 30]; - [BlackRookH8 -> 30]; - [BlackQueen -> 30]; - [BlackKing -> 30] - } - PLAYER 1 { - COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 - PAYOFF :(CheckB()) - :(CheckW()) - } -} MODEL [ | | ] " ... ... ... ... bR bN.bB bQ.bK bB.bN bR. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-02 11:17:03
|
Revision: 1661 http://toss.svn.sourceforge.net/toss/?rev=1661&view=rev Author: lukstafi Date: 2012-02-02 11:16:52 +0000 (Thu, 02 Feb 2012) Log Message: ----------- Trampolined Menhir engine; added chess to local JS game selection (not in interface). Modified Paths: -------------- trunk/Toss/Arena/Arena.ml trunk/Toss/MenhirLib/engine.ml trunk/Toss/Server/GameSelection.ml trunk/Toss/WebClient/JsHandler.js Modified: trunk/Toss/Arena/Arena.ml =================================================================== --- trunk/Toss/Arena/Arena.ml 2012-02-01 19:28:39 UTC (rev 1660) +++ trunk/Toss/Arena/Arena.ml 2012-02-02 11:16:52 UTC (rev 1661) @@ -315,6 +315,13 @@ let graph = Aux.array_from_assoc (List.rev locations) in let pats=List.rev_map (FormulaSubst.subst_rels_expr def_rels_pure) patterns in let apply_moves rules mvs s = List.fold_left (apply_move rules) s mvs in + let result_state = + apply_moves rules hist { + struc = state; + time = time; + cur_loc = cur_loc; + history = []; + } in { rules = rules; patterns = pats; @@ -324,13 +331,7 @@ data = data; defined_rels = List.map (fun (a, b, c) -> (a, (b, c))) defined_rels; starting_struc = state; - }, - apply_moves rules hist { - struc = state; - time = time; - cur_loc = cur_loc; - history = []; - } + }, result_state Modified: trunk/Toss/MenhirLib/engine.ml =================================================================== --- trunk/Toss/MenhirLib/engine.ml 2012-02-01 19:28:39 UTC (rev 1660) +++ trunk/Toss/MenhirLib/engine.ml 2012-02-02 11:16:52 UTC (rev 1661) @@ -48,12 +48,22 @@ (* --------------------------------------------------------------------------- *) - (* The type [void] is empty. Many of the functions below have return type - [void]. This guarantees that they never return a value. Instead, they - must stop by raising an exception: either [Accept] or [Error]. *) + (* Many of the functions below have return type [trampoline]. This + guarantees that they never return a value, but continue the + computation. Instead, they must stop by raising an exception: + either [Accept] or [Error]. *) - type void + type trampoline = + | Run of t_env * bool + | Continue of t_env + | Action of t_env + | Shift of t_env * bool * terminal * T.semantic_value * state + | Reduce of t_env * T.production + | Initiate of t_env + | ErrorCont of t_env + and t_env = (state, semantic_value, token) env + (* --------------------------------------------------------------------------- *) (* In the code-based back-end, the [run] function is sometimes responsible @@ -79,7 +89,7 @@ Here, the code is structured in a slightly different way. It is up to the caller of [run] to indicate whether to discard a token. *) - let rec run env please_discard : void = + let run env please_discard : trampoline = (* Log the fact that we just entered this state. *) @@ -100,11 +110,13 @@ T.default_reduction s - reduce (* there is a default reduction; perform it *) - continue (* there is none; continue below *) + (fun env prod -> Reduce (env, prod)) + (* there is a default reduction; perform it *) + (fun env -> Continue env) + (* there is none; continue below *) env - and continue env : void = + and continue env : trampoline = (* There is no default reduction. Consult the current lookahead token so as to determine which action should be taken. *) @@ -119,10 +131,10 @@ if env.shifted = (-1) then begin Log.resuming_error_handling(); - error env + ErrorCont env end else - action env + Action env (* --------------------------------------------------------------------------- *) @@ -130,7 +142,7 @@ a default reduction. We also know that the current lookahead token is not [error]: it is a real token, stored in [env.token]. *) - and action env : void = + let action env : trampoline = (* We consult the two-dimensional action table, indexed by the current state and the current lookahead token, in order to @@ -141,9 +153,10 @@ env.current (* determines a row *) (T.token2terminal token) (* determines a column *) (T.token2value token) - shift (* shift continuation *) - reduce (* reduce continuation *) - initiate (* failure continuation *) + (fun env please_discard terminal value s' -> + Shift (env, please_discard, terminal, value, s')) + (fun env prod -> Reduce (env, prod)) + (fun env -> Initiate env) (* failure continuation *) env (* --------------------------------------------------------------------------- *) @@ -152,12 +165,12 @@ (Goto transitions are taken care of within [reduce] below.) The symbol can be either an actual token or the [error] pseudo-token. *) - and shift env + let shift env (please_discard : bool) (terminal : terminal) (value : semantic_value) (s' : state) - : void = + : trampoline = (* Log the transition. *) @@ -178,13 +191,19 @@ (* Switch to state [s']. *) env.current <- s'; - run env please_discard + Run (env, please_discard) (* --------------------------------------------------------------------------- *) + let errorbookkeeping env = + Log.initiating_error_handling(); + env.previouserror <- env.shifted; + env.shifted <- (-1); + ErrorCont env + (* This function takes care of reductions. *) - and reduce env (prod : production) : void = + let reduce env (prod : production) : trampoline = (* Log a reduction event. *) @@ -218,7 +237,7 @@ production [prod]. *) env.current <- T.goto env.stack.state prod; - run env false + Run (env, false) end else @@ -232,41 +251,21 @@ (* [initiate] and [errorbookkeeping] initiate error handling. See the functions by the same names in [CodeBackend]. *) - and initiate env : void = + let initiate env : trampoline = assert (env.shifted >= 0); if T.recovery && env.shifted = 0 then begin Log.discarding_last_token (T.token2terminal env.token); discard env; env.shifted <- 0; - action env + Action env end else errorbookkeeping env - and errorbookkeeping env = - Log.initiating_error_handling(); - env.previouserror <- env.shifted; - env.shifted <- (-1); - error env - (* [error] handles errors. *) - and error env : void = + let error_shift env please_discard terminal value s' = - (* Consult the column associated with the [error] pseudo-token in the - action table. *) - - T.action - env.current (* determines a row *) - T.error_terminal (* determines a column *) - T.error_value - error_shift (* shift continuation *) - error_reduce (* reduce continuation *) - error_fail (* failure continuation *) - env - - and error_shift env please_discard terminal value s' = - (* Here, [terminal] is [T.error_terminal], and [value] is [T.error_value]. *) assert (terminal = T.error_terminal && value = T.error_value); @@ -274,16 +273,16 @@ (* This state is capable of shifting the [error] token. *) Log.handling_error env.current; - shift env please_discard terminal value s' + Shift (env, please_discard, terminal, value, s') - and error_reduce env prod = + let error_reduce env prod = (* This state is capable of performing a reduction on [error]. *) Log.handling_error env.current; - reduce env prod + Reduce (env, prod) - and error_fail env = + let error_fail env = (* This state is unable to handle errors. Attempt to pop a stack cell. *) @@ -303,10 +302,24 @@ env.stack <- next; env.current <- cell.state; - error env + ErrorCont env end + let error env : trampoline = + + (* Consult the column associated with the [error] pseudo-token in the + action table. *) + + T.action + env.current (* determines a row *) + T.error_terminal (* determines a column *) + T.error_value + error_shift (* shift continuation *) + error_reduce (* reduce continuation *) + error_fail (* failure continuation *) + env + (* --------------------------------------------------------------------------- *) let entry @@ -353,12 +366,25 @@ try - (* If ocaml offered a [match/with] construct with zero branches, this is - what we would use here, since the type [void] has zero cases. *) - - let (_ : void) = run env false in - assert false (* cannot fail *) - + let result = ref (run env false) in + while true do + match !result with + | Run (env, please_discard) -> + result := run env please_discard + | Continue env -> + result := continue env + | Action env -> + result := action env + | Shift (env, please_discard, terminal, value, s') -> + result := shift env please_discard terminal value s' + | Reduce (env, prod) -> + result := reduce env prod + | Initiate env -> + result := initiate env + | ErrorCont env -> + result := error env + done; + assert false with | Accept v -> v Modified: trunk/Toss/Server/GameSelection.ml =================================================================== --- trunk/Toss/Server/GameSelection.ml 2012-02-01 19:28:39 UTC (rev 1660) +++ trunk/Toss/Server/GameSelection.ml 2012-02-02 11:16:52 UTC (rev 1661) @@ -21,15 +21,13 @@ Heuristic.default_heuristic ~struc:state.Arena.struc ?advr game let compile_game_data game_name game_str = - Aux.alert ("Parsing "^game_name^"..."); + Aux.alert ("Preparing "^game_name^"..."); let (game, game_state as game_with_state) = ArenaParser.parse_game_state Lexer.lex (Lexing.from_string game_str) in - Aux.alert ("Parsed "^game_name^" -- computing its heuristic..."); let adv_ratio = try Some (float_of_string (List.assoc "adv_ratio" game.Arena.data)) with Not_found -> None in let heuristic = compute_heuristic adv_ratio game_with_state in - Aux.alert ("Heuristic for "^game_name^" computed."); game_name, {heuristic = heuristic; game_state = game_with_state; @@ -1533,6 +1531,7 @@ \" ") + let checkers_str = (" PLAYERS 1, 2 DATA depth: 4, adv_ratio: 2 @@ -1828,7 +1827,7 @@ [ compile_game_data "Breakthrough" breakthrough_str; compile_game_data "Checkers" checkers_str; - (* compile_game_data "Chess" chess_str; *) + compile_game_data "Chess" chess_str; compile_game_data "Connect4" connect4_str; compile_game_data "Entanglement" entanglement_str; compile_game_data "Gomoku" gomoku_str; Modified: trunk/Toss/WebClient/JsHandler.js =================================================================== --- trunk/Toss/WebClient/JsHandler.js 2012-02-01 19:28:39 UTC (rev 1660) +++ trunk/Toss/WebClient/JsHandler.js 2012-02-02 11:16:52 UTC (rev 1661) @@ -892,4 +892,4 @@ if( y.fun ) { x.fun = y.fun; return 0; } var i = y.length; while (i--) x[i] = y[i]; return 0; } @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-01 19:28:49
|
Revision: 1660 http://toss.svn.sourceforge.net/toss/?rev=1660&view=rev Author: lukstafi Date: 2012-02-01 19:28:39 +0000 (Wed, 01 Feb 2012) Log Message: ----------- Local JS client: display iterations instead of tree size; diagnostic alerts for preparations of games; recompiled JsHandler.js. Modified Paths: -------------- trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/Play/Play.ml trunk/Toss/Play/Play.mli trunk/Toss/Server/GameSelection.ml trunk/Toss/Server/JsHandler.ml trunk/Toss/WebClient/JsHandler.js trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/Play.js Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2012-02-01 18:27:03 UTC (rev 1659) +++ trunk/Toss/Formula/Aux.ml 2012-02-01 19:28:39 UTC (rev 1660) @@ -772,3 +772,14 @@ ) ELSE ( Str.global_replace (Str.regexp regexp) templ s ) ENDIF + +(* Display prominently a message and wait for user + acknowledgement. Intended mostly for diagnostic purposes. *) +let alert s = + IFDEF JAVASCRIPT THEN ( + let js_alert = Js.Unsafe.variable "alert" in + Js.Unsafe.fun_call js_alert [|Js.Unsafe.inject (Js.string s)|] + ) ELSE ( + prerr_endline (s ^ " -- PRESS [ENTER]"); + ignore (read_line ()) + ) ENDIF Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2012-02-01 18:27:03 UTC (rev 1659) +++ trunk/Toss/Formula/Aux.mli 2012-02-01 19:28:39 UTC (rev 1660) @@ -369,3 +369,7 @@ except that all substrings of [s] that match [regexp] have been replaced by [templ]. *) val replace_regexp : regexp:string -> templ:string -> string -> string + +(** Display prominently a message and wait for user + acknowledgement. Intended mostly for diagnostic purposes. *) +val alert : string -> unit Modified: trunk/Toss/Play/Play.ml =================================================================== --- trunk/Toss/Play/Play.ml 2012-02-01 18:27:03 UTC (rev 1659) +++ trunk/Toss/Play/Play.ml 2012-02-01 19:28:39 UTC (rev 1660) @@ -45,6 +45,8 @@ unfold ~timeout:timed_out ~ab:ab game heur ~info_leaf:(fun _ _ _ -> 0) ~info_node:(maxdepth_node) ~choice:(maximax_depth_choice ab) +let latest_unfold_iters_left = ref 0 + (* Maximax unfolding upto depth. *) let rec unfold_maximax_upto ?(ab=false) count game heur (t, pmvs) = let mvs = (choose_moves game t) :: pmvs in @@ -61,13 +63,12 @@ with | Not_found -> (t, mvs) | Aux.Timeout msg -> + latest_unfold_iters_left := count; if !debug_level > 0 then Printf.printf "Timeout %f (%s)%!" (Aux.gettimeofday() -. !timeout) msg; (t, mvs) -let latest_gametree_size = ref 0 - (* Maximax unfold upto depth and choose move. *) let maximax_unfold_choose ?(check_stable=3) count game state heur = let ab = Heuristic.is_constant_sum heur in (* TODO: payoffs as well! *) @@ -77,7 +78,6 @@ let t = init game state (fun _ _ _ -> 0) heur in try let (u, mvs) = unfold_maximax_upto ~ab count game heur (t, []) in - latest_gametree_size := GameTree.size u; let nbr_to_check = min (2*check_stable + 1) (List.length mvs / 3) in let last_mvs = Aux.take_n (max 1 nbr_to_check) mvs in if !debug_level = 2 then Modified: trunk/Toss/Play/Play.mli =================================================================== --- trunk/Toss/Play/Play.mli 2012-02-01 18:27:03 UTC (rev 1659) +++ trunk/Toss/Play/Play.mli 2012-02-01 19:28:39 UTC (rev 1660) @@ -13,17 +13,18 @@ int GameTree.game_tree -> int GameTree.game_tree -(** Maximax unfolding upto depth, keep previous moves for stability. *) +(** Maximax unfolding upto iterations, keep previous moves for stability. *) val unfold_maximax_upto : ?ab:bool -> int -> Arena.game -> Formula.real_expr array array -> 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. *) +(** Maximax unfold upto iterations and choose move. *) val maximax_unfold_choose : ?check_stable:int -> int -> Arena.game -> Arena.game_state -> Formula.real_expr array array -> (Arena.move * Arena.game_state) list -(** Size of the game-tree produced by the latest call of - {!Play.maximax_unfold_choose}. *) -val latest_gametree_size : int ref +(** In case the computation is interrupted by a timeout, how many + iterations were left to perform by {!Play.maximax_unfold_choose} + or {!Play.unfold_maximax_upto}. *) +val latest_unfold_iters_left : int ref Modified: trunk/Toss/Server/GameSelection.ml =================================================================== --- trunk/Toss/Server/GameSelection.ml 2012-02-01 18:27:03 UTC (rev 1659) +++ trunk/Toss/Server/GameSelection.ml 2012-02-01 19:28:39 UTC (rev 1660) @@ -20,22 +20,1205 @@ with Not_found -> Heuristic.default_heuristic ~struc:state.Arena.struc ?advr game -let compile_game_data game_str = +let compile_game_data game_name game_str = + Aux.alert ("Parsing "^game_name^"..."); let (game, game_state as game_with_state) = ArenaParser.parse_game_state Lexer.lex (Lexing.from_string game_str) in + Aux.alert ("Parsed "^game_name^" -- computing its heuristic..."); let adv_ratio = try Some (float_of_string (List.assoc "adv_ratio" game.Arena.data)) with Not_found -> None in - {heuristic = compute_heuristic adv_ratio game_with_state; + let heuristic = compute_heuristic adv_ratio game_with_state in + Aux.alert ("Heuristic for "^game_name^" computed."); + game_name, + {heuristic = heuristic; game_state = game_with_state; playclock = 30; (* game clock from where? *) game_str = game_str; } -(* Maximum call stack size exceeded in JS (pbbly parsing Chess) -let chess_str = -*) +let chess_str = (" +PLAYERS 1, 2 +DATA depth: 0, adv_ratio: 1 +SET Sum (x | wP(x) : 1) +SET Sum (x | wR(x) : 1) +SET Sum (x | wN(x) : 1) +SET Sum (x | wB(x) : 1) +SET Sum (x | wQ(x) : 1) +SET Sum (x | bP(x) : 1) +SET Sum (x | bR(x) : 1) +SET Sum (x | bN(x) : 1) +SET Sum (x | bB(x) : 1) +SET Sum (x | bQ(x) : 1) +SET Sum (x | wBeats(x) : 1 + :(b(x)) + 3 * :(bK(x))) +SET Sum (x | bBeats(x) : 1 + :(w(x)) + 3 * :(wK(x))) +REL IsFirst(x) = not ex z C(z, x) +REL IsSecond(x) = ex y (C(y, x) and IsFirst(y)) +REL IsEight(x) = not ex z C(x, z) +REL IsSeventh(x) = ex y (C(x, y) and IsEight(y)) +REL IsA1(x) = not ex z R(z, x) and IsFirst(x) +REL IsH1(x) = not ex z R(x, z) and IsFirst(x) +REL IsA8(x) = not ex z R(z, x) and IsEight(x) +REL IsH8(x) = not ex z R(x, z) and IsEight(x) +REL w(x) = wP(x) or wR(x) or wN(x) or wB(x) or wQ(x) or wK(x) +REL b(x) = bP(x) or bR(x) or bN(x) or bB(x) or bQ(x) or bK(x) +REL DoubleC(x, y) = ex z ((C(x, z) and C(z, y)) or (C(y, z) and C(z, x))) +REL DoubleR(x, y) = ex z ((R(x, z) and R(z, y)) or (R(y, z) and R(z, x))) +REL KnightRCC(x, y) = ex z ((R(x, z) or R(z, x)) and DoubleC(z, y)) +REL KnightCRR(x, y) = ex z ((C(x, z) or C(z, x)) and DoubleR(z, y)) +REL Knight(x, y) = KnightRCC(x, y) or KnightCRR(x, y) +REL FreeD1 (x, y) = tc x, y (D1 (x, y) and not w(y) and not b(y)) +REL FreeD2 (x, y) = tc x, y (D2 (x, y) and not w(y) and not b(y)) +REL Diag1 (x, y) = ex z (FreeD1 (x, z) and (z = y or D1 (z, y))) +REL Diag2 (x, y) = ex z (FreeD2 (x, z) and (z = y or D2 (z, y))) +REL Diag (x, y) = Diag1 (x, y) or Diag2 (x, y) +REL FreeC (x, y) = tc x, y ((C(x, y) or C(y, x)) and not w(y) and not b(y)) +REL FreeR (x, y) = tc x, y ((R(x, y) or R(y, x)) and not w(y) and not b(y)) +REL Col (x, y) = ex z (FreeC (x, z) and (z = y or (C(z, y) or C(y, z)))) +REL Row (x, y) = ex z (FreeR (x, z) and (z = y or (R(z, y) or R(y, z)))) +REL Line (x, y) = Col (x, y) or Row (x, y) +REL Near (x, y) = C(x,y) or C(y,x) or R(x,y) or R(y,x) or D1(x, y) or D2(x, y) +REL wPBeats (x) = ex y (wP(y) and ex z ((R(y, z) or R(z, y)) and C(z, x))) +REL bPBeats (x) = ex y (bP(y) and ex z ((R(y, z) or R(z, y)) and C(x, z))) +REL wDiagBeats (x) = ex y ((wQ(y) or wB(y)) and Diag(y, x)) +REL bDiagBeats (x) = ex y ((bQ(y) or bB(y)) and Diag(y, x)) +REL wLineBeats (x) = ex y ((wQ(y) or wR(y)) and Line(y, x)) +REL bLineBeats (x) = ex y ((bQ(y) or bR(y)) and Line(y, x)) +REL wFigBeats(x) = wDiagBeats(x) or wLineBeats(x) or ex y(wN(y) and Knight(y,x)) +REL bFigBeats(x) = bDiagBeats(x) or bLineBeats(x) or ex y(bN(y) and Knight(y,x)) +REL wBeats(x) = wFigBeats(x) or wPBeats(x) or ex y (wK(y) and Near(y, x)) +REL bBeats(x) = bFigBeats(x) or bPBeats(x) or ex y (bK(y) and Near(y, x)) +REL CheckW() = ex x (wK(x) and bBeats(x)) +REL CheckB() = ex x (bK(x) and wBeats(x)) +RULE WhitePawnMove: + [ | | ] \" + ... + ... + + wP +\" -> [ | | ] \" + ... + wP + + . +\" emb w, b pre not IsEight(a2) post not CheckW() +RULE BlackPawnMove: + [ | | ] \" + ... + bP. + + . +\" -> [ | | ] \" + ... + ... + + bP +\" emb w, b pre not IsFirst(a1) post not CheckB() +RULE WhitePawnMoveDbl: + [ | | ] \" + + . + ... + ... + + wP +\" -> [ | | ] \" + ... + wP + + . + ... + ... +\" emb w, b pre IsSecond(a1) post not CheckW() +RULE BlackPawnMoveDbl: + [ | | ] \" + ... + bP. + + . + ... + ... +\" -> [ | | ] \" + + + ... + ... + + bP +\" emb w, b pre IsSeventh(a3) post not CheckB() +RULE WhitePawnBeat: + [ a, b | wP { a }; b { b } | - ] + -> + [ a, b | wP { b } | - ] + emb w, b + pre not IsEight(b) and ex z (C(a, z) and (R(z, b) or R(b, z))) + post not CheckW() +RULE WhitePawnBeatPromote: + [ a, b | wP { a }; b { b } | - ] + -> + [ a, b | wQ { b } | - ] + emb w, b + pre IsEight(b) and ex z (C(a, z) and (R(z, b) or R(b, z))) + post not CheckW() +RULE WhitePawnBeatRDbl: + [ | | ] \" + ... + ?..-bP + ... + ? ... + ... + wP.bP +\" -> [ | | ] \" + ... + ?... + ... + ? wP. + ... + .... +\" emb w, b post not CheckW() +RULE WhitePawnBeatLDbl: + [ | | ] \" + ... + -bP? + ... + . ?.. + ... + bP.wP +\" -> [ | | ] \" + ... + ...? + ... + wP ?.. + ... + .... +\" emb w, b post not CheckW() +RULE BlackPawnBeat: + [ a, b | bP { a }; w { b } | - ] + -> + [ a, b | bP { b } | - ] + emb w, b + pre not IsFirst(b) and ex z (C(z, a) and (R(z, b) or R(b, z))) + post not CheckB() +RULE BlackPawnBeatPromote: + [ a, b | bP { a }; w { b } | - ] + -> + [ a, b | bQ { b } | - ] + emb w, b + pre IsFirst(b) and ex z (C(z, a) and (R(z, b) or R(b, z))) + post not CheckB() +RULE BlackPawnBeatRDbl: + [ | | ] \" + ... + bP.wP + ... + ? ... + ... + ?..-wP +\" -> [ | | ] \" + ... + .... + ... + ? bP. + ... + ?... +\" emb w, b post not CheckB() +RULE BlackPawnBeatLDbl: + [ | | ] \" + ... + wP.bP + ... + . ?.. + ... + -wP? +\" -> [ | | ] \" + ... + .... + ... + bP ?.. + ... + ...? +\" emb w, b post not CheckB() +RULE WhitePawnPromote: + [ | | ] \" + ... + ... + + wP +\" -> [ | | ] \" + ... + wQ. + + . +\" emb w, b pre IsEight(a2) post not CheckW() +RULE BlackPawnPromote: + [ | | ] \" + ... + bP. + + . +\" -> [ | | ] \" + ... + ... + + bQ +\" emb w, b pre IsFirst(a1) post not CheckB() +RULE WhiteKnight: + [ a, b | wN { a }; _opt_b { b } | - ] + -> + [ a, b | wN { b } | - ] + emb w, b pre Knight(a, b) post not CheckW() +RULE BlackKnight: + [ a, b | bN { a }; _opt_w { b } | - ] + -> + [ a, b | bN { b } | - ] + emb w, b pre Knight(a, b) post not CheckB() +RULE WhiteBishop: + [ a, b | wB { a }; _opt_b { b } | - ] + -> + [ a, b | wB { b } | - ] + emb w, b pre Diag(a, b) post not CheckW() +RULE BlackBishop: + [ a, b | bB { a }; _opt_w { b } | - ] + -> + [ a, b | bB { b } | - ] + emb w, b pre Diag(a, b) post not CheckB() +RULE WhiteRook: + [ a, b | wR { a }; _opt_b { b } | - ] + -> + [ a, b | wR { b } | - ] + emb w, b pre not IsA1(a) and not IsH1(a) and Line(a, b) post not CheckW() +RULE WhiteRookA1: + [ a, b | wR { a }; _opt_b { b } | - ] + -> + [ a, b | wR { b } | - ] + emb w, b pre IsA1(a) and Line(a, b) post not CheckW() +RULE WhiteRookH1: + [ a, b | wR { a }; _opt_b { b } | - ] + -> + [ a, b | wR { b } | - ] + emb w, b pre IsH1(a) and Line(a, b) post not CheckW() +RULE BlackRook: + [ a, b | bR { a }; _opt_w { b } | - ] + -> + [ a, b | bR { b } | - ] + emb w, b pre not IsA8(a) and not IsH8(a) and Line(a, b) post not CheckB() +RULE BlackRookA8: + [ a, b | bR { a }; _opt_w { b } | - ] + -> + [ a, b | bR { b } | - ] + emb w, b pre IsA8(a) and Line(a, b) post not CheckB() +RULE BlackRookH8: + [ a, b | bR { a }; _opt_w { b } | - ] + -> + [ a, b | bR { b } | - ] + emb w, b pre IsH8(a) and Line(a, b) post not CheckB() +RULE WhiteQueen: + [ a, b | wQ { a }; _opt_b { b } | - ] + -> + [ a, b | wQ { b } | - ] + emb w, b pre (Line(a, b) or Diag(a, b)) post not CheckW() +RULE BlackQueen: + [ a, b | bQ { a }; _opt_w { b } | - ] + -> + [ a, b | bQ { b } | - ] + emb w, b pre (Line(a, b) or Diag(a, b)) post not CheckB() +RULE WhiteKing: + [ a, b | wK { a }; _opt_b { b } | - ] + -> + [ a, b | wK { b } | - ] + emb w, b pre Near(a, b) post not CheckW() +RULE BlackKing: + [ a, b | bK { a }; _opt_w { b } | - ] + -> + [ a, b | bK { b } | - ] + emb w, b pre Near(a, b) post not CheckB() +RULE WhiteLeftCastle: + [ | | ] \" + ... ... ... + wR. ... wK. +\" -> [ | | ] \" + ... ... ... + ... wK.wR ... +\" emb w,b pre not(bBeats(c1) or bBeats(d1) or bBeats(e1)) post true +RULE WhiteRightCastle: + [ | | ] \" + ... ... + wK. ...wR +\" -> [ | | ] \" + ... ... + ...wR wK. +\" emb w,b pre not (bBeats(a1) or bBeats(b1) or bBeats(c1)) post true +RULE BlackLeftCastle: + [ | | ] \" + ... ... ... + bR. ... bK. +\" -> [ | | ] \" + ... ... ... + ... bK.bR ... +\" emb w,b pre not(wBeats(c1) or wBeats(d1) or wBeats(e1)) post true +RULE BlackRightCastle: + [ | | ] \" + ... ... + bK. ...bR +\" -> [ | | ] \" + ... ... + ...bR bK. +\" emb w,b pre not (wBeats(a1) or wBeats(b1) or wBeats(c1)) post true +LOC 0 { // both can castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 1]; + [WhitePawnMoveDbl -> 1]; + [WhitePawnBeat -> 1]; + [WhitePawnBeatPromote -> 1]; + [WhitePawnBeatLDbl -> 1]; + [WhitePawnBeatRDbl -> 1]; + [WhitePawnPromote -> 1]; + [WhiteKnight -> 1]; + [WhiteBishop -> 1]; + [WhiteRook -> 1]; + [WhiteRookA1 -> 5]; + [WhiteRookH1 -> 3]; + [WhiteQueen -> 1]; + [WhiteLeftCastle -> 7]; + [WhiteRightCastle -> 7]; + [WhiteKing -> 7] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 1 { // both can castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 0]; + [BlackPawnMoveDbl -> 0]; + [BlackPawnBeat -> 0]; + [BlackPawnBeatPromote -> 0]; + [BlackPawnBeatLDbl -> 0]; + [BlackPawnBeatRDbl -> 0]; + [BlackPawnPromote -> 0]; + [BlackKnight -> 0]; + [BlackBishop -> 0]; + [BlackRook -> 0]; + [BlackRookA8 -> 16]; + [BlackRookH8 -> 8]; + [BlackQueen -> 0]; + [BlackLeftCastle -> 24]; + [BlackRightCastle -> 24]; + [BlackKing -> 24] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 2 { // w left, b can castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 3]; + [WhitePawnMoveDbl -> 3]; + [WhitePawnBeat -> 3]; + [WhitePawnBeatPromote -> 3]; + [WhitePawnBeatLDbl -> 3]; + [WhitePawnBeatRDbl -> 3]; + [WhitePawnPromote -> 3]; + [WhiteKnight -> 3]; + [WhiteBishop -> 3]; + [WhiteRook -> 3]; + [WhiteRookA1 -> 7]; + [WhiteRookH1 -> 3]; + [WhiteQueen -> 3]; + [WhiteLeftCastle -> 7]; + [WhiteKing -> 7] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 3 { // w left, b can castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 2]; + [BlackPawnMoveDbl -> 2]; + [BlackPawnBeat -> 2]; + [BlackPawnBeatPromote -> 2]; + [BlackPawnBeatLDbl -> 2]; + [BlackPawnBeatRDbl -> 2]; + [BlackPawnPromote -> 2]; + [BlackKnight -> 2]; + [BlackBishop -> 2]; + [BlackRook -> 2]; + [BlackRookA8 -> 18]; + [BlackRookH8 -> 10]; + [BlackQueen -> 2]; + [BlackLeftCastle -> 26]; + [BlackRightCastle -> 26]; + [BlackKing -> 26] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 4 { // w right, b can castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 5]; + [WhitePawnMoveDbl -> 5]; + [WhitePawnBeat -> 5]; + [WhitePawnBeatPromote -> 5]; + [WhitePawnBeatLDbl -> 5]; + [WhitePawnBeatRDbl -> 5]; + [WhitePawnPromote -> 5]; + [WhiteKnight -> 5]; + [WhiteBishop -> 5]; + [WhiteRook -> 5]; + [WhiteRookA1 -> 5]; + [WhiteRookH1 -> 7]; + [WhiteQueen -> 5]; + [WhiteRightCastle -> 7]; + [WhiteKing -> 7] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 5 { // w right, b can castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 4]; + [BlackPawnMoveDbl -> 4]; + [BlackPawnBeat -> 4]; + [BlackPawnBeatPromote -> 4]; + [BlackPawnBeatLDbl -> 4]; + [BlackPawnBeatRDbl -> 4]; + [BlackPawnPromote -> 4]; + [BlackKnight -> 4]; + [BlackBishop -> 4]; + [BlackRook -> 4]; + [BlackRookA8 -> 20]; + [BlackRookH8 -> 12]; + [BlackQueen -> 4]; + [BlackLeftCastle -> 28]; + [BlackRightCastle -> 28]; + [BlackKing -> 28] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 6 { // w no, b can castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 7]; + [WhitePawnMoveDbl -> 7]; + [WhitePawnBeat -> 7]; + [WhitePawnBeatPromote -> 7]; + [WhitePawnBeatLDbl -> 7]; + [WhitePawnBeatRDbl -> 7]; + [WhitePawnPromote -> 7]; + [WhiteKnight -> 7]; + [WhiteBishop -> 7]; + [WhiteRook -> 7]; + [WhiteRookA1 -> 7]; + [WhiteRookH1 -> 7]; + [WhiteQueen -> 7]; + [WhiteKing -> 7] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 7 { // w no, b can castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 6]; + [BlackPawnMoveDbl -> 6]; + [BlackPawnBeat -> 6]; + [BlackPawnBeatPromote -> 6]; + [BlackPawnBeatLDbl -> 6]; + [BlackPawnBeatRDbl -> 6]; + [BlackPawnPromote -> 6]; + [BlackKnight -> 6]; + [BlackBishop -> 6]; + [BlackRook -> 6]; + [BlackRookA8 -> 22]; + [BlackRookH8 -> 14]; + [BlackQueen -> 6]; + [BlackLeftCastle -> 30]; + [BlackRightCastle -> 30]; + [BlackKing -> 30] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 8 { // w can, b left castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 9]; + [WhitePawnMoveDbl -> 9]; + [WhitePawnBeat -> 9]; + [WhitePawnBeatPromote -> 9]; + [WhitePawnBeatLDbl -> 9]; + [WhitePawnBeatRDbl -> 9]; + [WhitePawnPromote -> 9]; + [WhiteKnight -> 9]; + [WhiteBishop -> 9]; + [WhiteRook -> 9]; + [WhiteRookA1 -> 13]; + [WhiteRookH1 -> 11]; + [WhiteQueen -> 9]; + [WhiteLeftCastle -> 15]; + [WhiteRightCastle -> 15]; + [WhiteKing -> 15] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 9 { // w can, b left castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 8]; + [BlackPawnMoveDbl -> 8]; + [BlackPawnBeat -> 8]; + [BlackPawnBeatPromote -> 8]; + [BlackPawnBeatLDbl -> 8]; + [BlackPawnBeatRDbl -> 8]; + [BlackPawnPromote -> 8]; + [BlackKnight -> 8]; + [BlackBishop -> 8]; + [BlackRook -> 8]; + [BlackRookA8 -> 24]; + [BlackRookH8 -> 8]; + [BlackQueen -> 8]; + [BlackLeftCastle -> 24]; + [BlackKing -> 24] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 10 { // w left, b left castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 11]; + [WhitePawnMoveDbl -> 11]; + [WhitePawnBeat -> 11]; + [WhitePawnBeatPromote -> 11]; + [WhitePawnBeatLDbl -> 11]; + [WhitePawnBeatRDbl -> 11]; + [WhitePawnPromote -> 11]; + [WhiteKnight -> 11]; + [WhiteBishop -> 11]; + [WhiteRook -> 11]; + [WhiteRookA1 -> 15]; + [WhiteRookH1 -> 11]; + [WhiteQueen -> 11]; + [WhiteLeftCastle -> 15]; + [WhiteKing -> 15] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 11 { // w left, b left castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 10]; + [BlackPawnMoveDbl -> 10]; + [BlackPawnBeat -> 10]; + [BlackPawnBeatPromote -> 10]; + [BlackPawnBeatLDbl -> 10]; + [BlackPawnBeatRDbl -> 10]; + [BlackPawnPromote -> 10]; + [BlackKnight -> 10]; + [BlackBishop -> 10]; + [BlackRook -> 10]; + [BlackRookA8 -> 26]; + [BlackRookH8 -> 10]; + [BlackQueen -> 10]; + [BlackLeftCastle -> 26]; + [BlackKing -> 26] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 12 { // w right, b left castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 13]; + [WhitePawnMoveDbl -> 13]; + [WhitePawnBeat -> 13]; + [WhitePawnBeatPromote -> 13]; + [WhitePawnBeatLDbl -> 13]; + [WhitePawnBeatRDbl -> 13]; + [WhitePawnPromote -> 13]; + [WhiteKnight -> 13]; + [WhiteBishop -> 13]; + [WhiteRook -> 13]; + [WhiteRookA1 -> 13]; + [WhiteRookH1 -> 15]; + [WhiteQueen -> 13]; + [WhiteRightCastle -> 15]; + [WhiteKing -> 15] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 13 { // w right, b left castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 12]; + [BlackPawnMoveDbl -> 12]; + [BlackPawnBeat -> 12]; + [BlackPawnBeatPromote -> 12]; + [BlackPawnBeatLDbl -> 12]; + [BlackPawnBeatRDbl -> 12]; + [BlackPawnPromote -> 12]; + [BlackKnight -> 12]; + [BlackBishop -> 12]; + [BlackRook -> 12]; + [BlackRookA8 -> 28]; + [BlackRookH8 -> 12]; + [BlackQueen -> 12]; + [BlackLeftCastle -> 28]; + [BlackKing -> 28] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 14 { // w no, b left castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 15]; + [WhitePawnMoveDbl -> 15]; + [WhitePawnBeat -> 15]; + [WhitePawnBeatPromote -> 15]; + [WhitePawnBeatLDbl -> 15]; + [WhitePawnBeatRDbl -> 15]; + [WhitePawnPromote -> 15]; + [WhiteKnight -> 15]; + [WhiteBishop -> 15]; + [WhiteRook -> 15]; + [WhiteRookA1 -> 15]; + [WhiteRookH1 -> 15]; + [WhiteQueen -> 15]; + [WhiteKing -> 15] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 15 { // w no, b left castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 14]; + [BlackPawnMoveDbl -> 14]; + [BlackPawnBeat -> 14]; + [BlackPawnBeatPromote -> 14]; + [BlackPawnBeatLDbl -> 14]; + [BlackPawnBeatRDbl -> 14]; + [BlackPawnPromote -> 14]; + [BlackKnight -> 14]; + [BlackBishop -> 14]; + [BlackRook -> 14]; + [BlackRookA8 -> 30]; + [BlackRookH8 -> 14]; + [BlackQueen -> 14]; + [BlackLeftCastle -> 30]; + [BlackKing -> 30] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 16 { // w can, b right castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 17]; + [WhitePawnMoveDbl -> 17]; + [WhitePawnBeat -> 17]; + [WhitePawnBeatPromote -> 17]; + [WhitePawnBeatLDbl -> 17]; + [WhitePawnBeatRDbl -> 17]; + [WhitePawnPromote -> 17]; + [WhiteKnight -> 17]; + [WhiteBishop -> 17]; + [WhiteRook -> 17]; + [WhiteRookA1 -> 21]; + [WhiteRookH1 -> 19]; + [WhiteQueen -> 17]; + [WhiteLeftCastle -> 23]; + [WhiteRightCastle -> 23]; + [WhiteKing -> 23] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 17 { // w can, b right castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 16]; + [BlackPawnMoveDbl -> 16]; + [BlackPawnBeat -> 16]; + [BlackPawnBeatPromote -> 16]; + [BlackPawnBeatLDbl -> 16]; + [BlackPawnBeatRDbl -> 16]; + [BlackPawnPromote -> 16]; + [BlackKnight -> 16]; + [BlackBishop -> 16]; + [BlackRook -> 16]; + [BlackRookA8 -> 16]; + [BlackRookH8 -> 24]; + [BlackQueen -> 16]; + [BlackRightCastle -> 24]; + [BlackKing -> 24] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 18 { // w left, b right castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 19]; + [WhitePawnMoveDbl -> 19]; + [WhitePawnBeat -> 19]; + [WhitePawnBeatPromote -> 19]; + [WhitePawnBeatLDbl -> 19]; + [WhitePawnBeatRDbl -> 19]; + [WhitePawnPromote -> 19]; + [WhiteKnight -> 19]; + [WhiteBishop -> 19]; + [WhiteRook -> 19]; + [WhiteRookA1 -> 23]; + [WhiteRookH1 -> 19]; + [WhiteQueen -> 19]; + [WhiteLeftCastle -> 23]; + [WhiteKing -> 23] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 19 { // w left, b right castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 18]; + [BlackPawnMoveDbl -> 18]; + [BlackPawnBeat -> 18]; + [BlackPawnBeatPromote -> 18]; + [BlackPawnBeatLDbl -> 18]; + [BlackPawnBeatRDbl -> 18]; + [BlackPawnPromote -> 18]; + [BlackKnight -> 18]; + [BlackBishop -> 18]; + [BlackRook -> 18]; + [BlackRookA8 -> 18]; + [BlackRookH8 -> 26]; + [BlackQueen -> 18]; + [BlackRightCastle -> 26]; + [BlackKing -> 26] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 20 { // w right, b right castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 21]; + [WhitePawnMoveDbl -> 21]; + [WhitePawnBeat -> 21]; + [WhitePawnBeatPromote -> 21]; + [WhitePawnBeatLDbl -> 21]; + [WhitePawnBeatRDbl -> 21]; + [WhitePawnPromote -> 21]; + [WhiteKnight -> 21]; + [WhiteBishop -> 21]; + [WhiteRook -> 21]; + [WhiteRookA1 -> 21]; + [WhiteRookH1 -> 23]; + [WhiteQueen -> 21]; + [WhiteRightCastle -> 23]; + [WhiteKing -> 23] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 21 { // w right, b right castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 20]; + [BlackPawnMoveDbl -> 20]; + [BlackPawnBeat -> 20]; + [BlackPawnBeatPromote -> 20]; + [BlackPawnBeatLDbl -> 20]; + [BlackPawnBeatRDbl -> 20]; + [BlackPawnPromote -> 20]; + [BlackKnight -> 20]; + [BlackBishop -> 20]; + [BlackRook -> 20]; + [BlackRookA8 -> 20]; + [BlackRookH8 -> 28]; + [BlackQueen -> 20]; + [BlackRightCastle -> 28]; + [BlackKing -> 28] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 22 { // w no, b right castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 23]; + [WhitePawnMoveDbl -> 23]; + [WhitePawnBeat -> 23]; + [WhitePawnBeatPromote -> 23]; + [WhitePawnBeatLDbl -> 23]; + [WhitePawnBeatRDbl -> 23]; + [WhitePawnPromote -> 23]; + [WhiteKnight -> 23]; + [WhiteBishop -> 23]; + [WhiteRook -> 23]; + [WhiteRookA1 -> 23]; + [WhiteRookH1 -> 23]; + [WhiteQueen -> 23]; + [WhiteKing -> 23] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 23 { // w no, b right castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 22]; + [BlackPawnMoveDbl -> 22]; + [BlackPawnBeat -> 22]; + [BlackPawnBeatPromote -> 22]; + [BlackPawnBeatLDbl -> 22]; + [BlackPawnBeatRDbl -> 22]; + [BlackPawnPromote -> 22]; + [BlackKnight -> 22]; + [BlackBishop -> 22]; + [BlackRook -> 22]; + [BlackRookA8 -> 22]; + [BlackRookH8 -> 30]; + [BlackQueen -> 22]; + [BlackRightCastle -> 30]; + [BlackKing -> 30] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 24 { // w can, b no castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 25]; + [WhitePawnMoveDbl -> 25]; + [WhitePawnBeat -> 25]; + [WhitePawnBeatPromote -> 25]; + [WhitePawnBeatLDbl -> 25]; + [WhitePawnBeatRDbl -> 25]; + [WhitePawnPromote -> 25]; + [WhiteKnight -> 25]; + [WhiteBishop -> 25]; + [WhiteRook -> 25]; + [WhiteRookA1 -> 29]; + [WhiteRookH1 -> 27]; + [WhiteQueen -> 25]; + [WhiteLeftCastle -> 31]; + [WhiteRightCastle -> 31]; + [WhiteKing -> 31] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 25 { // w can, b no castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 24]; + [BlackPawnMoveDbl -> 24]; + [BlackPawnBeat -> 24]; + [BlackPawnBeatPromote -> 24]; + [BlackPawnBeatLDbl -> 24]; + [BlackPawnBeatRDbl -> 24]; + [BlackPawnPromote -> 24]; + [BlackKnight -> 24]; + [BlackBishop -> 24]; + [BlackRook -> 24]; + [BlackRookA8 -> 24]; + [BlackRookH8 -> 24]; + [BlackQueen -> 24]; + [BlackKing -> 24] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 26 { // w left, b no castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 27]; + [WhitePawnMoveDbl -> 27]; + [WhitePawnBeat -> 27]; + [WhitePawnBeatPromote -> 27]; + [WhitePawnBeatLDbl -> 27]; + [WhitePawnBeatRDbl -> 27]; + [WhitePawnPromote -> 27]; + [WhiteKnight -> 27]; + [WhiteBishop -> 27]; + [WhiteRook -> 27]; + [WhiteRookA1 -> 31]; + [WhiteRookH1 -> 27]; + [WhiteQueen -> 27]; + [WhiteLeftCastle -> 31]; + [WhiteKing -> 31] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 27 { // w left, b no castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 26]; + [BlackPawnMoveDbl -> 26]; + [BlackPawnBeat -> 26]; + [BlackPawnBeatPromote -> 26]; + [BlackPawnBeatLDbl -> 26]; + [BlackPawnBeatRDbl -> 26]; + [BlackPawnPromote -> 26]; + [BlackKnight -> 26]; + [BlackBishop -> 26]; + [BlackRook -> 26]; + [BlackRookA8 -> 26]; + [BlackRookH8 -> 26]; + [BlackQueen -> 26]; + [BlackKing -> 26] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 28 { // w right, b no castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 29]; + [WhitePawnMoveDbl -> 29]; + [WhitePawnBeat -> 29]; + [WhitePawnBeatPromote -> 29]; + [WhitePawnBeatLDbl -> 29]; + [WhitePawnBeatRDbl -> 29]; + [WhitePawnPromote -> 29]; + [WhiteKnight -> 29]; + [WhiteBishop -> 29]; + [WhiteRook -> 29]; + [WhiteRookA1 -> 29]; + [WhiteRookH1 -> 31]; + [WhiteQueen -> 29]; + [WhiteRightCastle -> 31]; + [WhiteKing -> 31] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 29 { // w right, b no castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 28]; + [BlackPawnMoveDbl -> 28]; + [BlackPawnBeat -> 28]; + [BlackPawnBeatPromote -> 28]; + [BlackPawnBeatLDbl -> 28]; + [BlackPawnBeatRDbl -> 28]; + [BlackPawnPromote -> 28]; + [BlackKnight -> 28]; + [BlackBishop -> 28]; + [BlackRook -> 28]; + [BlackRookA8 -> 28]; + [BlackRookH8 -> 28]; + [BlackQueen -> 28]; + [BlackKing -> 28] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +LOC 30 { // w no, b no castle + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + MOVES + [WhitePawnMove -> 31]; + [WhitePawnMoveDbl -> 31]; + [WhitePawnBeat -> 31]; + [WhitePawnBeatPromote -> 31]; + [WhitePawnBeatLDbl -> 31]; + [WhitePawnBeatRDbl -> 31]; + [WhitePawnPromote -> 31]; + [WhiteKnight -> 31]; + [WhiteBishop -> 31]; + [WhiteRook -> 31]; + [WhiteRookA1 -> 31]; + [WhiteRookH1 -> 31]; + [WhiteQueen -> 31]; + [WhiteKing -> 31] + } + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + } +} +LOC 31 { // w no, b no castle + PLAYER 2 { + COND -1; -5; -3; -3; -9; 1; 5; 3; 3; 9; -0.05; 0.05 + PAYOFF :(CheckW()) - :(CheckB()) + MOVES + [BlackPawnMove -> 30]; + [BlackPawnMoveDbl -> 30]; + [BlackPawnBeat -> 30]; + [BlackPawnBeatPromote -> 30]; + [BlackPawnBeatLDbl -> 30]; + [BlackPawnBeatRDbl -> 30]; + [BlackPawnPromote -> 30]; + [BlackKnight -> 30]; + [BlackBishop -> 30]; + [BlackRook -> 30]; + [BlackRookA8 -> 30]; + [BlackRookH8 -> 30]; + [BlackQueen -> 30]; + [BlackKing -> 30] + } + PLAYER 1 { + COND 1; 5; 3; 3; 9; -1; -5; -3; -3; -9; 0.05; -0.05 + PAYOFF :(CheckB()) - :(CheckW()) + } +} +MODEL [ | | ] \" + ... ... ... ... + bR bN.bB bQ.bK bB.bN bR. + ... ... ... ... + bP.bP bP.bP bP.bP bP.bP + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + wP wP.wP wP.wP wP.wP wP. + ... ... ... ... + wR.wN wB.wQ wK.wB wN.wR +\" with +D1(x, y) = ex z ( (R(x, z) and C(z, y)) or (R(y, z) and C(z, x)) ) ; +D2(x, y) = ex z ( (R(x, z) and C(y, z)) or (R(y, z) and C(x, z)) ) +") + let connect4_str = ("PLAYERS 1, 2 DATA r1: circle, r2: line, adv_ratio: 4, depth: 6 REL Row4 (x, y, z, v) = R(x, y) and R(y, z) and R(z, v) @@ -643,12 +1826,12 @@ let games = ref [ - "Breakthrough", compile_game_data breakthrough_str; - "Checkers", compile_game_data checkers_str; - (* "Chess", compile_game_data chess_str; *) - "Connect4", compile_game_data connect4_str; - "Entanglement", compile_game_data entanglement_str; - "Gomoku", compile_game_data gomoku_str; - "Pawn-Whopping", compile_game_data pawn_whopping_str; - "Tic-Tac-Toe", compile_game_data tictactoe_str; + compile_game_data "Breakthrough" breakthrough_str; + compile_game_data "Checkers" checkers_str; + (* compile_game_data "Chess" chess_str; *) + compile_game_data "Connect4" connect4_str; + compile_game_data "Entanglement" entanglement_str; + compile_game_data "Gomoku" gomoku_str; + compile_game_data "Pawn-Whopping" pawn_whopping_str; + compile_game_data "Tic-Tac-Toe" tictactoe_str; ] Modified: trunk/Toss/Server/JsHandler.ml =================================================================== --- trunk/Toss/Server/JsHandler.ml 2012-02-01 18:27:03 UTC (rev 1659) +++ trunk/Toss/Server/JsHandler.ml 2012-02-01 19:28:39 UTC (rev 1660) @@ -147,16 +147,17 @@ let game, _ = !cur_game.game_state in let state = List.hd !play_states in try + let large_iters = 100000 in let (move, _) = - Aux.random_elem (Play.maximax_unfold_choose 100000 + Aux.random_elem (Play.maximax_unfold_choose large_iters game state !cur_game.heuristic) in Play.cancel_timeout (); - let algo_iters = !Play.latest_gametree_size in + let algo_iters = large_iters - !Play.latest_unfold_iters_left in let move_id = Aux.array_argfind (fun (_, m, _) -> m = move) !cur_all_moves in let result = js_of_move game state move_id (!cur_all_moves.(move_id)) in - Js.Unsafe.set result (js"comp_tree_size") + Js.Unsafe.set result (js"comp_iters") (Js.number_of_float (float_of_int algo_iters)); Js.Unsafe.set result (js"comp_started") (Js.number_of_float comp_started); @@ -176,7 +177,7 @@ let set_game game_name game_str = let game_name = of_js game_name and game_str = of_js game_str in try - games := (game_name, compile_game_data game_str) :: !games; + games := compile_game_data game_name game_str :: !games; js ("Game "^game_name^" set.") with Lexer.Parsing_error s -> js ("Game "^game_name^" ERROR: "^s) Modified: trunk/Toss/WebClient/JsHandler.js =================================================================== --- trunk/Toss/WebClient/JsHandler.js 2012-02-01 18:27:03 UTC (rev 1659) +++ trunk/Toss/WebClient/JsHandler.js 2012-02-01 19:28:39 UTC (rev 1660) @@ -892,4 +892,4 @@ if( y.fun ) { x.fun = y.fun; return 0; } var i = y.length; while (i--) x[i] = y[i]; return 0; } @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-01 18:27:11
|
Revision: 1659 http://toss.svn.sourceforge.net/toss/?rev=1659&view=rev Author: lukaszkaiser Date: 2012-02-01 18:27:03 +0000 (Wed, 01 Feb 2012) Log Message: ----------- MenhirLib sources to test --table with js_of_ocaml. Modified Paths: -------------- trunk/Toss/Makefile trunk/Toss/menhir_conf Added Paths: ----------- trunk/Toss/MenhirLib/ trunk/Toss/MenhirLib/engine.ml trunk/Toss/MenhirLib/engine.mli trunk/Toss/MenhirLib/engineTypes.ml trunk/Toss/MenhirLib/infiniteArray.ml trunk/Toss/MenhirLib/infiniteArray.mli trunk/Toss/MenhirLib/packedIntArray.ml trunk/Toss/MenhirLib/packedIntArray.mli trunk/Toss/MenhirLib/rowDisplacement.ml trunk/Toss/MenhirLib/rowDisplacement.mli trunk/Toss/MenhirLib/tableFormat.ml trunk/Toss/MenhirLib/tableInterpreter.ml trunk/Toss/MenhirLib/tableInterpreter.mli Removed Paths: ------------- trunk/Toss/js_of_ocaml_test.html trunk/Toss/js_of_ocaml_test.ml Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2012-02-01 14:15:01 UTC (rev 1658) +++ trunk/Toss/Makefile 2012-02-01 18:27:03 UTC (rev 1659) @@ -53,15 +53,15 @@ OCAMLBUILDNOPP=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf \ $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) -FormulaINCSatINC=Formula -FormulaINC=Formula,Formula/Sat,Formula/Sat/dpll -SolverINC=Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim -ArenaINC=Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver -PlayINC=Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena -LearnINC=Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena -GGPINC=Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena,Play -ServerINC=Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena,Play,GGP,Learn -.INC=Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena,Play,GGP,Learn,Server +FormulaINCSatINC=MenhirLib,Formula +FormulaINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll +SolverINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim +ArenaINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver +PlayINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena +LearnINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena +GGPINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena,Play +ServerINC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena,Play,GGP,Learn +.INC=MenhirLib,Formula,Formula/Sat,Formula/Sat/dpll,Solver/RealQuantElim,Solver,Arena,Play,GGP,Learn,Server %.native: %.ml caml_extensions/pa_let_try.cmo $(OCAMLBUILD) -Is $($(subst /,INC,$(dir $@))) $@ Added: trunk/Toss/MenhirLib/engine.ml =================================================================== --- trunk/Toss/MenhirLib/engine.ml (rev 0) +++ trunk/Toss/MenhirLib/engine.ml 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,367 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +open EngineTypes + +(* The LR parsing engine. *) + +(* This module is used: + + - at compile time, if so requested by the user, via the --interpret options; + - at run time, in the table-based back-end. *) + +module Make (T : TABLE) = struct + + (* This propagates type and exception definitions. *) + + include T + + let _eRR : exn = + Error + + (* --------------------------------------------------------------------------- *) + + (* [discard] takes a token off the input stream, queries the lexer + for a new one, and stores it into [env.token], overwriting the + previous token. If [env.shifted] has not yet reached its limit, + it is incremented. *) + + let discard env = + let lexbuf = env.lexbuf in + let token = env.lexer lexbuf in + env.token <- token; + Log.lookahead_token lexbuf (T.token2terminal token); + let shifted = env.shifted + 1 in + if shifted >= 0 then + env.shifted <- shifted + + (* --------------------------------------------------------------------------- *) + + (* The type [void] is empty. Many of the functions below have return type + [void]. This guarantees that they never return a value. Instead, they + must stop by raising an exception: either [Accept] or [Error]. *) + + type void + + (* --------------------------------------------------------------------------- *) + + (* In the code-based back-end, the [run] function is sometimes responsible + for pushing a new cell on the stack. This is motivated by code sharing + concerns. In this interpreter, there is no such concern; [run]'s caller + is always responsible for updating the stack. *) + + (* In the code-based back-end, there is a [run] function for each state + [s]. This function can behave in two slightly different ways, depending + on when it is invoked, or (equivalently) depending on [s]. + + If [run] is invoked after shifting a terminal symbol (or, equivalently, + if [s] has a terminal incoming symbol), then [run] discards a token, + unless [s] has a default reduction on [#]. (Indeed, in that case, + requesting the next token might drive the lexer off the end of the input + stream.) + + If, on the other hand, [run] is invoked after performing a goto transition, + or invoked directly by an entry point, then there is nothing to discard. + + These two cases are reflected in [CodeBackend.gettoken]. + + Here, the code is structured in a slightly different way. It is up to + the caller of [run] to indicate whether to discard a token. *) + + let rec run env please_discard : void = + + (* Log the fact that we just entered this state. *) + + let s = env.current in + Log.state s; + + (* If [please_discard] is set, discard a token and fetch the next one. *) + + (* This flag is set when [s] is being entered by shifting a terminal + symbol and [s] does not have a default reduction on [#]. *) + + if please_discard then + discard env; + + (* Examine what situation we are in. This case analysis is analogous to + that performed in [CodeBackend.gettoken], in the sub-case where we do + not have a terminal incoming symbol. *) + + T.default_reduction + s + reduce (* there is a default reduction; perform it *) + continue (* there is none; continue below *) + env + + and continue env : void = + + (* There is no default reduction. Consult the current lookahead token + so as to determine which action should be taken. *) + + (* Peeking at the first input token, without taking it off the input + stream, is normally done by reading [env.token]. However, we check + [env.shifted] first: if it is -1, then the lookahead token is the + [error] token. *) + + (* Note that, if we just called [discard] above, then the lookahead + token cannot be [error]. *) + + if env.shifted = (-1) then begin + Log.resuming_error_handling(); + error env + end + else + action env + + (* --------------------------------------------------------------------------- *) + + (* When [action] is invoked, we know that the current state does not have + a default reduction. We also know that the current lookahead token is + not [error]: it is a real token, stored in [env.token]. *) + + and action env : void = + + (* We consult the two-dimensional action table, indexed by the + current state and the current lookahead token, in order to + determine which action should be taken. *) + + let token = env.token in + T.action + env.current (* determines a row *) + (T.token2terminal token) (* determines a column *) + (T.token2value token) + shift (* shift continuation *) + reduce (* reduce continuation *) + initiate (* failure continuation *) + env + + (* --------------------------------------------------------------------------- *) + + (* This function takes care of shift transitions along a terminal symbol. + (Goto transitions are taken care of within [reduce] below.) The symbol + can be either an actual token or the [error] pseudo-token. *) + + and shift env + (please_discard : bool) + (terminal : terminal) + (value : semantic_value) + (s' : state) + : void = + + (* Log the transition. *) + + Log.shift terminal s'; + + (* Push a new cell onto the stack, containing the identity of the + state that we are leaving. *) + + let lexbuf = env.lexbuf in + env.stack <- { + state = env.current; + semv = value; + startp = lexbuf.Lexing.lex_start_p; + endp = lexbuf.Lexing.lex_curr_p; + next = env.stack; + }; + + (* Switch to state [s']. *) + + env.current <- s'; + run env please_discard + + (* --------------------------------------------------------------------------- *) + + (* This function takes care of reductions. *) + + and reduce env (prod : production) : void = + + (* Log a reduction event. *) + + Log.reduce_or_accept prod; + + (* Invoke the semantic action. The semantic action is responsible for + truncating the stack, updating the current state, producing a cell that + contains a new semantic value, and raising [Accept] or [Error] if + appropriate. *) + + (* If the semantic action raises [Error], we catch it immediately and + initiate error handling. *) + + (* The apparently weird idiom used here is an encoding for a + [let/unless] construct, which does not exist in ocaml. *) + + if ( + try + T.semantic_action prod env; + true + with Error -> + false + ) then begin + + (* By our convention, the semantic action is responsible for updating + the stack. The state now found in the top stack cell is the return + state. *) + + (* Perform a goto transition. The target state is determined + by consulting the goto table at the return state and at + production [prod]. *) + + env.current <- T.goto env.stack.state prod; + run env false + + end + else + errorbookkeeping env + + + (* --------------------------------------------------------------------------- *) + + (* The following functions deal with errors. *) + + (* [initiate] and [errorbookkeeping] initiate error handling. See the functions + by the same names in [CodeBackend]. *) + + and initiate env : void = + assert (env.shifted >= 0); + if T.recovery && env.shifted = 0 then begin + Log.discarding_last_token (T.token2terminal env.token); + discard env; + env.shifted <- 0; + action env + end + else + errorbookkeeping env + + and errorbookkeeping env = + Log.initiating_error_handling(); + env.previouserror <- env.shifted; + env.shifted <- (-1); + error env + + (* [error] handles errors. *) + + and error env : void = + + (* Consult the column associated with the [error] pseudo-token in the + action table. *) + + T.action + env.current (* determines a row *) + T.error_terminal (* determines a column *) + T.error_value + error_shift (* shift continuation *) + error_reduce (* reduce continuation *) + error_fail (* failure continuation *) + env + + and error_shift env please_discard terminal value s' = + + (* Here, [terminal] is [T.error_terminal], and [value] is [T.error_value]. *) + + assert (terminal = T.error_terminal && value = T.error_value); + + (* This state is capable of shifting the [error] token. *) + + Log.handling_error env.current; + shift env please_discard terminal value s' + + and error_reduce env prod = + + (* This state is capable of performing a reduction on [error]. *) + + Log.handling_error env.current; + reduce env prod + + and error_fail env = + + (* This state is unable to handle errors. Attempt to pop a stack + cell. *) + + let cell = env.stack in + let next = cell.next in + if next == cell then + + (* The stack is empty. Die. *) + + raise _eRR + + else begin + + (* The stack is nonempty. Pop a cell, updating the current state + with that found in the popped cell, and try again. *) + + env.stack <- next; + env.current <- cell.state; + error env + + end + + (* --------------------------------------------------------------------------- *) + + let entry + (s : state) + (lexer : Lexing.lexbuf -> token) + (lexbuf : Lexing.lexbuf) + : semantic_value = + + (* Build an empty stack. This is a dummy cell, which is its own + successor. Its fields other than [next] contain dummy values. *) + + let rec empty = { + state = s; (* dummy *) + semv = T.error_value; (* dummy *) + startp = lexbuf.Lexing.lex_start_p; (* dummy *) + endp = lexbuf.Lexing.lex_curr_p; (* dummy *) + next = empty; + } in + + (* Perform an initial call to the lexer. *) + + let token : token = + lexer lexbuf + in + + (* Log our first lookahead token. *) + + Log.lookahead_token lexbuf (T.token2terminal token); + + (* Build an initial environment. *) + + let env = { + lexer = lexer; + lexbuf = lexbuf; + token = token; + shifted = max_int; + previouserror = max_int; + stack = empty; + current = s; + } in + + (* Run. Catch [Accept], which represents normal termination. Let [Error] + escape. *) + + try + + (* If ocaml offered a [match/with] construct with zero branches, this is + what we would use here, since the type [void] has zero cases. *) + + let (_ : void) = run env false in + assert false (* cannot fail *) + + with + | Accept v -> + v + +end + Added: trunk/Toss/MenhirLib/engine.mli =================================================================== --- trunk/Toss/MenhirLib/engine.mli (rev 0) +++ trunk/Toss/MenhirLib/engine.mli 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,21 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +open EngineTypes + +(* The LR parsing engine. *) + +module Make (T : TABLE) : ENGINE with type state = T.state + and type token = T.token + and type semantic_value = T.semantic_value Added: trunk/Toss/MenhirLib/engineTypes.ml =================================================================== --- trunk/Toss/MenhirLib/engineTypes.ml (rev 0) +++ trunk/Toss/MenhirLib/engineTypes.ml 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,331 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +(* This file defines several types and module types that are used in the + specification of module [Engine]. *) + +(* --------------------------------------------------------------------------- *) + +(* It would be nice if we could keep the structure of stacks and environments + hidden. However, stacks and environments must be accessible to semantic + actions, so the following data structure definitions must be public. *) + +(* --------------------------------------------------------------------------- *) + +(* A stack is a linked list of cells. A sentinel cell -- which is its own + successor -- is used to mark the bottom of the stack. The sentinel cell + itself is not significant -- it contains dummy values. *) + +type ('state, 'semantic_value) stack = { + + (* The state that we should go back to if we pop this stack cell. *) + + (* This convention means that the state contained in the top stack cell is + not the current state [env.current]. It also means that the state found + within the sentinel is a dummy -- it is never consulted. This convention + is the same as that adopted by the code-based back-end. *) + + state: 'state; + + (* The semantic value associated with the chunk of input that this cell + represents. *) + + semv: 'semantic_value; + + (* The start and end positions of the chunk of input that this cell + represents. *) + + startp: Lexing.position; + endp: Lexing.position; + + (* The next cell down in the stack. If this is a self-pointer, then this + cell is the sentinel, and the stack is conceptually empty. *) + + next: ('state, 'semantic_value) stack; + +} + +(* --------------------------------------------------------------------------- *) + +(* A parsing environment contains basically all of the automaton's state. *) + +type ('state, 'semantic_value, 'token) env = { + + (* The lexer. *) + + lexer: Lexing.lexbuf -> 'token; + + (* The lexing buffer. It is used as an argument to the lexer, and also + accessed directly when extracting positions. *) + + lexbuf: Lexing.lexbuf; + + (* The last token that was obtained from the lexer. *) + + mutable token: 'token; + + (* A count of how many tokens were shifted since the beginning, or since + the last [error] token was encountered. By convention, if [shifted] + is (-1), then the current lookahead token is [error]. *) + + mutable shifted: int; + + (* A copy of the value of [shifted] just before the most recent error + was detected. This value is not used by the automaton itself, but + is made accessible to semantic actions. *) + + mutable previouserror: int; + + (* The stack. In [CodeBackend], it is passed around on its own, + whereas, here, it is accessed via the environment. *) + + mutable stack: ('state, 'semantic_value) stack; + + (* The current state. In [CodeBackend], it is passed around on its + own, whereas, here, it is accessed via the environment. *) + + mutable current: 'state; + +} + +(* --------------------------------------------------------------------------- *) + +(* This signature describes the parameters that must be supplied to the LR + engine. *) + +module type TABLE = sig + + (* The type of automaton states. *) + + type state + + (* The type of tokens. These can be thought of as real tokens, that is, + tokens returned by the lexer. They carry a semantic value. This type + does not include the [error] pseudo-token. *) + + type token + + (* The type of terminal symbols. These can be thought of as integer codes. + They do not carry a semantic value. This type does include the [error] + pseudo-token. *) + + type terminal + + (* The type of semantic values. *) + + type semantic_value + + (* A token is conceptually a pair of a (non-[error]) terminal symbol and + a semantic value. The following two functions are the pair projections. *) + + val token2terminal: token -> terminal + val token2value: token -> semantic_value + + (* Even though the [error] pseudo-token is not a real token, it is a + terminal symbol. Furthermore, for regularity, it must have a semantic + value. *) + + val error_terminal: terminal + val error_value: semantic_value + + (* The type of productions. *) + + type production + + (* If a state [s] has a default reduction on production [prod], then, upon + entering [s], the automaton should reduce [prod] without consulting the + lookahead token. The following function allows determining which states + have default reductions. *) + + (* Instead of returning a value of a sum type -- either [DefRed prod], or + [NoDefRed] -- it accepts two continuations, and invokes just one of + them. This mechanism allows avoiding a memory allocation. *) + + val default_reduction: + state -> + ('env -> production -> 'answer) -> + ('env -> 'answer) -> + 'env -> 'answer + + (* An LR automaton can normally take three kinds of actions: shift, reduce, + or fail. (Acceptance is a particular case of reduction: it consists in + reducing a start production.) *) + + (* There are two variants of the shift action. [shift/discard s] instructs + the automaton to discard the current token, request a new one from the + lexer, and move to state [s]. [shift/nodiscard s] instructs it to move to + state [s] without requesting a new token. This instruction should be used + when [s] has a default reduction on [#]. See [CodeBackend.gettoken] for + details. *) + + (* This is the automaton's action table. It maps a pair of a state and a + terminal symbol to an action. *) + + (* Instead of returning a value of a sum type -- one of shift/discard, + shift/nodiscard, reduce, or fail -- this function accepts three + continuations, and invokes just one them. This mechanism allows avoiding + a memory allocation. *) + + (* In summary, the parameters to [action] are as follows: + + - the first two parameters, a state and a terminal symbol, are used to + look up the action table; + + - the next parameter is the semantic value associated with the above + terminal symbol; it is not used, only passed along to the shift + continuation, as explained below; + + - the shift continuation expects an environment; a flag that tells + whether to discard the current token; the terminal symbol that + is being shifted; its semantic value; and the target state of + the transition; + + - the reduce continuation expects an environment and a production; + + - the fail continuation expects an environment; + + - the last parameter is the environment; it is not used, only passed + along to the selected continuation. *) + + val action: + state -> + terminal -> + semantic_value -> + ('env -> bool -> terminal -> semantic_value -> state -> 'answer) -> + ('env -> production -> 'answer) -> + ('env -> 'answer) -> + 'env -> 'answer + + (* This is the automaton's goto table. It maps a pair of a state and a + production to a new state. + + This convention is slightly different from the textbook approach. The + goto table is usually indexed by a state and a non-terminal symbol. *) + + val goto: state -> production -> state + + (* By convention, a semantic action is responsible for: + + 1. fetching whatever semantic values and positions it needs off the stack; + + 2. popping an appropriate number of cells off the stack, as dictated + by the length of the right-hand side of the production; this involves + updating [env.stack]; + + 3. computing a new semantic value, as well as new start and end positions; + + 4. pushing a new stack cell, which contains the three values + computed in step 3; this again involves updating [env.stack] + (only one update is necessary). + + Point 1 is essentially forced upon us: if semantic values were fetched + off the stack by this interpreter, then the calling convention for + semantic actions would be variadic: not all semantic actions would have + the same number of arguments. The rest follows rather naturally. *) + + (* If production [prod] is an accepting production, then the semantic action + is responsible for raising exception [Accept], instead of returning + normally. This convention allows us to not distinguish between regular + productions and accepting productions. All we have to do is catch that + exception at top level. *) + + (* Semantic actions are allowed to raise [Error]. *) + + exception Accept of semantic_value + exception Error + + type semantic_action = + (state, semantic_value, token) env -> unit + + val semantic_action: production -> semantic_action + + (* The LR engine can attempt error recovery. This consists in discarding + tokens, just after an error has been successfully handled, until a token + that can be successfully handled is found. This mechanism is optional. + The following flag enables it. *) + + val recovery: bool + + (* The LR engine requires a number of hooks, which are used for logging. *) + + (* The comments below indicate the conventional messages that correspond + to these hooks in the code-based back-end; see [CodeBackend]. *) + + module Log : sig + + (* State %d: *) + + val state: state -> unit + + (* Shifting (<terminal>) to state <state> *) + + val shift: terminal -> state -> unit + + (* Reducing a production should be logged either as a reduction + event (for regular productions) or as an acceptance event (for + start productions). *) + + (* Reducing production <production> / Accepting *) + + val reduce_or_accept: production -> unit + + (* Lookahead token is now <terminal> (<pos>-<pos>) *) + + val lookahead_token: Lexing.lexbuf -> terminal -> unit + + (* Initiating error handling *) + + val initiating_error_handling: unit -> unit + + (* Resuming error handling *) + + val resuming_error_handling: unit -> unit + + (* Handling error in state <state> *) + + val handling_error: state -> unit + + (* Discarding last token read (<terminal>) *) + + val discarding_last_token: terminal -> unit + + end + +end + +(* --------------------------------------------------------------------------- *) + +(* This signature describes the LR engine. *) + +module type ENGINE = sig + + type state + + type token + + type semantic_value + + (* An entry point to the engine requires a start state, a lexer, and a lexing + buffer. It either succeeds and produces a semantic value, or fails and + raises [Error]. *) + + exception Error + + val entry: + state -> + (Lexing.lexbuf -> token) -> + Lexing.lexbuf -> + semantic_value + +end Added: trunk/Toss/MenhirLib/infiniteArray.ml =================================================================== --- trunk/Toss/MenhirLib/infiniteArray.ml (rev 0) +++ trunk/Toss/MenhirLib/infiniteArray.ml 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,64 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +(* $Id: infiniteArray.ml,v 1.6 2007/09/10 21:09:37 fpottier Exp $ *) + +(** This module implements infinite arrays, that is, arrays that grow + transparently upon demand. *) + +type 'a t = { + default: 'a; + mutable table: 'a array; + mutable extent: int; (* the index of the greatest [set] ever, plus one *) + } + +let default_size = + 16384 (* must be non-zero *) + +let make x = { + default = x; + table = Array.make default_size x; + extent = 0; +} + +let rec new_length length i = + if i < length then + length + else + new_length (2 * length) i + +let ensure a i = + let table = a.table in + let length = Array.length table in + if i >= length then begin + let table' = Array.make (new_length (2 * length) i) a.default in + Array.blit table 0 table' 0 length; + a.table <- table' + end + +let get a i = + ensure a i; + a.table.(i) + +let set a i x = + ensure a i; + a.table.(i) <- x; + a.extent <- max (i + 1) a.extent + +let extent a = + a.extent + +let domain a = + Array.sub a.table 0 a.extent + Added: trunk/Toss/MenhirLib/infiniteArray.mli =================================================================== --- trunk/Toss/MenhirLib/infiniteArray.mli (rev 0) +++ trunk/Toss/MenhirLib/infiniteArray.mli 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,39 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +(* $Id: infiniteArray.mli,v 1.5 2007/09/10 21:09:37 fpottier Exp $ *) + +(** This module implements infinite arrays. **) +type 'a t + +(** [make x] creates an infinite array, where every slot contains [x]. **) +val make: 'a -> 'a t + +(** [get a i] returns the element contained at offset [i] in the array [a]. + Slots are numbered 0 and up. **) +val get: 'a t -> int -> 'a + +(** [set a i x] sets the element contained at offset [i] in the array + [a] to [x]. Slots are numbered 0 and up. **) +val set: 'a t -> int -> 'a -> unit + +(** [extent a] is the length of an initial segment of the array [a] + that is sufficiently large to contain all [set] operations ever + performed. In other words, all elements beyond that segment have + the default value. *) +val extent: 'a t -> int + +(** [domain a] is a fresh copy of an initial segment of the array [a] + whose length is [extent a]. *) +val domain: 'a t -> 'a array Added: trunk/Toss/MenhirLib/packedIntArray.ml =================================================================== --- trunk/Toss/MenhirLib/packedIntArray.ml (rev 0) +++ trunk/Toss/MenhirLib/packedIntArray.ml 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,199 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +(* A packed integer array is represented as a pair of an integer [k] and + a string [s]. The integer [k] is the number of bits per integer that we + use. The string [s] is just an array of bits, which is read in 8-bit + chunks. *) + +(* The ocaml programming language treats string literals and array literals + in slightly different ways: the former are statically allocated, while + the latter are dynamically allocated. (This is rather arbitrary.) In the + context of Menhir's table-based back-end, where compact, immutable + integer arrays are needed, ocaml strings are preferable to ocaml arrays. *) + +type t = + int * string + +(* The magnitude [k] of an integer [v] is the number of bits required + to represent [v]. It is rounded up to the nearest power of two, so + that [k] divides [Sys.word_size]. *) + +let magnitude (v : int) = + if v < 0 then + Sys.word_size + else + let rec check k max = (* [max] equals [2^k] *) + if (max <= 0) || (v < max) then + k + (* if [max] just overflew, then [v] requires a full ocaml + integer, and [k] is the number of bits in an ocaml integer + plus one, that is, [Sys.word_size]. *) + else + check (2 * k) (max * max) + in + check 1 2 + +(* [pack a] turns an array of integers into a packed integer array. *) + +(* Because the sign bit is the most significant bit, the magnitude of + any negative number is the word size. In other words, [pack] does + not achieve any space savings as soon as [a] contains any negative + numbers, even if they are ``small''. *) + +let pack (a : int array) : t = + + let m = Array.length a in + + (* Compute the maximum magnitude of the array elements. This tells + us how many bits per element we are going to use. *) + + let k = + Array.fold_left (fun k v -> + max k (magnitude v) + ) 1 a + in + + (* Because access to ocaml strings is performed on an 8-bit basis, + two cases arise. If [k] is less than 8, then we can pack multiple + array entries into a single character. If [k] is greater than 8, + then we must use multiple characters to represent a single array + entry. *) + + if k <= 8 then begin + + (* [w] is the number of array entries that we pack in a character. *) + + assert (8 mod k = 0); + let w = 8 / k in + + (* [n] is the length of the string that we allocate. *) + + let n = + if m mod w = 0 then + m / w + else + m / w + 1 + in + + let s = + String.create n + in + + (* Define a reader for the source array. The reader might run off + the end if [w] does not divide [m]. *) + + let i = ref 0 in + let next () = + let ii = !i in + if ii = m then + 0 (* ran off the end, pad with zeroes *) + else + let v = a.(ii) in + i := ii + 1; + v + in + + (* Fill up the string. *) + + for j = 0 to n - 1 do + let c = ref 0 in + for x = 1 to w do + c := (!c lsl k) lor next() + done; + s.[j] <- Char.chr !c + done; + + (* Done. *) + + k, s + + end + else begin (* k > 8 *) + + (* [w] is the number of characters that we use to encode an array entry. *) + + assert (k mod 8 = 0); + let w = k / 8 in + + (* [n] is the length of the string that we allocate. *) + + let n = + m * w + in + + let s = + String.create n + in + + (* Fill up the string. *) + + for i = 0 to m - 1 do + let v = ref a.(i) in + for x = 1 to w do + s.[(i + 1) * w - x] <- Char.chr (!v land 255); + v := !v lsr 8 + done + done; + + (* Done. *) + + k, s + + end + +(* Access to a string. *) + +let read (s : string) (i : int) : int = + Char.code (String.unsafe_get s i) + +(* [get1 t i] returns the integer stored in the packed array [t] at index [i]. + It assumes (and does not check) that the array's bit width is [1]. The + parameter [t] is just a string. *) + +let get1 (s : string) (i : int) : int = + let c = read s (i lsr 3) in + let c = c lsr ((lnot i) land 0b111) in + let c = c land 0b1 in + c + +(* [get t i] returns the integer stored in the packed array [t] at index [i]. *) + +(* Together, [pack] and [get] satisfy the following property: if the index [i] + is within bounds, then [get (pack a) i] equals [a.(i)]. *) + +let get ((k, s) : t) (i : int) : int = + match k with + | 1 -> + get1 s i + | 2 -> + let c = read s (i lsr 2) in + let c = c lsr (2 * ((lnot i) land 0b11)) in + let c = c land 0b11 in + c + | 4 -> + let c = read s (i lsr 1) in + let c = c lsr (4 * ((lnot i) land 0b1)) in + let c = c land 0b1111 in + c + | 8 -> + read s i + | 16 -> + let j = 2 * i in + (read s j) lsl 8 + read s (j + 1) + | _ -> + assert (k = 32); (* 64 bits unlikely, not supported *) + let j = 4 * i in + (((read s j lsl 8) + read s (j + 1)) lsl 8 + read s (j + 2)) lsl 8 + read s (j + 3) + Added: trunk/Toss/MenhirLib/packedIntArray.mli =================================================================== --- trunk/Toss/MenhirLib/packedIntArray.mli (rev 0) +++ trunk/Toss/MenhirLib/packedIntArray.mli 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,50 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +(* A packed integer array is represented as a pair of an integer [k] and + a string [s]. The integer [k] is the number of bits per integer that we + use. The string [s] is just an array of bits, which is read in 8-bit + chunks. *) + +(* The ocaml programming language treats string literals and array literals + in slightly different ways: the former are statically allocated, while + the latter are dynamically allocated. (This is rather arbitrary.) In the + context of Menhir's table-based back-end, where compact, immutable + integer arrays are needed, ocaml strings are preferable to ocaml arrays. *) + +type t = + int * string + +(* [pack a] turns an array of integers into a packed integer array. *) + +(* Because the sign bit is the most significant bit, the magnitude of + any negative number is the word size. In other words, [pack] does + not achieve any space savings as soon as [a] contains any negative + numbers, even if they are ``small''. *) + +val pack: int array -> t + +(* [get t i] returns the integer stored in the packed array [t] at index [i]. *) + +(* Together, [pack] and [get] satisfy the following property: if the index [i] + is within bounds, then [get (pack a) i] equals [a.(i)]. *) + +val get: t -> int -> int + +(* [get1 t i] returns the integer stored in the packed array [t] at index [i]. + It assumes (and does not check) that the array's bit width is [1]. The + parameter [t] is just a string. *) + +val get1: string -> int -> int + Added: trunk/Toss/MenhirLib/rowDisplacement.ml =================================================================== --- trunk/Toss/MenhirLib/rowDisplacement.ml (rev 0) +++ trunk/Toss/MenhirLib/rowDisplacement.ml 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,272 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +(* This module compresses a two-dimensional table, where some values + are considered insignificant, via row displacement. *) + +(* This idea reportedly appears in Aho and Ullman's ``Principles + of Compiler Design'' (1977). It is evaluated in Tarjan and Yao's + ``Storing a Sparse Table'' (1979) and in Dencker, D\xFCrre, and Heuft's + ``Optimization of Parser Tables for Portable Compilers'' (1984). *) + +(* A compressed table is represented as a pair of arrays. The + displacement array is an array of offsets into the data array. *) + +type 'a table = + int array * (* displacement *) + 'a array (* data *) + +(* In a natural version of this algorithm, displacements would be greater + than (or equal to) [-n]. However, in the particular setting of Menhir, + both arrays are intended to be compressed with [PackedIntArray], which + does not efficiently support negative numbers. For this reason, we are + careful not to produce negative displacements. *) + +(* In order to avoid producing negative displacements, we simply use the + least significant bit as the sign bit. This is implemented by [encode] + and [decode] below. *) + +(* One could also think, say, of adding [n] to every displacement, so as + to ensure that all displacements are nonnegative. This would work, but + would require [n] to be published, for use by the decoder. *) + +let encode (displacement : int) : int = + if displacement >= 0 then + displacement lsl 1 + else + (-displacement) lsl 1 + 1 + +let decode (displacement : int) : int = + if displacement land 1 = 0 then + displacement lsr 1 + else + -(displacement lsr 1) + +(* It is reasonable to assume that, as matrices grow large, their + density becomes low, i.e., they have many insignificant entries. + As a result, it is important to work with a sparse data structure + for rows. We internally represent a row as a list of its + significant entries, where each entry is a pair of a [j] index and + an element. *) + +type 'a row = + (int * 'a) list + +(* [compress equal insignificant dummy m n t] turns the two-dimensional table + [t] into a compressed table. The parameter [equal] is equality of data + values. The parameter [wildcard] tells which data values are insignificant, + and can thus be overwritten with other values. The parameter [dummy] is + used to fill holes in the data array. [m] and [n] are the integer + dimensions of the table [t]. *) + +let compress + (equal : 'a -> 'a -> bool) + (insignificant : 'a -> bool) + (dummy : 'a) + (m : int) (n : int) + (t : 'a array array) + : 'a table = + + (* Be defensive. *) + + assert (Array.length t = m); + assert begin + for i = 0 to m - 1 do + assert (Array.length t.(i) = n) + done; + true + end; + + (* This turns a row-as-array into a row-as-sparse-list. *) + + let sparse (line : 'a array) : 'a row = + + let rec loop (j : int) (row : 'a row) = + if j < 0 then + row + else + let x = line.(j) in + loop + (j - 1) + (if insignificant x then row else (j, x) :: row) + in + + loop (n - 1) [] + + in + + (* Define the rank of a row as its number of significant entries. *) + + let rank (row : 'a row) : int = + List.length row + in + + (* Construct a list of all rows, together with their index and rank. *) + + let rows : (int * int * 'a row) list = (* index, rank, row *) + Array.to_list ( + Array.mapi (fun i line -> + let row = sparse line in + i, rank row, row + ) t + ) + in + + (* Sort this list by decreasing rank. This does not have any impact + on correctness, but reportedly improves compression. The + intuitive idea is that rows with few significant elements are + easy to fit, so they should be inserted last, after the problem + has become quite constrained by fitting the heavier rows. This + heuristic is attributed to Ziegler. *) + + let rows = + List.sort (fun (_, rank1, _) (_, rank2, _) -> + compare rank2 rank1 + ) rows + in + + (* Allocate a one-dimensional array of displacements. *) + + let displacement : int array = + Array.make m 0 + in + + (* Allocate a one-dimensional, infinite array of values. Indices + into this array are written [k]. *) + + let data : 'a InfiniteArray.t = + InfiniteArray.make dummy + in + + (* Determine whether [row] fits at offset [k] within the current [data] + array, up to extension of this array. *) + + (* Note that this check always succeeds when [k] equals the length of + the [data] array. Indeed, the loop is then skipped. This property + guarantees the termination of the recursive function [fit] below. *) + + let fits k (row : 'a row) : bool = + + let d = InfiniteArray.extent data in + + let rec loop = function + | [] -> + true + | (j, x) :: row -> + + (* [x] is a significant element. *) + + (* By hypothesis, [k + j] is nonnegative. If it is greater than or + equal to the current length of the data array, stop -- the row + fits. *) + + assert (k + j >= 0); + + if k + j >= d then + true + + (* We now know that [k + j] is within bounds of the data + array. Check whether it is compatible with the element [y] found + there. If it is, continue. If it isn't, stop -- the row does not + fit. *) + + else + let y = InfiniteArray.get data (k + j) in + if insignificant y || equal x y then + loop row + else + false + + in + loop row + + in + + (* Find the leftmost position where a row fits. *) + + (* If the leftmost significant element in this row is at offset [j], + then we can hope to fit as far left as [-j] -- so this element + lands at offset [0] in the data array. *) + + (* Note that displacements may be negative. This means that, for + insignificant elements, accesses to the data array could fail: they could + be out of bounds, either towards the left or towards the right. This is + not a problem, as long as [get] is invoked only at significant + elements. *) + + let rec fit k row : int = + if fits k row then + k + else + fit (k + 1) row + in + + let fit row = + match row with + | [] -> + 0 (* irrelevant *) + | (j, _) :: _ -> + fit (-j) row + in + + (* Write [row] at (compatible) offset [k]. *) + + let rec write k = function + | [] -> + () + | (j, x) :: row -> + InfiniteArray.set data (k + j) x; + write k row + in + + (* Iterate over the sorted list of rows. Fit and write each row at + the leftmost compatible offset. Update the displacement table. *) + + let () = + List.iter (fun (i, _, row) -> + let k = fit row in (* if [row] has leading insignificant elements, then [k] can be negative *) + write k row; + displacement.(i) <- encode k + ) rows + in + + (* Return the compressed tables. *) + + displacement, InfiniteArray.domain data + +(* [get ct i j] returns the value found at indices [i] and [j] in the + compressed table [ct]. This function call is permitted only if the + value found at indices [i] and [j] in the original table is + significant -- otherwise, it could fail abruptly. *) + +(* Together, [compress] and [get] have the property that, if the value + found at indices [i] and [j] in an uncompressed table [t] is + significant, then [get (compress t) i j] is equal to that value. *) + +let get (displacement, data) i j = + assert (0 <= i && i < Array.length displacement); + let k = decode displacement.(i) in + assert (0 <= k + j && k + j < Array.length data); + (* failure of this assertion indicates an attempt to access an + insignificant element that happens to be mapped out of the bounds + of the [data] array. *) + data.(k + j) + +(* [getget] is a variant of [get] which only requires read access, + via accessors, to the two components of the table. *) + +let getget get_displacement get_data (displacement, data) i j = + let k = decode (get_displacement displacement i) in + get_data data (k + j) + Added: trunk/Toss/MenhirLib/rowDisplacement.mli =================================================================== --- trunk/Toss/MenhirLib/rowDisplacement.mli (rev 0) +++ trunk/Toss/MenhirLib/rowDisplacement.mli 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,63 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +(* This module compresses a two-dimensional table, where some values + are considered insignificant, via row displacement. *) + +(* A compressed table is represented as a pair of arrays. The + displacement array is an array of offsets into the data array. *) + +type 'a table = + int array * (* displacement *) + 'a array (* data *) + +(* [compress equal insignificant dummy m n t] turns the two-dimensional table + [t] into a compressed table. The parameter [equal] is equality of data + values. The parameter [wildcard] tells which data values are insignificant, + and can thus be overwritten with other values. The parameter [dummy] is + used to fill holes in the data array. [m] and [n] are the integer + dimensions of the table [t]. *) + +val compress: + ('a -> 'a -> bool) -> + ('a -> bool) -> + 'a -> + int -> int -> + 'a array array -> + 'a table + +(* [get ct i j] returns the value found at indices [i] and [j] in the + compressed table [ct]. This function call is permitted only if the + value found at indices [i] and [j] in the original table is + significant -- otherwise, it could fail abruptly. *) + +(* Together, [compress] and [get] have the property that, if the value + found at indices [i] and [j] in an uncompressed table [t] is + significant, then [get (compress t) i j] is equal to that value. *) + +val get: + 'a table -> + int -> int -> + 'a + +(* [getget] is a variant of [get] which only requires read access, + via accessors, to the two components of the table. *) + +val getget: + ('displacement -> int -> int) -> + ('data -> int -> 'a) -> + 'displacement * 'data -> + int -> int -> + 'a + Added: trunk/Toss/MenhirLib/tableFormat.ml =================================================================== --- trunk/Toss/MenhirLib/tableFormat.ml (rev 0) +++ trunk/Toss/MenhirLib/tableFormat.ml 2012-02-01 18:27:03 UTC (rev 1659) @@ -0,0 +1,134 @@ +(**************************************************************************) +(* *) +(* Menhir *) +(* *) +(* Fran\xE7ois Pottier, INRIA Rocquencourt *) +(* Yann R\xE9gis-Gianas, PPS, Universit\xE9 Paris Diderot *) +(* *) +(* Copyright 2005-2008 Institut National de Recherche en Informatique *) +(* et en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with the *) +(* special exception on linking described in file LICENSE. *) +(* *) +(**************************************************************************) + +(* This signature defines the format of the parse tables. It is used as + an argument to [TableInterpreter]. *) + +module type TABLES = sig + + (* This is the parser's type of tokens. *) + + type token + + (* This maps a token to its internal (generation-time) integer code. *) + + val token2terminal: token -> int + + (* This is the integer code for the error pseudo-token. *) + + val error_terminal: int + + (* This maps a token to its semantic value. *) + + val token2value: token -> Obj.t + + (* Traditionally, an LR automaton is described by two tables, namely, an + action table and a goto table. See, for instance, the Dragon book. + + The action table is a two-dimensional matrix that maps a state and a + lookahead token to an action. An action is one of: shift to a certain + state, reduce a certain production, accept, or fail. + + The goto table is a two-dimensional matrix that maps a state and a + non-terminal symbol to either a state or undefined. By construction, this + table is sparse: its undefined entries are never looked up. A compression + technique is free to overlap them with other entries. + + In Menhir, things are slightly different. If a state has a default + reduction on token [#], then that reduction must be performed without + consulting the lookahead token. As a result, we must first determine + whether that is the case, before we can obtain a lookahead token and use it + as an index in the action table. + + Thus, Menhir's tables are as follows. + + A one-dimensional default reduction table maps a state to either ``no + default reduction'' (encoded as: 0) or ``by default, reduce prod'' + (encoded as: 1 + prod). The action table is looked up only when there + is no default reduction. *) + + val default_reduction: PackedIntArray.t + + (* Menhir follows Dencker, D\xFCrre and Heuft, who point out that, although the + action table is not sparse by nature (i.e., the error entries are + significant), it can be made sparse by first factoring out a binary error + matrix, then replacing the error entries in the action table with undefined + entries. Thus: + + A two-dimensional error bitmap maps a state and a terminal to either + ``fail'' (encoded as: 0) or ``do not fail'' (encoded as: 1). The action + table, which is now sparse, is looked up only in the latter case. *) + + (* The error bitmap is flattened into a one-dimensional table; its width is + recorded so as to allow indexing. The table is then compressed via + [PackedIntArray]. The bit width of the resulting packed array must be + [1], so it is not explicitly recorded. *) + + (* The error bitmap does not contain a column for the [#] pseudo-terminal. + Thus, its width is [Terminal.n - 1]. We exploit the fact that the integer + code assigned to [#] is greatest: the fact that the right-most column + in the bitmap is missing does not affect the code for accessing it. *) + + val error: int (* width of the bitmap *) * string (* second component of [PackedIntArray.t] *) + + (* A two-dimensional action table maps a state and a terminal to one of + ``shift to state s and discard the current token'' (encoded as: s | 10), + ``shift to state s without discarding the current token'' (encoded as: s | + 11), or ``reduce prod'' (encoded as: prod | 01). *) + + (* The action table is first compressed via [RowDisplacement], then packed + via [PackedIntArray]. *) + + (* Like the error bitmap, the action table does not contain a column for the + [#] pseudo-terminal. *) + + val action: PackedIntArray.t * PackedIntArray.t + + (* A one-dimensional lhs table maps a production to its left-hand side (a + non-terminal symbol). *) + + val lhs: PackedIntArray.t + + (* A two-dimensional goto table maps a state and a non-terminal symbol to + either undefined (encoded as: 0) or a new state s (encoded as: 1 + s). *) + + (* The goto table is first compressed via [RowDisplacement], then packed + via [PackedIntArray]. *) + + val goto: PackedIntArray.t * PackedIntArray.t + + (* A one-dimensional semantic action table maps productions to semantic + actions. The calling convention for semantic actions is described in + [EngineTypes]. *) + + val semantic_action: ((int, Obj.t, token) EngineTypes.env -> unit) array + + (* The parser defines its own [Error] exception. This exception can be + raised by semantic actions and caught by the engine, and raised by the + engine towards the final user. *) + + exception Error + + (* The parser indicates whether to perform error recovery. *) + + val recovery: bool + + (* The parser... [truncated message content] |
From: <luk...@us...> - 2012-02-01 14:15:07
|
Revision: 1658 http://toss.svn.sourceforge.net/toss/?rev=1658&view=rev Author: lukaszkaiser Date: 2012-02-01 14:15:01 +0000 (Wed, 01 Feb 2012) Log Message: ----------- Tidy up local html, alerts only when asking for move. Modified Paths: -------------- trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/Play.js trunk/Toss/WebClient/local.html Modified: trunk/Toss/WebClient/Main.js =================================================================== --- trunk/Toss/WebClient/Main.js 2012-02-01 10:17:21 UTC (rev 1657) +++ trunk/Toss/WebClient/Main.js 2012-02-01 14:15:01 UTC (rev 1658) @@ -558,10 +558,11 @@ var fm = function (m) { document.getElementById("working").style.display = "none"; document.getElementById("working").innerHTML = "Working..."; - if (typeof m.comp_tree_size != 'undefined') + if (typeof m.comp_tree_size != 'undefined' && SIMPLE_MOVES == false) { alert ("Algorithm constructed tree of size " +m.comp_tree_size + " using exactly "+ (m.comp_ended - m.comp_started)+" seconds."); + } if (m != "") { PLAYS[CUR_PLAY_I].show_move (new Move (m)); f() } }; if (typeof LOCAL == 'undefined') { Modified: trunk/Toss/WebClient/Play.js =================================================================== --- trunk/Toss/WebClient/Play.js 2012-02-01 10:17:21 UTC (rev 1657) +++ trunk/Toss/WebClient/Play.js 2012-02-01 14:15:01 UTC (rev 1658) @@ -161,10 +161,11 @@ PlayDISP.free (); this.new_state (info); this.redraw (); - if (typeof info.comp_tree_size != 'undefined') + if (typeof info.comp_tree_size != 'undefined' && SIMPLE_MOVES == false) { alert ("Algorithm constructed tree of size " +info.comp_tree_size + " using exactly "+ (info.comp_ended - info.comp_started)+" seconds."); + } if (this.cur_state.players.length == 1 && this.players[this.cur_state.players[0]] == "computer") { var mv_time = document.getElementById("speed").value; Modified: trunk/Toss/WebClient/local.html =================================================================== --- trunk/Toss/WebClient/local.html 2012-02-01 10:17:21 UTC (rev 1657) +++ trunk/Toss/WebClient/local.html 2012-02-01 14:15:01 UTC (rev 1658) @@ -8,7 +8,6 @@ <meta http-equiv="X-UA-Compatible" content="chrome=1" /> <link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" /> <link rel="stylesheet" type="text/css" href="Style.css" media="screen" title="Default"/> - <script type="text/javascript" src="crypto-sha256.js"> </script> <script type="text/javascript" src="Local.js"> </script> <script type="text/javascript" src="JsHandler.js"> </script> <script type="text/javascript" src="State.js"> </script> @@ -18,34 +17,21 @@ <body onload="startup_local('')"> -<div id="ads"> -</div> <div id="main"> <div id="top"> <div id="logo"> - <a id="leftupperlogo-link" href="index.html"> + <a id="leftupperlogo-link" href="local.html"> <img id="leftupperlogo-img" src="toss.png" alt="tPlay" /> </a> </div> -<span id="topuser"></span> +<span id="localdown" style="position:relative; top: 0.7em;"> + <span id="topuser"></span> +</span> </div> -<div id="chess-level-warning"> -Chess is set to very weak play.</br> -<br/> -No training here, just have fun! -</div> - <div id="welcome"> -<p id="welcome-top">Enjoy the best games on <span class="logo-in">tPlay</span> - for free <span style="float: right;"> - <a href="http://itunes.apple.com/us/app/tplay/id438620686" - ><img style="height: 24px;" src="pics/appstore-small.png" /></a> - <g:plusone></g:plusone> - </span> -</p> <p id="p-under-welcome" style="display: none;"> Strategic games are fun! <a href="register.html">Register</a>, login and enjoy quality games @@ -53,11 +39,12 @@ </p> <p style="width:100%; text-align: justify;"> -<button onclick="new_play_local('Chess')" class="game-picbt" - title="Play Chess"> - <img style="max-width:95%" src="pics/Chess.png" alt="Chess Board" /> - <span id="pdescChess" class="game-picspan"> - <span class="game-pictxt">Chess</span> +<button onclick="new_play_local('Pawn-Whopping')" class="game-picbt" + class="boldobt" title="Play Pawn-Whopping"> + <img style="max-width:95%" src="pics/Pawn-Whopping.png" + alt="Pawn-Whopping Board" /> + <span id="pdescPawn-Whopping" class="game-picspan"> + <span class="game-pictxt">Pawn-Whopping</span> </span> </button> <button onclick="new_play_local('Connect4')" class="game-picbt" @@ -67,17 +54,6 @@ <span class="game-pictxt">Connect4</span> </span> </button> -<button onclick="new_play_local('Pawn-Whopping')" class="game-picbt" - class="boldobt" title="Play Pawn-Whopping"> - <img style="max-width:95%" src="pics/Pawn-Whopping.png" - alt="Pawn-Whopping Board" /> - <span id="pdescPawn-Whopping" class="game-picspan"> - <span class="game-pictxt">Pawn-Whopping</span> - </span> -</button> -</p> - -<p style="width:100%; text-align: justify"> <button onclick="new_play_local('Breakthrough')" class="game-picbt" class="boldobt" title="Play Breakthrough"> <img style="max-width:95%" src="pics/Breakthrough.png" @@ -86,6 +62,17 @@ <span class="game-pictxt">Breakthrough</span> </span> </button> +</p> + +<p style="width:100%; text-align: justify"> +<button onclick="new_play_local('Tic-Tac-Toe')" class="game-picbt" + class="boldobt" title="Play Tic-Tac-Toe"> + <img style="max-width:95%" src="pics/Tic-Tac-Toe.png" + alt="Tic-Tac-Toe Board" /> + <span id="pdescTic-Tac-Toe" class="game-picspan"> + <span class="game-pictxt">Tic-Tac-Toe</span> + </span> +</button> <button onclick="new_play_local('Checkers')" class="game-picbt" class="boldobt" title="Play Checkers"> <img style="max-width:95%" src="pics/Checkers.png" alt="Checkers Board" /> @@ -102,52 +89,8 @@ </button> </p> -<ul id="welcome-list-main" class="welcome-list"> - <li>Play - <a href="http://en.wikipedia.org/wiki/Breakthrough_(board_game)" - >Breakthrough,</a> - <a href="http://en.wikipedia.org/wiki/English_draughts" - >Checkers,</a> - <a href="http://en.wikipedia.org/wiki/Chess" - >Chess,</a> - <a href="http://en.wikipedia.org/wiki/Connect4" - >Connect4,</a> - <a href="http://en.wikipedia.org/wiki/Entanglement_(graph_measure)" - >Entanglement,</a> - <a href="http://en.wikipedia.org/wiki/Gomoku" - >Gomoku,</a> - <a href="http://en.wikipedia.org/wiki/Pawn_(chess)" - >Pawn-Whopping,</a> - and many other board games</li> -<li>Focus fully on the game thanks to our intuitive clean interface</li> -<li>Challenge your friends or play a fast game against the computer for fun</li> -</ul> - -<div id="news"> -<h3>News</h3> -<ul id="welcome-list-news" class="welcome-list"> -<li><b>24/10/11</b> Learning games from examples in web interface</li> -<li><b>19/10/11</b> Games learning engine and first buttons in the UI</li> -<li><b>14/09/11</b> Simple editing of games added to web interface</li> -<li><b>31/07/11</b> Store date and time of moves in games</li> -<li><b>30/07/11</b> Corrected opponent lists in the Profile tab</li> -<li><b>03/07/11</b> Added game descriptions viewable when playing</li> -<li><b>30/06/11</b> View previous moves in a play</li> -<li><b>27/06/11</b> Tabs and searching opponents in the profile page</li> -<li><b>22/06/11</b> Better organized lists of plays</li> -<li><b>19/06/11</b> News section on the front page of tPlay</li> -<li><b>15/06/11</b> Bug with underscores in user names corrected</li> -<li><b>10/06/11</b> New register site handles forgotten passwords</li> -<li><b>05/06/11</b> Pre-caching client states improves response times</li> -<li><b>03/06/11</b> Corrected tPlay 1.1 app accepted on App Store</li> -<li><b>30/05/11</b> Large restructuring of JavaScript code finished</li> -<li><b>24/05/11</b> Breakthrough generation from examples in SVN</li> -<li><b>23/05/11</b> First tPlay application accepted on App Store</li> -</ul> </div> -</div> - <div id="nosvg"> <p style="padding-left: 1.2em; font-size: 1.2em;"><b>SVG Support Missing</b></p> <p>Your browser does not seem to support SVG, @@ -257,6 +200,12 @@ player's pieces or by leaving the opposing player with no legal moves. The game ends in a draw, if neither side can force a win.</p> </div> + <div class="game-desc" id="Tic-Tac-Toe-desc"> + <p><a href="http://en.wikipedia.org/wiki/Tic-tac-toe">Tic-Tac-Toe</a>, + also known as Noughts and Crosses, is one of the simplest popular games. + Just make a line of three: horizontally, vertically, or diagonally. + </p> + </div> <div class="game-desc" id="Chess-desc"> <p><a href="http://en.wikipedia.org/wiki/Chess">Chess</a> is a two-player board game played on a chessboard, a square-checkered board with 64 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-02-01 10:17:29
|
Revision: 1657 http://toss.svn.sourceforge.net/toss/?rev=1657&view=rev Author: lukstafi Date: 2012-02-01 10:17:21 +0000 (Wed, 01 Feb 2012) Log Message: ----------- Standalone variant of JavaScript interface. Modified Paths: -------------- trunk/Toss/Formula/Aux.ml trunk/Toss/Formula/Aux.mli trunk/Toss/Formula/AuxIO.ml trunk/Toss/Formula/BoolFormula.ml trunk/Toss/Learn/LearnGameTest.ml trunk/Toss/Makefile trunk/Toss/Play/GameTree.ml trunk/Toss/Play/Move.mli trunk/Toss/Play/Play.ml trunk/Toss/Play/Play.mli trunk/Toss/Solver/RealQuantElim/OrderedPoly.ml trunk/Toss/Solver/RealQuantElim/OrderedPoly.mli trunk/Toss/Solver/RealQuantElim/Poly.ml trunk/Toss/Solver/RealQuantElim/SignTable.ml trunk/Toss/Solver/Structure.ml trunk/Toss/WebClient/Main.js trunk/Toss/WebClient/Play.js trunk/Toss/WebClient/State.js trunk/Toss/www/reference/reference.tex Added Paths: ----------- trunk/Toss/Server/GameSelection.ml trunk/Toss/Server/JsHandler.ml trunk/Toss/Solver/RealQuantElim/N.ml trunk/Toss/WebClient/JsHandler.js trunk/Toss/WebClient/Local.js trunk/Toss/WebClient/local.html trunk/Toss/www/reference/TossComponents.dot Modified: trunk/Toss/Formula/Aux.ml =================================================================== --- trunk/Toss/Formula/Aux.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Formula/Aux.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -2,10 +2,12 @@ structures and standard library-like definitions. *) let gettimeofday () = - IFDEF NOUNIX - THEN 1. - ELSE Unix.gettimeofday () - ENDIF + IFDEF JAVASCRIPT THEN ( + let t = Js.to_float ((jsnew Js.date_now ())##getTime()) in + t /. 1000. (* t is in milliseconds *) + ) ELSE ( + Unix.gettimeofday () + ) ENDIF exception Timeout of string @@ -739,3 +741,34 @@ Gc.minor_heap_size = 160*1024; (* 4*std, opt ~= L2 cache/proc *) Gc.major_heap_increment = 8*124*1024 (* 8*std ok *) } + +(* Replacements for basic Str functions. *) + +(* [split_regexp ~regexp:r s] splits [s] into substrings, taking as + delimiters the substrings that match [r], and returns the list of + substrings. For instance, [split ~regexp:"[ \t]+" s] splits [s] + into blank-separated words. An occurrence of the delimiter at the + beginning and at the end of the string is ignored. *) +let split_regexp ~regexp s = + IFDEF JAVASCRIPT THEN ( + let js_s = Js.string s in + let js_regex = jsnew Js.regExp (Js.string regexp) in + let res = js_s##split_regExp (js_regex) in + let res = Js.to_array (Js.str_array res) in + Array.to_list (Array.map Js.to_string res) + ) ELSE ( + Str.split (Str.regexp regexp) s + ) ENDIF + +(* [replace_regexp ~regexp ~templ s] returns a string identical to + [s], except that all substrings of [s] that match [regexp] have + been replaced by [templ]. *) +let replace_regexp ~regexp ~templ s = + IFDEF JAVASCRIPT THEN ( + let js_s = Js.string s in + let js_regex = jsnew Js.regExp (Js.string regexp) in + let res = js_s##replace (js_regex, Js.string templ) in + Js.to_string res + ) ELSE ( + Str.global_replace (Str.regexp regexp) templ s + ) ENDIF Modified: trunk/Toss/Formula/Aux.mli =================================================================== --- trunk/Toss/Formula/Aux.mli 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Formula/Aux.mli 2012-02-01 10:17:21 UTC (rev 1657) @@ -355,3 +355,17 @@ (** Set more agressive Gc values optimized for heavier computations. *) val set_optimized_gc : unit -> unit + +(** Replacements for basic Str functions. *) + +(** [split_regexp ~regexp:r s] splits [s] into substrings, taking as + delimiters the substrings that match [r], and returns the list of + substrings. For instance, [split ~regexp:"[ \t]+" s] splits [s] + into blank-separated words. An occurrence of the delimiter at the + beginning and at the end of the string is ignored. *) +val split_regexp : regexp:string -> string -> string list + +(** [replace_regexp ~regexp ~templ s] returns a string identical to [s], + except that all substrings of [s] that match [regexp] have been + replaced by [templ]. *) +val replace_regexp : regexp:string -> templ:string -> string -> string Modified: trunk/Toss/Formula/AuxIO.ml =================================================================== --- trunk/Toss/Formula/AuxIO.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Formula/AuxIO.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -14,12 +14,15 @@ if test_fname then f () let run_test_if_target target_name tests = - let f () = ignore (OUnit.run_test_tt ~verbose:true tests) in - (* So that the tests are not run twice while building TossTest. *) - run_if_target target_name f + IFDEF JAVASCRIPT THEN ( + failwith "JavaScript unit testing not implemented yet" + ) ELSE ( + let f () = ignore (OUnit.run_test_tt ~verbose:true tests) in + (* So that the tests are not run twice while building TossTest. *) + run_if_target target_name f + ) ENDIF - let rec input_file file = let buf = Buffer.create 256 in (try @@ -33,9 +36,14 @@ close_in f; res let list_dir dirname = - let files, dir_handle = (ref [], Unix.opendir dirname) in - let rec add () = files := (Unix.readdir dir_handle) :: !files; add () in - try add () with End_of_file -> Unix.closedir dir_handle; !files + IFDEF JAVASCRIPT THEN ( + failwith "JavaScript file manipulation not implemented yet" + ) ELSE ( + let files, dir_handle = (ref [], Unix.opendir dirname) in + let rec add () = + files := (Unix.readdir dir_handle) :: !files; add () in + try add () with End_of_file -> Unix.closedir dir_handle; !files + ) ENDIF let rec input_http_message file = let buf = Buffer.create 256 in @@ -76,29 +84,38 @@ exception Host_not_found let get_inet_addr addr_s = - try - Unix.inet_addr_of_string addr_s - with Failure _ -> + IFDEF JAVASCRIPT THEN ( + failwith "JavaScript TCP/IP manipulation not implemented yet" + ) ELSE ( try - let addr_arr = (Unix.gethostbyname addr_s).Unix.h_addr_list in - if Array.length addr_arr < 1 then raise Host_not_found else - addr_arr.(0) - with Not_found -> raise Host_not_found + Unix.inet_addr_of_string addr_s + with Failure _ -> + try + let addr_arr = (Unix.gethostbyname addr_s).Unix.h_addr_list in + if Array.length addr_arr < 1 then raise Host_not_found else + addr_arr.(0) + with Not_found -> raise Host_not_found + ) ENDIF let toss_call (client_port, client_addr_s) f_in x = - try - let client_addr = get_inet_addr client_addr_s in - let client_sock = Unix.ADDR_INET (client_addr, client_port) in - let (cl_in_ch, cl_out_ch) = Unix.open_connection client_sock in - output_string cl_out_ch "COMP\n"; - flush cl_out_ch; - let f a = try `Res (f_in a) with exn -> `Exn exn in - Marshal.to_channel cl_out_ch (f, x) [Marshal.Closures]; - flush cl_out_ch; - (fun () -> - let res = Marshal.from_channel cl_in_ch in - Unix.shutdown_connection cl_in_ch; - match res with `Res r -> r | `Exn e -> raise e) - with Unix.Unix_error (e, f, s) -> - Printf.printf "Toss call failed: %s; %s %s\n%!" (Unix.error_message e) f s; - (fun () -> f_in x) + IFDEF JAVASCRIPT THEN ( + failwith "JavaScript TCP/IP manipulation not implemented yet" + ) ELSE ( + try + let client_addr = get_inet_addr client_addr_s in + let client_sock = Unix.ADDR_INET (client_addr, client_port) in + let (cl_in_ch, cl_out_ch) = Unix.open_connection client_sock in + output_string cl_out_ch "COMP\n"; + flush cl_out_ch; + let f a = try `Res (f_in a) with exn -> `Exn exn in + Marshal.to_channel cl_out_ch (f, x) [Marshal.Closures]; + flush cl_out_ch; + (fun () -> + let res = Marshal.from_channel cl_in_ch in + Unix.shutdown_connection cl_in_ch; + match res with `Res r -> r | `Exn e -> raise e) + with Unix.Unix_error (e, f, s) -> + Printf.printf "Toss call failed: %s; %s %s\n%!" + (Unix.error_message e) f s; + (fun () -> f_in x) + ) ENDIF Modified: trunk/Toss/Formula/BoolFormula.ml =================================================================== --- trunk/Toss/Formula/BoolFormula.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Formula/BoolFormula.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -945,7 +945,7 @@ !clause in let list_int line = - let split = Str.split (Str.regexp "[ \t]+") line in + let split = Aux.split_regexp ~regexp:"[ \t]+" line in List.rev (List.tl (List.rev_map (fun s -> int_of_string s) (List.tl split))) in Modified: trunk/Toss/Learn/LearnGameTest.ml =================================================================== --- trunk/Toss/Learn/LearnGameTest.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Learn/LearnGameTest.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -84,7 +84,8 @@ let get_strucs s = let split_list ?(bound=None) pat s = let r = Str.regexp_string pat in - match bound with None-> Str.split r s | Some b-> Str.bounded_split r s b in + match bound with None-> Str.split r s + | Some b-> Str.bounded_split r s b in let cl = String.index s '\n' in let pref, st_s = String.sub s 0 cl, String.sub s cl ((String.length s)-cl) in let strucstr s = pref ^ " \n\"" ^ s ^ "\n\"" in Modified: trunk/Toss/Makefile =================================================================== --- trunk/Toss/Makefile 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Makefile 2012-02-01 10:17:21 UTC (rev 1657) @@ -3,9 +3,13 @@ TossServer: Server/Server.native cp _build/Server/Server.native TossServer -js_of_ocaml_test.js: js_of_ocaml_test.byte - js_of_ocaml js_of_ocaml_test.byte +WebClient/JsHandler.js: Server/JsHandler.byte + js_of_ocaml _build/$< + cp _build/Server/JsHandler.js WebClient/JsHandler.js +%.js: %.byte + js_of_ocaml _build/$< + RELEASE=0.6 Release: TossServer doc rm -f *~ Formula/*~ Solver/*~ Arena/*~ Play/*~ GGP/*~ \ @@ -41,7 +45,7 @@ OCB_LIB=-libs str,nums,unix,oUnit,sqlite3 OCB_LIBJS=-libs str,js_of_ocaml OCB_PP=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo js_of_ocaml/pa_js.cmo" -OCB_PPJS=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo -DNOREALQE -DNOUNIX js_of_ocaml/pa_js.cmo" +OCB_PPJS=-pp "camlp4o -I /usr/local/lib/ocaml/3.12.0 ../caml_extensions/pa_let_try.cmo pa_macro.cmo -DJAVASCRIPT js_of_ocaml/pa_js.cmo" OCAMLBUILD=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf $(OCB_PP) \ $(OCB_LIB) $(OCB_CFLAG) $(OCB_LFLAG) OCAMLBUILDJS=ocamlbuild -log build.log -j 8 -menhir ../menhir_conf $(OCB_PPJS) \ Modified: trunk/Toss/Play/GameTree.ml =================================================================== --- trunk/Toss/Play/GameTree.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Play/GameTree.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -39,7 +39,7 @@ player state.Arena.cur_loc state.Arena.time in let res = "\n" ^ msg ^ head_s ^ struc_s ^ "\n" ^ info_s in let prefix = if depth=0 then "" else (String.make depth '|') ^ " " in - Str.global_replace (Str.regexp "\n") ("\n" ^ prefix) res in + Aux.replace_regexp ~regexp:"\n" ~templ:("\n" ^ prefix) res in if upto < 0 then " Cut;" else match tree with | Terminal (state, player, info) -> Modified: trunk/Toss/Play/Move.mli =================================================================== --- trunk/Toss/Play/Move.mli 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Play/Move.mli 2012-02-01 10:17:21 UTC (rev 1657) @@ -12,12 +12,18 @@ TODO: fixed for now. *) val cGRID_SIZE : int -(** Generate moves available from a state, as an array, in fixed order. *) +(** Generate moves available from a state, as an array, in fixed + order. Does not check postconditions. *) val gen_moves : int -> (string * ContinuousRule.rule) list -> Structure.structure -> Arena.player_loc -> Arena.move array +(** Given moves available from a state, keep those for which + postconditions pass, and return the respective resulting game states. *) val gen_models : (string * ContinuousRule.rule) list -> Arena.game_state -> float -> Arena.move array -> Arena.move array * Arena.game_state array +(** Get moves and resulting game states, like {!Move.gen_models}, but for + all rules the players can apply in the given game state. Returns + the player together with a move. *) val list_moves : Arena.game -> Arena.game_state -> (int * Arena.move * Arena.game_state) array Modified: trunk/Toss/Play/Play.ml =================================================================== --- trunk/Toss/Play/Play.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Play/Play.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -6,9 +6,9 @@ let set_debug_level i = debug_level := i let timeout = ref 0. -let set_timeout t = timeout := Unix.gettimeofday() +. t +let set_timeout t = timeout := Aux.gettimeofday() +. t let cancel_timeout () = timeout := 0. -let timed_out () = !timeout > 1. && Unix.gettimeofday() +. 0.01 > !timeout +let timed_out () = !timeout > 1. && Aux.gettimeofday() +. 0.01 > !timeout (* ------------ MAXIMAX BY DEPTH ------------- *) @@ -63,9 +63,11 @@ | Aux.Timeout msg -> if !debug_level > 0 then Printf.printf "Timeout %f (%s)%!" - (Unix.gettimeofday() -. !timeout) msg; + (Aux.gettimeofday() -. !timeout) msg; (t, mvs) +let latest_gametree_size = ref 0 + (* Maximax unfold upto depth and choose move. *) let maximax_unfold_choose ?(check_stable=3) count game state heur = let ab = Heuristic.is_constant_sum heur in (* TODO: payoffs as well! *) @@ -75,6 +77,7 @@ let t = init game state (fun _ _ _ -> 0) heur in try let (u, mvs) = unfold_maximax_upto ~ab count game heur (t, []) in + latest_gametree_size := GameTree.size u; let nbr_to_check = min (2*check_stable + 1) (List.length mvs / 3) in let last_mvs = Aux.take_n (max 1 nbr_to_check) mvs in if !debug_level = 2 then Modified: trunk/Toss/Play/Play.mli =================================================================== --- trunk/Toss/Play/Play.mli 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Play/Play.mli 2012-02-01 10:17:21 UTC (rev 1657) @@ -23,3 +23,7 @@ val maximax_unfold_choose : ?check_stable:int -> int -> Arena.game -> Arena.game_state -> Formula.real_expr array array -> (Arena.move * Arena.game_state) list + +(** Size of the game-tree produced by the latest call of + {!Play.maximax_unfold_choose}. *) +val latest_gametree_size : int ref Added: trunk/Toss/Server/GameSelection.ml =================================================================== --- trunk/Toss/Server/GameSelection.ml (rev 0) +++ trunk/Toss/Server/GameSelection.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -0,0 +1,654 @@ +type game_state_data = { + heuristic : Formula.real_expr array array; (** heuristic *) + game_state : (Arena.game * Arena.game_state); (** game and state *) + playclock : int; (** playclock *) + game_str : string; (** game representation *) +} + +let compute_heuristic advr (game, state) = + let pat_arr = Array.of_list game.Arena.patterns in + let pl_heur l = + let len = List.length l.Arena.heur in + if len = 0 || len > Array.length pat_arr then raise Not_found else + let add_pat (i, h) pw = + let pat = Formula.Times (Formula.Const pw, pat_arr.(i)) in + (i+1, Formula.Plus (pat, h)) in + snd (List.fold_left add_pat (0, Formula.Const 0.) l.Arena.heur) in + try + let res = Array.map (fun a-> Array.map pl_heur a) game.Arena.graph in + res + with Not_found -> + Heuristic.default_heuristic ~struc:state.Arena.struc ?advr game + +let compile_game_data game_str = + let (game, game_state as game_with_state) = + ArenaParser.parse_game_state Lexer.lex (Lexing.from_string game_str) in + let adv_ratio = + try Some (float_of_string (List.assoc "adv_ratio" game.Arena.data)) + with Not_found -> None in + {heuristic = compute_heuristic adv_ratio game_with_state; + game_state = game_with_state; + playclock = 30; (* game clock from where? *) + game_str = game_str; + } + +(* Maximum call stack size exceeded in JS (pbbly parsing Chess) +let chess_str = +*) + +let connect4_str = ("PLAYERS 1, 2 +DATA r1: circle, r2: line, adv_ratio: 4, depth: 6 +REL Row4 (x, y, z, v) = R(x, y) and R(y, z) and R(z, v) +REL Col4 (x, y, z, v) = C(x, y) and C(y, z) and C(z, v) +REL DiagA4 (x, y, z, v) = DiagA(x, y) and DiagA(y, z) and DiagA(z, v) +REL DiagB4 (x, y, z, v) = DiagB(x, y) and DiagB(y, z) and DiagB(z, v) +REL Conn4 (x, y, z, v) = + Row4(x,y,z,v) or Col4(x,y,z,v) or DiagA4(x,y,z,v) or DiagB4(x,y,z,v) +REL WinQ() = + ex x,y,z,v (Q(x) and Q(y) and Q(z) and Q(v) and Conn4(x, y, z, v)) +REL WinP() = + ex x,y,z,v (P(x) and P(y) and P(z) and P(v) and Conn4(x, y, z, v)) +REL EmptyUnder (x) = ex y (C(y, x) and not P(y) and not Q(y)) +RULE Cross: + [a | P:1 {} | - ] -> [a | P (a) | - ] emb Q, P + pre not EmptyUnder (a) and not WinQ() +RULE Circle: + [a | Q:1 {} | - ] -> [a | Q (a) | - ] emb Q, P + pre not EmptyUnder (a) and not WinP() +LOC 0 { + PLAYER 1 { + PAYOFF :(WinP()) - :(WinQ()) + MOVES [Cross -> 1] + } + PLAYER 2 { + PAYOFF :(WinQ()) - :(WinP()) + } +} +LOC 1 { + PLAYER 1 { + PAYOFF :(WinP()) - :(WinQ()) + } + PLAYER 2 { + PAYOFF :(WinQ()) - :(WinP()) + MOVES [Circle -> 0] + } +} +MODEL [ | P:1 {}; Q:1 {} | ] \" + ... ... ... + ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... + ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... + ... ... ... + ... ... ... ... + ... ... ... ... +\" with DiagA (x, y) = ex u (R(x, u) and C(u, y)) ; + DiagB (x, y) = ex u (R(x, u) and C(y, u)) +") + +let pawn_whopping_str = (" +PLAYERS 1, 2 +DATA depth: 4, adv_ratio: 2 +REL DiagW (x, y) = ex z (C(x, z) and (R(y, z) or R(z, y))) +REL DiagB (x, y) = ex z (C(z, x) and (R(y, z) or R(z, y))) +REL IsFirst(x) = not ex z C(z, x) +REL IsSecond(x) = ex y (C(y, x) and IsFirst(y)) +REL IsEight(x) = not ex z C(x, z) +REL IsSeventh(x) = ex y (C(x, y) and IsEight(y)) +REL WhiteEnds() = (ex x (wP(x) and not ex y C(x, y))) or (not ex z bP(z)) +REL BlackEnds() = (ex x (bP(x) and not ex y C(y, x))) or (not ex z wP(z)) +RULE WhiteBeat: + [ a, b | wP { a }; bP { b } | - ] -> [ a, b | wP { b } | - ] emb wP, bP + pre DiagW(a, b) and not BlackEnds() +RULE WhiteMove: + [ | bP:1 {}; R:2 {} | ] \" + + . + + wP +\" -> [ | bP:1 {}; R:2 {} | ] \" + + wP + + . +\" emb wP, bP pre not BlackEnds() +RULE WhiteMoveTwo: + [ | bP:1 {}; R:2 {} | ] \" + + . + + . + + wP +\" -> [ | bP:1 {}; R:2 {} | ] \" + + wP + + . + + . +\" emb wP, bP pre IsSecond(a1) and not BlackEnds() +RULE WhiteRightPassant: + [ | | ] \" + ... + ?..-bP + ... + ? ... + ... + wP.bP +\" -> [ | | ] \" + ... + ?... + ... + ? wP. + ... + .... +\" emb wP, bP pre not BlackEnds() +RULE WhiteLeftPassant: + [ | | ] \" + ... + -bP? + ... + . ?.. + ... + bP.wP +\" -> [ | | ] \" + ... + ...? + ... + wP ?.. + ... + .... +\" emb wP, bP pre not BlackEnds() +RULE BlackBeat: + [ a, b | bP { a }; wP { b } | - ] -> [ a, b | bP { b } | - ] emb wP, bP + pre DiagB(a, b) and not WhiteEnds() +RULE BlackMove: + [ | R:2 {}; wP:1 {} | ] \" + + bP + + . +\" -> [ | R:2 {}; wP:1 {} | ] \" + + . + + bP +\" emb wP, bP pre not WhiteEnds() +RULE BlackMoveTwo: + [ | R:2 {}; wP:1 {} | ] \" + + bP + + . + + . +\" -> [ | R:2 {}; wP:1 {} | ] \" + + . + + . + + bP +\" emb wP, bP pre IsSeventh(a3) and not WhiteEnds() +RULE BlackRightPassant: + [ | | ] \" + ... + bP.wP + ... + ? ... + ... + ?..-wP +\" -> [ | | ] \" + ... + .... + ... + ? bP. + ... + ?... +\" emb wP, bP pre not WhiteEnds() +RULE BlackLeftPassant: + [ | | ] \" + ... + wP.bP + ... + . ?.. + ... + -wP? +\" -> [ | | ] \" + ... + .... + ... + bP ?.. + ... + ...? +\" emb wP, bP pre not WhiteEnds() +LOC 0 { + PLAYER 1 { + PAYOFF :(WhiteEnds()) - :(BlackEnds()) + MOVES + [WhiteBeat -> 1]; [WhiteMove -> 1]; [WhiteMoveTwo -> 1]; + [WhiteRightPassant -> 1]; [WhiteLeftPassant -> 1] + } + PLAYER 2 { PAYOFF :(BlackEnds()) - :(WhiteEnds()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(WhiteEnds()) - :(BlackEnds()) } + PLAYER 2 { + PAYOFF :(BlackEnds()) - :(WhiteEnds()) + MOVES + [BlackBeat -> 0]; [BlackMove -> 0]; [BlackMoveTwo -> 0]; + [BlackRightPassant -> 0]; [BlackLeftPassant -> 0] + } +} +MODEL [ | | ] \" + ... ... ... ... + ... ... ... ... + ... ... ... ... + bP.bP bP.bP bP.bP bP.bP + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + wP wP.wP wP.wP wP.wP wP. + ... ... ... ... + ... ... ... ... +\" +") + +let breakthrough_str = (" +PLAYERS 1, 2 +DATA depth: 2, adv_ratio: 2 +REL DiagW (x, y) = ex z (C(x, z) and (R(y, z) or R(z, y))) +REL DiagB (x, y) = ex z (C(z, x) and (R(y, z) or R(z, y))) +RULE WhiteDiag: + [ a, b | W { a }; _opt_B { b } | - ] + -> + [ a, b | W { b } | - ] + emb W, B pre DiagW(a, b) and not ex x (B(x) and not ex y C(y, x)) +RULE WhiteStraight: + [ | B:1 {}; R:2 {} | ] \" + + . + + W +\" -> [ | B:1 {}; R:2 {} | + ] \" + + W + + . +\" emb W, B pre not ex x (B(x) and not ex y C(y, x)) +RULE BlackDiag: + [ a, b | B { a }; _opt_W { b } | - ] + -> + [ a, b | B { b } | - ] + emb W, B pre DiagB(a, b) and not ex x (W(x) and not ex y C(x, y)) +RULE BlackStraight: + [ | R:2 {}; W:1 {} | ] \" + + B + + . +\" -> [ | R:2 {}; W:1 {} | + ] \" + + . + + B +\" emb W, B pre not ex x (W(x) and not ex y C(x, y)) +LOC 0 { + PLAYER 1 { + PAYOFF + :(ex x (W(x) and not ex y C(x, y))) - :(ex x (B(x) and not ex y C(y, x))) + MOVES + [WhiteDiag -> 1]; [WhiteStraight -> 1] + } + PLAYER 2 { + PAYOFF + :(ex x (B(x) and not ex y C(y, x))) - :(ex x (W(x) and not ex y C(x, y))) + } +} +LOC 1 { + PLAYER 1 { + PAYOFF + :(ex x (W(x) and not ex y C(x, y))) - :(ex x (B(x) and not ex y C(y, x))) + } + PLAYER 2 { + PAYOFF + :(ex x (B(x) and not ex y C(y, x))) - :(ex x (W(x) and not ex y C(x, y))) + MOVES + [BlackDiag -> 0]; [BlackStraight -> 0] + } +} +MODEL [ | | ] \" + ... ... ... ... + B B..B B..B B..B B.. + ... ... ... ... + B..B B..B B..B B..B + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + W W..W W..W W..W W.. + ... ... ... ... + W..W W..W W..W W..W +\" +") + +let checkers_str = (" +PLAYERS 1, 2 +DATA depth: 4, adv_ratio: 2 +REL IsFirst(x) = not ex z C(z, x) +REL IsEight(x) = not ex z C(x, z) +REL w(x) = W(x) or Wq(x) +REL b(x) = B(x) or Bq(x) +REL DiagWa (x, y) = ex z (C(x, z) and R(y, z)) +REL DiagBa (x, y) = ex z (C(z, x) and R(z, y)) +REL DiagWb (x, y) = ex z (C(x, z) and R(z, y)) +REL DiagBb (x, y) = ex z (C(z, x) and R(y, z)) +REL AnyDiag (x, y) = + DiagWa (x, y) or DiagWb (x, y) or DiagBa (x, y) or DiagBb (x, y) +REL DiagW2 (x, y, z) = + (DiagWa (x, y) and DiagWa (y, z)) or (DiagWb (x, y) and DiagWb (y, z)) +REL DiagB2 (x, y, z) = + (DiagBa (x, y) and DiagBa (y, z)) or (DiagBb (x, y) and DiagBb (y, z)) +REL Diag2 (x, y, z) = DiagW2 (x, y, z) or DiagB2 (x, y, z) +REL BeatsW (x, y) = ex z (b(z) and not b(y) and not w(y) and DiagW2 (x, z, y)) +REL BeatsWX (x, y) = ex z (b(z) and not b(y) and not w(y) and Diag2 (x, z, y)) +REL BeatsB (x, y) = ex z (w(z) and not b(y) and not w(y) and DiagB2 (x, z, y)) +REL BeatsBX (x, y) = ex z (w(z) and not b(y) and not w(y) and Diag2 (x, z, y)) +REL BJumps() = ex x, y ((B(x) and BeatsB (x, y)) or (Bq(x) and BeatsBX (x, y))) +REL WJumps() = ex x, y ((W(x) and BeatsW (x, y)) or (Wq(x) and BeatsWX (x, y))) +RULE RedMove: + [ a, b | W { a } | - ] -> [ a, b | W { b } | - ] emb w, b + pre (not IsEight(b)) and (DiagWa(a, b) or DiagWb(a, b)) and not WJumps() +RULE WhiteMove: + [ a, b | B { a } | - ] -> [ a, b | B { b } | - ] emb w, b + pre (not IsFirst(b)) and (DiagBa(a, b) or DiagBb(a, b)) and not BJumps() +RULE RedPromote: + [ a, b | W { a } | - ] -> [ a, b | Wq { b } | - ] emb w, b + pre (IsEight(b)) and (DiagWa(a, b) or DiagWb(a, b)) and not WJumps() +RULE WhitePromote: + [ a, b | B { a } | - ] -> [ a, b | Bq { b } | - ] emb w, b + pre (IsFirst(b)) and (DiagBa(a, b) or DiagBb(a, b)) and not BJumps() +RULE RedQMove: + [ a, b | Wq { a } | - ] -> [ a, b | Wq { b } | - ] emb w, b + pre AnyDiag (a, b) and not WJumps() +RULE WhiteQMove: + [ a, b | Bq { a } | - ] -> [ a, b | Bq { b } | - ] emb w, b + pre AnyDiag (a, b) and not BJumps() +RULE RedBeat: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | W { c } | - ] emb w, b + pre DiagW2 (a, b, c) and not IsEight(c) + post not ex x, y (_new_W(x) and BeatsWX (x, y)) +RULE WhiteBeat: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | B { c } | - ] emb w, b + pre DiagB2 (a, b, c) and not IsFirst(c) + post not ex x, y (_new_B(x) and BeatsBX (x, y)) +RULE RedBeatBoth: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | W { c } | - ] emb w, b + pre _new_W(a) and Diag2 (a, b, c) and not IsEight(c) + post not ex x, y (_new_W(x) and BeatsWX (x, y)) +RULE WhiteBeatBoth: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | B { c } | - ] emb w, b + pre _new_B(a) and Diag2 (a, b, c) and not IsFirst(c) + post not ex x, y (_new_B(x) and BeatsBX (x, y)) +RULE RedBeatPromote: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | Wq { c } | - ] emb w, b + pre DiagW2 (a, b, c) and IsEight(c) +RULE WhiteBeatPromote: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | Bq { c } | - ] emb w, b + pre DiagB2 (a, b, c) and IsFirst(c) +RULE RedBeatCont: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | W { c } | - ] emb w, b + pre DiagW2 (a, b, c) and not IsEight(c) + post ex x, y (_new_W(x) and BeatsWX (x, y)) +RULE WhiteBeatCont: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | B { c } | - ] emb w, b + pre DiagB2 (a, b, c) and not IsFirst(c) + post ex x, y (_new_B(x) and BeatsBX (x, y)) +RULE RedBeatBothCont: + [ a, b, c | W { a }; b { b } | - ] -> [ a, b, c | W { c } | - ] emb w, b + pre _new_W(a) and Diag2 (a, b, c) and not IsEight(c) + post ex x, y (_new_W(x) and BeatsWX (x, y)) +RULE WhiteBeatBothCont: + [ a, b, c | B { a }; w { b } | - ] -> [ a, b, c | B { c } | - ] emb w, b + pre _new_B(a) and Diag2 (a, b, c) and not IsFirst(c) + post ex x, y (_new_B(x) and BeatsBX (x, y)) +RULE RedQBeat: + [ a, b, c | Wq { a }; b { b } | - ] -> [ a, b, c | Wq { c } | - ] emb w, b + pre Diag2 (a, b, c) +RULE WhiteQBeat: + [ a, b, c | Bq { a }; w { b } | - ] -> [ a, b, c | Bq { c } | - ] emb w, b + pre Diag2 (a, b, c) +LOC 0 { + PLAYER 1 { + PAYOFF :(ex x w(x)) - :(ex x b(x)) + MOVES + [RedMove -> 1]; [RedPromote -> 1]; [RedQMove -> 1]; + [RedBeat -> 1]; [RedBeatPromote -> 1]; [RedQBeat -> 1]; + [RedBeatCont -> 2] + } + PLAYER 2 { + PAYOFF :(ex x b(x)) - :(ex x w(x)) + } +} +LOC 1 { + PLAYER 1 { + PAYOFF :(ex x w(x)) - :(ex x b(x)) + } + PLAYER 2 { + PAYOFF :(ex x b(x)) - :(ex x w(x)) + MOVES + [WhiteMove -> 0]; [WhitePromote -> 0]; [WhiteQMove -> 0]; + [WhiteBeat -> 0]; [WhiteBeatPromote -> 0]; [WhiteQBeat -> 0]; + [WhiteBeatCont -> 3] + } +} +LOC 2 { + PLAYER 1 { + PAYOFF :(ex x w(x)) - :(ex x b(x)) + MOVES [RedBeatBoth -> 1]; [RedBeatPromote -> 1]; [RedBeatBothCont -> 2] + } + PLAYER 2 { + PAYOFF :(ex x b(x)) - :(ex x w(x)) + } +} +LOC 3 { + PLAYER 1 { + PAYOFF :(ex x w(x)) - :(ex x b(x)) + } + PLAYER 2 { + PAYOFF :(ex x b(x)) - :(ex x w(x)) + MOVES + [WhiteBeatBoth -> 0]; [WhiteBeatPromote -> 0]; [WhiteBeatBothCont -> 3] + } +} +MODEL [ | Wq:1 { }; Bq:1 { } | + ] \" + ... ... ... ... + B.. B.. B.. B.. + ... ... ... ... + B.. B.. B.. B.. + ... ... ... ... + B.. B.. B.. B.. + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + W.. W.. W.. W.. + ... ... ... ... + W.. W.. W.. W.. + ... ... ... ... + W.. W.. W.. W.. +\" +") + +let gomoku_str = (" +PLAYERS 1, 2 +DATA rCircle: circle, rCross: line, adv_ratio: 5, depth: 2 +REL Row5 (x, y, z, v, w) = R(x, y) and R(y, z) and R(z, v) and R(v, w) +REL Col5 (x, y, z, v, w) = C(x, y) and C(y, z) and C(z, v) and C(v, w) +REL DiagA5 (x, y, z, v, w) = + DiagA(x, y) and DiagA(y, z) and DiagA(z, v) and DiagA(v, w) +REL DiagB5 (x, y, z, v, w) = + DiagB(x, y) and DiagB(y, z) and DiagB(z, v) and DiagB(v, w) +REL Conn5 (x, y, z, v, w) = + Row5(x,y,z,v,w) or Col5(x,y,z,v,w) or DiagA5(x,y,z,v,w) or DiagB5(x,y,z,v,w) +REL WinQ() = + ex x,y,z,v,w (Q(x) and Q(y) and Q(z) and Q(v) and Q(w) and Conn5(x,y,z,v,w)) +REL WinP() = + ex x,y,z,v,w (P(x) and P(y) and P(z) and P(v) and P(w) and Conn5(x,y,z,v,w)) +RULE Cross: + [a1 | P:1 {}; Q:1 {} | - ] + -> + [a1 | P (a1); Q:1 {} | - ] + emb Q, P pre not WinQ() +RULE Circle: + [a1 | P:1 {}; Q:1 {} | - ] + -> + [a1 | P:1 {}; Q (a1) | - ] + emb Q, P pre not WinP() +LOC 0 { + PLAYER 1 { + PAYOFF :(WinP()) - :(WinQ()) + MOVES [Cross -> 1] + } + PLAYER 2 { PAYOFF :(WinQ()) - :(WinP()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(WinP()) - :(WinQ()) } + PLAYER 2 { + PAYOFF :(WinQ()) - :(WinP()) + MOVES [Circle -> 0] + } +} +MODEL [ | P:1 {}; Q:1 {} | ] \" + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... +\" with DiagA (x, y) = ex u (R(x, u) and C(u, y)); + DiagB (x, y) = ex u (R(x, u) and C(y, u)) +") + +let entanglement_str = (" +PLAYERS 1, 2 +RULE Follow: + [ a1, a2 | C { (a2) }; R { (a1) } | + vx { a1->0., a2->0. }; vy { a1->0., a2->0. }; + x { a1->-10., a2->-10. }; y { a1->-10., a2->10. } ] + -> + [ a1, a2 | C { (a1) }; R { (a1) } | + vx { a1->0., a2->0. }; vy { a1->0., a2->0. }; + x { a1->-10., a2->-10. }; y { a1->-10., a2->10. } ] +emb R, C +RULE Wait: + [ a1 | R { (a1) } | + vx { a1->0. }; vy { a1->0. }; x { a1->-10. }; y { a1->-10. } ] + -> + [ a1 | R { (a1) } | + vx { a1->0. }; vy { a1->0. }; x { a1->-10. }; y { a1->-10. } ] +emb R, C +RULE Run: + [ a1, a2 | C:1 { }; E { (a1, a2) }; R { (a1) }; _opt_C { (a1) } | + vx { a1->0., a2->0. }; vy { a1->0., a2->0. }; + x { a1->-10., a2->10. }; y { a1->-10., a2->-10. } ] + -> + [ a1, a2 | C:1 { }; E { (a1, a2) }; R { (a2) }; _opt_C { (a1) } | + vx { a1->0., a2->0. }; vy { a1->0., a2->0. }; + x { a1->-10., a2->10. }; y { a1->-10., a2->-10. } ] +emb R, C +LOC 0 { + PLAYER 1 { + PAYOFF 0. + MOVES [Follow -> 1]; [Wait -> 1] + } + PLAYER 2 { PAYOFF 0. } +} +LOC 1 { + PLAYER 1 { PAYOFF 1. } + PLAYER 2 { + PAYOFF -1. + MOVES [Run -> 0] + } + } +MODEL [ d4, a2, a1, b1, b2, e4, c2, c1, f4, d2, d1, f1, f2, g1, g2, h1, h2, e1, e2, i1, i2 | C { (d4); (e4); (f4) }; E { (a2, a1); (a2, b2); (a1, a2); (a1, b1); (b1, a1); (b1, b2); (b1, c1); (b2, a2); (b2, b1); (b2, c2); (c2, b2); (c2, c1); (c2, d2); (c1, b1); (c1, c2); (c1, d1); (d2, c2); (d2, d1); (d2, e1); (d1, c1); (d1, d2); (d1, e2); (f1, f2); (f1, g1); (f1, e1); (f2, f1); (f2, g2); (f2, e2); (g1, f1); (g1, g2); (g1, h1); (g2, f2); (g2, g1); (g2, h2); (h1, g1); (h1, h2); (h1, i1); (h2, g2); (h2, h1); (h2, i2); (e1, d2); (e1, f1); (e1, e2); (e2, d1); (e2, f2); (e2, e1); (i1, h1); (i1, i2); (i2, h2); (i2, i1) }; R { (e1) }; _opt_C:1 { } | vx { d4->0., a2->0., a1->0., b1->0., b2->0., e4->0., c2->0., c1->0., f4->0., d2->0., d1->0., f1->0., f2->0., g1->0., g2->0., h1->0., h2->0., e1->0., e2->0., i1->0., i2->0. }; vy { d4->0., a2->0., a1->0., b1->0., b2->0., e4->0., c2->0., c1->0., f4->0., d2->0., d1->0., f1->0., f2->0., g1->0., g2->0., h1->0., h2->0., e1->0., e2->0., i1->0., i2->0. }; x { d4->100., a2->-50., a1->-50., b1->0., b2->0., e4->150., c2->50., c1->50., f4->200., d2->100., d1->100., f1->200., f2->200., g1->250., g2->250., h1->300., h2->300., e1->150., e2->150., i1->350., i2->350. }; y { d4->-150., a2->-100., a1->-50., b1->-50., b2->-100., e4->0., c2->-100., c1->-50., f4->-150., d2->-100., d1->-50., f1->-100., f2->-50., g1->-100., g2->-50., h1->-100., h2->-50., e1->-100., e2->-50., i1->-100., i2->-50. } ] +") + +let tictactoe_str = (" +PLAYERS 1, 2 +DATA r1: circle, r2: line, adv_ratio: 5, depth: 3 +REL DiagA (x, y) = ex u (R(x, u) and C(u, y)) +REL DiagB (x, y) = ex u (R(x, u) and C(y, u)) +REL Row3 (x, y, z) = R(x, y) and R(y, z) +REL Col3 (x, y, z) = C(x, y) and C(y, z) +REL DiagA3 (x, y, z) = DiagA(x, y) and DiagA(y, z) +REL DiagB3 (x, y, z) = DiagB(x, y) and DiagB(y, z) +REL Conn3 (x, y, z) = + Row3(x, y, z) or Col3(x, y, z) or DiagA3(x, y, z) or DiagB3(x, y, z) +REL WinQ() = ex x, y, z (Q(x) and Q(y) and Q(z) and Conn3(x, y, z)) +REL WinP() = ex x, y, z (P(x) and P(y) and P(z) and Conn3(x, y, z)) +RULE Cross: + [a | P:1 {} | - ] -> [a | P (a) | - ] emb Q, P pre not WinQ() +RULE Circle: + [a | Q:1 {} | - ] -> [a | Q (a) | - ] emb Q, P pre not WinP() +LOC 0 { + PLAYER 1 { PAYOFF :(WinP()) - :(WinQ()) + MOVES [Cross -> 1] } + PLAYER 2 { PAYOFF :(WinQ()) - :(WinP()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(WinP()) - :(WinQ()) } + PLAYER 2 { PAYOFF :(WinQ()) - :(WinP()) + MOVES [Circle -> 0] } +} +MODEL [ | P:1 {}; Q:1 {} | ] \" + + . . . + + . . . + + . . . +\" +") + +let games = ref + [ + "Breakthrough", compile_game_data breakthrough_str; + "Checkers", compile_game_data checkers_str; + (* "Chess", compile_game_data chess_str; *) + "Connect4", compile_game_data connect4_str; + "Entanglement", compile_game_data entanglement_str; + "Gomoku", compile_game_data gomoku_str; + "Pawn-Whopping", compile_game_data pawn_whopping_str; + "Tic-Tac-Toe", compile_game_data tictactoe_str; + ] Added: trunk/Toss/Server/JsHandler.ml =================================================================== --- trunk/Toss/Server/JsHandler.ml (rev 0) +++ trunk/Toss/Server/JsHandler.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -0,0 +1,184 @@ +(* JavaScript Handler for a subset of ReqHandler.handle_http_post requests. *) + + +(* ---------- Basic request type and internal handler ---------- *) + +open GameSelection + +(* History of states in last-in-first-out order. *) +let play_states = ref [] +(* Arbitrarily initialized -- [cur_game] only has effect with + non-empty [play_states]. The game state in any [game_data] is only + the initial state, not the current state of a game. *) +let cur_game = ref (snd (List.hd !GameSelection.games)) +let cur_move = ref 0 +let cur_all_moves = ref [| |] + +(* TODO; FIXME; remove the function below. *) +let select_moving a = (* temporary func - accept just one player w/ moves *) + let locs = Aux.array_find_all (fun l -> l.Arena.moves <> []) a in + if List.length locs <> 1 then failwith "too many moves" else + if locs = [] then a.(0) else List.hd locs + + +(* ------------ The Handler ------------ *) +let js = Js.string +let of_js = Js.to_string +let js_object = Js.Unsafe.variable "Object" +let js_any = Js.Unsafe.inject + +let js_handler = Js.Unsafe.variable "LOCAL" +let set_handle name f = + Js.Unsafe.set js_handler (js name) (Js.wrap_callback f) + + +let js_of_move game state move_id (player, move, _) = + let struc = state.Arena.struc in + let matched = Js.array + (Aux.array_map_of_list (fun (_, e) -> + js (Structure.elem_name struc e)) move.Arena.matching) in + let js_move = jsnew js_object () in + let player_name = Aux.rev_assoc game.Arena.player_names player in + Js.Unsafe.set js_move (js"matched") matched; + Js.Unsafe.set js_move (js"rule") (js (move.Arena.rule)); + Js.Unsafe.set js_move (js"player") (js player_name); + Js.Unsafe.set js_move (js"id") (Js.float (float_of_int move_id)); + js_move + +(* Translate current structure into an "info_obj" format. *) +let js_of_game_state game state = + let struc = state.Arena.struc in + let get_pos e = + Structure.fun_val struc "x" e, Structure.fun_val struc "y" e in + let elems = Structure.elements struc in + let (posx, posy) = List.split (List.map get_pos elems) in + let mkfl f l = List.fold_left f (List.hd l) (List.tl l) in + let (minl, maxl, suml) = (mkfl min, mkfl max, mkfl (+.)) in + let minx, maxx, miny, maxy = minl posx, maxl posx, minl posy, maxl posy in + (* elems are arrays of element name and position *) + let elems = Array.of_list + (List.map + (fun e -> + let e0 = js (Structure.elem_name struc e) in + let x, y = get_pos e in + Js.array [|js_any e0; js_any (Js.float x); js_any (Js.float y)|]) + elems) in + (* rels are arrays of element names, with additional "name" field *) + let num = Js.number_of_float in + let rels = Array.of_list + (Aux.concat_map + (fun (rel, _) -> + let tups = Structure.Tuples.elements + (Structure.rel_graph rel struc) in + let tups = List.map + (fun args -> Js.array + (Array.map (fun e -> js (Structure.elem_name struc e)) args)) + tups in + List.iter + (fun args -> Js.Unsafe.set args (js"name") (js rel)) tups; + tups) + (Structure.rel_signature struc)) in + let info_obj = jsnew js_object () in + Js.Unsafe.set info_obj (js"maxx") (num maxx); + Js.Unsafe.set info_obj (js"minx") (num minx); + Js.Unsafe.set info_obj (js"maxy") (num maxy); + Js.Unsafe.set info_obj (js"miny") (num miny); + Js.Unsafe.set info_obj (js"elems") (Js.array elems); + Js.Unsafe.set info_obj (js"rels") (Js.array rels); + if !cur_all_moves <> [||] then + Js.Unsafe.set info_obj (js"moves") + (Js.array (Array.mapi (js_of_move game state) !cur_all_moves)) + else ( (* find payoffs *) + let payoffs = Array.mapi + (fun i v -> i, Solver.M.get_real_val v.Arena.payoff struc) + game.Arena.graph.(state.Arena.cur_loc) in + let result = jsnew js_object () in + Array.iter + (fun (i, payoff) -> + (* Players use their names on the JS side, not numbers! *) + let player_name = Aux.rev_assoc game.Arena.player_names i in + Js.Unsafe.set result (js player_name) (Js.float payoff)) + payoffs; + Js.Unsafe.set info_obj (js"result") result); + info_obj + +let new_play game_name pl1 pl2 = + (* players are currently not used by [JsHandler] *) + let game_data = List.assoc (of_js game_name) !GameSelection.games in + let game, state = game_data.game_state in + cur_game := game_data; + play_states := [state]; + cur_all_moves := Move.list_moves game state; + cur_move := 0; + js_of_game_state game state + +let _ = set_handle "new_play" new_play + +let preview_move move_nbr = + let n = List.length !play_states - (move_nbr + 1) in + if n < 0 then Js.null + else + let game, _ = !cur_game.game_state in + let state = List.nth !play_states n in + Js.some (js_of_game_state game state) + +let _ = set_handle "prev_move" preview_move + +let make_move move_id cont = + if !play_states = [] then Js.null + else + let (p, m, n_state) = + !cur_all_moves.(int_of_float (Js.to_float move_id)) in + let game, _ = !cur_game.game_state in + play_states := n_state :: !play_states; + cur_all_moves := Move.list_moves game n_state; + cur_move := 0; + Js.Unsafe.fun_call cont + [|js_any (js_of_game_state game n_state)|] + +let _ = set_handle "make_move" make_move + +let suggest player_name time cont = + (* We do not use the player name. *) + Random.self_init (); + let time = Js.to_float time in + Play.set_timeout time; + let comp_started = Aux.gettimeofday () in + let game, _ = !cur_game.game_state in + let state = List.hd !play_states in + try + let (move, _) = + Aux.random_elem (Play.maximax_unfold_choose 100000 + game state !cur_game.heuristic) in + Play.cancel_timeout (); + let algo_iters = !Play.latest_gametree_size in + let move_id = Aux.array_argfind + (fun (_, m, _) -> m = move) !cur_all_moves in + let result = + js_of_move game state move_id (!cur_all_moves.(move_id)) in + Js.Unsafe.set result (js"comp_tree_size") + (Js.number_of_float (float_of_int algo_iters)); + Js.Unsafe.set result (js"comp_started") + (Js.number_of_float comp_started); + Js.Unsafe.set result (js"comp_ended") + (Js.number_of_float (Aux.gettimeofday ())); + Js.Unsafe.fun_call cont [|js_any result|] + with Not_found -> Js.null + +let _ = set_handle "suggest" suggest + +let get_game game_name = + let game_data = List.assoc (of_js game_name) !GameSelection.games in + js game_data.game_str + +let _ = set_handle "get_game" get_game + +let set_game game_name game_str = + let game_name = of_js game_name and game_str = of_js game_str in + try + games := (game_name, compile_game_data game_str) :: !games; + js ("Game "^game_name^" set.") + with Lexer.Parsing_error s -> + js ("Game "^game_name^" ERROR: "^s) + +let _ = set_handle "set_game" set_game Added: trunk/Toss/Solver/RealQuantElim/N.ml =================================================================== --- trunk/Toss/Solver/RealQuantElim/N.ml (rev 0) +++ trunk/Toss/Solver/RealQuantElim/N.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -0,0 +1,37 @@ +(* A proxy to the [Num] module from the [nums] library. *) + +module LocalNum = (struct + type num = int * int + let sign_num n = failwith "Local Num not implemented yet" + let mod_num m n = failwith "Local Num not implemented yet" + let div_num m n = failwith "Local Num not implemented yet" + let ( // ) = div_num + let num_of_int n = failwith "Local Num not implemented yet" + let ( +/ ) m n = failwith "Local Num not implemented yet" + let ( -/ ) m n = failwith "Local Num not implemented yet" + let ( */ ) m n = failwith "Local Num not implemented yet" + let float_of_num n = failwith "Local Num not implemented yet" + let num_of_string s = failwith "Local Num not implemented yet" + let string_of_num n = failwith "Local Num not implemented yet" + let abs_num n = failwith "Local Num not implemented yet" +end : sig + type num + val sign_num : num -> int + val mod_num : num -> num -> num + val div_num : num -> num -> num + val ( // ) : num -> num -> num + val num_of_int : int -> num + val ( +/ ) : num -> num -> num + val ( -/ ) : num -> num -> num + val ( */ ) : num -> num -> num + val float_of_num : num -> float + val num_of_string : string -> num + val string_of_num : num -> string + val abs_num : num -> num +end) + +IFDEF JAVASCRIPT THEN +module Q = LocalNum + ELSE +module Q = Num + ENDIF Modified: trunk/Toss/Solver/RealQuantElim/OrderedPoly.ml =================================================================== --- trunk/Toss/Solver/RealQuantElim/OrderedPoly.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Solver/RealQuantElim/OrderedPoly.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -1,6 +1,6 @@ (* Polynomials with ordered variables, integer coefficients.*) -open Num +open N.Q (* ----------------------- BASIC TYPE DEFINITIONS --------------------------- *) @@ -219,7 +219,7 @@ match (p, q) with (Const n, Const m) -> if allow_frac then Const (n // m) else - if Num.sign_num (Num.mod_num n m) = 0 then Const (n // m) else + if N.Q.sign_num (N.Q.mod_num n m) = 0 then Const (n // m) else raise Not_found | (Poly (v, _), Poly (w, _)) -> if v <> w then raise Unmatched_variables else @@ -232,8 +232,8 @@ | Const n -> ( match u with Const m -> - if allow_frac then (Const (n // m), Const (Num.num_of_int 0)) else - let r = Num.mod_num n m in (Const ((n -/ r) // m), Const r) + if allow_frac then (Const (n // m), Const (N.Q.num_of_int 0)) else + let r = N.Q.mod_num n m in (Const ((n -/ r) // m), Const r) | Poly (_, _) -> raise Unmatched_variables ) | Poly (v, (p, d) :: ps) -> Modified: trunk/Toss/Solver/RealQuantElim/OrderedPoly.mli =================================================================== --- trunk/Toss/Solver/RealQuantElim/OrderedPoly.mli 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Solver/RealQuantElim/OrderedPoly.mli 2012-02-01 10:17:21 UTC (rev 1657) @@ -3,7 +3,7 @@ (** {2 Basic Type Definitions} *) -type polynomial = Const of Num.num | Poly of string * (polynomial * int) list +type polynomial = Const of N.Q.num | Poly of string * (polynomial * int) list type t = polynomial (** to be compatible with OrderedType signature *) @@ -29,14 +29,15 @@ val var : polynomial -> string val lower : polynomial -> polynomial -val constant_value : polynomial -> Num.num option +val constant_value : polynomial -> N.Q.num option val deg : polynomial -> int val leading_coeff : int -> polynomial -> polynomial val const_coeff : polynomial -> polynomial option val omit_leading : polynomial -> polynomial val multiple : int -> polynomial -> polynomial -val multiple_num : Num.num -> polynomial -> polynomial -val constant_factors : polynomial -> polynomial -> (Num.num * Num.num) option +val multiple_num : N.Q.num -> polynomial -> polynomial +val constant_factors : + polynomial -> polynomial -> (N.Q.num * N.Q.num) option (** {2 Arithmetic Functions} *) Modified: trunk/Toss/Solver/RealQuantElim/Poly.ml =================================================================== --- trunk/Toss/Solver/RealQuantElim/Poly.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Solver/RealQuantElim/Poly.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -49,7 +49,7 @@ (* ----------------- CONVERTION TO UNORDERED POLYNOMIALS -------------------- *) let rec make_unordered = function - OrderedPoly.Const n -> Const (Num.float_of_num n) + OrderedPoly.Const n -> Const (N.Q.float_of_num n) | OrderedPoly.Poly (v, lst) -> make_unordered_list v lst and make_unordered_list v = function @@ -74,11 +74,11 @@ let scale = 1000000 in let f_scaled = Printf.sprintf "%.0f" (f *. (float_of_int scale)) in if f_scaled = "nan" || f_scaled = "inf" || f_scaled = "-inf" - then Num.num_of_int (-1) (* unlikely number *) + then N.Q.num_of_int (-1) (* unlikely number *) else - let num_scale = Num.num_of_int scale in - let num_f_scaled = Num.num_of_string f_scaled in - Num.div_num num_f_scaled num_scale + let num_scale = N.Q.num_of_int scale in + let num_f_scaled = N.Q.num_of_string f_scaled in + N.Q.div_num num_f_scaled num_scale (* List variables in the given polynomial. *) let rec vars = function Modified: trunk/Toss/Solver/RealQuantElim/SignTable.ml =================================================================== --- trunk/Toss/Solver/RealQuantElim/SignTable.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Solver/RealQuantElim/SignTable.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -72,7 +72,7 @@ let int_case_str case = let psgn_str (p, i) = match constant_value p with - Some n -> if Num.sign_num n <> sign i then "wrong" else "ok" + Some n -> if N.Q.sign_num n <> sign i then "wrong" else "ok" | None -> if i > 0 then (str p) ^ " > 0" else if i = 0 then (str p) ^ " = 0" else (str p) ^ " < 0" @@ -104,7 +104,7 @@ | (r, _) :: rs -> let mulr = match q with None -> r | Some qp -> mul qp r in match constant_factors p mulr with - Some (c1, c2) -> ((-2, i), (Num.sign_num c1) * (Num.sign_num c2)) + Some (c1, c2) -> ((-2, i), (N.Q.sign_num c1) * (N.Q.sign_num c2)) | None -> find_const_factor ~i:(i+1) ~q:q p rs (* Helper function: find if p = q1 * q2 * c for some q1, q2 in [acc]. *) @@ -120,7 +120,8 @@ [] -> acc | p :: ps -> match constant_value p with - Some n -> determine_vals (acc @ [(p, ((-2, -2), Num.sign_num n))]) ps + Some n -> + determine_vals (acc @ [(p, ((-2, -2), N.Q.sign_num n))]) ps | None -> match find_const_factor p acc with ((-1, _), _) -> Modified: trunk/Toss/Solver/Structure.ml =================================================================== --- trunk/Toss/Solver/Structure.ml 2012-01-30 19:21:45 UTC (rev 1656) +++ trunk/Toss/Solver/Structure.ml 2012-02-01 10:17:21 UTC (rev 1657) @@ -1253,19 +1253,19 @@ find_unique (StringMap.fold (fun rel _ acc -> rel::acc) !struc.rel_signature []) in let uniq = uniq1 @ uniq2 @ uniq3 in - let lines = Str.split (Str.regexp "[\r\n]+\t*") board in + let lines = Aux.split_regexp ~regexp:"[\r\n]+\t*" board in let lines = List.filter (fun s->String.length s > 2) lines in - let rec split_line line = - let is_ok c = c = ' ' || c = '.' || Aux.is_alphanum c || c = '_' || + let rec split_line line = + let is_ok c = c = ' ' || c = '.' || Aux.is_alphanum c || c = '_' || c = '*' || c = '?' || c = '#' || c = '+' || c = '-' in let error txt = raise (Board_parse_error - ("Unrecognized field line: \"" ^ txt ^ - "\" of board line: \"" ^ line ^"\"")) in + ("Unrecognized field line: \"" ^ txt ^ + "\" of board line: \"" ^ line ^"\"")) in if line = "" then [] else if String.length line < 3 then error line else - if (is_ok line.[0] && is_ok line.[1] && is_ok line.[2]) then - let rest = String.sub line 3 ((String.length line) - 3) in - (String.sub line 0 3) :: (split_line rest) - else error (String.sub line 0 3) in + if (is_ok line.[0] && is_ok line.[1] && is_ok line.[2]) then + let rest = String.sub line 3 ((String.length line) - 3) in + (String.sub line 0 3) :: (split_line rest) + else error (String.sub line 0 3) in let rec rev_combine_pairs acc = function | [] -> acc | [hd] -> @@ -1296,12 +1296,12 @@ else if s.[0] = '*' then ["*"] (* treated specially *) else if sl = 0 && s.[sl] = '?' then ["_any_"] else if s.[0] = '+' then - let p = unabbrev (omit 1 s) in ["_new_" ^ p; p] + let p = unabbrev (omit 1 s) in ["_new_"^p; p] else if s.[0] = '-' then ["_del_"^unabbrev (omit 1 s)] else if s.[sl] = '?' then [unabbrev (String.sub s 0 sl); "_any_"] else if s.[0] = '?' then ["_opt_"^unabbrev (omit 1 s)] else if s.[sl] = '#' then - ["_diffthan_" ^ unabbrev (String.sub s 0 sl); "_any_"] + ["_diffthan_"^unabbrev (String.sub s 0 sl); "_any_"] else if s.[0] = '#' then ["_diffthan_"^unabbrev (omit 1 s)] else [unabbrev s] in let board_els = @@ -1346,8 +1346,8 @@ done; if List.hd !fields <> [] then raise (Board_parse_error - (Printf.sprintf - "Row %d is too long, expected %d columns" r c_max)); + (Printf.sprintf + "Row %d is too long, expected %d columns" r c_max)); fields := List.tl !fields; done; !struc Added: trunk/Toss/WebClient/JsHandler.js =================================================================== --- trunk/Toss/WebClient/JsHandler.js (rev 0) +++ trunk/Toss/WebClient/JsHandler.js 2012-02-01 10:17:21 UTC (rev 1657) @@ -0,0 +1,895 @@ +// This program was compiled from OCaml by js_of_ocaml 1.0 +function caml_raise_with_arg (tag, arg) { throw [0, tag, arg]; } +function caml_raise_with_string (tag, msg) { + caml_raise_with_arg (tag, new MlWrappedString (msg)); +} +function caml_invalid_argument (msg) { + caml_raise_with_string(caml_global_data[4], msg); +} +function caml_array_bound_error () { + caml_invalid_argument("index out of bounds"); +} +function caml_str_repeat(n, s) { + if (!n) { return ""; } + if (n & 1) { return caml_str_repeat(n - 1, s) + s; } + var r = caml_str_repeat(n >> 1, s); + return r + r; +} +function MlString(param) { + if (param != null) { + this.bytes = this.fullBytes = param; + this.last = this.len = param.length; + } +} +MlString.prototype = { + string:null, + bytes:null, + fullBytes:null, + array:null, + len:null, + last:0, + toJsString:function() { + return this.string = decodeURIComponent (escape(this.getFullBytes())); + }, + toBytes:function() { + if (this.string != null) + var b = unescape (encodeURIComponent (this.string)); + else { + var b = "", a = this.array, l = a.length; + for (var i = 0; i < l; i ++) b += String.fromCharCode (a[i]); + } + this.bytes = this.fullBytes = b; + this.last = this.len = b.length; + return b; + }, + getBytes:function() { + var b = this.bytes; + if (b == null) b = this.toBytes(); + return b; + }, + getFullBytes:function() { + var b = this.fullBytes; + if (b !== null) return b; + b = this.bytes; + if (b == null) b = this.toBytes (); + if (this.last < this.len) { + this.bytes = (b += caml_str_repeat(this.len - this.last, '\0')); + this.last = this.len; + } + this.fullBytes = b; + return b; + }, + toArray:function() { + var b = this.bytes; + if (b == null) b = this.toBytes (); + var a = [], l = this.last; + for (var i = 0; i < l; i++) a[i] = b.charCodeAt(i); + for (l = this.len; i < l; i++) a[i] = 0; + this.string = this.bytes = this.fullBytes = null; + this.last = this.len; + this.array = a; + return a; + }, + getArray:function() { + var a = this.array; + if (!a) a = this.toArray(); + return a; + }, + getLen:function() { + var len = this.len; + if (len !== null) return len; + this.toBytes(); + return this.len; + }, + toString:function() { var s = this.string; return s?s:this.toJsString(); }, + valueOf:function() { var s = this.string; return s?s:this.toJsString(); }, + blitToArray:function(i1, a2, i2, l) { + var a1 = this.array; + if (a1) + for (var i = 0; i < l; i++) a2 [i2 + i] = a1 [i1 + i]; + else { + var b = this.bytes; + if (b == null) b = this.toBytes(); + var l1 = this.last - i1; + if (l <= l1) + for (var i = 0; i < l; i++) a2 [i2 + i] = b.charCodeAt(i1 + i); + else { + for (var i = 0; i < l1; i++) a2 [i2 + i] = b.charCodeAt(i1 + i); + for (; i < l; i++) a2 [i2 + i] = 0; + } + } + }, + get:function (i) { + var a = this.array; + if (a) return a[i]; + var b = this.bytes; + if (b == null) b = this.toBytes(); + return (i<this.last)?b.charCodeAt(i):0; + }, + safeGet:function (i) { + if (!this.len) this.toBytes(); + if ((i < 0) || (i >= this.len)) caml_array_bound_error (); + return this.get(i); + }, + set:function (i, c) { + var a = this.array; + if (!a) { + if (this.last == i) { + this.bytes += String.fromCharCode (c & 0xff); + this.last ++; + return 0; + } + a = this.toArray(); + } else if (this.bytes != null) { + this.bytes = this.fullBytes = this.string = null; + } + a[i] = c & 0xff; + return 0; + }, + safeSet:function (i, c) { + if (this.len == null) this.toBytes (); + if ((i < 0) || (i >= this.len)) caml_array_bound_error (); + this.set(i, c); + }, + fill:function (ofs, len, c) { + if (ofs >= this.last && this.last && c == 0) return; + var a = this.array; + if (!a) a = this.toArray(); + else if (this.bytes != null) { + this.bytes = this.fullBytes = this.string = null; + } + var l = ofs + len; + for (var i = ofs; i < l; i++) a[i] = c; + }, + compare:function (s2) { + if (this.string != null && s2.string != null) { + if (this.string < s2.string) return -1; + if (this.string > s2.string) return 1; + return 0; + } + var b1 = this.getFullBytes (); + var b2 = s2.getFullBytes (); + if (b1 < b2) return -1; + if (b1 > b2) return 1; + return 0; + }, + equal:function (s2) { + if (this.string != null && s2.string != null) + return this.string == s2.string; + return this.getFullBytes () == s2.getFullBytes (); + }, + lessThan:function (s2) { + if (this.string != null && s2.string != null) + return this.string < s2.string; + return this.getFullBytes () < s2.getFullBytes (); + }, + lessEqual:function (s2) { + if (this.string != null && s2.string != null) + return this.string <= s2.string; + return this.getFullBytes () <= s2.getFullBytes (); + } +} +function MlWrappedString (s) { this.string = s; } +MlWrappedString.prototype = new MlString(); +function MlMakeString (l) { this.bytes = ""; this.len = l; } +MlMakeString.prototype = new MlString (); +function caml_array_get (array, index) { + if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error(); + return array[index+1]; +} +function caml_array_set (array, index, newval) { + if ((index < 0) || (index >= array.length - 1)) caml_array_bound_error(); + array[index+1]=newval; return 0; +} +function caml_blit_string(s1, i1, s2, i2, len) { + if (len === 0) return; + if (i2 === s2.last && i1 === 0 && s1.last == len) { + var s = s1.bytes; + if (s !== null) + s2.bytes += s1.bytes; + else + s2.bytes += s1.getBytes(); + s2.last += len; + return; + } + var a = s2.array; + if (!a) a = s2.toArray(); else { s2.bytes = s2.string = null; } + s1.blitToArray (i1, a, i2, len); +} +function caml_call_gen(f, args) { + if(f.fun) + return caml_call_gen(f.fun, args); + var n = f.length; + var d = n - args.length; + if (d == 0) + return f.apply(null, args); + else if (d < 0) + return caml_call_gen(f.apply(null, args.slice(0,n)), args.slice(n)); + else + return function (x){ return caml_call_gen(f, args.concat([x])); }; +} +function caml_classify_float (x) { + if (isFinite (x)) { + if (Math.abs(x) >= 2.2250738585072014e-308) return 0; + if (x != 0) return 1; + return 2; + } + return isNaN(x)?4:3; +} +function caml_int64_compare(x,y) { + var x3 = x[3] << 16; + var y3 = y[3] << 16; + if (x3 > y3) return 1; + if (x3 < y3) return -1; + if (x[2] > y[2]) return 1; + if (x[2] < y[2]) return -1; + if (x[1] > y[1]) return 1; + if (x[1] < y[1]) return -1; + return 0; +} +function caml_int_compare (a, b) { + if (a < b) return (-1); if (a == b) return 0; return 1; +} +function caml_compare_val (a, b, total) { + var stack = []; + for(;;) { + if (!(total && a === b)) { + if (a instanceof MlString) { + if (b instanceof MlString) { + if (a != b) { + var x = a.compare(b); + if (x != 0) return x; + } + } else + return 1; + } else if (a instanceof Array && a[0] == (a[0]|0)) { + var ta = a[0]; + if (ta === 250) { + a = a[1]; + continue; + } else if (b instanceof Array && b[0] == (b[0]|0)) { + var tb = b[0]; + if (tb === 250) { + b = b[1]; + continue; + } else if (ta != tb) { + return (ta < tb)?-1:1; + } else { + switch (ta) { + case 248: { + var x = caml_int_compare(a[2], b[2]); + if (x != 0) return x; + break; + } + case 255: { + var x = caml_int64_compare(a, b); + if (x != 0) return x; + break; + } + default: + if (a.length != b.length) return (a.length < b.length)?-1:1; + if (a.length > 1) stack.push(a, b, 1); + } + } + } else + return 1; + } else if (b instanceof MlString || + (b instanceof Array && b[0] == (b[0]|0))) { + return -1; + } else { + if (a < b) return -1; + if (a > b) retur... [truncated message content] |
From: <luk...@us...> - 2012-01-30 19:21:56
|
Revision: 1656 http://toss.svn.sourceforge.net/toss/?rev=1656&view=rev Author: lukaszkaiser Date: 2012-01-30 19:21:45 +0000 (Mon, 30 Jan 2012) Log Message: ----------- Small test correction, less Str in Structure. Modified Paths: -------------- trunk/Toss/Learn/LearnGameTest.ml trunk/Toss/Solver/Structure.ml Modified: trunk/Toss/Learn/LearnGameTest.ml =================================================================== --- trunk/Toss/Learn/LearnGameTest.ml 2012-01-30 15:14:41 UTC (rev 1655) +++ trunk/Toss/Learn/LearnGameTest.ml 2012-01-30 19:21:45 UTC (rev 1656) @@ -49,26 +49,26 @@ REL Win1() = ex x0 (Q(x0) and ex x1 R(x0, x1)) REL Win2() = ex x1 (Q(x1) and ex x0 R(x0, x1)) -RULE Mv1-0: +RULE Mv1r0: [e1 | P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | P (e1); Q:1 {}; R:2 {} | ] emb R,Q,P pre (true) and not Win2() -RULE Mv2-0: +RULE Mv2r0: [e1 | P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | P:1 {}; Q (e1); R:2 {} | ] emb R,Q,P pre (true) and not Win1() LOC 0 { PLAYER 1 { PAYOFF : (Win1()) - :(Win2()) - MOVES [Mv1-0 -> 1]} + MOVES [Mv1r0 -> 1]} PLAYER 2 { PAYOFF : (Win2()) - :(Win1()) } } LOC 1 { PLAYER 1 { PAYOFF :(Win1()) - :(Win2()) } PLAYER 2 { PAYOFF :(Win2()) - :(Win1()) - MOVES [Mv2-0 -> 0] } + MOVES [Mv2r0 -> 0]} } MODEL [ | P:1 {}; Q:1 {} | ] R R \" Modified: trunk/Toss/Solver/Structure.ml =================================================================== --- trunk/Toss/Solver/Structure.ml 2012-01-30 15:14:41 UTC (rev 1655) +++ trunk/Toss/Solver/Structure.ml 2012-01-30 19:21:45 UTC (rev 1656) @@ -1255,16 +1255,17 @@ let uniq = uniq1 @ uniq2 @ uniq3 in let lines = Str.split (Str.regexp "[\r\n]+\t*") board in let lines = List.filter (fun s->String.length s > 2) lines in - let rexp = - Str.regexp "[a-zA-Z0-9_ .*?#+-][a-zA-Z0-9_ .?#][a-zA-Z0-9_ .?#]" in - let split_line line = - List.map (function - | Str.Delim field -> assert (String.length field = 3); field - | Str.Text txt -> - raise (Board_parse_error - ("Unrecognized field line: \"" ^ txt ^ - "\" of board line: \"" ^ line ^"\""))) - (Str.full_split rexp line) in + let rec split_line line = + let is_ok c = c = ' ' || c = '.' || Aux.is_alphanum c || c = '_' || + c = '*' || c = '?' || c = '#' || c = '+' || c = '-' in + let error txt = raise (Board_parse_error + ("Unrecognized field line: \"" ^ txt ^ + "\" of board line: \"" ^ line ^"\"")) in + if line = "" then [] else if String.length line < 3 then error line else + if (is_ok line.[0] && is_ok line.[1] && is_ok line.[2]) then + let rest = String.sub line 3 ((String.length line) - 3) in + (String.sub line 0 3) :: (split_line rest) + else error (String.sub line 0 3) in let rec rev_combine_pairs acc = function | [] -> acc | [hd] -> @@ -1284,7 +1285,7 @@ else let fields = ref fields in let parse s = - let s = Str.string_before s + let s = String.sub s 0 (min (try String.index s ' ' with Not_found -> 3) (try String.index s '.' with Not_found -> 3)) in let sl = String.length s - 1 in @@ -1295,12 +1296,12 @@ else if s.[0] = '*' then ["*"] (* treated specially *) else if sl = 0 && s.[sl] = '?' then ["_any_"] else if s.[0] = '+' then - let p = unabbrev (omit 1 s) in ["_new_"^p; p] + let p = unabbrev (omit 1 s) in ["_new_" ^ p; p] else if s.[0] = '-' then ["_del_"^unabbrev (omit 1 s)] - else if s.[sl] = '?' then [unabbrev (Str.string_before s sl); "_any_"] + else if s.[sl] = '?' then [unabbrev (String.sub s 0 sl); "_any_"] else if s.[0] = '?' then ["_opt_"^unabbrev (omit 1 s)] else if s.[sl] = '#' then - ["_diffthan_"^unabbrev (Str.string_before s sl); "_any_"] + ["_diffthan_" ^ unabbrev (String.sub s 0 sl); "_any_"] else if s.[0] = '#' then ["_diffthan_"^unabbrev (omit 1 s)] else [unabbrev s] in let board_els = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-01-30 15:14:51
|
Revision: 1655 http://toss.svn.sourceforge.net/toss/?rev=1655&view=rev Author: lukaszkaiser Date: 2012-01-30 15:14:41 +0000 (Mon, 30 Jan 2012) Log Message: ----------- Technical correction to make videos work on www. Modified Paths: -------------- trunk/Toss/Learn/Makefile trunk/Toss/www/xsl/common.xsl Added Paths: ----------- trunk/Toss/www/.htaccess Modified: trunk/Toss/Learn/Makefile =================================================================== --- trunk/Toss/Learn/Makefile 2012-01-24 14:43:58 UTC (rev 1654) +++ trunk/Toss/Learn/Makefile 2012-01-30 15:14:41 UTC (rev 1655) @@ -59,9 +59,17 @@ %.webm: ffmpeg -an -i videos/$(basename $@).3gp $@ +%.mp4: + ffmpeg -an -i videos/$(basename $@).3gp $@ + +%.ogv: %.mp4 + ffmpeg -an -i videos/$(basename $@).3gp $@ + VIDEOS_WEBM = $(addsuffix .webm, $(VIDEOS_BASE)) +VIDEOS_OGG = $(addsuffix .ogv, $(VIDEOS_BASE)) +VIDEOS_MP4 = $(addsuffix .mp4, $(VIDEOS_BASE)) -webms: $(VIDEOS_WEBM) +webvideos: $(VIDEOS_WEBM) $(VIDEOS_MP4) $(VIDEOS_OGG) .PHONY: clean Added: trunk/Toss/www/.htaccess =================================================================== --- trunk/Toss/www/.htaccess (rev 0) +++ trunk/Toss/www/.htaccess 2012-01-30 15:14:41 UTC (rev 1655) @@ -0,0 +1,3 @@ +AddType video/webm .webm +AddType video/ogg .ogv +AddType video/mp4 .mp4 Modified: trunk/Toss/www/xsl/common.xsl =================================================================== --- trunk/Toss/www/xsl/common.xsl 2012-01-24 14:43:58 UTC (rev 1654) +++ trunk/Toss/www/xsl/common.xsl 2012-01-30 15:14:41 UTC (rev 1655) @@ -112,8 +112,9 @@ <xsl:template match="playvideo"> <video width="352" height="288" controls="controls"> - <source src="videos/{@name}.3gp" type="video/3gpp" /> + <source src="videos/{@name}.mp4" type="video/mp4" /> <source src="videos/{@name}.webm" type="video/webm" /> + <source src="videos/{@name}.ogv" type="video/ogg" /> Your browser does not support the video tag. </video> <a href="videos/{@name}.txt">Text</a> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-01-24 14:44:09
|
Revision: 1654 http://toss.svn.sourceforge.net/toss/?rev=1654&view=rev Author: lukaszkaiser Date: 2012-01-24 14:43:58 +0000 (Tue, 24 Jan 2012) Log Message: ----------- Allow reco in bash mode. Modified Paths: -------------- trunk/Toss/Learn/Makefile trunk/Toss/Learn/reco.cpp trunk/Toss/www/learn.xml Modified: trunk/Toss/Learn/Makefile =================================================================== --- trunk/Toss/Learn/Makefile 2012-01-24 00:49:05 UTC (rev 1653) +++ trunk/Toss/Learn/Makefile 2012-01-24 14:43:58 UTC (rev 1654) @@ -39,11 +39,11 @@ %.reco: if [[ $@ = Breakthrough* ]]; then \ - ./reco W B videos/$(basename $@).3gp > res.play.log; \ + ./reco W B videos/$(basename $@).3gp n > res.play.log; \ elif [[ $@ = Pawn* ]]; then \ - ./reco W B videos/$(basename $@).3gp > res.play.log; \ + ./reco W B videos/$(basename $@).3gp n > res.play.log; \ else \ - ./reco Q P videos/$(basename $@).3gp > res.play.log; \ + ./reco Q P videos/$(basename $@).3gp n > res.play.log; \ fi diff res.play.log examples/$(basename $@) rm res.play.log Modified: trunk/Toss/Learn/reco.cpp =================================================================== --- trunk/Toss/Learn/reco.cpp 2012-01-24 00:49:05 UTC (rev 1653) +++ trunk/Toss/Learn/reco.cpp 2012-01-24 14:43:58 UTC (rev 1654) @@ -61,11 +61,13 @@ { char res[2000]; int rnbr = -2; + int window = 1; - if (argc != 4) { - printf ("Usage: reco [letter for white] [letter for black] [filename]\n"); + if ((argc != 4 && argc != 5) || (argc == 5 && argv[4][0] != 'n')) { + printf ("Usage: reco [white] [black] [filename] (n: no window) \n"); return (1); } + if (argc == 5) { window = 0; } // Print signature and set it in shapes module printf ("[ | %c:1 {}; %c:1 {} | ]\n\n", argv[1][0], argv[2][0]); @@ -73,7 +75,7 @@ setRedChar (argv[2][0]); // Start recognition - cvNamedWindow ("Reco", CV_WINDOW_AUTOSIZE); + if (window) { cvNamedWindow ("Reco", CV_WINDOW_AUTOSIZE); } CvCapture* capture = cvCreateFileCapture (argv[3]); // cvCreateCameraCapture( 0 ); IplImage *img, *col, *gray, *small, *smallpre; @@ -154,7 +156,7 @@ from_point (p.shape[s].end), CV_RGB (200, 100, 100), 3); } } - cvShowImage( "Reco", small ); + if (window) { cvShowImage( "Reco", small ); } if (time % timeSTEP == 0) { // wait timeSTEP frames int ok_lines = 0; for( i = 0; i < lines->total; i++ ) { @@ -205,8 +207,10 @@ for (int i = 0; i < SIZEX*SIZEY*24; i++) fullsh_str[i] = 0; } time++; - char c = cvWaitKey (50); - if (c == 27) break; + if (window) { + char c = cvWaitKey (50); + if (c == 27) break; + } } cvReleaseCapture (&capture); cvDestroyWindow ("Reco"); Modified: trunk/Toss/www/learn.xml =================================================================== --- trunk/Toss/www/learn.xml 2012-01-24 00:49:05 UTC (rev 1653) +++ trunk/Toss/www/learn.xml 2012-01-24 14:43:58 UTC (rev 1654) @@ -14,7 +14,9 @@ <section title="Breakthrough"> <subsection>Resulting game: </subsection> - <a href="videos/Breakthrough001.toss.txt">toss file</a> <br/> + <a href="videos/Breakthrough001.toss.txt">toss file</a>, + <a href="http://tplay.org/index.html?simple=true?game=Breakthrough" + >play</a> <br/> <subsection>Illustrating plays and positions not won by anyone</subsection> <br/> @@ -31,7 +33,9 @@ <section title="Connect4"> <subsection>Resulting game: </subsection> - <a href="videos/Connect4001.toss.txt">toss file</a> <br/> + <a href="videos/Connect4001.toss.txt">toss file</a>, + <a href="http://tplay.org/index.html?simple=true?game=Connect4" + >play</a> <br/> <subsection>Illustrating plays and positions not won by anyone</subsection> <br/> @@ -71,7 +75,9 @@ <section title="Pawn-Whopping"> <subsection>Resulting game: </subsection> - <a href="videos/Pawn-Whopping001.toss.txt">toss file</a> <br/> + <a href="videos/Pawn-Whopping001.toss.txt">toss file</a>, + <a href="http://tplay.org/index.html?simple=true?game=Pawn-Whopping" + >play</a> <br/> <subsection>Illustrating plays and positions not won by anyone</subsection> <br/> @@ -97,7 +103,9 @@ <section title="Tic-Tac-Toe"> <subsection>Resulting game: </subsection> - <a href="videos/Tic-Tac-Toe001.toss.txt">toss file</a> <br/> + <a href="videos/Tic-Tac-Toe001.toss.txt">toss file</a>, + <a href="http://tplay.org/index.html?simple=true?game=Tic-Tac-Toe" + >play</a> <br/> <subsection>Illustrating plays and positions not won by anyone</subsection> <br/> @@ -134,7 +142,9 @@ <section title="Gomoku"> <subsection>Resulting game: </subsection> - <a href="videos/Gomoku001.toss.txt">toss file</a> <br/> + <a href="videos/Gomoku001.toss.txt">toss file</a>, + <a href="http://tplay.org/index.html?simple=true?game=Gomoku" + >play</a> <br/> <subsection>Illustrating plays and positions not won by anyone</subsection> <br/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-01-24 00:49:12
|
Revision: 1653 http://toss.svn.sourceforge.net/toss/?rev=1653&view=rev Author: lukaszkaiser Date: 2012-01-24 00:49:05 +0000 (Tue, 24 Jan 2012) Log Message: ----------- Nicer webpage on game rule learning, cleanups. Modified Paths: -------------- trunk/Toss/Learn/Makefile trunk/Toss/www/xsl/common.xsl Added Paths: ----------- trunk/Toss/Learn/examples/Pawn-Whopping001.toss trunk/Toss/www/learn.xml Removed Paths: ------------- trunk/Toss/Learn/learn.html Modified: trunk/Toss/Learn/Makefile =================================================================== --- trunk/Toss/Learn/Makefile 2012-01-23 23:33:10 UTC (rev 1652) +++ trunk/Toss/Learn/Makefile 2012-01-24 00:49:05 UTC (rev 1653) @@ -34,7 +34,7 @@ make Breakthrough001.learn make Gomoku001.learn make Connect4001.learn - #make Pawn-Whopping001.learn + make Pawn-Whopping001.learn %.reco: @@ -48,7 +48,7 @@ diff res.play.log examples/$(basename $@) rm res.play.log -VIDEOS_TO_TEST = videos/T* +VIDEOS_TO_TEST = videos/* VIDEOS = $(notdir $(shell find $(VIDEOS_TO_TEST) -maxdepth 1 -name '*.3gp')) VIDEOS_BASE = $(basename $(VIDEOS)) VIDEOS_RECO = $(addsuffix .reco, $(VIDEOS_BASE)) @@ -56,6 +56,14 @@ recotests: reco $(VIDEOS_RECO) +%.webm: + ffmpeg -an -i videos/$(basename $@).3gp $@ + +VIDEOS_WEBM = $(addsuffix .webm, $(VIDEOS_BASE)) + +webms: $(VIDEOS_WEBM) + + .PHONY: clean clean: Added: trunk/Toss/Learn/examples/Pawn-Whopping001.toss =================================================================== --- trunk/Toss/Learn/examples/Pawn-Whopping001.toss (rev 0) +++ trunk/Toss/Learn/examples/Pawn-Whopping001.toss 2012-01-24 00:49:05 UTC (rev 1653) @@ -0,0 +1,71 @@ +PLAYERS 1, 2 +REL Win1() = ex x1 (W(x1) and all x0 not C(x1, x0)) +REL Win2() = ex x1 (B(x1) and all x0 not C(x0, x1)) + +RULE Mv1r0: +[e1, e2 | B:1 {}; C:2 {}; Da:2 {}; Db:2 {}; R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C:2 {}; Da:2 {}; Db:2 {}; R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (ex x1 + (W(x1) and ex x0 (C(x0, x1) and all x2 not C(x2, x0)) and + ex x0 (C(x1, x0) and ex x2 (C(x0, x2) and x2 = e2)))) and not Win2() +RULE Mv1r1: +[e1, e2 | B:1 {}; C (e1, e2); Da:2 {}; Db:2 {}; R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C (e1, e2); Da:2 {}; Db:2 {}; R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (true) and not Win2() +RULE Mv1r2: +[e1, e2 | B (e2); C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (true) and not Win2() +RULE Mv1r3: +[e1, e2 | B (e2); C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (true) and not Win2() + + +RULE Mv2r0: +[e1, e2 | B (e2); C:2 {}; Da:2 {}; Db:2 {}; R:2 {}; W:1 {} | ] -> [e1, e2 | B (e1); C:2 {}; Da:2 {}; Db:2 {}; R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (ex x1 + (B(x1) and ex x0 (C(x1, x0) and all x2 not C(x0, x2)) and + ex x0 (C(x0, x1) and ex x2 (C(x2, x0) and x2 = e1)))) and not Win1() +RULE Mv2r1: +[e1, e2 | B (e2); C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W (e1) | ] -> [e1, e2 | B (e1); C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (true) and not Win1() +RULE Mv2r2: +[e1, e2 | B (e2); C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W (e1) | ] -> [e1, e2 | B (e1); C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (true) and not Win1() +RULE Mv2r3: +[e1, e2 | B (e2); C (e1, e2); Da:2 {}; Db:2 {}; R:2 {}; W:1 {} | ] -> [e1, e2 | B (e1); C (e1, e2); Da:2 {}; Db:2 {}; R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (true) and not Win1() + +LOC 0 { + PLAYER 1 { PAYOFF : (Win1()) - :(Win2()) + MOVES [Mv1r0 -> 1]; [Mv1r1 -> 1]; [Mv1r2 -> 1]; [Mv1r3 -> 1]} + PLAYER 2 { PAYOFF : (Win2()) - :(Win1()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(Win1()) - :(Win2()) } + PLAYER 2 { PAYOFF :(Win2()) - :(Win1()) + MOVES [Mv2r0 -> 0]; [Mv2r1 -> 0]; [Mv2r2 -> 0]; [Mv2r3 -> 0]} +} +MODEL [a1, b1, c1, d1, e1, f1, g1, h1, a2, b2, c2, d2, e2, f2, g2, h2, a3, b3, c3, d3, e3, f3, g3, h3, a4, b4, c4, d4, e4, f4, g4, h4, a5, b5, c5, d5, e5, f5, g5, h5, a6, b6, c6, d6, e6, f6, g6, h6, a7, b7, c7, d7, e7, f7, g7, h7, a8, b8, c8, d8, e8, f8, g8, h8 | Da {(a1, b2); (b1, c2); (c1, d2); (d1, e2); (e1, f2); (f1, g2); (g1, h2); (a2, b3); (b2, c3); (c2, d3); (d2, e3); (e2, f3); (f2, g3); (g2, h3); (a3, b4); (b3, c4); (c3, d4); (d3, e4); (e3, f4); (f3, g4); (g3, h4); (a4, b5); (b4, c5); (c4, d5); (d4, e5); (e4, f5); (f4, g5); (g4, h5); (a5, b6); (b5, c6); (c5, d6); (d5, e6); (e5, f6); (f5, g6); (g5, h6); (a6, b7); (b6, c7); (c6, d7); (d6, e7); (e6, f7); (f6, g7); (g6, h7); (a7, b8); (b7, c8); (c7, d8); (d7, e8); (e7, f8); (f7, g8); (g7, h8)}; Db {(b1, a2); (c1, b2); (d1, c2); (e1, d2); (f1, e2); (g1, f2); (h1, g2); (b2, a3); (c2, b3); (d2, c3); (e2, d3); (f2, e3); (g2, f3); (h2, g3); (b3, a4); (c3, b4); (d3, c4); (e3, d4); (f3, e4); (g3, f4); (h3, g4); (b4, a5); (c4, b5); (d4, c5); (e4, d5); (f4, e5); (g4, f5); (h4, g5); (b5, a6); (c5, b6); (d5, c6); (e5, d6); (f5, e6); (g5, f6); (h5, g6); (b6, a7); (c6, b7); (d6, c7); (e6, d7); (f6, e7); (g6, f7); (h6, g7); (b7, a8); (c7, b8); (d7, c8); (e7, d8); (f7, e8); (g7, f8); (h7, g8)} | ] " + ... ... ... ... + ... ... ... ... + ... ... ... ... + B..B B..B B..B B..B + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + W W..W W..W W..W W.. + ... ... ... ... + ... ... ... ... +" Deleted: trunk/Toss/Learn/learn.html =================================================================== --- trunk/Toss/Learn/learn.html 2012-01-23 23:33:10 UTC (rev 1652) +++ trunk/Toss/Learn/learn.html 2012-01-24 00:49:05 UTC (rev 1653) @@ -1,160 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:bibtex="http://bibtexml.sf.net/" xml:lang="en" lang="en"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <link rel="stylesheet" type="text/css" href="./styles/common.css" media="all" /> - <link rel="stylesheet" type="text/css" href="./styles/screen.css" media="screen" /> - <link rel="stylesheet" type="text/css" href="./styles/print.css" media="print" /> - <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,bold" /> - <link rel="shortcut icon" href="./img/favicon.ico" /> - <title>Learning Game Rules from Videos</title> - <script src="./scripts/nomap.js" type="text/javascript"></script> - <script src="./scripts/main.js" type="text/javascript"></script> - </head> - <body onload="gload()" onunload="gunload()"> - <div id="page"> - <div id="header"> - <div id="headerlogo"> - <a href="http://toss.sourceforge.net" id="logo"></a> - <div id="mgi-title"> - <h3></h3> - </div> - </div> - <a href="http://toss.sourceforge.net" id="left-logo">Toss</a> - <div id="parentnav"> - <ul> - <li> - <a href="index.html.de">Deutsch</a> - </li> - <li class="selected"> - <span>English</span> - </li> - <li> - <a href="index.html.fr">Français</a> - </li> - <li> - <a href="index.html.pol">Polski</a> - </li> - </ul> - </div> - </div> - <div id="container" class="with-sidebar"> - <div id="primary"> - <div id="content"> - <div> - -<div class="title"> - <h1 property="foaf:title">Learning Game Rules from Videos</h1> -</div> - -<h2>Breakthrough</h2> - -<p>Illustrating plays and positions not won by anyone</p> -<video width="352" height="288" controls="controls"> - <source src="videos/Breakthrough001_01.nwn.3gp" type="video/3gpp" /> - <source src="videos/Breakthrough001_01.nwn.webm" type="video/webm" /> - Your browser does not support the video tag. -</video> -<video width="352" height="288" controls="controls"> - <source src="videos/Breakthrough001_02.nwn.3gp" type="video/3gpp" /> - <source src="videos/Breakthrough001_02.nwn.webm" type="video/webm" /> - Your browser does not support the video tag. -</video> -<video width="352" height="288" controls="controls"> - <source src="videos/Breakthrough001_03.nwn.3gp" type="video/3gpp" /> - <source src="videos/Breakthrough001_03.nwn.webm" type="video/webm" /> - Your browser does not support the video tag. -</video> - - -<p>Winning for the first player</p> -<video width="352" height="288" controls="controls"> - <source src="videos/Breakthrough001_01.wn0.3gp" type="video/3gpp" /> - <source src="videos/Breakthrough001_01.wn0.webm" type="video/webm" /> - Your browser does not support the video tag. -</video> - -<p>Winning for the second player</p> -<video width="352" height="288" controls="controls"> - <source src="videos/Breakthrough001_01.wn1.3gp" type="video/3gpp" /> - <source src="videos/Breakthrough001_01.wn1.webm" type="video/webm" /> - Your browser does not support the video tag. -</video> - - - </div> - </div> - </div> - <div id="secondary"> - <div id="sidebar"> - <div class="childnav" id="menu"> - <div class="childnav-top"></div> - <ul> - <li class="selected"> - <a href="./index.html.en" class="menu-top">Home</a> - </li> - <li class=""> - <a href="http://tplay.org" class="menu-top">Play Online</a> - </li> - <li class=""> - <a href="http://sourceforge.net/project/showfiles.php?group_id=115606" class="menu-top">Download Toss</a> - </li> - <li class=""> - <a href="./create.html.en" class="menu-title menu-top">Create Games</a> - <ul> - <li class=""> - <a href="http://vimeo.com/10110495" class="menu-sub">Video Tutorial</a> - </li> - <li class=""> - <a href="./examples.html.en" class="menu-sub">Examples</a> - </li> - <li class=""> - <a href="./gui_interface.html.en" class="menu-sub">GUI Interface Guide</a> - </li> - </ul> - </li> - <li class=""> - <a href="./play.html.en" class="menu-top">Watch Toss Play</a> - </li> - <li class=""> - <a href="./docs.html.en" class="menu-title menu-top">Documentation</a> - <ul> - <li class=""> - <a href="./reference/reference.pdf" class="menu-sub">Reference (pdf)</a> - </li> - <li class=""> - <a href="./reference/index.html.en" class="menu-sub">Reference (html)</a> - </li> - </ul> - </li> - <li class=""> - <a href="./Publications/index.html.en" class="menu-top">Papers and Talks</a> - </li> - <li class=""> - <a href="./develop.html.en" class="menu-title menu-top">Develop Toss</a> - <ul> - <li class=""> - <a href="./ocaml.html.en" class="menu-sub">Mini OCaml Tutorial</a> - </li> - <li class=""> - <a href="./codebasics.html.en" class="menu-sub">Toss Code Basics</a> - </li> - <li class=""> - <a href="./code_doc/index.html.en" class="menu-sub">Code Documentation</a> - </li> - </ul> - </li> - <li class=""> - <a href="./contact.html.en" class="menu-top">Contact and Links</a> - </li> - </ul> - </div> - </div> - </div> - </div> - </div> - <div id="footer"> - © 2012 Toss Team - </div> - </body> -</html> Added: trunk/Toss/www/learn.xml =================================================================== --- trunk/Toss/www/learn.xml (rev 0) +++ trunk/Toss/www/learn.xml 2012-01-24 00:49:05 UTC (rev 1653) @@ -0,0 +1,165 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE lecture SYSTEM "xsl/xhtml1-lat1.ent"> + +<?xml-stylesheet type="text/xsl" href="xsl/main.xsl" charset="UTF-8"?> + +<personal> + <title lang="en">Learning Game Rules from Videos</title> + <title lang="de">Spielregeln von Videos Lehrnen (auf Englisch)</title> + <title lang="pol">Indukcja reguł gier z filmów (po angielsku)</title> + <title lang="fr">Apprendre des règles de jeux (à anglais)</title> + <history> + <link id="learn" href="/learn.html">Learning Game Rules from Videos</link> + </history> + + <section title="Breakthrough"> + <subsection>Resulting game: </subsection> + <a href="videos/Breakthrough001.toss.txt">toss file</a> <br/> + + <subsection>Illustrating plays and positions not won by anyone</subsection> + <br/> + <playvideo name="Breakthrough001_01.nwn" /> + <playvideo name="Breakthrough001_02.nwn" /> + <playvideo name="Breakthrough001_03.nwn" /> + + <subsection>Winning for the first player</subsection> <br/> + <playvideo name="Breakthrough001_01.wn0" /> + + <subsection>Winning for the second player</subsection> <br/> + <playvideo name="Breakthrough001_01.wn1" /> + </section> + + <section title="Connect4"> + <subsection>Resulting game: </subsection> + <a href="videos/Connect4001.toss.txt">toss file</a> <br/> + + <subsection>Illustrating plays and positions not won by anyone</subsection> + <br/> + <playvideo name="Connect4001_01.nwn" /> + <playvideo name="Connect4001_02.nwn" /> + <playvideo name="Connect4001_03.nwn" /> + <playvideo name="Connect4001_04.nwn" /> + <playvideo name="Connect4001_05.nwn" /> + <playvideo name="Connect4001_06.nwn" /> + <playvideo name="Connect4001_07.nwn" /> + <playvideo name="Connect4001_08.nwn" /> + <playvideo name="Connect4001_09.nwn" /> + <playvideo name="Connect4001_10.nwn" /> + <playvideo name="Connect4001_11.nwn" /> + <playvideo name="Connect4001_12.nwn" /> + <playvideo name="Connect4001_13.nwn" /> + + <subsection>Winning for the first player</subsection> <br/> + <playvideo name="Connect4001_01.wn0" /> + <playvideo name="Connect4001_02.wn0" /> + <playvideo name="Connect4001_03.wn0" /> + <playvideo name="Connect4001_04.wn0" /> + + <subsection>Winning for the second player</subsection> <br/> + <playvideo name="Connect4001_01.wn1" /> + <playvideo name="Connect4001_02.wn1" /> + <playvideo name="Connect4001_03.wn1" /> + <playvideo name="Connect4001_04.wn1" /> + + <subsection>Illustrating illegal moves (last one)</subsection> <br/> + <playvideo name="Connect4001_01.wrg" /> + <playvideo name="Connect4001_02.wrg" /> + <playvideo name="Connect4001_03.wrg" /> + <playvideo name="Connect4001_04.wrg" /> + </section> + + + <section title="Pawn-Whopping"> + <subsection>Resulting game: </subsection> + <a href="videos/Pawn-Whopping001.toss.txt">toss file</a> <br/> + + <subsection>Illustrating plays and positions not won by anyone</subsection> + <br/> + <playvideo name="Pawn-Whopping001_01.nwn" /> + <playvideo name="Pawn-Whopping001_02.nwn" /> + <playvideo name="Pawn-Whopping001_03.nwn" /> + <playvideo name="Pawn-Whopping001_04.nwn" /> + + <subsection>Winning for the first player</subsection> <br/> + <playvideo name="Pawn-Whopping001_01.wn0" /> + + <subsection>Winning for the second player</subsection> <br/> + <playvideo name="Pawn-Whopping001_01.wn1" /> + + <subsection>Illustrating illegal moves (last one)</subsection> <br/> + <playvideo name="Pawn-Whopping001_01.wrg" /> + <playvideo name="Pawn-Whopping001_02.wrg" /> + <playvideo name="Pawn-Whopping001_03.wrg" /> + <playvideo name="Pawn-Whopping001_04.wrg" /> + <playvideo name="Pawn-Whopping001_05.wrg" /> + <playvideo name="Pawn-Whopping001_06.wrg" /> + </section> + + <section title="Tic-Tac-Toe"> + <subsection>Resulting game: </subsection> + <a href="videos/Tic-Tac-Toe001.toss.txt">toss file</a> <br/> + + <subsection>Illustrating plays and positions not won by anyone</subsection> + <br/> + <playvideo name="Tic-Tac-Toe001_01.nwn" /> + <playvideo name="Tic-Tac-Toe001_02.nwn" /> + <playvideo name="Tic-Tac-Toe001_03.nwn" /> + <playvideo name="Tic-Tac-Toe001_04.nwn" /> + <playvideo name="Tic-Tac-Toe001_05.nwn" /> + <playvideo name="Tic-Tac-Toe001_06.nwn" /> + <playvideo name="Tic-Tac-Toe001_07.nwn" /> + <playvideo name="Tic-Tac-Toe001_08.nwn" /> + <playvideo name="Tic-Tac-Toe001_09.nwn" /> + <playvideo name="Tic-Tac-Toe001_10.nwn" /> + <playvideo name="Tic-Tac-Toe001_11.nwn" /> + <playvideo name="Tic-Tac-Toe001_12.nwn" /> + <playvideo name="Tic-Tac-Toe001_13.nwn" /> + <playvideo name="Tic-Tac-Toe001_14.nwn" /> + <playvideo name="Tic-Tac-Toe001_15.nwn" /> + <playvideo name="Tic-Tac-Toe001_16.nwn" /> + <playvideo name="Tic-Tac-Toe001_17.nwn" /> + + <subsection>Winning for the first player</subsection> <br/> + <playvideo name="Tic-Tac-Toe001_01.wn0" /> + <playvideo name="Tic-Tac-Toe001_02.wn0" /> + <playvideo name="Tic-Tac-Toe001_03.wn0" /> + <playvideo name="Tic-Tac-Toe001_04.wn0" /> + + <subsection>Winning for the second player</subsection> <br/> + <playvideo name="Tic-Tac-Toe001_01.wn1" /> + <playvideo name="Tic-Tac-Toe001_02.wn1" /> + <playvideo name="Tic-Tac-Toe001_03.wn1" /> + <playvideo name="Tic-Tac-Toe001_04.wn1" /> + </section> + + <section title="Gomoku"> + <subsection>Resulting game: </subsection> + <a href="videos/Gomoku001.toss.txt">toss file</a> <br/> + + <subsection>Illustrating plays and positions not won by anyone</subsection> + <br/> + <playvideo name="Gomoku001_01.nwn" /> + <playvideo name="Gomoku001_02.nwn" /> + <playvideo name="Gomoku001_03.nwn" /> + <playvideo name="Gomoku001_04.nwn" /> + <playvideo name="Gomoku001_05.nwn" /> + <playvideo name="Gomoku001_06.nwn" /> + <playvideo name="Gomoku001_07.nwn" /> + <playvideo name="Gomoku001_08.nwn" /> + <playvideo name="Gomoku001_09.nwn" /> + + <subsection>Winning for the first player</subsection> <br/> + <playvideo name="Gomoku001_01.wn0" /> + <playvideo name="Gomoku001_02.wn0" /> + <playvideo name="Gomoku001_03.wn0" /> + <playvideo name="Gomoku001_04.wn0" /> + + <subsection>Winning for the second player</subsection> <br/> + <playvideo name="Gomoku001_01.wn1" /> + <playvideo name="Gomoku001_02.wn1" /> + <playvideo name="Gomoku001_03.wn1" /> + <playvideo name="Gomoku001_04.wn1" /> + </section> + + +</personal> Modified: trunk/Toss/www/xsl/common.xsl =================================================================== --- trunk/Toss/www/xsl/common.xsl 2012-01-23 23:33:10 UTC (rev 1652) +++ trunk/Toss/www/xsl/common.xsl 2012-01-24 00:49:05 UTC (rev 1653) @@ -110,13 +110,22 @@ </pre> </xsl:template> +<xsl:template match="playvideo"> + <video width="352" height="288" controls="controls"> + <source src="videos/{@name}.3gp" type="video/3gpp" /> + <source src="videos/{@name}.webm" type="video/webm" /> + Your browser does not support the video tag. + </video> + <a href="videos/{@name}.txt">Text</a> +</xsl:template> + + <xsl:template match="pre"> <pre class="code"> <xsl:apply-templates /> </pre> </xsl:template> - <xsl:template match="em"> <em><xsl:apply-templates /></em> </xsl:template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-01-23 23:33:18
|
Revision: 1652 http://toss.svn.sourceforge.net/toss/?rev=1652&view=rev Author: lukaszkaiser Date: 2012-01-23 23:33:10 +0000 (Mon, 23 Jan 2012) Log Message: ----------- Final Tic-Tac-Toe Videos, tests cleanup and html description. Modified Paths: -------------- trunk/Toss/Learn/Makefile trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.wn0 trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.wn1 trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.wn0 trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.wn1 trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.wn0 trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.wn1 trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.wn0 trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.wn1 trunk/Toss/Learn/examples/Tic-Tac-Toe001_05.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_06.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_07.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_08.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_09.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_10.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_11.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_12.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_13.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_14.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_15.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_16.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_17.nwn Added Paths: ----------- trunk/Toss/Learn/examples/Breakthrough001.toss trunk/Toss/Learn/examples/Connect4001.toss trunk/Toss/Learn/examples/Gomoku001.toss trunk/Toss/Learn/examples/Tic-Tac-Toe001.toss trunk/Toss/Learn/examples/Tic-Tac-Toe002.toss trunk/Toss/Learn/learn.html trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.wn0.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.wn1.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.wn0.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.wn1.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.wn0.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.wn1.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.wn0.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.wn1.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_05.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_06.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_07.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_08.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_09.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_10.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_11.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_12.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_13.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_14.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_15.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_16.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_17.nwn.3gp Removed Paths: ------------- trunk/Toss/Learn/grid.pdf Modified: trunk/Toss/Learn/Makefile =================================================================== --- trunk/Toss/Learn/Makefile 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/Makefile 2012-01-23 23:33:10 UTC (rev 1652) @@ -24,7 +24,9 @@ %.learn: make -C .. Learn/LearnGameTest.native - time ../LearnGameTest.native -f $(basename $@) > $(basename $@).toss + time ../LearnGameTest.native -f $(basename $@) > res.toss + diff res.toss examples/$(basename $@).toss + rm res.toss learntests: make Tic-Tac-Toe001.learn @@ -46,7 +48,7 @@ diff res.play.log examples/$(basename $@) rm res.play.log -VIDEOS_TO_TEST = videos/* +VIDEOS_TO_TEST = videos/T* VIDEOS = $(notdir $(shell find $(VIDEOS_TO_TEST) -maxdepth 1 -name '*.3gp')) VIDEOS_BASE = $(basename $(VIDEOS)) VIDEOS_RECO = $(addsuffix .reco, $(VIDEOS_BASE)) Added: trunk/Toss/Learn/examples/Breakthrough001.toss =================================================================== --- trunk/Toss/Learn/examples/Breakthrough001.toss (rev 0) +++ trunk/Toss/Learn/examples/Breakthrough001.toss 2012-01-23 23:33:10 UTC (rev 1652) @@ -0,0 +1,75 @@ +PLAYERS 1, 2 +REL Win1() = ex x1 (W(x1) and all x0 not C(x1, x0)) +REL Win2() = ex x1 (B(x1) and all x0 not C(x0, x1)) + +RULE Mv1r0: +[e1, e2 | B:1 {}; C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (true) and not Win2() +RULE Mv1r1: +[e1, e2 | B:1 {}; C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (true) and not Win2() +RULE Mv1r2: +[e1, e2 | B:1 {}; C (e1, e2); Da:2 {}; Db:2 {}; R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C (e1, e2); Da:2 {}; Db:2 {}; R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (true) and not Win2() +RULE Mv1r3: +[e1, e2 | B (e2); C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (true) and not Win2() +RULE Mv1r4: +[e1, e2 | B (e2); C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W (e1) | ] -> [e1, e2 | B:1 {}; C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W (e2) | ] +emb W,R,Db,Da,C,B +pre (true) and not Win2() + + +RULE Mv2r0: +[e1, e2 | B (e2); C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W:1 {} | ] -> [e1, e2 | B (e1); C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (true) and not Win1() +RULE Mv2r1: +[e1, e2 | B (e2); C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W (e1) | ] -> [e1, e2 | B (e1); C:2 {}; Da:2 {}; Db (e1, e2); R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (true) and not Win1() +RULE Mv2r2: +[e1, e2 | B (e2); C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W:1 {} | ] -> [e1, e2 | B (e1); C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (true) and not Win1() +RULE Mv2r3: +[e1, e2 | B (e2); C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W (e1) | ] -> [e1, e2 | B (e1); C:2 {}; Da (e1, e2); Db:2 {}; R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (true) and not Win1() +RULE Mv2r4: +[e1, e2 | B (e2); C (e1, e2); Da:2 {}; Db:2 {}; R:2 {}; W:1 {} | ] -> [e1, e2 | B (e1); C (e1, e2); Da:2 {}; Db:2 {}; R:2 {}; W:1 {} | ] +emb W,R,Db,Da,C,B +pre (true) and not Win1() + +LOC 0 { + PLAYER 1 { PAYOFF : (Win1()) - :(Win2()) + MOVES [Mv1r0 -> 1]; [Mv1r1 -> 1]; [Mv1r2 -> 1]; [Mv1r3 -> 1]; [Mv1r4 -> 1]} + PLAYER 2 { PAYOFF : (Win2()) - :(Win1()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(Win1()) - :(Win2()) } + PLAYER 2 { PAYOFF :(Win2()) - :(Win1()) + MOVES [Mv2r0 -> 0]; [Mv2r1 -> 0]; [Mv2r2 -> 0]; [Mv2r3 -> 0]; [Mv2r4 -> 0]} +} +MODEL [a1, b1, c1, d1, e1, f1, g1, h1, a2, b2, c2, d2, e2, f2, g2, h2, a3, b3, c3, d3, e3, f3, g3, h3, a4, b4, c4, d4, e4, f4, g4, h4, a5, b5, c5, d5, e5, f5, g5, h5, a6, b6, c6, d6, e6, f6, g6, h6, a7, b7, c7, d7, e7, f7, g7, h7, a8, b8, c8, d8, e8, f8, g8, h8 | Da {(a1, b2); (b1, c2); (c1, d2); (d1, e2); (e1, f2); (f1, g2); (g1, h2); (a2, b3); (b2, c3); (c2, d3); (d2, e3); (e2, f3); (f2, g3); (g2, h3); (a3, b4); (b3, c4); (c3, d4); (d3, e4); (e3, f4); (f3, g4); (g3, h4); (a4, b5); (b4, c5); (c4, d5); (d4, e5); (e4, f5); (f4, g5); (g4, h5); (a5, b6); (b5, c6); (c5, d6); (d5, e6); (e5, f6); (f5, g6); (g5, h6); (a6, b7); (b6, c7); (c6, d7); (d6, e7); (e6, f7); (f6, g7); (g6, h7); (a7, b8); (b7, c8); (c7, d8); (d7, e8); (e7, f8); (f7, g8); (g7, h8)}; Db {(b1, a2); (c1, b2); (d1, c2); (e1, d2); (f1, e2); (g1, f2); (h1, g2); (b2, a3); (c2, b3); (d2, c3); (e2, d3); (f2, e3); (g2, f3); (h2, g3); (b3, a4); (c3, b4); (d3, c4); (e3, d4); (f3, e4); (g3, f4); (h3, g4); (b4, a5); (c4, b5); (d4, c5); (e4, d5); (f4, e5); (g4, f5); (h4, g5); (b5, a6); (c5, b6); (d5, c6); (e5, d6); (f5, e6); (g5, f6); (h5, g6); (b6, a7); (c6, b7); (d6, c7); (e6, d7); (f6, e7); (g6, f7); (h6, g7); (b7, a8); (c7, b8); (d7, c8); (e7, d8); (f7, e8); (g7, f8); (h7, g8)} | ] " + ... ... ... ... + B B..B B..B B..B B.. + ... ... ... ... + B..B B..B B..B B..B + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + W W..W W..W W..W W.. + ... ... ... ... + W..W W..W W..W W..W +" Added: trunk/Toss/Learn/examples/Connect4001.toss =================================================================== --- trunk/Toss/Learn/examples/Connect4001.toss (rev 0) +++ trunk/Toss/Learn/examples/Connect4001.toss 2012-01-23 23:33:10 UTC (rev 1652) @@ -0,0 +1,51 @@ +PLAYERS 1, 2 +REL Win1() = ex x0, x1 ( + (tc !3 x0, x1 ((Q(x0) and Q(x1) and C(x0, x1)))) or + (tc !3 x0, x1 ((Q(x0) and Q(x1) and Da(x0, x1)))) or + (tc !3 x0, x1 ((Q(x0) and Q(x1) and Db(x0, x1)))) or + (tc !3 x0, x1 ((Q(x0) and Q(x1) and R(x0, x1)))) ) +REL Win2() = ex x0, x1 ( + (tc !3 x0, x1 ((P(x0) and P(x1) and C(x0, x1)))) or + (tc !3 x0, x1 ((P(x0) and P(x1) and Da(x0, x1)))) or + (tc !3 x0, x1 ((P(x0) and P(x1) and Db(x0, x1)))) or + (tc !3 x0, x1 ((P(x0) and P(x1) and R(x0, x1)))) ) + +RULE Mv1r0: +[e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q (e1); R:2 {} | ] +emb R,Q,P,Db,Da,C +pre (ex x1 (x1 = e1 and all x0 not C(x0, x1)) or + ex x1 (P(x1) and ex x0 (C(x1, x0) and x0 = e1)) or + ex x1 (Q(x1) and ex x0 (C(x1, x0) and x0 = e1))) and not Win2() + + +RULE Mv2r0: +[e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | C:2 {}; Da:2 {}; Db:2 {}; P (e1); Q:1 {}; R:2 {} | ] +emb R,Q,P,Db,Da,C +pre (ex x1 (x1 = e1 and all x0 not C(x0, x1)) or + ex x1 (P(x1) and ex x0 (C(x1, x0) and x0 = e1)) or + ex x1 (Q(x1) and ex x0 (C(x1, x0) and x0 = e1))) and not Win1() + +LOC 0 { + PLAYER 1 { PAYOFF : (Win1()) - :(Win2()) + MOVES [Mv1r0 -> 1]} + PLAYER 2 { PAYOFF : (Win2()) - :(Win1()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(Win1()) - :(Win2()) } + PLAYER 2 { PAYOFF :(Win2()) - :(Win1()) + MOVES [Mv2r0 -> 0]} +} +MODEL [a1, b1, c1, d1, e1, f1, g1, a2, b2, c2, d2, e2, f2, g2, a3, b3, c3, d3, e3, f3, g3, a4, b4, c4, d4, e4, f4, g4, a5, b5, c5, d5, e5, f5, g5, a6, b6, c6, d6, e6, f6, g6 | Da {(a1, b2); (b1, c2); (c1, d2); (d1, e2); (e1, f2); (f1, g2); (a2, b3); (b2, c3); (c2, d3); (d2, e3); (e2, f3); (f2, g3); (a3, b4); (b3, c4); (c3, d4); (d3, e4); (e3, f4); (f3, g4); (a4, b5); (b4, c5); (c4, d5); (d4, e5); (e4, f5); (f4, g5); (a5, b6); (b5, c6); (c5, d6); (d5, e6); (e5, f6); (f5, g6)}; Db {(b1, a2); (c1, b2); (d1, c2); (e1, d2); (f1, e2); (g1, f2); (b2, a3); (c2, b3); (d2, c3); (e2, d3); (f2, e3); (g2, f3); (b3, a4); (c3, b4); (d3, c4); (e3, d4); (f3, e4); (g3, f4); (b4, a5); (c4, b5); (d4, c5); (e4, d5); (f4, e5); (g4, f5); (b5, a6); (c5, b6); (d5, c6); (e5, d6); (f5, e6); (g5, f6)}; P:1 {}; Q:1 {} | ] " + + . . . . . . . + + . . . . . . . + + . . . . . . . + + . . . . . . . + + . . . . . . . + + . . . . . . . +" Added: trunk/Toss/Learn/examples/Gomoku001.toss =================================================================== --- trunk/Toss/Learn/examples/Gomoku001.toss (rev 0) +++ trunk/Toss/Learn/examples/Gomoku001.toss 2012-01-23 23:33:10 UTC (rev 1652) @@ -0,0 +1,51 @@ +PLAYERS 1, 2 +REL Win1() = ex x0, x1 ( + (tc !4 x0, x1 ((Q(x0) and Q(x1) and C(x0, x1)))) or + (tc !4 x0, x1 ((Q(x0) and Q(x1) and Da(x0, x1)))) or + (tc !4 x0, x1 ((Q(x0) and Q(x1) and Db(x0, x1)))) or + (tc !4 x0, x1 ((Q(x0) and Q(x1) and R(x0, x1)))) ) +REL Win2() = ex x0, x1 ( + (tc !4 x0, x1 ((P(x0) and P(x1) and C(x0, x1)))) or + (tc !4 x0, x1 ((P(x0) and P(x1) and Da(x0, x1)))) or + (tc !4 x0, x1 ((P(x0) and P(x1) and Db(x0, x1)))) or + (tc !4 x0, x1 ((P(x0) and P(x1) and R(x0, x1)))) ) + +RULE Mv1r0: +[e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q (e1); R:2 {} | ] +emb R,Q,P,Db,Da,C +pre (true) and not Win2() + + +RULE Mv2r0: +[e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | C:2 {}; Da:2 {}; Db:2 {}; P (e1); Q:1 {}; R:2 {} | ] +emb R,Q,P,Db,Da,C +pre (true) and not Win1() + +LOC 0 { + PLAYER 1 { PAYOFF : (Win1()) - :(Win2()) + MOVES [Mv1r0 -> 1]} + PLAYER 2 { PAYOFF : (Win2()) - :(Win1()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(Win1()) - :(Win2()) } + PLAYER 2 { PAYOFF :(Win2()) - :(Win1()) + MOVES [Mv2r0 -> 0]} +} +MODEL [a1, b1, c1, d1, e1, f1, g1, h1, a2, b2, c2, d2, e2, f2, g2, h2, a3, b3, c3, d3, e3, f3, g3, h3, a4, b4, c4, d4, e4, f4, g4, h4, a5, b5, c5, d5, e5, f5, g5, h5, a6, b6, c6, d6, e6, f6, g6, h6, a7, b7, c7, d7, e7, f7, g7, h7, a8, b8, c8, d8, e8, f8, g8, h8 | Da {(a1, b2); (b1, c2); (c1, d2); (d1, e2); (e1, f2); (f1, g2); (g1, h2); (a2, b3); (b2, c3); (c2, d3); (d2, e3); (e2, f3); (f2, g3); (g2, h3); (a3, b4); (b3, c4); (c3, d4); (d3, e4); (e3, f4); (f3, g4); (g3, h4); (a4, b5); (b4, c5); (c4, d5); (d4, e5); (e4, f5); (f4, g5); (g4, h5); (a5, b6); (b5, c6); (c5, d6); (d5, e6); (e5, f6); (f5, g6); (g5, h6); (a6, b7); (b6, c7); (c6, d7); (d6, e7); (e6, f7); (f6, g7); (g6, h7); (a7, b8); (b7, c8); (c7, d8); (d7, e8); (e7, f8); (f7, g8); (g7, h8)}; Db {(b1, a2); (c1, b2); (d1, c2); (e1, d2); (f1, e2); (g1, f2); (h1, g2); (b2, a3); (c2, b3); (d2, c3); (e2, d3); (f2, e3); (g2, f3); (h2, g3); (b3, a4); (c3, b4); (d3, c4); (e3, d4); (f3, e4); (g3, f4); (h3, g4); (b4, a5); (c4, b5); (d4, c5); (e4, d5); (f4, e5); (g4, f5); (h4, g5); (b5, a6); (c5, b6); (d5, c6); (e5, d6); (f5, e6); (g5, f6); (h5, g6); (b6, a7); (c6, b7); (d6, c7); (e6, d7); (f6, e7); (g6, f7); (h6, g7); (b7, a8); (c7, b8); (d7, c8); (e7, d8); (f7, e8); (g7, f8); (h7, g8)}; P:1 {}; Q:1 {} | ] " + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... + ... ... ... ... +" Added: trunk/Toss/Learn/examples/Tic-Tac-Toe001.toss =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001.toss (rev 0) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001.toss 2012-01-23 23:33:10 UTC (rev 1652) @@ -0,0 +1,41 @@ +PLAYERS 1, 2 +REL Win1() = ex x0, x1 ( + (tc !2 x0, x1 ((Q(x0) and Q(x1) and C(x0, x1)))) or + (tc !2 x0, x1 ((Q(x0) and Q(x1) and Da(x0, x1)))) or + (tc !2 x0, x1 ((Q(x0) and Q(x1) and Db(x0, x1)))) or + (tc !2 x0, x1 ((Q(x0) and Q(x1) and R(x0, x1)))) ) +REL Win2() = ex x0, x1 ( + (tc !2 x0, x1 ((P(x0) and P(x1) and C(x0, x1)))) or + (tc !2 x0, x1 ((P(x0) and P(x1) and Da(x0, x1)))) or + (tc !2 x0, x1 ((P(x0) and P(x1) and Db(x0, x1)))) or + (tc !2 x0, x1 ((P(x0) and P(x1) and R(x0, x1)))) ) + +RULE Mv1r0: +[e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q (e1); R:2 {} | ] +emb R,Q,P,Db,Da,C +pre (true) and not Win2() + + +RULE Mv2r0: +[e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | C:2 {}; Da:2 {}; Db:2 {}; P (e1); Q:1 {}; R:2 {} | ] +emb R,Q,P,Db,Da,C +pre (true) and not Win1() + +LOC 0 { + PLAYER 1 { PAYOFF : (Win1()) - :(Win2()) + MOVES [Mv1r0 -> 1]} + PLAYER 2 { PAYOFF : (Win2()) - :(Win1()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(Win1()) - :(Win2()) } + PLAYER 2 { PAYOFF :(Win2()) - :(Win1()) + MOVES [Mv2r0 -> 0]} +} +MODEL [a1, b1, c1, a2, b2, c2, a3, b3, c3 | Da {(a1, b2); (b1, c2); (a2, b3); (b2, c3)}; Db {(b1, a2); (c1, b2); (b2, a3); (c2, b3)}; P:1 {}; Q:1 {} | ] " + + . . . + + . . . + + . . . +" Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.wn0 =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.wn0 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.wn0 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.wn1 =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.wn1 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.wn1 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.wn0 =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.wn0 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.wn0 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . Q . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.wn1 =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.wn1 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_02.wn1 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . P . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.wn0 =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.wn0 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.wn0 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . Q Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.wn1 =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.wn1 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_03.wn1 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . P Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.wn0 =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.wn0 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.wn0 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] Q . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.wn1 =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.wn1 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_04.wn1 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] P . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_05.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_05.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_05.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . Q . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_06.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_06.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_06.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . Q Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_07.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_07.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_07.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_08.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_08.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_08.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_09.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_09.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_09.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] Q . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_10.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_10.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_10.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_11.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_11.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_11.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_12.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_12.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_12.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_13.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_13.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_13.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . P . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_14.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_14.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_14.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . P Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_15.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_15.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_15.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_16.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_16.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_16.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_17.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_17.nwn 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_17.nwn 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] P . . Added: trunk/Toss/Learn/examples/Tic-Tac-Toe002.toss =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe002.toss (rev 0) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe002.toss 2012-01-23 23:33:10 UTC (rev 1652) @@ -0,0 +1,41 @@ +PLAYERS 1, 2 +REL Win1() = ex x0, x1 ( + (tc !2 x0, x1 ((Q(x0) and Q(x1) and C(x0, x1)))) or + (tc !2 x0, x1 ((Q(x0) and Q(x1) and Da(x0, x1)))) or + (tc !2 x0, x1 ((Q(x0) and Q(x1) and Db(x0, x1)))) or + (tc !2 x0, x1 ((Q(x0) and Q(x1) and R(x0, x1)))) ) +REL Win2() = ex x0, x1 ( + (tc !2 x0, x1 ((P(x0) and P(x1) and C(x0, x1)))) or + (tc !2 x0, x1 ((P(x0) and P(x1) and Da(x0, x1)))) or + (tc !2 x0, x1 ((P(x0) and P(x1) and Db(x0, x1)))) or + (tc !2 x0, x1 ((P(x0) and P(x1) and R(x0, x1)))) ) + +RULE Mv1r0: +[e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q (e1); R:2 {} | ] +emb R,Q,P,Db,Da,C +pre (true) and not Win2() + + +RULE Mv2r0: +[e1 | C:2 {}; Da:2 {}; Db:2 {}; P:1 {}; Q:1 {}; R:2 {} | ] -> [e1 | C:2 {}; Da:2 {}; Db:2 {}; P (e1); Q:1 {}; R:2 {} | ] +emb R,Q,P,Db,Da,C +pre (true) and not Win1() + +LOC 0 { + PLAYER 1 { PAYOFF : (Win1()) - :(Win2()) + MOVES [Mv1r0 -> 1]} + PLAYER 2 { PAYOFF : (Win2()) - :(Win1()) } +} +LOC 1 { + PLAYER 1 { PAYOFF :(Win1()) - :(Win2()) } + PLAYER 2 { PAYOFF :(Win2()) - :(Win1()) + MOVES [Mv2r0 -> 0]} +} +MODEL [a1, b1, c1, a2, b2, c2, a3, b3, c3 | Da {(a1, b2); (b1, c2); (a2, b3); (b2, c3)}; Db {(b1, a2); (c1, b2); (b2, a3); (c2, b3)}; P:1 {}; Q:1 {} | ] " + + . . . + + . . . + + . . . +" Deleted: trunk/Toss/Learn/grid.pdf =================================================================== --- trunk/Toss/Learn/grid.pdf 2012-01-23 03:10:29 UTC (rev 1651) +++ trunk/Toss/Learn/grid.pdf 2012-01-23 23:33:10 UTC (rev 1652) @@ -1,69 +0,0 @@ -%PDF-1.4 -%\xD0\xD4\xC5\xD8 -1 0 obj -<<>> -endobj -2 0 obj -<<>> -endobj -3 0 obj -<< /pgfprgb [/Pattern /DeviceRGB] >> -endobj -6 0 obj << -/Length 139 -/Filter /FlateDecode ->> -stream -xڅ\x911\xC20Ew\x9F\xE2_ \x96\x83S㜠3\xE2]Z$&\xAEOڡ\x90Ш\x8Bc\xFF\xFF\xBE\x9C(\x82 \x82\x91\xE4䌥 -"T\x8CUI2\xE7dx,\xF4B\xA1Fl( k\xF6o\xACr\xE2\xEC\xB1\xC0e -\xF1*,.n\xF8i\x97\xCA\xF8v3\xE8T\x95zƽ\xF6c\xCBj\x97u\xF5\x91\xFC\x978\xB4\xFC>7\x8F\xDB\xF5\xF6N\x9D@\x97\xBF\x81\x9E[m?\xE6\xF6\xD4U@ -endstream -endobj -5 0 obj << -/Type /Page -/Contents 6 0 R -/Resources 4 0 R -/MediaBox [0 0 612 792] -/Parent 7 0 R ->> endobj -4 0 obj << - /ColorSpace 3 0 R /Pattern 2 0 R /ExtGState 1 0 R -/ProcSet [ /PDF ] ->> endobj -7 0 obj << -/Type /Pages -/Count 1 -/Kids [5 0 R] ->> endobj -8 0 obj << -/Type /Catalog -/Pages 7 0 R ->> endobj -9 0 obj << -/Producer (pdfTeX-1.40.10) -/Creator (TeX) -/CreationDate (D:20111210202438+01'00') -/ModDate (D:20111210202438+01'00') -/Trapped /False -/PTEX.Fullbanner (This is pdfTeX, Version 3.1415926-1.40.10-2.2 (TeX Live 2009/Debian) kpathsea version 5.0.0) ->> endobj -xref -0 10 -0000000000 65535 f -0000000015 00000 n -0000000035 00000 n -0000000055 00000 n -0000000430 00000 n -0000000326 00000 n -0000000108 00000 n -0000000521 00000 n -0000000578 00000 n -0000000627 00000 n -trailer -<< /Size 10 -/Root 8 0 R -/Info 9 0 R -/ID [<6450C2B72902EC0DBB009F58BA2907F2> <6450C2B72902EC0DBB009F58BA2907F2>] >> -startxref -892 -%%EOF Added: trunk/Toss/Learn/learn.html =================================================================== --- trunk/Toss/Learn/learn.html (rev 0) +++ trunk/Toss/Learn/learn.html 2012-01-23 23:33:10 UTC (rev 1652) @@ -0,0 +1,160 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:bibtex="http://bibtexml.sf.net/" xml:lang="en" lang="en"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <link rel="stylesheet" type="text/css" href="./styles/common.css" media="all" /> + <link rel="stylesheet" type="text/css" href="./styles/screen.css" media="screen" /> + <link rel="stylesheet" type="text/css" href="./styles/print.css" media="print" /> + <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu:regular,bold" /> + <link rel="shortcut icon" href="./img/favicon.ico" /> + <title>Learning Game Rules from Videos</title> + <script src="./scripts/nomap.js" type="text/javascript"></script> + <script src="./scripts/main.js" type="text/javascript"></script> + </head> + <body onload="gload()" onunload="gunload()"> + <div id="page"> + <div id="header"> + <div id="headerlogo"> + <a href="http://toss.sourceforge.net" id="logo"></a> + <div id="mgi-title"> + <h3></h3> + </div> + </div> + <a href="http://toss.sourceforge.net" id="left-logo">Toss</a> + <div id="parentnav"> + <ul> + <li> + <a href="index.html.de">Deutsch</a> + </li> + <li class="selected"> + <span>English</span> + </li> + <li> + <a href="index.html.fr">Français</a> + </li> + <li> + <a href="index.html.pol">Polski</a> + </li> + </ul> + </div> + </div> + <div id="container" class="with-sidebar"> + <div id="primary"> + <div id="content"> + <div> + +<div class="title"> + <h1 property="foaf:title">Learning Game Rules from Videos</h1> +</div> + +<h2>Breakthrough</h2> + +<p>Illustrating plays and positions not won by anyone</p> +<video width="352" height="288" controls="controls"> + <source src="videos/Breakthrough001_01.nwn.3gp" type="video/3gpp" /> + <source src="videos/Breakthrough001_01.nwn.webm" type="video/webm" /> + Your browser does not support the video tag. +</video> +<video width="352" height="288" controls="controls"> + <source src="videos/Breakthrough001_02.nwn.3gp" type="video/3gpp" /> + <source src="videos/Breakthrough001_02.nwn.webm" type="video/webm" /> + Your browser does not support the video tag. +</video> +<video width="352" height="288" controls="controls"> + <source src="videos/Breakthrough001_03.nwn.3gp" type="video/3gpp" /> + <source src="videos/Breakthrough001_03.nwn.webm" type="video/webm" /> + Your browser does not support the video tag. +</video> + + +<p>Winning for the first player</p> +<video width="352" height="288" controls="controls"> + <source src="videos/Breakthrough001_01.wn0.3gp" type="video/3gpp" /> + <source src="videos/Breakthrough001_01.wn0.webm" type="video/webm" /> + Your browser does not support the video tag. +</video> + +<p>Winning for the second player</p> +<video width="352" height="288" controls="controls"> + <source src="videos/Breakthrough001_01.wn1.3gp" type="video/3gpp" /> + <source src="videos/Breakthrough001_01.wn1.webm" type="video/webm" /> + Your browser does not support the video tag. +</video> + + + </div> + </div> + </div> + <div id="secondary"> + <div id="sidebar"> + <div class="childnav" id="menu"> + <div class="childnav-top"></div> + <ul> + <li class="selected"> + <a href="./index.html.en" class="menu-top">Home</a> + </li> + <li class=""> + <a href="http://tplay.org" class="menu-top">Play Online</a> + </li> + <li class=""> + <a href="http://sourceforge.net/project/showfiles.php?group_id=115606" class="menu-top">Download Toss</a> + </li> + <li class=""> + <a href="./create.html.en" class="menu-title menu-top">Create Games</a> + <ul> + <li class=""> + <a href="http://vimeo.com/10110495" class="menu-sub">Video Tutorial</a> + </li> + <li class=""> + <a href="./examples.html.en" class="menu-sub">Examples</a> + </li> + <li class=""> + <a href="./gui_interface.html.en" class="menu-sub">GUI Interface Guide</a> + </li> + </ul> + </li> + <li class=""> + <a href="./play.html.en" class="menu-top">Watch Toss Play</a> + </li> + <li class=""> + <a href="./docs.html.en" class="menu-title menu-top">Documentation</a> + <ul> + <li class=""> + <a href="./reference/reference.pdf" class="menu-sub">Reference (pdf)</a> + </li> + <li class=""> + <a href="./reference/index.html.en" class="menu-sub">Reference (html)</a> + </li> + </ul> + </li> + <li class=""> + <a href="./Publications/index.html.en" class="menu-top">Papers and Talks</a> + </li> + <li class=""> + <a href="./develop.html.en" class="menu-title menu-top">Develop Toss</a> + <ul> + <li class=""> + <a href="./ocaml.html.en" class="menu-sub">Mini OCaml Tutorial</a> + </li> + <li class=""> + <a href="./codebasics.html.en" class="menu-sub">Toss Code Basics</a> + </li> + <li class=""> + <a href="./code_doc/index.html.en" class="menu-sub">Code Documentation</a> + </li> + </ul> + </li> + <li class=""> + <a href="./contact.html.en" class="menu-top">Contact and Links</a> + </li> + </ul> + </div> + </div> + </div> + </div> + </div> + <div id="footer"> + © 2012 Toss Team + </div> + </body> +</html> Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_02.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_03.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_04.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_05.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_05.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_06.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_06.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_07.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_07.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_08.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_08.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_09.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_09.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_10.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_10.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_11.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_11.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_12.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_12.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_13.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_13.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_14.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_14.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_15.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_15.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_16.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_16.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_17.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_17.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-01-23 03:10:37
|
Revision: 1651 http://toss.svn.sourceforge.net/toss/?rev=1651&view=rev Author: lukaszkaiser Date: 2012-01-23 03:10:29 +0000 (Mon, 23 Jan 2012) Log Message: ----------- Videos for Connect4. Modified Paths: -------------- trunk/Toss/Learn/examples/Connect4001_01.nwn trunk/Toss/Learn/examples/Connect4001_01.wn0 trunk/Toss/Learn/examples/Connect4001_01.wn1 trunk/Toss/Learn/examples/Connect4001_01.wrg trunk/Toss/Learn/examples/Connect4001_02.nwn trunk/Toss/Learn/examples/Connect4001_02.wn0 trunk/Toss/Learn/examples/Connect4001_02.wn1 trunk/Toss/Learn/examples/Connect4001_02.wrg trunk/Toss/Learn/examples/Connect4001_03.nwn trunk/Toss/Learn/examples/Connect4001_03.wn0 trunk/Toss/Learn/examples/Connect4001_03.wn1 trunk/Toss/Learn/examples/Connect4001_03.wrg trunk/Toss/Learn/examples/Connect4001_04.nwn trunk/Toss/Learn/examples/Connect4001_04.wn0 trunk/Toss/Learn/examples/Connect4001_04.wn1 trunk/Toss/Learn/examples/Connect4001_04.wrg trunk/Toss/Learn/examples/Connect4001_05.nwn trunk/Toss/Learn/examples/Connect4001_06.nwn trunk/Toss/Learn/examples/Connect4001_07.nwn trunk/Toss/Learn/examples/Connect4001_08.nwn trunk/Toss/Learn/examples/Connect4001_09.nwn trunk/Toss/Learn/examples/Connect4001_10.nwn trunk/Toss/Learn/examples/Connect4001_11.nwn trunk/Toss/Learn/examples/Connect4001_12.nwn trunk/Toss/Learn/examples/Connect4001_13.nwn trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.nwn trunk/Toss/Learn/reco.cpp trunk/Toss/Learn/shapes.c trunk/Toss/Learn/shapes.h Added Paths: ----------- trunk/Toss/Learn/videos/Connect4001_01.nwn.3gp trunk/Toss/Learn/videos/Connect4001_01.wn0.3gp trunk/Toss/Learn/videos/Connect4001_01.wn1.3gp trunk/Toss/Learn/videos/Connect4001_01.wrg.3gp trunk/Toss/Learn/videos/Connect4001_02.nwn.3gp trunk/Toss/Learn/videos/Connect4001_02.wn0.3gp trunk/Toss/Learn/videos/Connect4001_02.wn1.3gp trunk/Toss/Learn/videos/Connect4001_02.wrg.3gp trunk/Toss/Learn/videos/Connect4001_03.nwn.3gp trunk/Toss/Learn/videos/Connect4001_03.wn0.3gp trunk/Toss/Learn/videos/Connect4001_03.wn1.3gp trunk/Toss/Learn/videos/Connect4001_03.wrg.3gp trunk/Toss/Learn/videos/Connect4001_04.nwn.3gp trunk/Toss/Learn/videos/Connect4001_04.wn0.3gp trunk/Toss/Learn/videos/Connect4001_04.wn1.3gp trunk/Toss/Learn/videos/Connect4001_04.wrg.3gp trunk/Toss/Learn/videos/Connect4001_05.nwn.3gp trunk/Toss/Learn/videos/Connect4001_06.nwn.3gp trunk/Toss/Learn/videos/Connect4001_07.nwn.3gp trunk/Toss/Learn/videos/Connect4001_08.nwn.3gp trunk/Toss/Learn/videos/Connect4001_09.nwn.3gp trunk/Toss/Learn/videos/Connect4001_10.nwn.3gp trunk/Toss/Learn/videos/Connect4001_11.nwn.3gp trunk/Toss/Learn/videos/Connect4001_12.nwn.3gp trunk/Toss/Learn/videos/Connect4001_13.nwn.3gp trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.nwn.3gp Modified: trunk/Toss/Learn/examples/Connect4001_01.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_01.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_01.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_01.wn0 =================================================================== --- trunk/Toss/Learn/examples/Connect4001_01.wn0 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_01.wn0 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... @@ -7,9 +7,9 @@ ... ... ... ... ... ... ... ... ... ... -... ... ... ... +... Q..Q Q..Q ... ... ... ... - Q..Q Q..Q ... + ... ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_01.wn1 =================================================================== --- trunk/Toss/Learn/examples/Connect4001_01.wn1 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_01.wn1 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... @@ -7,9 +7,9 @@ ... ... ... ... ... ... ... ... ... ... -... ... ... ... +... P..P P..P ... ... ... ... - P..P P..P ... + ... ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_01.wrg =================================================================== --- trunk/Toss/Learn/examples/Connect4001_01.wrg 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_01.wrg 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_02.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_02.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_02.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... @@ -7,9 +7,9 @@ ... ... ... ... ... ... ... ... ... ... -... ... ... ... +... ...Q Q..Q ... ... ... ... - ...Q Q..Q ... + ... ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_02.wn0 =================================================================== --- trunk/Toss/Learn/examples/Connect4001_02.wn0 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_02.wn0 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_02.wn1 =================================================================== --- trunk/Toss/Learn/examples/Connect4001_02.wn1 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_02.wn1 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... -... P.. ... ... +... ... P.. ... ... ... ... - ...P ... ... + ... ...P ... ... ... ... ... -... P.. ... ... +... ... P.. ... ... ... ... - ...P ... ... + ... ...P ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_02.wrg =================================================================== --- trunk/Toss/Learn/examples/Connect4001_02.wrg 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_02.wrg 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_03.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_03.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_03.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... - ...Q ... ... + ... ...Q ... ... ... ... ... -... Q.. ... ... +... ... Q.. ... ... ... ... - ...Q ... ... + ... ...Q ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_03.wn0 =================================================================== --- trunk/Toss/Learn/examples/Connect4001_03.wn0 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_03.wn0 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... -... ... Q.. ... +... ... ...Q ... ... ... ... - ... Q.. ... + ... ...Q ... ... ... ... ... -... Q.. ... ... +... ...Q ... ... ... ... ... - Q.. ... ... + ...Q ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_03.wn1 =================================================================== --- trunk/Toss/Learn/examples/Connect4001_03.wn1 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_03.wn1 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... -... ... P.. ... +... ... ...P ... ... ... ... - ... P.. ... + ... ...P ... ... ... ... ... -... P.. ... ... +... ...P ... ... ... ... ... - P.. ... ... + ...P ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_03.wrg =================================================================== --- trunk/Toss/Learn/examples/Connect4001_03.wrg 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_03.wrg 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... @@ -13,6 +13,7 @@ ... ... ... ... ... P.. ... ... + ... ... ... ... ... ... ... ... ... ... @@ -26,6 +27,7 @@ ... ... ... ... ... P..Q ... ... + ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_04.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_04.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_04.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... -... ... Q.. ... +... ... ... ... ... ... ... - ... Q.. ... + ... ...Q ... ... ... ... ... -... Q.. ... ... +... ...Q ... ... ... ... ... - ... ... ... + ...Q ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_04.wn0 =================================================================== --- trunk/Toss/Learn/examples/Connect4001_04.wn0 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_04.wn0 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_04.wn1 =================================================================== --- trunk/Toss/Learn/examples/Connect4001_04.wn1 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_04.wn1 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_04.wrg =================================================================== --- trunk/Toss/Learn/examples/Connect4001_04.wrg 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_04.wrg 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... @@ -13,6 +13,7 @@ ... ... ... ... ... P.. ... ... + ... ... ... ... ... ... ... ... ... ... @@ -26,6 +27,7 @@ ... ... ... ... ... P.. Q.. ... + ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_05.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_05.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_05.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... -... Q.. ... ... +... ... ... ... ... ... ... ... Q.. ... ... ... ... ... ... ... Q.. ... ... ... ... - ... ... ... + ... ... Q.. ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_06.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_06.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_06.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... @@ -7,9 +7,9 @@ ... ... ... ... ... ... ... ... ... ... -... ... ... ... +... ...P P..P ... ... ... ... - ...P P..P ... + ... ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_07.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_07.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_07.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... - ...P ... ... + ... ...P ... ... ... ... ... -... P.. ... ... +... ... P.. ... ... ... ... - ...P ... ... + ... ...P ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_08.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_08.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_08.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... -... ... P.. ... +... ... ... ... ... ... ... - ... P.. ... + ... ...P ... ... ... ... ... -... P.. ... ... +... ...P ... ... ... ... ... - ... ... ... + ...P ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_09.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_09.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_09.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,15 +1,15 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... ... ... -... P.. ... ... +... ... ... ... ... ... ... ... P.. ... ... ... ... ... ... ... P.. ... ... ... ... - ... ... ... + ... ... P.. ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_10.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_10.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_10.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_11.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_11.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_11.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_12.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_12.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_12.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... @@ -13,6 +13,7 @@ ... ... ... ... ... P.. ... ... + ... ... ... ... ... ... ... ... ... ... @@ -26,6 +27,7 @@ ... ... ... ... ... P..Q ... ... + ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Connect4001_13.nwn =================================================================== --- trunk/Toss/Learn/examples/Connect4001_13.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Connect4001_13.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... @@ -13,6 +13,7 @@ ... ... ... ... ... P.. ... ... + ... ... ... ... ... ... ... ... ... ... @@ -26,6 +27,7 @@ ... ... ... ... ... P.. Q.. ... + ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.nwn =================================================================== --- trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.nwn 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/examples/Tic-Tac-Toe001_01.nwn 2012-01-23 03:10:29 UTC (rev 1651) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] . . . @@ -16,6 +16,12 @@ . . . + + + + + + . . P Modified: trunk/Toss/Learn/reco.cpp =================================================================== --- trunk/Toss/Learn/reco.cpp 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/reco.cpp 2012-01-23 03:10:29 UTC (rev 1651) @@ -51,7 +51,7 @@ } CvPoint from_point (point p) { - double x = p.x + MARGINX; //(p.x * SIZEX) / (SIZEX + 2*MARGINX) + MARGINX; + double x = p.x + MARGINX; double y = p.y + MARGINY; return (cvPoint ((int) x, (int) y)); } @@ -76,8 +76,8 @@ cvNamedWindow ("Reco", CV_WINDOW_AUTOSIZE); CvCapture* capture = cvCreateFileCapture (argv[3]); // cvCreateCameraCapture( 0 ); - IplImage *img, *col, *gray, *small; - int data_count = 0; + IplImage *img, *col, *gray, *small, *smallpre; + int data_count = 0, is_connect_four = 0; char data[SIZEX][SIZEY]; unsigned int color[SIZEX][SIZEY]; unsigned int cur_data = 0; @@ -100,6 +100,9 @@ cvCvtColor (img, gray, CV_BGR2GRAY); small = cvCreateImage (cvSize (SIZEX + 2*MARGINX, SIZEY + 2*MARGINY), 8, 1); cvResize (gray, small, CV_INTER_LINEAR); + smallpre = cvCreateImage (cvSize (SIZEX+2*MARGINX, SIZEY+2*MARGINY), 8, 1); + cvResize (gray, smallpre, CV_INTER_LINEAR); + if ((time / timeSTEP) < 35) { // beginings are cleaner, compensate a bit cvCanny (small, small, 195, 230); } else { @@ -125,13 +128,24 @@ CvSeq* lines = 0; int i; lines = cvHoughLines2( small, storage, CV_HOUGH_PROBABILISTIC, - 1, CV_PI/180, 120, 50, 30 ); + 1, CV_PI/180, 80, 50, 30 ); if (debugLEVEL > 1) { + printf ("Lines %i\n", lines->total); for( i = 0; i < lines->total; i++ ) { CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i); cvLine( small, line[0], line[1], CV_RGB(100,200,200), 3 ); } } + if ((((time / timeSTEP) < 2) && lines->total < 5) || is_connect_four == 1) { + is_connect_four = 1; // connect4 + setGridSize (7, 6); + cvCanny (smallpre, smallpre, 170, 200); + small = smallpre; + } else if ((time / timeSTEP) < 2 && lines->total > 30) { // chess board + setGridSize (8, 8); + } else if ((time / timeSTEP) < 2) { // tic-tac-toe + setGridSize (3, 3); + } if (rnbr >= 0) { shape p = (get_patterns())[rnbr]; Modified: trunk/Toss/Learn/shapes.c =================================================================== --- trunk/Toss/Learn/shapes.c 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/shapes.c 2012-01-23 03:10:29 UTC (rev 1651) @@ -812,10 +812,11 @@ /* Keep old scale unchaged if within these bound, useful for video. */ int videoSTEP = 0; point prev_dim = { 1., 1. }; -float prev_dim_change_bound = 2; +float prev_dim_change_bound = 3; /* Scale Margin since we do not detect outliers at present. */ -float scale_margin = 0.88; +float scale_marginx = 0.88; +float scale_marginy = 0.88; /* Find scale factor given pattern and shape dimensions. */ static point find_scale (const point pattern_dim, const point shape_dim) { @@ -834,8 +835,8 @@ res.y = shape_dim.y / pattern_dim.y; } - res.x = scale_margin * res.x; - res.y = scale_margin * res.y; + res.x = scale_marginx * res.x; + res.y = scale_marginy * res.y; if ((videoSTEP > 0) && (res.x < prev_dim_change_bound * prev_dim.x) && @@ -852,7 +853,7 @@ /* Keep old translation unchaged if within these bound, useful for video. */ point prev_move = { 0., 0. }; -float prev_move_change_bound = 50; +float prev_move_change_bound = 100; /* Find best fit (scale and translation) between shape and pattern. */ static interval best_fit (interval* shape, const int s_size, interval* pattern, @@ -1374,81 +1375,107 @@ return (new_shape); } -#define gridSIZE 8 + +#define gridMaxSIZE 8 +int gridSIZEX = 3; +int gridSIZEY = 3; +void setGridSize (int x, int y) { + if (x <= gridMaxSIZE && y <= gridMaxSIZE) { + gridSIZEX = x; + gridSIZEY = y; + } +} + #define gridJUMP 1 #define gridMARGIN 0.5 #define maxOUT 9 -int gridSIZES[gridSIZE][gridSIZE]; -interval * gridSHAPES[gridSIZE][gridSIZE]; -unsigned int gridCOLORS[gridSIZE][gridSIZE]; -char gridCHARS[gridSIZE][gridSIZE]; -char gridPrevCHARS[gridSIZE][gridSIZE]; -char gridSavedCHARS[gridSIZE][gridSIZE]; +int gridSIZES[gridMaxSIZE][gridMaxSIZE]; +interval * gridSHAPES[gridMaxSIZE][gridMaxSIZE]; +unsigned int gridCOLORS[gridMaxSIZE][gridMaxSIZE]; +char gridCHARS[gridMaxSIZE][gridMaxSIZE]; +char gridPrevCHARS[gridMaxSIZE][gridMaxSIZE]; +char gridSavedCHARS[gridMaxSIZE][gridMaxSIZE]; int gridCharsREPEATED = 0; int prevOutlier = 0; int prevSaved = 0; int lastHandDetect = 0; -void print_grid (char* s, int n) { +void print_grid (char* s, int x, int y) { int o; o = sprintf (s, "SHAPES 1 PRECISION 0 RECO FACTOR 1.6 "); o += sprintf (s+o, "SHAPE grid MAXDIST 900 CORRECTION 2 "); o += sprintf (s+o, "SCALE DEVIATION 0 ROTATION MIN -1 MAX 1 DENSITY 0 "); - o += sprintf (s+o, "START %i ", 2*n+2); + o += sprintf (s+o, "START %i ", x+y+2); int i = 0; - for (i = 0; i < n+1; i++) { - o += sprintf (s+o, "(%i, %i) -- (%i, %i) ", -n, n - 2*i, n, n - 2*i); - o += sprintf (s+o, "(%i, %i) -- (%i, %i) ", n - 2*i, -n, n - 2*i, n); + for (i = 0; i < y+1; i++) { + o += sprintf (s+o, "(%i, %i) -- (%i, %i) ", -x, y - 2*i, x, y - 2*i); } + for (i = 0; i < x+1; i++) { + o += sprintf (s+o, "(%i, %i) -- (%i, %i) ", x - 2*i, -y, x - 2*i, y); + } sprintf (s+o, "END\n"); } /* Cut grid point shape scaling to result around mid. */ -static interval* cut_res_grid (const interval* shape, const int size, int gi, - int gj, const point res_mid, int* res_size) { +static interval* cut_res_grid (const interval* shape, const int size, + int gi, int gj, float shiftx, float shifty, + const point res_mid, int* res_size) { point bl, tr; - bl.x = gridJUMP * (2*gi - gridSIZE) + gridMARGIN; - bl.y = gridJUMP * (2*gj - gridSIZE) + gridMARGIN; - tr.x = gridJUMP * (2*gi + 2 - gridSIZE) - gridMARGIN; - tr.y = gridJUMP * (2*gj + 2 - gridSIZE) - gridMARGIN; + bl.x = gridJUMP * (2*gi - gridSIZEX) + gridMARGIN - shiftx; + bl.y = gridJUMP * (2*gj - gridSIZEY) + gridMARGIN - shifty; + tr.x = gridJUMP * (2*gi + 2 - gridSIZEX) - gridMARGIN + shiftx; + tr.y = gridJUMP * (2*gj + 2 - gridSIZEY) - gridMARGIN + shifty; res_point (&bl, res_mid); res_point (&tr, res_mid); return (cut_shape (shape, size, bl, tr, res_size)); } static unsigned int aggregate_color (const interval* shape, const int size, + int gi, int gj, const point res_mid, unsigned int color[SIZEX][SIZEY]) { interval cut_mid = mid_dimen (shape, size); int i = 0, j = 0, r = 0, g = 0, b = 0, nbr = 0; - if (size == 0) { return (0); } /* - for (i = (int) (cut_mid.start.x - cut_mid.end.x); - i <= cut_mid.start.x + cut_mid.end.x; i++) { - for (j = (int) (cut_mid.start.y - cut_mid.end.y); - j <= cut_mid.start.y + cut_mid.end.y; j++) { - b += (int) (color[i][j] % 256); - g += (int) ((color[i][j] / 256) % 256); - r += (int) ((color[i][j] / (256*256)) % 256); - nbr++; + if (gridSIZEX == gridSIZEY) { + if (size == 0) { return (0); } + for (i = 0; i < size; i++) { + b += (int) (color[(int) shape[i].start.x][(int) shape[i].start.y] % 256); + g += (int) ((color[(int) shape[i].start.x][(int) shape[i].start.y] / 256) % 256); + r += (int) ((color[(int) shape[i].start.x][(int) shape[i].start.y] / (256*256)) % 256); } - } */ - for (i = 0; i < size; i++) { - b += (int) (color[(int) shape[i].start.x][(int) shape[i].start.y] % 256); - g += (int) ((color[(int) shape[i].start.x][(int) shape[i].start.y] / 256) % 256); - r += (int) ((color[(int) shape[i].start.x][(int) shape[i].start.y] / (256*256)) % 256); + nbr = size; + r = (int) (r / nbr); + g = (int) (g / nbr); + b = (int) (b / nbr); + return (b + 256*g + 256*256*r); + } else { // take full grid part + point bl, tr; + bl.x = gridJUMP * (2*gi - gridSIZEX) + gridMARGIN; + bl.y = gridJUMP * (2*gj - gridSIZEY) + gridMARGIN; + tr.x = gridJUMP * (2*gi + 2 - gridSIZEX) - gridMARGIN; + tr.y = gridJUMP * (2*gj + 2 - gridSIZEY) - gridMARGIN; + res_point (&bl, res_mid); + res_point (&tr, res_mid); + for (i = (int) bl.x; i <= (int) tr.x; i++) { + for (j = (int) bl.y; j <= tr.y; j++) { + b += (int) (color[i][j] % 256); + g += (int) ((color[i][j] / 256) % 256); + r += (int) ((color[i][j] / (256*256)) % 256); + nbr++; + } + } + r = (int) (r / nbr); + g = (int) (g / nbr); + b = (int) (b / nbr); + return (b + 256*g + 256*256*r); } - nbr = size; - r = (int) (r / nbr); - g = (int) (g / nbr); - b = (int) (b / nbr); - return (b + 256*g + 256*256*r); } -#define redblueDELTA 5 #define minshapePTS 2 -#define minshapeHAND 3 #define maxMoveCHANGE 2 +int redblueDELTA = 5; +int minshapeHAND = 3; char blueChar = 'W'; void setBlueChar (char c) { blueChar = c; } @@ -1457,42 +1484,79 @@ /* The output character for a field with specified shape size and color. */ static char describe_field (const int shape_size, const unsigned int col) { - if (shape_size > minshapePTS && - (col % 256) > (col / (256*256)) + redblueDELTA) { - return (blueChar); - } else if (shape_size > minshapePTS) { - return (redChar); - } else { - return (' '); + if (gridSIZEX == gridSIZEY) { + if (shape_size > minshapePTS && + (col % 256) > (col / (256*256)) + redblueDELTA) { + return (blueChar); + } else if (shape_size > minshapePTS) { + return (redChar); + } else { + return (' '); + } + } else { // Connect 4 -- different colors (red / yellow) + int r, g, b; + r = col / (256 * 256); + g = (col / 256) % 256; + b = col % 256; + if (r - b < 3*16+12) { // neither red nor yellow + return (' '); + } else if (r - g < 4*16) { // red + return (redChar); + } else { // yellow + return (blueChar); + } } } int gridOutputCounter = 0; /* Print out grid. */ -static void output_grid (int sizes[gridSIZE][gridSIZE], - char chars[gridSIZE][gridSIZE]) { +static void output_grid (int sizes[gridMaxSIZE][gridMaxSIZE], + unsigned int colors[gridMaxSIZE][gridMaxSIZE], + char chars[gridMaxSIZE][gridMaxSIZE]) { int gi, gj; gridOutputCounter++; - for (gj = 0; gj < gridSIZE; gj++) { - for (gi = 0; gi < gridSIZE; gi++) { - if (shapesDebugLEVEL > 1) { + for (gj = 0; gj < gridSIZEY; gj++) { + for (gi = 0; gi < gridSIZEX; gi++) { + if (shapesDebugLEVEL > 1) { if ((gi+gj) % 2 == 0) { - printf ("%.2i ", sizes[gi][gj]); - } else { printf ("%.2i.", sizes[gi][gj]); }; + if (gridSIZEX == gridSIZEY) { + printf ("%.2i ", sizes[gi][gj]); + } else { + printf (" %.6x ", colors[gi][gj]); + } + } else { + if (gridSIZEX == gridSIZEY) { + printf ("%.2i.", sizes[gi][gj]); + } else { + printf (".%.6x.", colors[gi][gj]); + } + }; } else { - if ((gi+gj) % 2 == 0) { + if ((gi+gj) % 2 == 0 || gridSIZEX < 4) { printf (" "); } else { printf ("..."); }; } } printf ("\n"); - for (gi = 0; gi < gridSIZE; gi++) { - if ((gi+gj) % 2 == 0) { - printf ("%c ", chars[gi][gj]); + for (gi = 0; gi < gridSIZEX; gi++) { + if (shapesDebugLEVEL > 1) { + char c = + chars[gi][gj] == ' ' && ((gi + gj) % 2 != 0) ? '.' : chars[gi][gj]; + char sp = (gi + gj) % 2 != 0 ? '.' : ' '; + if (gridSIZEX == gridSIZEY) { + printf ("%c%c%c", c, sp, sp); + } else { + printf ("%c%c%c%c%c%c%c%c", sp, c, sp, sp, sp, sp, sp, sp); + } } else { - char c = chars[gi][gj] == ' ' ? '.' : chars[gi][gj]; - printf ("%c..", c); + if ((gi+gj) % 2 == 0 || gridSIZEX < 4) { + char c = chars[gi][gj]; + printf ("%c ", c == ' ' && gridSIZEX < 4 ? '.' : c); + } else { + char c = chars[gi][gj] == ' ' ? '.' : chars[gi][gj]; + printf ("%c..", c); + } } } printf ("\n"); @@ -1501,7 +1565,7 @@ /* Outputs current grid if nothing was output before. */ void output_on_end (void) { - if (gridOutputCounter == 0) { output_grid (gridSIZES, gridCHARS); }; + if (gridOutputCounter == 0) { output_grid (gridSIZES,gridCOLORS,gridCHARS); }; } /* Run complete recognition from string, return result. */ @@ -1511,7 +1575,14 @@ int shape_size; interval* shape; int offset = 0; - shape = sread_shape (shape_str, &shape_size, &offset); + if (gridSIZEX == gridSIZEY) { + shape = sread_shape (shape_str, &shape_size, &offset); + if (gridSIZEX == 3) { redblueDELTA = - 3*16; } // Tic-Tac-Toe on white + } else { // in Connect4 too few lines to rely on them + shape = sread_shape (full_str, &shape_size, &offset); + scale_marginx = 1; + scale_marginy = 0.85; + } videoSTEP = step; if (shapesDebugLEVEL > 2) { @@ -1530,13 +1601,17 @@ // Initial pattern will be a grid char init_grid[20000]; - print_grid (init_grid, gridSIZE); + print_grid (init_grid, gridSIZEX, gridSIZEY); // Match pattern and compute its mid-point int res = 0; init_patterns_from_string (init_grid); res = match_pattern (smaller_shape, smaller_shape_size); *res_nbr = res; + if (gridSIZEX != gridSIZEY) { // Connect4 correction + res_vec.start.y -= 10; + res_vec.start.x -= 5; + } point res_mid = mid_dimen (patterns[res].shape, patterns[res].size).start; if (res < 0) { @@ -1559,12 +1634,13 @@ // Put grid subshapes into grid; int gi = 0, gj = 0, cut_size = 0, diffChars = 0, diffRedBlue = 0; interval * cut; - for (gi = 0; gi < gridSIZE; gi++) { - for (gj = 0; gj < gridSIZE; gj++) { - cut = cut_res_grid (full, full_size, gi, gj, res_mid, &cut_size); + for (gi = 0; gi < gridSIZEX; gi++) { + for (gj = 0; gj < gridSIZEY; gj++) { + cut = cut_res_grid (full, full_size, gi,gj,0,0, res_mid, &cut_size); gridSIZES[gi][gj] = cut_size; gridSHAPES[gi][gj] = cut; - gridCOLORS[gi][gj] = aggregate_color (cut, cut_size, color); + gridCOLORS[gi][gj] = + aggregate_color (cut, cut_size, gi, gj, res_mid, color); char desc = describe_field (cut_size, gridCOLORS[gi][gj]); if (desc != gridCHARS[gi][gj]) { diffChars++; @@ -1585,24 +1661,26 @@ diffChars++; } - if (shapesDebugLEVEL > 2) { + if (shapesDebugLEVEL > 0) { printf ("TMPGRID diffChars %i\n", diffChars); - if (shapesDebugLEVEL > 2) { output_grid (gridSIZES, gridCHARS); }; + if (shapesDebugLEVEL > 2) { + output_grid (gridSIZES, gridCOLORS, gridCHARS); + }; } // Did a structure repeat? If too much changed, it's an outlier -- reset. if (diffChars == 0) { gridCharsREPEATED++; }; if (step > 1 && diffChars > maxMoveCHANGE) { prevOutlier = 1; - for (gi = 0; gi < gridSIZE; gi++) { - for (gj = 0; gj < gridSIZE; gj++) { + for (gi = 0; gi < gridSIZEX; gi++) { + for (gj = 0; gj < gridSIZEY; gj++) { gridCHARS[gi][gj] = gridPrevCHARS[gi][gj]; } } } else { if (gridCharsREPEATED == 0 && diffChars > 0) { - for (gi = 0; gi < gridSIZE; gi++) { // savei in case nothing repeats - for (gj = 0; gj < gridSIZE; gj++) { + for (gi = 0; gi < gridSIZEX; gi++) { // savei in case nothing repeats + for (gj = 0; gj < gridSIZEY; gj++) { gridSavedCHARS[gi][gj] = gridCHARS[gi][gj]; } } @@ -1612,15 +1690,24 @@ } // Detect right hand as a blank space in bottom right corner. - cut_res_grid (full, full_size, gridSIZE, gridSIZE, res_mid, &cut_size); - if (shapesDebugLEVEL > 0) { printf ("Hand cut size %i.\n", cut_size); } + if (gridSIZEX == 8) { // chessboard + cut_res_grid (full, full_size, gridSIZEX, gridSIZEY, 0, 0, + res_mid, &cut_size); + } else if (gridSIZEX == 3) { // ttt + cut_res_grid (full, full_size, gridSIZEX, gridSIZEY, 0.5, 0.5, + res_mid, &cut_size); + } else { // Connect 4 + cut_res_grid (full, full_size, gridSIZEX-1,gridSIZEY, 1, 1, + res_mid, &cut_size); + } + if (shapesDebugLEVEL > 1) { printf ("Hand cut size %i.\n", cut_size); } if (cut_size < minshapeHAND && gridCharsREPEATED == 0 && prevSaved == 1) { if (shapesDebugLEVEL > 1) { printf ("Hand detected %i last %i.\n", cut_size, lastHandDetect); } if (lastHandDetect > 1 && lastHandDetect < maxOUT){ - output_grid(gridSIZES, gridSavedCHARS); + output_grid(gridSIZES, gridCOLORS, gridSavedCHARS); if (shapesDebugLEVEL > 1) { printf ("lhd %i", lastHandDetect); }; printf ("\n\n"); }; @@ -1641,7 +1728,7 @@ // Print out grid at the first repetition. if (gridCharsREPEATED == 1) { if (shapesDebugLEVEL > 1) { printf ("%i \n", diffChars); }; - output_grid (gridSIZES, gridCHARS); + output_grid (gridSIZES, gridCOLORS, gridCHARS); prevOutlier = 0; prevSaved = 0; gridCharsREPEATED++; Modified: trunk/Toss/Learn/shapes.h =================================================================== --- trunk/Toss/Learn/shapes.h 2012-01-22 17:29:13 UTC (rev 1650) +++ trunk/Toss/Learn/shapes.h 2012-01-23 03:10:29 UTC (rev 1651) @@ -5,6 +5,7 @@ void setBlueChar (char c); void setRedChar (char c); +void setGridSize (int x, int y); typedef struct point_s {double x; double y;} point; typedef struct interval_s {point start; point end;} interval; Added: trunk/Toss/Learn/videos/Connect4001_01.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_01.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_01.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_01.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_01.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_01.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_01.wrg.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_01.wrg.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_02.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_02.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_02.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_02.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_02.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_02.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_02.wrg.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_02.wrg.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_03.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_03.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_03.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_03.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_03.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_03.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_03.wrg.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_03.wrg.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_04.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_04.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_04.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_04.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_04.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_04.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_04.wrg.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_04.wrg.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_05.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_05.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_06.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_06.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_07.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_07.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_08.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_08.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_09.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_09.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_10.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_10.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_11.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_11.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_12.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_12.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Connect4001_13.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Connect4001_13.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Tic-Tac-Toe001_01.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <luk...@us...> - 2012-01-22 17:29:20
|
Revision: 1650 http://toss.svn.sourceforge.net/toss/?rev=1650&view=rev Author: lukaszkaiser Date: 2012-01-22 17:29:13 +0000 (Sun, 22 Jan 2012) Log Message: ----------- Videos for Gomoku. Modified Paths: -------------- trunk/Toss/Learn/Makefile trunk/Toss/Learn/examples/Gomoku001_01.nwn trunk/Toss/Learn/examples/Gomoku001_01.wn0 trunk/Toss/Learn/examples/Gomoku001_01.wn1 trunk/Toss/Learn/examples/Gomoku001_02.nwn trunk/Toss/Learn/examples/Gomoku001_02.wn0 trunk/Toss/Learn/examples/Gomoku001_02.wn1 trunk/Toss/Learn/examples/Gomoku001_03.nwn trunk/Toss/Learn/examples/Gomoku001_03.wn0 trunk/Toss/Learn/examples/Gomoku001_03.wn1 trunk/Toss/Learn/examples/Gomoku001_04.nwn trunk/Toss/Learn/examples/Gomoku001_04.wn0 trunk/Toss/Learn/examples/Gomoku001_04.wn1 trunk/Toss/Learn/examples/Gomoku001_05.nwn trunk/Toss/Learn/examples/Gomoku001_06.nwn trunk/Toss/Learn/examples/Gomoku001_07.nwn trunk/Toss/Learn/examples/Gomoku001_08.nwn trunk/Toss/Learn/examples/Gomoku001_09.nwn trunk/Toss/Learn/reco.cpp Added Paths: ----------- trunk/Toss/Learn/videos/Gomoku001_01.nwn.3gp trunk/Toss/Learn/videos/Gomoku001_01.wn0.3gp trunk/Toss/Learn/videos/Gomoku001_01.wn1.3gp trunk/Toss/Learn/videos/Gomoku001_02.nwn.3gp trunk/Toss/Learn/videos/Gomoku001_02.wn0.3gp trunk/Toss/Learn/videos/Gomoku001_02.wn1.3gp trunk/Toss/Learn/videos/Gomoku001_03.nwn.3gp trunk/Toss/Learn/videos/Gomoku001_03.wn0.3gp trunk/Toss/Learn/videos/Gomoku001_03.wn1.3gp trunk/Toss/Learn/videos/Gomoku001_04.nwn.3gp trunk/Toss/Learn/videos/Gomoku001_04.wn0.3gp trunk/Toss/Learn/videos/Gomoku001_04.wn1.3gp trunk/Toss/Learn/videos/Gomoku001_05.nwn.3gp trunk/Toss/Learn/videos/Gomoku001_06.nwn.3gp trunk/Toss/Learn/videos/Gomoku001_07.nwn.3gp trunk/Toss/Learn/videos/Gomoku001_08.nwn.3gp trunk/Toss/Learn/videos/Gomoku001_09.nwn.3gp Modified: trunk/Toss/Learn/Makefile =================================================================== --- trunk/Toss/Learn/Makefile 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/Makefile 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,5 +1,7 @@ all: tests reco +SHELL := /bin/bash + shapes.o: shapes.c shapes.h gcc -c shapes.c @@ -24,11 +26,6 @@ make -C .. Learn/LearnGameTest.native time ../LearnGameTest.native -f $(basename $@) > $(basename $@).toss -%.reco: - ./reco videos/$(basename $@).3gp W B > res.play.log - diff res.play.log examples/$(basename $@) - rm res.play.log - learntests: make Tic-Tac-Toe001.learn make Tic-Tac-Toe002.learn @@ -37,26 +34,26 @@ make Connect4001.learn #make Pawn-Whopping001.learn -recotests: reco - make Breakthrough001_01.nwn.reco - make Breakthrough001_01.wn0.reco - make Breakthrough001_01.wn1.reco - make Breakthrough001_02.nwn.reco - make Breakthrough001_03.nwn.reco - make Pawn-Whopping001_01.nwn.reco - make Pawn-Whopping001_01.wn0.reco - make Pawn-Whopping001_01.wn1.reco - make Pawn-Whopping001_01.wrg.reco - make Pawn-Whopping001_02.nwn.reco - make Pawn-Whopping001_02.wrg.reco - make Pawn-Whopping001_03.nwn.reco - make Pawn-Whopping001_03.wrg.reco - make Pawn-Whopping001_04.nwn.reco - make Pawn-Whopping001_04.wrg.reco - make Pawn-Whopping001_05.wrg.reco - make Pawn-Whopping001_06.wrg.reco +%.reco: + if [[ $@ = Breakthrough* ]]; then \ + ./reco W B videos/$(basename $@).3gp > res.play.log; \ + elif [[ $@ = Pawn* ]]; then \ + ./reco W B videos/$(basename $@).3gp > res.play.log; \ + else \ + ./reco Q P videos/$(basename $@).3gp > res.play.log; \ + fi + diff res.play.log examples/$(basename $@) + rm res.play.log +VIDEOS_TO_TEST = videos/* +VIDEOS = $(notdir $(shell find $(VIDEOS_TO_TEST) -maxdepth 1 -name '*.3gp')) +VIDEOS_BASE = $(basename $(VIDEOS)) +VIDEOS_RECO = $(addsuffix .reco, $(VIDEOS_BASE)) + +recotests: reco $(VIDEOS_RECO) + + .PHONY: clean clean: Modified: trunk/Toss/Learn/examples/Gomoku001_01.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_01.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_01.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -17,6 +17,7 @@ ... ... ... ... ... ... ... ... + ... ... ... ... ... ... ... ... ... ... ... ... @@ -34,6 +35,7 @@ ... ... ... ... ... ... ... ... + ... ... ... ... ... ... ... ... ... ... ... ... @@ -51,6 +53,7 @@ ... ... ... ... ... ... ... ... + ... ... ... ... ... ... ... ... ... ... ... ... Modified: trunk/Toss/Learn/examples/Gomoku001_01.wn0 =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_01.wn0 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_01.wn0 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_01.wn1 =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_01.wn1 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_01.wn1 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_02.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_02.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_02.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_02.wn0 =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_02.wn0 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_02.wn0 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_02.wn1 =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_02.wn1 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_02.wn1 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_03.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_03.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_03.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_03.wn0 =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_03.wn0 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_03.wn0 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ Q.. ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_03.wn1 =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_03.wn1 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_03.wn1 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ P.. ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_04.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_04.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_04.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_04.wn0 =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_04.wn0 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_04.wn0 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... Q.. ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_04.wn1 =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_04.wn1 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_04.wn1 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... P.. ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_05.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_05.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_05.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_06.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_06.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_06.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_07.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_07.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_07.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_08.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_08.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_08.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... ... ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/examples/Gomoku001_09.nwn =================================================================== --- trunk/Toss/Learn/examples/Gomoku001_09.nwn 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/examples/Gomoku001_09.nwn 2012-01-22 17:29:13 UTC (rev 1650) @@ -1,4 +1,4 @@ -[ | P:1 {}; Q:1 {} | ] +[ | Q:1 {}; P:1 {} | ] ... ... ... ... ... ... ... ... @@ -16,3 +16,4 @@ ... ... P.. ... ... ... ... ... ... ... ... ... + Modified: trunk/Toss/Learn/reco.cpp =================================================================== --- trunk/Toss/Learn/reco.cpp 2012-01-22 02:38:57 UTC (rev 1649) +++ trunk/Toss/Learn/reco.cpp 2012-01-22 17:29:13 UTC (rev 1650) @@ -63,18 +63,18 @@ int rnbr = -2; if (argc != 4) { - printf ("Usage: reco [filename] [letter for white] [letter for black]\n"); + printf ("Usage: reco [letter for white] [letter for black] [filename]\n"); return (1); } // Print signature and set it in shapes module - printf ("[ | %c:1 {}; %c:1 {} | ]\n\n", argv[2][0], argv[3][0]); - setBlueChar (argv[2][0]); - setRedChar (argv[3][0]); + printf ("[ | %c:1 {}; %c:1 {} | ]\n\n", argv[1][0], argv[2][0]); + setBlueChar (argv[1][0]); + setRedChar (argv[2][0]); // Start recognition cvNamedWindow ("Reco", CV_WINDOW_AUTOSIZE); - CvCapture* capture = cvCreateFileCapture (argv[1]); + CvCapture* capture = cvCreateFileCapture (argv[3]); // cvCreateCameraCapture( 0 ); IplImage *img, *col, *gray, *small; int data_count = 0; Added: trunk/Toss/Learn/videos/Gomoku001_01.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_01.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_01.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_01.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_01.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_01.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_02.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_02.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_02.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_02.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_02.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_02.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_03.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_03.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_03.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_03.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_03.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_03.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_04.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_04.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_04.wn0.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_04.wn0.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_04.wn1.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_04.wn1.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_05.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_05.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_06.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_06.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_07.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_07.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_08.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_08.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Toss/Learn/videos/Gomoku001_09.nwn.3gp =================================================================== (Binary files differ) Property changes on: trunk/Toss/Learn/videos/Gomoku001_09.nwn.3gp ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |