Share via


Chess in Silverlight 2

The Silverlight folks have created a chess-playing demo in Silverlight 2.

The game is here: https://silverlight.net/samples/sl2/silverlightchess/run/default.html (credits and other samples here)

Silverlight 2 (formerly 1.1), for those who don't know, is the version of Silverlight that supports the .Net framework. So the point of this demo is to demonstrate how much faster JIT-compiled managed code (C#) is than interpreted Javascript.  Each side can be played by a human, or by an implementation of a chess-playing algorithm written in either C# or JScript. Presumably, when played by the computer, each side is only given a specific amount of time in which to select a move. The quality of that move will depend on how many moves (nodes in the tree) the implementation can analyze in the allowed time. 

The screenshot below is a typical game (the .Net algorithm is playing white at the bottom). As you can see, the .Net implementation gets to analyze about 1000x more moves than the Javascript implementation in the time allotted. As a result, it invariably wins. 

image

Now, if you're a bit bored, you can try something mildly amusing. About half-way through the game, as the .Net side is moving in for the kill, click on the player buttons at the bottom and top to switch which implementation is playing which side. It can be interesting to watch the .Net implementation start trying to dig its way out of the hole. In most runs that I tried, it was usually able to pull out a win (though in one case, it was only able to force a stalemate).

PS. You'll need to install Silverlight 2 from here, if you don't have it.

 Updated 12/18/2008: Updated the post to the Silverlight 2 version (it used to refer to 1.1 Alpha, which was renamed to 2.0 when it shipped)

Comments