[Toss-devel-svn] SF.net SVN: toss:[1218] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2010-12-04 23:46:22
|
Revision: 1218
http://toss.svn.sourceforge.net/toss/?rev=1218&view=rev
Author: lukaszkaiser
Date: 2010-12-04 23:46:15 +0000 (Sat, 04 Dec 2010)
Log Message:
-----------
Chess in WebClient, using names for rules.
Modified Paths:
--------------
trunk/Toss/WebClient/TossConnect.js
trunk/Toss/WebClient/TossDefaultStyle.js
trunk/Toss/WebClient/TossMain.js
trunk/Toss/WebClient/TossStyle.css
trunk/Toss/WebClient/Wrapper.py
trunk/Toss/WebClient/index.html
trunk/Toss/examples/Breakthrough.toss
trunk/Toss/examples/Chess.toss
trunk/Toss/examples/Entanglement.toss
trunk/Toss/examples/Gomoku.toss
trunk/Toss/examples/Tic-Tac-Toe.toss
Modified: trunk/Toss/WebClient/TossConnect.js
===================================================================
--- trunk/Toss/WebClient/TossConnect.js 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/WebClient/TossConnect.js 2010-12-04 23:46:15 UTC (rev 1218)
@@ -29,6 +29,8 @@
var SUGGESTED_ELEM_SIZEX = 25; // suggested size of elements
var SUGGESTED_ELEM_SIZEY = 25; // suggested size of elements
+var CACHED_MOVES = ""
+
// Helper function: sign of a number.
function sign (x) {
if (x > 0.01) { return (1); }
@@ -36,6 +38,11 @@
else { return (0); }
}
+// Clears cached moves.
+function clear_move_cache () {
+ CACHED_MOVES = "";
+}
+
// Send [msg] to server and return response text.
function sync_server_msg (msg) {
var xml_request = new XMLHttpRequest ();
@@ -83,8 +90,17 @@
// Get moves applicable to [elem] in Toss Model active on [port].
function get_moves (port, elem) {
- var moves_s = srv (port, 'c.cur_move_touching("' + elem + '")');
- return (convert_python_list (';', moves_s))
+ if (CACHED_MOVES == "") {
+ CACHED_MOVES = srv (port, 'c.cur_moves()');
+ }
+ var all_moves = convert_python_list (';', CACHED_MOVES);
+ var elem_moves = []
+ for (i = 0; i < all_moves.length; i++) {
+ if (all_moves[i].indexOf(elem) >= 0) {
+ elem_moves.push(all_moves[i])
+ }
+ }
+ return (elem_moves)
}
// Get relation tuples of Toss Model active on [port].
Modified: trunk/Toss/WebClient/TossDefaultStyle.js
===================================================================
--- trunk/Toss/WebClient/TossDefaultStyle.js 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/WebClient/TossDefaultStyle.js 2010-12-04 23:46:15 UTC (rev 1218)
@@ -9,6 +9,133 @@
// - draw_rel (rel_name, args)
+var DEFpawn = '<g transform="translate(-22.5,-22.5)"> \
+ <path \
+ d="M 22,9 C 19.792,9 18,10.792 18,13 C 18,13.885 18.294,14.712 18.781,15.375 C 16.829,16.497 15.5,18.588 15.5,21 C 15.5,23.034 16.442,24.839 17.906,26.031 C 14.907,27.089 10.5,31.578 10.5,39.5 L 33.5,39.5 C 33.5,31.578 29.093,27.089 26.094,26.031 C 27.558,24.839 28.5,23.034 28.5,21 C 28.5,18.588 27.171,16.497 25.219,15.375 C 25.706,14.712 26,13.885 26,13 C 26,10.792 24.208,9 22,9 z " \
+ class="chess-path-A" /> \
+ </g>';
+
+var DEFknight = '<g transform="translate(-22.5,-22.5)"> \
+ <path \
+ d="M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18" \
+ class="chess-path-B" /> \
+ <path \
+ d="M 24,18 C 24.384,20.911 18.447,25.369 16,27 C 13,29 13.181,31.343 11,31 C 9.9583,30.056 12.413,27.962 11,28 C 10,28 11.187,29.232 10,30 C 9,30 5.9968,31 6,26 C 6,24 12,14 12,14 C 12,14 13.886,12.098 14,10.5 C 13.274,9.5056 13.5,8.5 13.5,7.5 C 14.5,6.5 16.5,10 16.5,10 L 18.5,10 C 18.5,10 19.282,8.0081 21,7 C 22,7 22,10 22,10" \
+ class="chess-path-B" /> \
+ <path \
+ d="M 9 23.5 A 0.5 0.5 0 1 1 8,23.5 A 0.5 0.5 0 1 1 9 23.5 z" \
+ transform="translate(0.5,2)" \
+ class="chess-path-C" /> \
+ <path \
+ d="M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z" \
+ transform="matrix(0.866,0.5,-0.5,0.866,9.6926,-5.1734)" \
+ class="chess-path-C" /> \
+ <path \
+ d="M 37,39 C 38,19 31.5,11.5 25,10.5" \
+ class="chess-path-D" /> \
+ </g>';
+
+var DEFbishop = '<g transform="translate(-22.5,-22.5)"> \
+ <path \
+ d="M 9,36 C 12.385,35.028 19.115,36.431 22.5,34 C 25.885,36.431 32.615,35.028 36,36 C 36,36 37.646,36.542 39,38 C 38.323,38.972 37.354,38.986 36,38.5 C 32.615,37.528 25.885,38.958 22.5,37.5 C 19.115,38.958 12.385,37.528 9,38.5 C 7.6459,38.986 6.6771,38.972 6,38 C 7.3541,36.055 9,36 9,36 z " \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 15,32 C 17.5,34.5 27.5,34.5 30,32 C 30.5,30.5 30,30 30,30 C 30,27.5 27.5,26 27.5,26 C 33,24.5 33.5,14.5 22.5,10.5 C 11.5,14.5 12,24.5 17.5,26 C 17.5,26 15,27.5 15,30 C 15,30 14.5,30.5 15,32 z " \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 25 10 A 2.5 2.5 0 1 1 20,10 A 2.5 2.5 0 1 1 25 10 z" \
+ transform="translate(0,-2)" \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 17.5,26 L 27.5,26" \
+ style="stroke-linecap:butt;" class="chess-path-D" /> \
+ <path \
+ d="M 15,30 L 30,30" \
+ style="stroke-linecap:butt;" class="chess-path-D" /> \
+ <path \
+ d="M 22.5,15.5 L 22.5,20.5" \
+ style="stroke-linecap:butt;" class="chess-path-D" /> \
+ <path \
+ d="M 20,18 L 25,18" \
+ style="stroke-linecap:butt;" class="chess-path-D" /> \
+ </g>';
+
+var DEFrook = '<g transform="translate(-22.5,-22.5)"> \
+ <path \
+ d="M 9,39 L 36,39 L 36,36 L 9,36 L 9,39 z " \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 12,36 L 12,32 L 33,32 L 33,36 L 12,36 z " \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 11,14 L 11,9 L 15,9 L 15,11 L 20,11 L 20,9 L 25,9 L 25,11 L 30,11 L 30,9 L 34,9 L 34,14" \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 34,14 L 31,17 L 14,17 L 11,14" \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 31,17 L 31,29.5 L 14,29.5 L 14,17" \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 31,29.5 L 32.5,32 L 12.5,32 L 14,29.5" \
+ class="chess-path-B" /> \
+ <path \
+ d="M 11,14 L 34,14" \
+ class="chess-path-D" /> \
+ </g>';
+
+var DEFqueen = '<g transform="translate(-22.5,-22.5)"> \
+ <path \
+ d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" \
+ transform="translate(-1,-1)" \
+ style="fill-rule: none;" class="chess-path-B" /> \
+ <path \
+ d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" \
+ transform="translate(15.5,-5.5)" \
+ style="fill-rule: none;" class="chess-path-B" /> \
+ <path \
+ d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" \
+ transform="translate(32,-1)" \
+ style="fill-rule: none;" class="chess-path-B" /> \
+ <path \
+ d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" \
+ transform="translate(7,-4.5)" \
+ style="fill-rule: none;" class="chess-path-B" /> \
+ <path \
+ d="M 9 13 A 2 2 0 1 1 5,13 A 2 2 0 1 1 9 13 z" \
+ transform="translate(24,-4)" \
+ style="fill-rule: none;" class="chess-path-B" /> \
+ <path \
+ d="M 9,26 C 17.5,24.5 30,24.5 36,26 L 38,14 L 31,25 L 31,11 L 25.5,24.5 L 22.5,9.5 L 19.5,24.5 L 14,10.5 L 14,25 L 7,14 L 9,26 z " \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 9,26 C 9,28 10.5,28 11.5,30 C 12.5,31.5 12.5,31 12,33.5 C 10.5,34.5 10.5,36 10.5,36 C 9,37.5 11,38.5 11,38.5 C 17.5,39.5 27.5,39.5 34,38.5 C 34,38.5 35.5,37.5 34,36 C 34,36 34.5,34.5 33,33.5 C 32.5,31 32.5,31.5 33.5,30 C 34.5,28 36,28 36,26 C 27.5,24.5 17.5,24.5 9,26 z " \
+ style="stroke-linecap:butt;" class="chess-path-B" /> \
+ <path \
+ d="M 11.5,30 C 15,29 30,29 33.5,30" \
+ class="chess-path-D" /> \
+ <path \
+ d="M 12,33.5 C 18,32.5 27,32.5 33,33.5" \
+ class="chess-path-D" /> \
+ <path \
+ d="M 10.5,36 C 15.5,35 29,35 34,36" \
+ class="chess-path-D" /> \
+ </g>';
+
+var DEFking = '<g transform="translate(-22.5,-22.5)"> \
+ <path d="M 22.5,11.625 L 22.5,6" class="chess-path-D" /> \
+ <path d="M 22.5,25 C 22.5,25 27,17.5 25.5,14.5 C 25.5,14.5 24.5,12 22.5,12 C 20.5,12 19.5,14.5 19.5,14.5 C 18,17.5 22.5,25 22.5,25" \
+ style="fill:stroke-linecap:butt;" class="chess-path-B" /> \
+ <path d="M 11.5,37 C 17,40.5 27,40.5 32.5,37 L 32.5,30 C 32.5,30 41.5,25.5 38.5,19.5 C 34.5,13 25,16 22.5,23.5 L 22.5,27 L 22.5,23.5 C 19,16 9.5,13 6.5,19.5 C 3.5,25.5 11.5,29.5 11.5,29.5 L 11.5,37 z " \
+ class="chess-path-D" /> \
+ <path d="M 20,8 L 25,8" class="chess-path-D" /> \
+ <path d="M 11.5,29.5 C 17,27 27,27 32.5,30" class="chess-path-D" /> \
+ <path d="M 11.5,37 C 17,34.5 27,34.5 32.5,37" \
+ class="chess-path-D" /> \
+ <path d="M 11.5,33.5 C 17,31.5 27,31.5 32.5,33.5" \
+ class="chess-path-D" /> \
+ </g>';
+
// Draw a box around the board.
function draw_outline () {
var w = SVG_WIDTH + 2*SVG_MARGINX;
@@ -45,11 +172,11 @@
// Draw relation [rel_name] between elements [args].
function draw_rel (rel_name, args) {
if (args.length == 1) {
+ var is = 'id="' + "pred_" + args[0] + "_" + rel_name + '" ';
+ var hs = 'onclick="' + "handle_elem_click('" + args[0] + "')" + '" ';
var pos = ELEM_POS[args[0]];
if (rel_name == "P") { // Tic-tac-toe cross
- var is = 'id="' + "pred_" + args[0] + "_" + rel_name + '" ';
var cs = 'class="' + "model-pred-" + rel_name + '" ';
- var hs = 'onclick="' + "handle_elem_click('" + args[0] + "')" + '" ';
var ls1 = '<line x1="-10" y1="-10" x2="10" y2="10" />';
var ls2 = '<line x1="10" y1="-10" x2="-10" y2="10" />';
var cr = svg_from_string (pos[0], pos[1], 12, 12,
@@ -61,6 +188,54 @@
["id", "pred_" + args[0] + "_" + rel_name],
["class", "model-pred-" + rel_name],
["onclick", ("handle_elem_click('" + args[0] + "')")]]);
+ } else if (rel_name == "wP") { // Chess Figure: white pawn
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessW" ' + is + hs + '>' + DEFpawn + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "bP") { // Chess Figure: black pawn
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessB" ' + is + hs + '>' + DEFpawn + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "wN") { // Chess Figure: white knight
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessW" ' + is + hs + '>' + DEFknight + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "bN") { // Chess Figure: black knight
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessB" ' + is + hs + '>' + DEFknight + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "wB") { // Chess Figure: white bishop
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessW" ' + is + hs + '>' + DEFbishop + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "bB") { // Chess Figure: black bishop
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessB" ' + is + hs + '>' + DEFbishop + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "wR") { // Chess Figure: white rook
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessW" ' + is + hs + '>' + DEFrook + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "bR") { // Chess Figure: black rook
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessB" ' + is + hs + '>' + DEFrook + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "wQ") { // Chess Figure: white queen
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessW" ' + is + hs + '>' + DEFqueen + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "bQ") { // Chess Figure: black queen
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessB" ' + is + hs + '>' + DEFqueen + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "wK") { // Chess Figure: white king
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessW" ' + is + hs + '>' + DEFking + '</g>');
+ document.getElementById("svg").appendChild(f);
+ } else if (rel_name == "bK") { // Chess Figure: black king
+ var f = svg_from_string (pos[0], pos[1], 20, 20,
+ '<g class="chessB" ' + is + hs + '>' + DEFking + '</g>');
+ document.getElementById("svg").appendChild(f);
} else {
add_svg ("circle",
[["cx", pos[0]], ["cy", pos[1]], ["r", SUGGESTED_ELEM_SIZEX - 5],
Modified: trunk/Toss/WebClient/TossMain.js
===================================================================
--- trunk/Toss/WebClient/TossMain.js 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/WebClient/TossMain.js 2010-12-04 23:46:15 UTC (rev 1218)
@@ -49,9 +49,11 @@
// Clear whole svg box.
function clear_svg () {
+ clear_move_cache ();
ELEM_COUNTERS = {};
CUR_MOVE = "";
CUR_ELEMS = [];
+ document.getElementById('cur-move').innerHTML = "none";
var svg_e = document.getElementById("svg");
svg_e.parentNode.removeChild (svg_e);
}
@@ -82,6 +84,7 @@
// Helper function: highlight move, unhighlight old, save current.
function show_move (m) {
var m_act = get_move_elems (m);
+ var m_rule = m.substring (m.indexOf("},")+4, m.lastIndexOf(',')-1);
for (var i = 0; i < CUR_ELEMS.length; i++) {
unhighlight_elem (CUR_ELEMS[i]);
}
@@ -92,7 +95,8 @@
if (m_str == "") {
document.getElementById('cur-move').innerHTML = "none";
} else {
- document.getElementById('cur-move').innerHTML = m_str;
+ document.getElementById('cur-move').innerHTML =
+ m_rule + ': <br/>' + m_str;
}
CUR_ELEMS = m_act;
CUR_MOVE = m.toString();
@@ -225,6 +229,7 @@
return;
}
srv (TOSS_PORT, 'c.make_move' + CUR_MOVE);
+ clear_move_cache ();
CUR_MOVE = "";
CUR_ELEMS = [];
ELEM_COUNTERS = {};
Modified: trunk/Toss/WebClient/TossStyle.css
===================================================================
--- trunk/Toss/WebClient/TossStyle.css 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/WebClient/TossStyle.css 2010-12-04 23:46:15 UTC (rev 1218)
@@ -390,3 +390,113 @@
stroke: #260314;
stroke-width: 3px;
}
+
+.chessW .chess-path-A {
+ opacity:1;
+ fill:#ffffff;
+ fill-opacity:1;
+ fill-rule:nonzero;
+ stroke:#000000;
+ stroke-width:1.5;
+ stroke-linecap:round;
+ stroke-linejoin:miter;
+ stroke-miterlimit:4;
+ stroke-dasharray:none;
+ stroke-dashoffset:10;
+ stroke-opacity:1;
+}
+
+.chessB .chess-path-A {
+ opacity:1;
+ fill:#000000;
+ fill-opacity:1;
+ fill-rule:nonzero;
+ stroke:#000000;
+ stroke-width:1.5;
+ stroke-linecap:round;
+ stroke-linejoin:miter;
+ stroke-miterlimit:4;
+ stroke-dasharray:none;
+ stroke-dashoffset:10;
+ stroke-opacity:1;
+}
+
+.chessW .chess-path-B {
+ opacity:1;
+ fill:#ffffff;
+ fill-opacity:1;
+ fill-rule:evenodd;
+ stroke:#000000;
+ stroke-width:1.5;
+ stroke-linecap:round;
+ stroke-linejoin:round;
+ stroke-miterlimit:4;
+ stroke-dasharray:none;
+ stroke-opacity:1;
+}
+
+.chessB .chess-path-B {
+ opacity:1;
+ fill:#000000;
+ fill-opacity:1;
+ fill-rule:evenodd;
+ stroke:#000000;
+ stroke-width:1.5;
+ stroke-linecap:round;
+ stroke-linejoin:round;
+ stroke-miterlimit:4;
+ stroke-dasharray:none;
+ stroke-opacity:1;
+}
+
+.chessW .chess-path-C {
+ opacity:1;
+ fill:#000000;
+ fill-opacity:1;
+ stroke:#000000;
+ stroke-width:1.5;
+ stroke-linecap:round;
+ stroke-linejoin:round;
+ stroke-miterlimit:4;
+ stroke-dasharray:none;
+ stroke-opacity:1;
+}
+
+.chessB .chess-path-C {
+ opacity:1;
+ fill:#ffffff;
+ fill-opacity:1;
+ stroke:#ffffff;
+ stroke-width:1.5;
+ stroke-linecap:round;
+ stroke-linejoin:round;
+ stroke-miterlimit:4;
+ stroke-dasharray:none;
+ stroke-opacity:1;
+}
+
+.chessW .chess-path-D {
+ fill: #ffffff;
+ fill-opacity: 0.75;
+ fill-rule:evenodd;
+ stroke: #000000;
+ stroke-width:1;
+ stroke-linecap:round;
+ stroke-linejoin:mitter;
+ stroke-miterlimit:4;
+ stroke-dasharray:none;
+ stroke-opacity:1;
+}
+
+.chessB .chess-path-D {
+ fill: #000000;
+ fill-opacity: 0.75;
+ fill-rule:evenodd;
+ stroke: #000000;
+ stroke-width:1;
+ stroke-linecap:round;
+ stroke-linejoin:mitter;
+ stroke-miterlimit:4;
+ stroke-dasharray:none;
+ stroke-opacity:1;
+}
Modified: trunk/Toss/WebClient/Wrapper.py
===================================================================
--- trunk/Toss/WebClient/Wrapper.py 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/WebClient/Wrapper.py 2010-12-04 23:46:15 UTC (rev 1218)
@@ -433,6 +433,15 @@
state_str = ("#"+file_name+"#") + "$".join (state.split ("\n"))
self.set_state (state_str)
+ def cur_moves (self):
+ cur_loc = self.get_cur_loc ()
+ moves = []
+ for (r, itvls, endp) in self.get_loc_moves (cur_loc):
+ for m in self.query (r):
+ # FIXME! currently we ignore params in html (skip itvls here)
+ moves.append ((m, r, endp))
+ return ("; ".join([str(m) for m in moves]))
+
def cur_move_touching (self, elem):
cur_loc = self.get_cur_loc ()
moves = []
Modified: trunk/Toss/WebClient/index.html
===================================================================
--- trunk/Toss/WebClient/index.html 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/WebClient/index.html 2010-12-04 23:46:15 UTC (rev 1218)
@@ -37,6 +37,9 @@
<a id="Breakthrough" href="#" onclick="game_click('Breakthrough')">Breakthrough</a>
</li>
<li class="menu-list-item">
+ <a id="Chess" href="#" onclick="game_click('Chess')">Chess</a>
+ </li>
+ <li class="menu-list-item">
<a id="Entanglement" href="#" onclick="game_click('Entanglement')">Entanglement</a>
</li>
<li class="menu-list-item">
@@ -102,6 +105,10 @@
strategy requires to balance attacking pivotal pieces of the opponent and organizing
your own defensive patterns. Play yourself to see how challenging this can be.</p>
</div>
+ <div id="Chess-desc" style="display: none;">
+ <p><a href="http://en.wikipedia.org/wiki/Chess">Chess</a>,
+ the great classical game.</p>
+ </div>
<div id="Entanglement-desc" style="display: none;">
<p><a href="http://en.wikipedia.org/wiki/Entanglement_(graph_measure)">Entanglement</a> is a game
in which a number of cops attempt to capture a robber. In each step, the cops are informed
Modified: trunk/Toss/examples/Breakthrough.toss
===================================================================
--- trunk/Toss/examples/Breakthrough.toss 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/examples/Breakthrough.toss 2010-12-04 23:46:15 UTC (rev 1218)
@@ -1,6 +1,6 @@
PLAYERS 1, 2
DATA depth: 3
-RULE 1:
+RULE WhiteBeatLeft:
[ | B:1 {} | ] "
?B ?
@@ -14,7 +14,7 @@
? .
" emb W, B
pre not ex x (B(x) and not ex y C(y, x))
-RULE 2:
+RULE WhiteMove:
[ | B:1 {}; R:2 {} | ] "
.
@@ -27,7 +27,7 @@
.
" emb W, B pre not ex x (B(x) and not ex y C(y, x))
-RULE 3:
+RULE WhiteBeatRight:
[ | B:1 {} | ] "
? ?B
@@ -41,7 +41,7 @@
. ?
" emb W, B
pre not ex x (B(x) and not ex y C(y, x))
-RULE 4:
+RULE BlackBeatLeft:
[ | W:1 {} | ] "
B ?
@@ -55,7 +55,7 @@
? B
" emb W, B
pre not ex x (W(x) and not ex y C(x, y))
-RULE 5:
+RULE BlackMove:
[ | R:2 {}; W:1 {} | ] "
B
@@ -68,7 +68,7 @@
B
" emb W, B pre not ex x (W(x) and not ex y C(x, y))
-RULE 6:
+RULE BlackBeatRight:
[ | W:1 {} | ] "
? B
@@ -92,7 +92,7 @@
:(ex x (B(x) and not ex y C(y, x))) +
-1. * :(ex x (W(x) and not ex y C(x, y)))
}
- MOVES [1 -> 1]; [2 -> 1]; [3 -> 1]
+ MOVES [WhiteBeatLeft -> 1]; [WhiteMove -> 1]; [WhiteBeatRight -> 1]
}
LOC 1 {
PLAYER 2
@@ -104,7 +104,7 @@
:(ex x (B(x) and not ex y C(y, x))) +
-1. * :(ex x (W(x) and not ex y C(x, y)))
}
- MOVES [4 -> 0]; [5 -> 0]; [6 -> 0]
+ MOVES [BlackBeatLeft -> 0]; [BlackMove -> 0]; [BlackBeatRight -> 0]
}
MODEL [ | |
] "
Modified: trunk/Toss/examples/Chess.toss
===================================================================
--- trunk/Toss/examples/Chess.toss 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/examples/Chess.toss 2010-12-04 23:46:15 UTC (rev 1218)
@@ -320,8 +320,8 @@
LOC 1 {
PLAYER 2
PAYOFF {
- 1: :(WinW()) - :(WinB());
- 2: :(WinB()) - :(WinW())
+ 1: :(CheckB()) - :(CheckW());
+ 2: :(CheckW()) - :(CheckB())
}
MOVES
[BlackPawnMove -> 0];
Modified: trunk/Toss/examples/Entanglement.toss
===================================================================
--- trunk/Toss/examples/Entanglement.toss 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/examples/Entanglement.toss 2010-12-04 23:46:15 UTC (rev 1218)
@@ -1,5 +1,5 @@
PLAYERS 1, 2
-RULE 1:
+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. } ]
@@ -8,7 +8,14 @@
vx { a1->0., a2->0. }; vy { a1->0., a2->0. };
x { a1->-10., a2->-10. }; y { a1->-10., a2->10. } ]
emb R, C
-RULE 2:
+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. } ]
@@ -17,13 +24,6 @@
vx { a1->0., a2->0. }; vy { a1->0., a2->0. };
x { a1->-10., a2->10. }; y { a1->-10., a2->-10. } ]
emb R, C
-RULE 3:
- [ 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
LOC 0 {
PLAYER 1
PAYOFF {
@@ -31,8 +31,8 @@
2: 0.
}
MOVES
- [1 -> 1];
- [3 -> 1]
+ [Follow -> 1];
+ [Wait -> 1]
}
LOC 1 {
PLAYER 2
@@ -40,7 +40,7 @@
1: 1.;
2: -1.
}
- MOVES
- [2 -> 0]
+ 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. } ]
Modified: trunk/Toss/examples/Gomoku.toss
===================================================================
--- trunk/Toss/examples/Gomoku.toss 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/examples/Gomoku.toss 2010-12-04 23:46:15 UTC (rev 1218)
@@ -1,6 +1,6 @@
PLAYERS 1, 2
DATA r1: circle, r2: line, adv_ratio: 4
-RULE 1:
+RULE Circle:
[a1 | P:1 {}; Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}] ->
[a1 | P (a1); Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}]
emb Q, P
@@ -18,7 +18,7 @@
(R(v, r) and C(w, r) and R(w, s) and C(x, s) and R(x, t) and C(y, t) and
R(y, u) and
C(z, u))))
-RULE 2:
+RULE Cross:
[a1 | P:1 {}; Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}] ->
[a1 | P:1 {}; Q (a1) | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}]
emb Q, P
@@ -92,7 +92,7 @@
t) and R(y, u) and C(z, u))))
)
}
- MOVES [1 -> 1]
+ MOVES [Circle -> 1]
}
LOC 1 {
PLAYER 2
@@ -150,7 +150,7 @@
t) and R(y, u) and C(z, u))))
)
}
- MOVES [2 -> 0]
+ MOVES [Cross -> 0]
}
MODEL [ | P:1 {}; Q:1 {} |
] "
Modified: trunk/Toss/examples/Tic-Tac-Toe.toss
===================================================================
--- trunk/Toss/examples/Tic-Tac-Toe.toss 2010-12-04 15:39:08 UTC (rev 1217)
+++ trunk/Toss/examples/Tic-Tac-Toe.toss 2010-12-04 23:46:15 UTC (rev 1218)
@@ -13,11 +13,11 @@
(C(x, y) and C(y, z)) or
(ex u, v (R(x, v) and C(v, y) and R(y, u) and C(u, z))) or
(ex u, v (R(x, v) and C(y, v) and R(y, u) and C(z, u))) ))
-RULE 1:
+RULE Circle:
[a1 | P:1 {}; Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}] ->
[a1 | P (a1); Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}]
emb Q, P pre not WinQ()
-RULE 2:
+RULE Cross:
[a1 | P:1 {}; Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}] ->
[a1 | P:1 {}; Q (a1) | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}]
emb Q, P pre not WinP()
@@ -27,7 +27,7 @@
1: :(WinP()) - :(WinQ());
2: :(WinQ()) - :(WinP())
}
- MOVES [1 -> 1]
+ MOVES [Circle -> 1]
}
LOC 1 {
PLAYER 2
@@ -35,7 +35,7 @@
1: :(WinP()) - :(WinQ());
2: :(WinQ()) - :(WinP())
}
- MOVES [2 -> 0]
+ MOVES [Cross -> 0]
}
MODEL [ | P:1 {}; Q:1 {} |
] "
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|