Commit 87681496 authored by judge's avatar judge

Commit Qwebchess before fucking with it

Thanks [BG3]
parent ef3a2d18
......@@ -71,6 +71,10 @@ def open_fifo(name, mode, timeout=None):
raise w.exception
return w.result
def force_quit():
def quit():
if os.path.exists(path+client+".in") and os.path.exists(path+client+".out"):
......@@ -105,7 +109,7 @@ def quit():
def main(argv):
print "Content-Type: text/plain\r\n\r\n"
print "Content-Type: text/plain\r\n" #Removed the second new line. Makes parsing everything easier ~BG3
global client
form = cgi.FieldStorage()
......@@ -137,6 +141,10 @@ def main(argv):
x = int(form["x"].value)
y = int(form["y"].value)
if request == "force_quit":
return 0
if os.path.exists(path+client+".in") and os.path.exists(path+client+".out"):
if request == "quit":
......@@ -150,7 +158,7 @@ def main(argv):
print "New game."
args = path+" --no-graphics"
if mode == None or mode == "bishop":
args += " @fifo:../qchess-cgi-data/"+client+" @internal:AgentBishop"
args += " @fifo:../qchess-cgi-data/"+client+" @internal:AgentBishop --log=../qchess-cgi-data/"+client+".log"
if mode == "random":
args += " @fifo:../qchess-cgi-data/"+client+" @internal:AgentRandom"
elif mode == "eigengame":
<title> UCC::Progcomp 2013 </title>
<body bgcolor=white>
<h1> Quantum Chess </h1>
<p> <b> Competition: </b> Write an AI to play Quantum Chess. You can enter in <b>any</b> language that supports reading/writing from standard input/output. </p>
<p> <b>Competition: </b> Write an AI to play Quantum Chess. You can enter in <b>any</b> language that supports reading/writing from standard input/output. </p>
<p> Quantum chess is a variant of chess in which the type of a piece changes during play. </p>
<p> The game was invented by Selim Akl, and first implemented by Alice Wismath.
You can see their original website <a href=""/>here</a>. </p>
<h2> Rules </h2>
<p> The game was invented by Selim Akl, and first implemented by Alice Wismath. You can see their original website <a href="/web/20130509192429/"/>here</a>.
<p> The rules are basically the same as <a href=""/>the original rules</a>. </p>
<hr><h2> Rules </h2><p> The rules are basically the same as <a href="/web/20130509192429/"/>the original rules</a>. </p>
<h3> Differences / Clarifications </h3>
......@@ -31,40 +24,32 @@
<li> I might shorten the number of moves before a draw is declared, we'll see. </li>
<h2> Getting Started </h2>
<hr><h2> Getting Started </h2>
<li> <a href="" target="_blank"/>Join the mailing list</a> </li>
<li> <a href="/web/20130509192429/" target="_blank"/>Join the mailing list</a> </li>
<ul> <li> <b> Important: </b> Don't email the mailing list directly; email the competition organiser (matches at ucc dot asn dot au) </li> </ul>
<li> <a href=""/>Join the #progcomp channel on IRC</a> </li>
<li> <a href="get.html"/>Obtain a copy of the qchess program</a> </li>
<li> <a href="using.html"/>Using the qchess program</a> </li>
<li> <a href="agent.html"/>Writing an agent for the qchess program</a> </li>
<li> <a href="enter.html"/>Entering the competition</a> </li>
<li> <a href="/web/20130509192429/"/>Join the #progcomp channel on IRC</a> </li>
<li> <a href="/web/20130509192429/"/>Obtain a copy of the qchess program</a> </li>
<li> <a href="/web/20130509192429/"/>Using the qchess program</a> </li>
<li> <a href="/web/20130509192429/"/>Writing an agent for the qchess program</a> </li>
<li> <a href="/web/20130509192429/"/>Entering the competition</a> </li>
<h2> Important Links </h2>
<hr><h2> Important Links </h2>
<table border="1">
<tr> <th> git </th> <td> <a href="" target="_blank"/></a> </td> </tr>
<tr> <th> IRC </th> <td> <a href="irc://"/>#progcomp</a> </td> </tr>
<tr> <th> Mailing List </th> <td> <a href="" target="_blank"/>progcomp at ucc</a> </td> </tr>
<tr> <th> Dates </th> <td> <a href="dates.txt"/>subject to change</a> </td> </tr>
<tr> <th> Results </th> <td> <a href="results"/>will appear here</a> </td> </tr>
<tr> <th> Contact </th> <td> matches or wheel at ucc </td> </tr>
<tr> <th> git </th> <td> <a href="/web/20130509192429/" target="_blank"/></a> </td> </tr>
<tr> <th> IRC </th> <td> <a href="/web/20130509192429/irc://"/>#progcomp</a> </td> </tr>
<tr> <th> Mailing List </th> <td> <a href="/web/20130509192429/" target="_blank"/>progcomp at ucc</a> </td> </tr> <tr>
<th> Dates </th> <td> <a href="/web/20130509192429/"/>subject to change</a> </td> </tr>
<tr> <th> Results </th> <td> <a href="/web/20130509192429/"/>will appear here</a> </td> </tr>
<tr> <th> Contact </th> <td> matches or wheel at ucc </td> </tr>
<hr><p> Page last updated 2013-03-29 by matches </p>
<p> Page last updated 2013-03-29 by matches </p>
<p> <a href="/web/20130509192429/">The UCC Website</a> </p>
<p> <a href="">The UCC Website</a> </p>
<p> <a href="">UCC::Progcomp Website</a> </p>
<p> <a href="/web/20130509192429/">UCC::Progcomp Website</a> </p>
<title>QChess Web UI</title>
<!--<link rel="stylesheet" href="css.css" />-->
<script type="text/javascript" src="js.js"></script>
<body onload="javascript:boardLoad();" style="width: 100%">
<table style="margin-left: auto; margin-right: auto; font-size: 20" width=600px height=600px>
<tr><td onclick="javascript:selectPiece('00');" id="00"></td><td onclick="javascript:selectPiece('01');" id="01"></td><td onclick="javascript:selectPiece('02');" id="02"></td><td onclick="javascript:selectPiece('03');" id="03"></td><td onclick="javascript:selectPiece('04');" id="04"></td><td onclick="javascript:selectPiece('05');" id="05"></td><td onclick="javascript:selectPiece('06');" id="06"></td><td onclick="javascript:selectPiece('07');" id="07"></td></tr>
<tr><td onclick="javascript:selectPiece('10');" id="10"></td><td onclick="javascript:selectPiece('11');" id="11"></td><td onclick="javascript:selectPiece('12');" id="12"></td><td onclick="javascript:selectPiece('13');" id="13"></td><td onclick="javascript:selectPiece('14');" id="14"></td><td onclick="javascript:selectPiece('15');" id="15"></td><td onclick="javascript:selectPiece('16');" id="16"></td><td onclick="javascript:selectPiece('17');" id="17"></td></tr>
<tr><td onclick="javascript:selectPiece('20');" id="20"></td><td onclick="javascript:selectPiece('21');" id="21"></td><td onclick="javascript:selectPiece('22');" id="22"></td><td onclick="javascript:selectPiece('23');" id="23"></td><td onclick="javascript:selectPiece('24');" id="24"></td><td onclick="javascript:selectPiece('25');" id="25"></td><td onclick="javascript:selectPiece('26');" id="26"></td><td onclick="javascript:selectPiece('27');" id="27"></td></tr>
<tr><td onclick="javascript:selectPiece('30');" id="30"></td><td onclick="javascript:selectPiece('31');" id="31"></td><td onclick="javascript:selectPiece('32');" id="32"></td><td onclick="javascript:selectPiece('33');" id="33"></td><td onclick="javascript:selectPiece('34');" id="34"></td><td onclick="javascript:selectPiece('35');" id="35"></td><td onclick="javascript:selectPiece('36');" id="36"></td><td onclick="javascript:selectPiece('37');" id="37"></td></tr>
<tr><td onclick="javascript:selectPiece('40');" id="40"></td><td onclick="javascript:selectPiece('41');" id="41"></td><td onclick="javascript:selectPiece('42');" id="42"></td><td onclick="javascript:selectPiece('43');" id="43"></td><td onclick="javascript:selectPiece('44');" id="44"></td><td onclick="javascript:selectPiece('45');" id="45"></td><td onclick="javascript:selectPiece('46');" id="46"></td><td onclick="javascript:selectPiece('47');" id="47"></td></tr>
<tr><td onclick="javascript:selectPiece('50');" id="50"></td><td onclick="javascript:selectPiece('51');" id="51"></td><td onclick="javascript:selectPiece('52');" id="52"></td><td onclick="javascript:selectPiece('53');" id="53"></td><td onclick="javascript:selectPiece('54');" id="54"></td><td onclick="javascript:selectPiece('55');" id="55"></td><td onclick="javascript:selectPiece('56');" id="56"></td><td onclick="javascript:selectPiece('57');" id="57"></td></tr>
<tr><td onclick="javascript:selectPiece('60');" id="60"></td><td onclick="javascript:selectPiece('61');" id="61"></td><td onclick="javascript:selectPiece('62');" id="62"></td><td onclick="javascript:selectPiece('63');" id="63"></td><td onclick="javascript:selectPiece('64');" id="64"></td><td onclick="javascript:selectPiece('65');" id="65"></td><td onclick="javascript:selectPiece('66');" id="66"></td><td onclick="javascript:selectPiece('67');" id="67"></td></tr>
<tr><td onclick="javascript:selectPiece('70');" id="70"></td><td onclick="javascript:selectPiece('71');" id="71"></td><td onclick="javascript:selectPiece('72');" id="72"></td><td onclick="javascript:selectPiece('73');" id="73"></td><td onclick="javascript:selectPiece('74');" id="74"></td><td onclick="javascript:selectPiece('75');" id="75"></td><td onclick="javascript:selectPiece('76');" id="76"></td><td onclick="javascript:selectPiece('77');" id="77"></td></tr>
<br />
<br />
<small>Made By Sam Moore [SZM] and Mitchell Pomery [BG3]</small>
\ No newline at end of file
// (0 indexed)
pieceSelected = "";
piece = "";
function selectPiece(loc) {
x = (""+loc).charAt(1);
y = (""+loc).charAt(0);
if (pieceSelected == "") {
if (document.getElementById(loc).innerHTML.charAt(0) == "W") {
console.log("Piece Selected: " + loc);
pieceSelected = loc;
ajaxUpdate("x=" + x + "&y=" + y);
else {
if (validMove(pieceSelected, piece, loc)) {
ajaxUpdate("x=" + x + "&y=" + y);
doMove(pieceSelected, loc);
pieceSelected = "";
else {
console.log("Invalid Move");
function validMove(start, piece, end) {
return true;
function doMove(start, end) {
begin = document.getElementById(start);
end = document.getElementById(end);
htmlToMove = begin.innerHTML;
end.innerHTML = htmlToMove;
begin.innerHTML = "";
//console.log("Piece Moved");
function boardLoad() {
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
e = i + "" + j;
elem = document.getElementById(e)
if ((i + j) % 2 == 0)"#FFF";
//Place pieces on the board
for (i = 0; i < 8; i++) {
black = document.getElementById("1" + i);
white = document.getElementById("6" + i);
black.innerHTML = "B<br /><small>p</small> <bold>?</bold> <small>?</small></span>";
white.innerHTML = "W<br /><small>p</small> <bold>?</bold> <small>?</small></span>";
black = document.getElementById("0" + i);
white = document.getElementById("7" + i);
piece = "p";
if (i == 0 || i == 7)
piece = "r";
if (i == 1 || i == 6)
piece = "h";
if (i == 2 || i == 5)
piece = "b";
if (i == 3)
piece = "k";
if (i == 4)
piece = "q";
black.innerHTML = "B<br /><small>" + piece + "</small> <bold>?</bold> <small>?</small>";
white.innerHTML = "W<br /><small>" + piece + "</small> <bold>?</bold> <small>?</small>";
setTimeout(function(){ajaxUpdate("r=start");}, 1000);
//AJAX Stuff
function ajaxUpdate(queryString) {
var ajaxRequest; // The variable that makes Ajax possible!
try {
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e) {
// Internet Explorer Browsers
try {
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// Something went wrong
alert("Your Browser is not Ajax Compatible, Please Upgrade to Google Chrome.");
return false;
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function () {
//alert("RS" + ajaxRequest.readyState);
if (ajaxRequest.readyState == 4) {
console.log("AJAX Response: " + ajaxRequest.responseText);
ret = ""+ajaxRequest.responseText;
if (ret.charAt(4) == "-" && ret.charAt(5) == ">") {
//Piece has been moved
//console.log("Moving other piece");
lines = ret.split("\n");
//if (lines[3] != "SELECT?") {
if (lines[2] != "SELECT?") {
x1 = lines[2].charAt(0);
y1 = lines[2].charAt(2);
x2 = lines[2].charAt(7);
y2 = lines[2].charAt(9);
console.log("Black Move: " + x1 + "" + y1 + " -> " + x2 + "" + y2);
doMove(y1 + "" + x1, y2 + "" + x2);
else {
console.log("Black Unable to move");
else {
lines = ret.split("\n");
if (lines[1] == "MOVE?") {
//We selected a piece
//console.log("choose where to move our piece");
piece = lines[0].charAt(6);
//console.log("Piece: " + piece);
content = document.getElementById(pieceSelected);
contentHTML = content.innerHTML;
//contentHTML = contentHTML.replace("?", piece);
//"W<br /><small>p</small> <bold>?</bold> <small>?</small></span>";
if (lines[0].charAt(4) == "1") {
//console.log("changing quantum piece");
contentHTML = replaceAt(contentHTML, 44, piece);
contentHTML = replaceAt(contentHTML, 28, piece);
//contentHTML = "CHANGED" + contentHTML;
content.innerHTML = contentHTML;
//ar = "" + queryString;
ar = "/../../../cgi-bin/qchess.cgi?" + queryString;
console.log("AJAX Request: " + ar);"GET", ar, true);
function replaceAt(s, n, t) {
//console.log(s.substring(0, n) + "\n" + t + "\n" + s.substring(n + 1) + "\n");
return (s.substring(0, n) + t + s.substring(n + 1));
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment