Original code forked from http://code.google.com/p/spartak-chess r41