/Home or play chess at
http://chessforeva.appspot.com
......... Google App Engine ........... .... ....

Chess software for fun

otrdiena, 2010. gada 28. septembris

Mediocre for web-calculations


This topic is old and experimental. Don't take it seriously, these are ideas on server based chess calculations.

(NOT WORKING ANYMORE, JAVA SECURITY POLICY DISABLES APPLETS)
Mediocre is a java chess engine by http://mediocrechess.blogspot.com
It's possible to use it for calculations in javascript web-pages

Example

Instructions:

Put iframe in Your web-page

<iframe src="http://smecers.appspot.com/govs/mediocre/MediocreCall.htm" width="360" height="280" id="mediframe"></iframe>

Then add some javascript code to send and receive from this iframe.
Syntax for request:
mediocre: -just a tag
searchd: -how deep to search
setboard: -position to set up and do a move

<script>
function Ask()
{
var request='mediocre: searchd:3 setboard: r4rk1/1b4pN/6QR/1np2p2/8/7P/p2q1PP1/4R1K1 w - - 0 1';
var medifr=document.getElementById("mediframe");
medifr.contentWindow.postMessage(request,medifr.src);
}

function CallBackFromMediocre(domain,strparm)
{
var alive=(strparm.substr(0,15)=="mediocre-alive:");
//if(alive) alert("Mediocre is alive!");

var move=((strparm.substr(0,13)=="mediocre-ret:") ? strparm.substr(13) :"");
//if(move.length>0) alert('Mediocre goes ' + move);
}

window.addEventListener("message", function(e) { CallBackFromMediocre(e.origin,e.data) }, false);
</script>









 

(REQUIRES SILVERLIGHT INSTALLED) 
The other great chess engine is Valil by http://www.valil.com. The code below is compiled C# for MS silverlight (required there).
Example

Instructions:

Put iframe in Your web-page

<iframe src="http://smecers.appspot.com/govs/valil_silverlightchess/ValilCall.htm" width="240" height="400" id="valilframe"></iframe>

Then add some javascript code to send and receive from this iframe.
Syntax for request:
valil: -just a tag
searchd: -how deep to search
setboard: -position to set up and do a move

<script>
setTimeout('Ask()',5000);

function Ask()
{
var request='valil: searchd:6 setboard:2r1kbR1/5r2/1p3pN1/2p2P1p/P7/1P3K1P/8/6R1 w - - 0 1';
var valilifr=document.getElementById("valilframe");
valilifr.contentWindow.postMessage(request,valilifr.src);
}

function CallBackFromValil(domain,strparm)
{
var alive=(strparm.substr(0,12)=="valil-alive:");
//if(alive) document.getElementById("answer").innerHTML+="Valil is alive!";

var move=((strparm.substr(0,10)=="valil-ret:") ? strparm.substr(10) :"");
//if(move.length>0) document.getElementById("answer").innerHTML+="Valil goes " + move;
}

window.addEventListener("message", function(e) { CallBackFromValil(e.origin,e.data) }, false)
</script>

IE specific.
1) use unspecified domain
contentWindow.postMessage(..., "*");
2) use
window.attachEvent instead of window.addEventListener .
Do not expect proper working of event based messaging on all type of browsers.
Anyway, it is possible. Read more on internet.


Few words about these chess engines.

Java and silverlight(C#) versions can't beat Rybka, Stockfish, Fritz nor Crafty. And, there are stronger chess implementations in java or silverlight too. Anyway, these are quite good at deeper search level (6 for example) and are usable in browser with the right plugin pre-installed.
In fact, authors (mentioned above, much thanks! to them) have done really good work on these projects. There is also a Unity3D version of Valil - compiled C# just works perfectly on 3D-game engine. Sources of this chess code are here: Valil, Mediocre. Both are compiled in 2010, very up-to-date. And, of course, the online playable version is at http://chessforeva.appspot.com.
The short opening book for first moves is present for Valil only.

Nav komentāru:

Ierakstīt komentāru