<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FORTH GO &#187; chessbox</title>
	<atom:link href="http://www.forthgo.com/blog/category/code/chessbox/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.forthgo.com/blog</link>
	<description>Code and Recreations of Xan Gregg</description>
	<lastBuildDate>Sat, 20 Aug 2011 17:32:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>GNU Chess Bugs</title>
		<link>http://www.forthgo.com/blog/2005/12/15/gnu-chess-bugs/</link>
		<comments>http://www.forthgo.com/blog/2005/12/15/gnu-chess-bugs/#comments</comments>
		<pubDate>Fri, 16 Dec 2005 01:50:07 +0000</pubDate>
		<dc:creator>xan</dc:creator>
				<category><![CDATA[chessbox]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.forthgo.com/blog/?p=85</guid>
		<description><![CDATA[After porting GNU Chess from C to Java a few months ago, I reported a few bugs and suspicious code to the GNU Chess mailing list. I&#8217;ve finally gotten around to making a bug write-up on this site.]]></description>
			<content:encoded><![CDATA[<p>After porting GNU Chess from C to Java a few months ago, I reported a few bugs and suspicious code to the GNU Chess mailing list. I&#8217;ve finally gotten around to making a <a href='http://www.forthgo.com/blog/gnu-chess-507-bugs/'>bug write-up</a> on this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.forthgo.com/blog/2005/12/15/gnu-chess-bugs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XBoard and GNU4J</title>
		<link>http://www.forthgo.com/blog/2005/07/22/xboard-and-gnu4j/</link>
		<comments>http://www.forthgo.com/blog/2005/07/22/xboard-and-gnu4j/#comments</comments>
		<pubDate>Fri, 22 Jul 2005 23:52:58 +0000</pubDate>
		<dc:creator>xan</dc:creator>
				<category><![CDATA[chessbox]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.forthgo.com/blog/?p=42</guid>
		<description><![CDATA[I realized I could run XBoard on my Mac within X11 and let it talk to <a href='http://www.chessbox.org/'>chessbox_gnu4j</a> via the command line  <a href="http://www.forthgo.com/blog/2005/07/22/xboard-and-gnu4j/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After I got the Java port of the GNU Chess engine working last month, I mentioned converting <a href='http://www.tim-mann.org/xboard.html'>XBoard</a> to Java to provide a GUI for the engine. These days I&#8217;m investigating using <a href='http://www.jinchess.com/'>Jin</a> as a GUI. Jin is a Java client app for Internet chess servers. The architecture is pluggable with plug-ins for <a href='http://www.freechess.org/'>FICS</a> and <a href='http://www.chessclub.com/'>ICC</a>. My plan is to make a plug-in for local engines, perhaps pretending to be other players on the network to play against.</p>
<p>Before doing any of that though, I realized I could run XBoard on my Mac within X11 and let it talk to <a href='http://www.chessbox.org/'>chessbox_gnu4j</a> via the command line like it talks to other engines. Putting the jar file in the same directory as XBoard, the command to launch XBoard and have it use the Java engine is:</p>
<p><code>   ./xboard -fcp "java -cp chessbox_gnu4j.jar org.chessbox.gnu4j.Main"</code></p>
<p>Playing this way uncovered a couple of bugs, which I have fixed. Taking back a move and starting a new game didn&#8217;t work. I&#8217;ve updated the download at <a href='http://www.chessbox.org/'>chessbox.org</a> to version 1.02.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.forthgo.com/blog/2005/07/22/xboard-and-gnu4j/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploring Minimax</title>
		<link>http://www.forthgo.com/blog/2005/06/13/exploring-minimax/</link>
		<comments>http://www.forthgo.com/blog/2005/06/13/exploring-minimax/#comments</comments>
		<pubDate>Tue, 14 Jun 2005 01:51:37 +0000</pubDate>
		<dc:creator>xan</dc:creator>
				<category><![CDATA[chessbox]]></category>

		<guid isPermaLink="false">http://www.forthgo.com/blog/2005/06/13/exploring-minimax/</guid>
		<description><![CDATA[I&#8217;ve been playing around with the GNU Chess code trying to understand the minimax algorithm and its alpha-beta pruning. The pruning offers a chance for a huge optimization if you can immediately refute candidate moves. Unforunately, refuting a move often &#8230; <a href="http://www.forthgo.com/blog/2005/06/13/exploring-minimax/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with the GNU Chess code trying to understand the <a href='http://en.wikipedia.org/wiki/Minimax'>minimax algorithm</a> and its alpha-beta pruning. The pruning offers a chance for a huge optimization if you can immediately refute candidate moves. Unforunately, refuting a move often requires finding the best response, which means searching the whole subtree, which defeats the purpose of the optimization. So implementers typically guess at the best refutations with checks, captures and moves that scored well in other subtrees (a.k.a. &#8220;killer&#8221; moves). My tinkering didn&#8217;t have any real impact on performance, but I&#8217;m getting a better idea about how things work.</p>
<p>Anyway, in the process of exploring the code, I noticed some of the output was being duplicated. I&#8217;ve posted a new version to <a href='http://www.chessbox.org/'>chessbox.org</a> with the minor bug fixes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.forthgo.com/blog/2005/06/13/exploring-minimax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Chessbox</title>
		<link>http://www.forthgo.com/blog/2005/06/06/introducing-chessbox/</link>
		<comments>http://www.forthgo.com/blog/2005/06/06/introducing-chessbox/#comments</comments>
		<pubDate>Tue, 07 Jun 2005 00:31:15 +0000</pubDate>
		<dc:creator>xan</dc:creator>
				<category><![CDATA[chessbox]]></category>

		<guid isPermaLink="false">http://www.forthgo.com/blog/2005/06/05/introducing-chessbox/</guid>
		<description><![CDATA[My Java port of GNU Chess is now available at a new domain name www.chessbox.org, which is just a redirect to www.forthgo.com/chessbox/. The tagline for chessbox is &#8220;a collection of chess pieces&#8221; allowing it to be a home for various &#8230; <a href="http://www.forthgo.com/blog/2005/06/06/introducing-chessbox/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My Java port of GNU Chess is now available at a new domain name <a href="http://www.chessbox.org/">www.chessbox.org</a>, which is just a redirect to <a href="http://www.forthgo.com/chessbox/">www.forthgo.com/chessbox/</a>. The tagline for chessbox is &#8220;a collection of chess pieces&#8221; allowing it to be a home for various open source chess programs that I (or friends!) might port/derive/create as time and interest allows.  The Java port of GNU Chess is now called &#8220;chessbox_gnu4j&#8221;. If you&#8217;ve got a better name, I&#8217;d like to hear it.</p>
<p>The code is released with the same license as GNU Chess, GPL. I&#8217;m not sure if I had a choice in the matter since it is clearly a derivative work of GNU Chess.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.forthgo.com/blog/2005/06/06/introducing-chessbox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Predictable Randomness</title>
		<link>http://www.forthgo.com/blog/2005/05/31/predictable-randomness/</link>
		<comments>http://www.forthgo.com/blog/2005/05/31/predictable-randomness/#comments</comments>
		<pubDate>Wed, 01 Jun 2005 00:47:40 +0000</pubDate>
		<dc:creator>xan</dc:creator>
				<category><![CDATA[Chess]]></category>
		<category><![CDATA[chessbox]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.forthgo.com/blog/2005/05/26/predictable-randomness/</guid>
		<description><![CDATA[One GNU Chess source file I didn&#8217;t port to Java was the random number generator, and that turned out to be a problem for processing the binary opening book files. The board position hash codes are 64-bit numbers created by &#8230; <a href="http://www.forthgo.com/blog/2005/05/31/predictable-randomness/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One GNU Chess source file I didn&#8217;t port to Java was the random number generator, and that turned out to be a problem for processing the binary opening book files. </p>
<p>The board position hash codes are 64-bit numbers created by xor&#8217;ing a set of hash codes that come from the random number generator. These hash codes are written to the binary book file, so in order to read a binary book file, you have to get the exact same sequence of &#8220;random&#8221; numbers from your random number generator. So I ported over the random number algorithm and was then able to read the binary book files which allows the program to play moves from the opening book.</p>
<p>I also got PGN file reading working, so I don&#8217;t know of any remaining functional issues (except for the i/o handling, especially control-C, which I may just ignore).</p>
<p>I tried the program on the 300 &#8220;Win at Chess&#8221; problems.  The Java version got 278 correct, and the C version got 284 correct. Both used 5 seconds per move on my Mac G5.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.forthgo.com/blog/2005/05/31/predictable-randomness/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8220;Jnuchess&#8221; Plays and Wins</title>
		<link>http://www.forthgo.com/blog/2005/05/23/jnuchess-plays-and-wins/</link>
		<comments>http://www.forthgo.com/blog/2005/05/23/jnuchess-plays-and-wins/#comments</comments>
		<pubDate>Mon, 23 May 2005 23:25:25 +0000</pubDate>
		<dc:creator>xan</dc:creator>
				<category><![CDATA[Chess]]></category>
		<category><![CDATA[chessbox]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.forthgo.com/blog/2005/05/22/jnuchess-plays-and-wins/</guid>
		<description><![CDATA[The Java port of GNU Chess is now doing well enough to play a game and beat me. To get the main alpha-beta engine to work I had to track down about a half-dozen or so translation errors I had &#8230; <a href="http://www.forthgo.com/blog/2005/05/23/jnuchess-plays-and-wins/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Java port of GNU Chess is now doing well enough to play a game and beat me. To get the main alpha-beta engine to work I had to track down about a half-dozen or so translation errors I had made in going from C to Java. Fortunately, I got the C version to build under Xcode, which gave me a IDE with debugger that I could use to compare my code with the C code as they were both running.  Just as fortunately, most of the errors made themselves felt pretty early in the move evaluation process, so it wasn&#8217;t too tough to track down what was going wrong by narrowing the window between when things were good and when they were bad.</p>
<p>There are several sets of &#8220;find the best move&#8221; problems that are used for evaluating chess programs. With 5 seconds per problem for the &#8220;BT2630&#8243; set, my Java version of GNU Chess gets 7 out of 30 correct (10 if I increase the hash table size from 1K to 16K entries, and 16 if I give it about 30 seconds per problem), and the C version gets 11 out of 30 correct (12 with the bigger hash table).  The C version is still running about twice as fast at processing positions.  The hash table management appears to be a place where improvement is possible.</p>
<p>The toughest errors to track down were those that originated in the C source. In one case the Java version would get an IndexOutOfBounds exception evaluating a position, and it turned out the position was invalid as there was a black pawn on its eighth rank (it hadn&#8217;t been promoted). It made me feel a little better than the C code had the same problem, except that negative array indices executed silently there. I couldn&#8217;t find any problem with the move generation code or the move execution code, but I eventually found that there was a backdoor for stale moves to enter into consideration. </p>
<p>Moves in the hash table that were once good &#8220;killer&#8221; moves would be considered later even if the board had changed, as long as they were still legal. So at some point a move such as g2-g1 would make it on the list with a rook on g2. Later the move would be considered again when a black pawn was on g2, and the legality-checking code wasn&#8217;t watching for such a pawn move (since none would be generated by the move generator without also setting the promotion info). So a fix to <code>IsLegalMove</code> finally got things going.</p>
<p>Everything I test shows new errors, and now I&#8217;m seeing problem processing the opening book&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.forthgo.com/blog/2005/05/23/jnuchess-plays-and-wins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GNU Chess/Java Starts to Run</title>
		<link>http://www.forthgo.com/blog/2005/05/16/gnu-chessjava-starts-to-run/</link>
		<comments>http://www.forthgo.com/blog/2005/05/16/gnu-chessjava-starts-to-run/#comments</comments>
		<pubDate>Tue, 17 May 2005 02:24:11 +0000</pubDate>
		<dc:creator>xan</dc:creator>
				<category><![CDATA[Chess]]></category>
		<category><![CDATA[chessbox]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.forthgo.com/blog/2005/05/15/gnu-chessjava-starts-to-run/</guid>
		<description><![CDATA[I decided to go ahead and convert the remaining printf() calls (too chicken to try switching to Java 5 at this point) and ignore the signal() calls so I could try running GNU Chess/Java. The signal() calls are only used &#8230; <a href="http://www.forthgo.com/blog/2005/05/16/gnu-chessjava-starts-to-run/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I decided to go ahead and convert the remaining <code>printf()</code> calls (too chicken to try switching to Java 5 at this point) and ignore the <code>signal()</code> calls so I could try running GNU Chess/Java. The <code>signal()</code> calls are only used for handling control-C to allow interupting of the think process. Not sure what the Java equivalent would be. </p>
<p>For a while, I would get early crashes when trying to run. Usually these were NullPointerExceptions due to uninitialized array members. IndexOutOfBounds errors were a little trickier to fix, and for one of them I had to actually run the C version to compare values.  Turns out the array index was -1 there, too!  I&#8217;ve already marked a half dozen or so places where the C code looks suspicious, so I think this effort will unearth a few problems in the original source.</p>
<p>There were a couple of errors to get around when trying to build the C version, which I&#8217;m guessing are due to different versions of the developer tools on Mac OS X 10.4.  There is also a problem running the C version. It seems to process one command and then get a bus error. Coincidentally, the Java version has a similar problem. After processing one command, it gets lost trying to look for more input &#8212; there&#8217;s some threading issue going on.</p>
<p>The program has some self-test commands that I was able to use to compare speeds.  The Java version appears to be about half the speed of the C version. Some results</p>
<table>
<tr>
<th>Test</th>
<th>C</th>
<th>Java</th>
</tr>
<tr>
<td>movegen</td>
<td>34M moves/sec</td>
<td>16M moves/sec</td>
</tr>
<tr>
<td>eval</td>
<td>217K evals/sec </td>
<td>110K evals/sec</td>
</tr>
</table>
<p>Not bad. </p>
<p>Other tests, which actually try to find the best moves, are crashing &#8230;. If I can get past that, I may need a catchy name for this project. Jnuchess?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.forthgo.com/blog/2005/05/16/gnu-chessjava-starts-to-run/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

