[Toss-devel-svn] SF.net SVN: toss:[1269] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2010-12-21 23:42:22
|
Revision: 1269
http://toss.svn.sourceforge.net/toss/?rev=1269&view=rev
Author: lukaszkaiser
Date: 2010-12-21 23:42:15 +0000 (Tue, 21 Dec 2010)
Log Message:
-----------
WebClient improvements, Gc compact on NOOP, more readable definitions of Tic-Tac-Toe and Gomoku.
Modified Paths:
--------------
trunk/Toss/Play/Server.ml
trunk/Toss/WebClient/Connect.js
trunk/Toss/WebClient/DefaultStyle.js
trunk/Toss/WebClient/Handler.py
trunk/Toss/WebClient/Main.js
trunk/Toss/WebClient/README
trunk/Toss/WebClient/Style.css
trunk/Toss/WebClient/Wrapper.py
trunk/Toss/WebClient/index.html
trunk/Toss/examples/Gomoku.toss
trunk/Toss/examples/Tic-Tac-Toe.toss
Modified: trunk/Toss/Play/Server.ml
===================================================================
--- trunk/Toss/Play/Server.ml 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/Play/Server.ml 2010-12-21 23:42:15 UTC (rev 1269)
@@ -354,8 +354,7 @@
memory = memory;
});
- if GDL.our_turn !state
- then
+ if GDL.our_turn !state then (
let time_used =
int_of_float time_started - int_of_float (ceil (Sys.time ())) in
let p, ps =
@@ -376,9 +375,11 @@
let msg_len = String.length mov_msg in
"HTTP/1.0 200 OK\r\nContent-type: text/acl\r\nContent-length: "
^ string_of_int msg_len ^ "\r\n\r\n" ^ mov_msg
- else
+ ) else (
+ Gc.compact ();
"HTTP/1.0 200 OK\r\nContent-type: text/acl\r\nContent-length: "
^ "4\r\n\r\nNOOP"
+ )
| Aux.Right (GDL.Stop (_, actions)) ->
@@ -460,7 +461,7 @@
in
if !debug_level > 0 then (
Printf.printf "Resp-time: %F\n%!" (Sys.time () -. time_started);
- print_endline ("Repl: " ^ resp ^ "\n");
+ print_endline ("\nRepl: " ^ resp ^ "\n");
);
output_string out_ch (resp ^ "\n");
flush out_ch;
Modified: trunk/Toss/WebClient/Connect.js
===================================================================
--- trunk/Toss/WebClient/Connect.js 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/WebClient/Connect.js 2010-12-21 23:42:15 UTC (rev 1269)
@@ -21,12 +21,11 @@
var SUGGESTED_ELEM_SIZEX = 25; // suggested size of elements
var SUGGESTED_ELEM_SIZEY = 25; // suggested size of elements
-var CACHED_MOVES = ""
-
var DIM_STR = ""
var ELEM_STR = ""
var RELS_STR = ""
var MOVES_STR = ""
+var PAYOFF_STR = ""
// Helper function: sign of a number.
@@ -36,11 +35,6 @@
else { return (0); }
}
-// Clears cached moves.
-function clear_move_cache () {
- CACHED_MOVES = "";
-}
-
function set_info (info) {
var res_arr = [];
res_arr = info.split("$");
@@ -48,7 +42,13 @@
DIM_STR = res_arr[0];
ELEM_STR = res_arr[1];
RELS_STR = res_arr[2];
- MOVES_STR = res_arr[3];
+ if (res_arr[3].substring(0, 1) == "(") {
+ MOVES_STR = res_arr[3];
+ PAYOFF_STR = "";
+ } else {
+ MOVES_STR = "";
+ PAYOFF_STR = res_arr[3];
+ };
var dim = strip('(', ')', DIM_STR).split(',');
MODEL_MAXX = parseFloat(strip(' ', ' ', dim[0]));
MODEL_MINX = parseFloat(strip(' ', ' ', dim[1]));
@@ -56,7 +56,6 @@
MODEL_MINY = parseFloat(strip(' ', ' ', dim[3]));
MODEL_WIDTH = Math.max (SVG_WIDTH / 100, (MODEL_MAXX - MODEL_MINX));
MODEL_HEIGHT = Math.max (SVG_HEIGHT / 100, (MODEL_MAXY - MODEL_MINY));
-
return (true);
}
@@ -130,15 +129,16 @@
// Get moves applicable to [elem] in a game.
-function get_moves (elem) {
- if (CACHED_MOVES == "") {
- CACHED_MOVES = MOVES_STR
- }
- var all_moves = convert_python_list (';', CACHED_MOVES);
+function get_moves (elem, other) {
+ var all_moves = convert_python_list (';', MOVES_STR);
var elem_moves = []
for (i = 0; i < all_moves.length; i++) {
if (all_moves[i].indexOf(elem) >= 0) {
- elem_moves.push(all_moves[i])
+ if (other == "") {
+ elem_moves.push(all_moves[i])
+ } else if (all_moves[i].indexOf(other) >= 0) {
+ elem_moves.push(all_moves[i])
+ }
}
}
return (elem_moves)
Modified: trunk/Toss/WebClient/DefaultStyle.js
===================================================================
--- trunk/Toss/WebClient/DefaultStyle.js 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/WebClient/DefaultStyle.js 2010-12-21 23:42:15 UTC (rev 1269)
@@ -37,7 +37,7 @@
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-Bx" /> \
+ 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" /> \
@@ -65,7 +65,7 @@
style="stroke-linecap:butt;" class="chess-path-Bx" /> \
<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-Bx" /> \
+ 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" /> \
@@ -77,7 +77,7 @@
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-Bx" /> \
+ class="chess-path-B" /> \
<path \
d="M 11,14 L 34,14" \
class="chess-path-D" /> \
@@ -122,12 +122,12 @@
</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,11.625 L 22.5,6" class="chess-path-B" /> \
<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" /> \
+ class="chess-path-B" /> \
+ <path d="M 20,8 L 25,8" class="chess-path-B" /> \
<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" /> \
@@ -136,6 +136,20 @@
</g>';
+function is_int (s) {
+ return (parseInt(s).toString() == s)
+}
+
+// To draw chess board we distinguish even/odd placed elements.
+function elem_class (elem) {
+ var elem_cl = "model-elem";
+ if (is_int (elem.substring(1))) {
+ var psum = elem.charCodeAt(0) + parseInt (elem.substring(1));
+ elem_cl = "model-elem-" + (psum % 2);
+ };
+ return (elem_cl);
+}
+
// Draw the element [elem].
function draw_elem (elem) {
var pos = ELEM_POS[elem];
@@ -145,7 +159,7 @@
["width", 2 * SUGGESTED_ELEM_SIZEX],
["height", 2 * SUGGESTED_ELEM_SIZEX],
["id", "elem_" + elem],
- ["class", "model-elem"],
+ ["class", elem_class(elem)],
["onclick", ("handle_elem_click('" + elem + "')")]]
);
}
@@ -159,7 +173,7 @@
// Unhighlight the element [elem].
function unhighlight_elem (elem) {
var e = document.getElementById ("elem_" + elem);
- e.setAttribute ("class", "model-elem");
+ e.setAttribute ("class", elem_class(elem));
}
// Draw relation [rel_name] between elements [args].
Modified: trunk/Toss/WebClient/Handler.py
===================================================================
--- trunk/Toss/WebClient/Handler.py 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/WebClient/Handler.py 2010-12-21 23:42:15 UTC (rev 1269)
@@ -92,7 +92,9 @@
dim_s = str(client.model.get_dim())
model_s = str(client.model.get_elems_with_pos())
rels_s = str(client.model.get_rels_simple())
- moves_s = str(client.cur_moves())
+ moves = client.cur_moves()
+ moves_s = str(moves)
+ if (len(moves) == 0): moves_s = client.get_payoffs()
return (dim_s + "$" + model_s + "$" + rels_s + "$" + moves_s)
def get_free_id (db):
Modified: trunk/Toss/WebClient/Main.js
===================================================================
--- trunk/Toss/WebClient/Main.js 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/WebClient/Main.js 2010-12-21 23:42:15 UTC (rev 1269)
@@ -14,6 +14,8 @@
var FULL_OPNT_LEN = 0;
var CUR_OPNT_START = 0;
+var LAST_CLICKED_ELEM = "";
+
// Get model information from server.
function get_model_info () {
get_elems_with_pos ();
@@ -44,7 +46,7 @@
// Clear whole svg box.
function clear_svg () {
- clear_move_cache ();
+ LAST_CLICKED_ELEM = "";
ELEM_COUNTERS = {};
CUR_MOVE = "";
CUR_ELEMS = [];
@@ -60,6 +62,13 @@
get_model_info ();
create_svg_box (SVG_MARGINX, SVG_MARGINY, "board");
draw_model ();
+ if (PAYOFF_STR == "") {
+ document.getElementById('movebt').innerHTML = "Make move:";
+ document.getElementById('cur-move').innerHTML = "none";
+ } else {
+ document.getElementById('movebt').innerHTML = "Payoffs:";
+ document.getElementById('cur-move').innerHTML = PAYOFF_STR;
+ }
document.getElementById("working").style.display = "none";
}
@@ -79,6 +88,7 @@
// Helper function: highlight move, unhighlight old, save current.
function show_move (m) {
var m_act = get_move_elems (m);
+ m_act.sort ();
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]);
@@ -91,7 +101,7 @@
document.getElementById('cur-move').innerHTML = "none";
} else {
document.getElementById('cur-move').innerHTML =
- m_rule + ': ' + m_str;
+ m_str.replace (/,/g, " — ") + " (" + m_rule + ")"
}
CUR_ELEMS = m_act;
CUR_MOVE = m.toString();
@@ -99,14 +109,28 @@
// Handler for clicks on elements.
function handle_elem_click (elem) {
- var moves = get_moves (elem);
+ var moves = get_moves (elem, LAST_CLICKED_ELEM);
+ if (moves.length == 0) {
+ LAST_CLICKED_ELEM = "";
+ moves = get_moves (elem, LAST_CLICKED_ELEM);
+ };
if (moves.length > ELEM_COUNTERS[elem]) {
show_move (moves[ELEM_COUNTERS[elem]]);
ELEM_COUNTERS[elem] += 1;
} else if (moves.length > 0) {
show_move (moves[0]);
ELEM_COUNTERS[elem] = 1;
- }
+ };
+ if (moves.length > 1 && LAST_CLICKED_ELEM == "") {
+ for (var i = 0; i < CUR_ELEMS.length; i++) {
+ unhighlight_elem (CUR_ELEMS[i]);
+ }
+ document.getElementById('cur-move').innerHTML = elem + " — ?"
+ highlight_elem (elem);
+ CUR_ELEMS = [elem];
+ CUR_MOVE = "";
+ };
+ LAST_CLICKED_ELEM = elem;
}
function play_py_id (i) {
@@ -160,16 +184,18 @@
function game_click (game) {
- document.getElementById("welcome").style.display = "none";
- document.getElementById("game-disp").style.display = "none";
- document.getElementById("plays").style.display = "none";
- GAME_NAME = game;
- if (game == "Tic-Tac-Toe") { // bigger margins needed
- create_svg_box (130, 130, "board");
- } else {
- create_svg_box (40, 40, "board");
- }
- document.getElementById("game-disp").style.display = "block";
+ document.getElementById("welcome").style.display = "none";
+ document.getElementById("game-disp").style.display = "none";
+ document.getElementById("plays").style.display = "none";
+ GAME_NAME = game;
+ if (game == "Tic-Tac-Toe") { // bigger margins needed
+ create_svg_box (130, 130, "board");
+ } else {
+ create_svg_box (40, 40, "board");
+ }
+ var gd = document.getElementById("game-disp");
+ gd.style.display = "block";
+ gd.setAttribute ("class", "Game-" + game);
}
function play_click (game, play_id, pi) {
@@ -198,13 +224,11 @@
document.getElementById("working").style.display = "block";
var info = srv("MOVE_PLAY", 'c, '+ CUR_MOVE +', '+ play_py_id (CUR_PLAY_I));
set_info (info);
- clear_move_cache ();
CUR_MOVE = "";
CUR_ELEMS = [];
ELEM_COUNTERS = {};
document.getElementById("cur-player").innerHTML =
disp_name(PLAYS[CUR_PLAY_I][(m + 1) % 2]);
- document.getElementById('cur-move').innerHTML = "none";
document.getElementById("working").style.display = "none";
full_redraw ();
PLAYS[CUR_PLAY_I][3] = parseInt(PLAYS[CUR_PLAY_I][3]) + 1;
@@ -214,8 +238,8 @@
var li = new_play_item (GAME_NAME, CUR_PLAY_I);
old_li.parentNode.replaceChild (li, old_li);
if (PLAYS[CUR_PLAY_I][(m + 1) % 2] == "computer") {
- suggest_move ();
- make_move ();
+ var m = suggest_move ();
+ if (m != "") { make_move (); }
}
}
@@ -345,12 +369,14 @@
function suggest_move () {
var m = srv("SUGGEST", 'c, '+ play_py_id (CUR_PLAY_I));
- show_move (m);
+ if (m != "") { show_move (m); }
+ return (m);
}
function suggest_move_better () {
var m = srv("SUGGESTX", 'c, '+ play_py_id (CUR_PLAY_I));
- show_move (m);
+ if (m != "") { show_move (m); }
+ return (m);
}
function toggle_suggestions () {
Modified: trunk/Toss/WebClient/README
===================================================================
--- trunk/Toss/WebClient/README 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/WebClient/README 2010-12-21 23:42:15 UTC (rev 1269)
@@ -19,8 +19,6 @@
TODO:
- - move interface: first click all, second click toggle, if one - confirm msg
- - display results, prevent suggestion bug when game has already ended
- sort plays by who's turn it is
- option to give up game and offer a draw
- enable google (or other) analytics
Modified: trunk/Toss/WebClient/Style.css
===================================================================
--- trunk/Toss/WebClient/Style.css 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/WebClient/Style.css 2010-12-21 23:42:15 UTC (rev 1269)
@@ -2,14 +2,16 @@
html {
position: absolute;
- height: 100%;
+ min-height: 100%;
+ height: auto;
+ min-width: 45em;
width: 100%;
}
body {
position: absolute;
- height: 100%;
width: 100%;
+ min-height: 100%;
padding: 0px;
margin: 0px;
text-align: center;
@@ -23,7 +25,7 @@
-moz-border-radius: 4px;
border-width: 1px;
color: #260314;
- background-color: #ffe4aa;
+ background-color: #fff1d4;
font-size: 0.9em;
font-family: Verdana, 'TeXGyreHerosRegular', sans;
}
@@ -34,10 +36,11 @@
}
#plays .bt {
- width: 7.5em;
+ width: 8em;
font-size: 0.75em;
- position: absolute;
- right: 2px;
+ /* position: absolute;
+ right: 2px; */
+ float: right;
}
.obt {
@@ -47,7 +50,7 @@
-moz-border-radius: 4px;
border-width: 0px;
color: #260314;
- background-color: #ffe4aa;
+ background-color: #fff1d4;
font-size: 0.9em;
font-family: Verdana, 'TeXGyreHerosRegular', sans;
}
@@ -58,11 +61,11 @@
}
.dbt {
- border-color: #ffe4aa;
+ border-color: #fff1d4;
border-radius: 4px;
-moz-border-radius: 4px;
border-width: 0px;
- color: #ffe4aa;
+ color: #fff1d4;
background-color: #400827;
font-size: 0.9em;
font-family: Verdana, 'TeXGyreHerosRegular', sans;
@@ -95,7 +98,7 @@
}
.loginput {
- border-color: #ffe4aa;
+ border-color: #fff1d4;
border-radius: 4px;
-moz-border-radius: 4px;
border-width: 1px;
@@ -104,7 +107,7 @@
}
.forminput {
- border-color: #ffe4aa;
+ border-color: #fff1d4;
border-radius: 4px;
-moz-border-radius: 4px;
border-width: 2px;
@@ -134,7 +137,7 @@
font-family: Verdana, 'TeXGyreHerosRegular', sans;
color: #400827;
background-color: #ffffff;
- border-color: #ffe4aa;
+ border-color: #fff1d4;
border-radius: 4px;
-moz-border-radius: 4px;
border-width: 1px;
@@ -150,9 +153,9 @@
font-family: Verdana, 'TeXGyreHerosRegular', sans;
font-size: 1em;
font-weight: bold;
- color: #ffe4aa;
+ color: #fff1d4;
background-color: #400827;
- border-color: #ffe4aa;
+ border-color: #fff1d4;
border-radius: 4px;
-moz-border-radius: 4px;
border-width: 0px;
@@ -189,7 +192,7 @@
}
#top a, #logo a:link, #logo a:active, #logo a:visited {
- color: #ffe4aa;
+ color: #fff1d4;
background-color: transparent;
text-decoration: none;
}
@@ -210,7 +213,7 @@
left: 0px;
width: 100%;
height: 2.5em;
- color: #ffe4aa;
+ color: #fff1d4;
background-color: #400827;
border-color: #260314;
border-style: solid;
@@ -252,7 +255,7 @@
text-align: center;
font-size: 0.9em;
font-weight: bold;
- color: #ffe4aa;
+ color: #fff1d4;
background-color: #400827;
border-color: #260314;
border-style: solid;
@@ -260,7 +263,7 @@
}
#bottom a, #bottom a:link, #bottom a:active, #bottom a:visited {
- color: #ffe4aa;
+ color: #fff1d4;
text-decoration: none;
}
@@ -286,7 +289,7 @@
left: 0.5em;
border: 0px;
background-color: #400827;
- color: #ffe4aa;
+ color: #fff1d4;
font-family: Verdana, 'TeXGyreHerosRegular', sans;
font-size: 1em;
font-weight: bold;
@@ -315,7 +318,7 @@
#topbar a {
font-weight: bold;
text-decoration: none;
- color: #ffe4aa;
+ color: #fff1d4;
width: 100%;
}
@@ -338,29 +341,28 @@
text-align: left;
position: absolute;
top: 0px;
- bottom: 0px;
left: 0px;
right: 0px;
margin-left: auto;
margin-right: auto;
width: 90%;
- height: 100%;
+ min-height: 100%;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 2px;
padding-right: 2px;
color: #260314;
- background-color: #ffe4aa;
+ background-color: #fff1d4;
border-left: 1px solid #260314;
border-right: 1px solid #260314;
}
-#main a, #main a:link, #main a:active, #main a:visited {
+#welcome a, #welcome a:link, #welcome a:active, #welcome a:visited {
color: #260314;
text-decoration: none;
}
-#main a:hover {
+#welcome a:hover {
color: #400827;
text-decoration: underline;
}
@@ -386,7 +388,7 @@
width: 20em;
margin-left: auto;
margin-right: auto;
- color: #ffe4aa;
+ color: #fff1d4;
background-color: #400827;
font-weight: bold;
padding: 1em;
@@ -420,7 +422,7 @@
-moz-border-radius: 4px;
border-width: 1px;
color: #260314;
- background-color: #ffe4aa;
+ background-color: #fff1d4;
font-weight: normal;
text-align: center;
font-size: 0.9em;
@@ -456,9 +458,10 @@
margin-left: auto;
margin-right: auto;
margin-top: 3em;
+ margin-bottom: 1.5em;
min-width: 10em;
- max-width: 90em;
- width: 80%;
+ max-width: 120em;
+ width: 100%;
display: none;
}
@@ -482,8 +485,8 @@
#board {
min-width: 10em;
- max-width: 90em;
- width: 70%;
+ max-width: 120em;
+ width: 100%;
margin-left: auto;
margin-right: auto;
margin-top: 0em;
@@ -500,7 +503,7 @@
margin-right: auto;
text-align: center;
font-weight: bold;
- color: #ffe4aa;
+ color: #fff1d4;
background-color: #400827;
display: none;
padding: 1em;
@@ -513,7 +516,7 @@
width: 16em;
text-align: center;
font-weight: bold;
- color: #ffe4aa;
+ color: #fff1d4;
background-color: #400827;
display: none;
padding: 1em;
@@ -531,10 +534,12 @@
}
#plays {
- position: absolute;
+ /* position: absolute;
left: 0px;
right: 0px;
- top: 2.5em;
+ top: 2.5em; */
+ margin-top: 3.5em;
+ margin-bottom: 2em;
margin-left: auto;
margin-right: auto;
width: 100%;
@@ -542,6 +547,16 @@
display: none;
}
+#plays a, #plays a:link, #plays a:active, #plays a:visited {
+ color: #260314;
+ text-decoration: none;
+}
+
+#plays a:hover {
+ color: #400827;
+ text-decoration: underline;
+}
+
.plays-list {
margin-left: 1em;
padding-left: 0px;
@@ -569,22 +584,34 @@
/* SVG styling */
#svg {
min-width: 10em;
- max-width: 90em;
- width: 80%;
+ max-width: 120em;
+ width: 65%;
min-height: 10em;
- max-height: 90em;
- height: 80%;
+ max-height: 120em;
+ height: 75%;
/* border: 1px solid #260314; */
}
-.model-elem {
- fill: #b5bf8f;
+.model-elem, .model-elem-0, .model-elem-1 {
+ fill: #ffe4aa; /* #ffce9e; */
stroke: #260314;
stroke-width: 3px;
}
+.Game-Chess .model-elem-0 {
+ fill: #d18b47;
+ stroke: #260314;
+ stroke-width: 3px;
+}
+
+.Game-Chess .model-elem-1 {
+ fill: #ffe4aa; /* #ffce9e; */
+ stroke: #260314;
+ stroke-width: 3px;
+}
+
.model-elem-highlight {
- fill: #ffe4aa;
+ fill: #b5bf8f;
stroke: #400827;
stroke-width: 3px;
}
@@ -596,12 +623,12 @@
}
.model-pred-Q {
- fill: #b5bf8f;
+ fill: #ffe4aa; /* #ffce9e; */
stroke: #260314;
}
.model-pred-C {
- fill: #ffe4aa;
+ fill: #fff1d4;
stroke: #260314;
stroke-width: 3px;
}
@@ -613,7 +640,7 @@
}
.model-pred-W {
- fill: #ffe4aa;
+ fill: #fff1d4;
stroke: #260314;
stroke-width: 3px;
}
@@ -632,7 +659,7 @@
.chessW .chess-path-A {
opacity: 1;
- fill: #ffe4aa;
+ fill: #fff1d4;
fill-opacity: 1;
fill-rule: nonzero;
stroke: #260314;
@@ -662,7 +689,7 @@
.chessW .chess-path-B {
opacity: 1;
- fill: #ffe4aa;
+ fill: #fff1d4;
fill-opacity: 1;
fill-rule: evenodd;
stroke: #260314;
@@ -690,7 +717,7 @@
.chessW .chess-path-Bx {
opacity: 1;
- fill: #ffe4aa;
+ fill: #fff1d4;
fill-opacity: 1;
fill-rule: evenodd;
stroke: #260314;
@@ -704,7 +731,7 @@
.chessB .chess-path-Bx {
opacity: 1;
- fill: #ffe4aa;
+ fill: #fff1d4;
fill-opacity: 1;
fill-rule: evenodd;
stroke: #400827;
@@ -731,9 +758,9 @@
.chessB .chess-path-C {
opacity:1;
- fill: #ffe4aa;
+ fill: #fff1d4;
fill-opacity: 1;
- stroke: #ffe4aa;
+ stroke: #fff1d4;
stroke-width: 1.5;
stroke-linecap: round;
stroke-linejoin: round;
@@ -743,7 +770,7 @@
}
.chessW .chess-path-D {
- fill: #ffe4aa;
+ fill: #fff1d4;
fill-opacity: 0.75;
fill-rule: evenodd;
stroke: #260314;
@@ -759,7 +786,7 @@
fill: #400827;
fill-opacity: 0.75;
fill-rule: evenodd;
- stroke: #ffe4aa;
+ stroke: #fff1d4;
stroke-width: 1;
stroke-linecap: round;
stroke-linejoin: miter;
Modified: trunk/Toss/WebClient/Wrapper.py
===================================================================
--- trunk/Toss/WebClient/Wrapper.py 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/WebClient/Wrapper.py 2010-12-21 23:42:15 UTC (rev 1269)
@@ -221,6 +221,7 @@
" alpha_beta_ord")
self.set_time (ts, t)
msg = [s.strip() for s in m.split(';')]
+ if len(msg) < 2: return ("")
emb = dict()
for s in msg[1].split(','):
es = [x.strip() for x in s.split(':')]
Modified: trunk/Toss/WebClient/index.html
===================================================================
--- trunk/Toss/WebClient/index.html 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/WebClient/index.html 2010-12-21 23:42:15 UTC (rev 1269)
@@ -15,6 +15,9 @@
</head>
<body onload="startup()">
+
+<div id="main">
+
<div id="top">
<div id="logo"><a href="index.html">tPlay</a></div>
<div id="topbar">
@@ -49,9 +52,7 @@
<a href="register.html">Register</a>
</span>
</div>
-</div>
-<div id="main">
<div id="opponents">
Pick Opponent:
@@ -150,7 +151,6 @@
<div id="board"><div id="working">Working...</div></div>
</div>
-</div>
<div id="bottom">
<button id="suggestions-toggle" onclick="toggle_suggestions()">
@@ -160,5 +160,7 @@
<a href="contact.html" id="contact">Contact and Info</a>
</div>
+</div>
+
</body>
</html>
Modified: trunk/Toss/examples/Gomoku.toss
===================================================================
--- trunk/Toss/examples/Gomoku.toss 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/examples/Gomoku.toss 2010-12-21 23:42:15 UTC (rev 1269)
@@ -1,157 +1,45 @@
PLAYERS 1, 2
DATA r1: circle, r2: line, adv_ratio: 4, depth: 1
+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 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 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}] ->
+ [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
- ex v, w, x, y, z
- (Q(v) and Q(w) and Q(x) and Q(y) and Q(z) and
- (R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- ex r, s, t, u
- (R(v, r) and C(r, w) and R(w, s) and C(s, x) and R(x, t) and C(t, y) and
- R(y, u) and
- C(u, z)) or
- ex r, s, t, u
- (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))))
+ emb Q, P pre not WinQ()
RULE Circle:
- [a1 | P:1 {}; Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}] ->
+ [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
- ex v, w, x, y, z
- (P(v) and P(w) and P(x) and P(y) and P(z) and
- (R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- ex r, s, t, u
- (R(v, r) and C(r, w) and R(w, s) and C(s, x) and R(x, t) and C(t, y) and
- R(y, u) and
- C(u, z)) or
- ex r, s, t, u
- (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))))
+ emb Q, P pre not WinP()
LOC 0 {
- PLAYER 1
+ PLAYER 1
PAYOFF {
- 1:
- :(
- ex v, w, x, y, z
- (P(v) and P(w) and P(x) and P(y) and P(z) and
- (C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- ex r, s, t, u
- (C(r, w) and C(s, x) and C(t, y) and C(u, z) and R(v, r) and R(w,
- s) and R(x, t) and R(y, u)) or
- ex r, s, t, u
- (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))))
- ) +
- -1. *
- :(
- ex v, w, x, y, z
- (Q(v) and Q(w) and Q(x) and Q(y) and Q(z) and
- (C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- ex r, s, t, u
- (C(r, w) and C(s, x) and C(t, y) and C(u, z) and R(v, r) and R(w,
- s) and R(x, t) and R(y, u)) or
- ex r, s, t, u
- (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))))
- );
- 2:
- :(
- ex v, w, x, y, z
- (Q(v) and Q(w) and Q(x) and Q(y) and Q(z) and
- (C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- ex r, s, t, u
- (C(r, w) and C(s, x) and C(t, y) and C(u, z) and R(v, r) and R(w,
- s) and R(x, t) and R(y, u)) or
- ex r, s, t, u
- (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))))
- ) +
- -1. *
- :(
- ex v, w, x, y, z
- (P(v) and P(w) and P(x) and P(y) and P(z) and
- (C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- ex r, s, t, u
- (C(r, w) and C(s, x) and C(t, y) and C(u, z) and R(v, r) and R(w,
- s) and R(x, t) and R(y, u)) or
- ex r, s, t, u
- (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))))
- )
- }
+ 1: :(WinP()) - :(WinQ());
+ 2: :(WinQ()) - :(WinP())
+ }
MOVES [Cross -> 1]
- }
+}
LOC 1 {
- PLAYER 2
+ PLAYER 2
PAYOFF {
- 1:
- :(
- ex v, w, x, y, z
- (P(v) and P(w) and P(x) and P(y) and P(z) and
- (C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- ex r, s, t, u
- (C(r, w) and C(s, x) and C(t, y) and C(u, z) and R(v, r) and R(w,
- s) and R(x, t) and R(y, u)) or
- ex r, s, t, u
- (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))))
- ) +
- -1. *
- :(
- ex v, w, x, y, z
- (Q(v) and Q(w) and Q(x) and Q(y) and Q(z) and
- (C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- ex r, s, t, u
- (C(r, w) and C(s, x) and C(t, y) and C(u, z) and R(v, r) and R(w,
- s) and R(x, t) and R(y, u)) or
- ex r, s, t, u
- (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))))
- );
- 2:
- :(
- ex v, w, x, y, z
- (Q(v) and Q(w) and Q(x) and Q(y) and Q(z) and
- (C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- ex r, s, t, u
- (C(r, w) and C(s, x) and C(t, y) and C(u, z) and R(v, r) and R(w,
- s) and R(x, t) and R(y, u)) or
- ex r, s, t, u
- (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))))
- ) +
- -1. *
- :(
- ex v, w, x, y, z
- (P(v) and P(w) and P(x) and P(y) and P(z) and
- (C(v, w) and C(w, x) and C(x, y) and C(y, z) or
- R(v, w) and R(w, x) and R(x, y) and R(y, z) or
- ex r, s, t, u
- (C(r, w) and C(s, x) and C(t, y) and C(u, z) and R(v, r) and R(w,
- s) and R(x, t) and R(y, u)) or
- ex r, s, t, u
- (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))))
- )
- }
+ 1: :(WinP()) - :(WinQ());
+ 2: :(WinQ()) - :(WinP())
+ }
MOVES [Circle -> 0]
- }
+}
MODEL [ | P:1 {}; Q:1 {} |
] "
... ... ... ...
Modified: trunk/Toss/examples/Tic-Tac-Toe.toss
===================================================================
--- trunk/Toss/examples/Tic-Tac-Toe.toss 2010-12-21 23:14:48 UTC (rev 1268)
+++ trunk/Toss/examples/Tic-Tac-Toe.toss 2010-12-21 23:42:15 UTC (rev 1269)
@@ -1,43 +1,41 @@
PLAYERS 1, 2
DATA r1: circle, r2: line, adv_ratio: 4, depth: 3
-REL WinQ() =
- ex x, y, z
- (Q(x) and Q(y) and Q(z) and (
- (R(x, y) and R(y, z)) or
- (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))) ))
-REL WinP() =
- ex x, y, z
- (P(x) and P(y) and P(z) and (
- (R(x, y) and R(y, z)) or
- (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))) ))
+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:
- [a1 | P:1 {}; Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}] ->
+ [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()
+ emb Q, P pre not WinQ()
RULE Circle:
- [a1 | P:1 {}; Q:1 {} | vx {a1->0.}; vy {a1->0.}; x {a1->0.}; y {a1->0.}] ->
+ [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()
+ emb Q, P pre not WinP()
LOC 0 {
- PLAYER 1
+ PLAYER 1
PAYOFF {
1: :(WinP()) - :(WinQ());
2: :(WinQ()) - :(WinP())
- }
+ }
MOVES [Cross -> 1]
- }
+}
LOC 1 {
- PLAYER 2
+ PLAYER 2
PAYOFF {
1: :(WinP()) - :(WinQ());
2: :(WinQ()) - :(WinP())
- }
+ }
MOVES [Circle -> 0]
- }
+}
MODEL [ | P:1 {}; Q:1 {} |
] "
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|