IMPORTANT UPDATE: This code samples page is now
obsolete! Find the newer versions of Huo Chess at
http://code.msdn.microsoft.com/Huo-Chess-C-C-VB-micro-fea2bb87 or at
http://huochess.codeplex.com/. See a detailed explanation of the Huo Chess algorithm at
http://www.codeproject.com/KB/game/cpp_microchess.aspx.
C# Micro Chess (Huo Chess) C# Micro Chess is a free and fully open source micro chess engine. The C# Micro Chess presented in this page is a C# port of the
Huo Chess engine (
http://archive.msdn.com/huochess). Huo Chess is developed and maintained by Spiros (Spyridon) Kakos (
http://www.kakos.com.gr).
Please visit http://archive.msdn.microsoft.com/vbhuochess for the Visual Basic Edition of Huo Chess.Please visit http://archive.msdn.microsoft.com/xnahuochess for the XNA Edition of Huo Chess with Graphical User Interface. Currently C# Micro Chess (Huo Chess) is at version 0.82 at a total of
52.5 KB in size.
Huo Chess plays decent chess and has managed to
draw Microchess, but unfortunately will probably lose if it plays with Garry Kasparov :)
Its algorithm can be used to study the underlying logic of a chess program or as a basis for your own chess program. The source code is fully available and heavily commented.
The algorithm used in this program for the implementation of the computer thinking is the "Brute Force Algorithm." Huo Chess plays with the material in mind, while its code has some hints of positional strategic playing embedded.
More analytically: When the program starts thinking, it scans the chessboard to find where its pieces are (see
ComputerMove function) and then tries all possible moves it can make. It analyzes these moves up to the thinking depth I have defined (via the
ComputerMove ->
HumanMove ->
ComputerMove2 path), measures the score (see
CountScore function) of the final position reached from all possible move variants and – finally – chooses the move that leads to the most promising (from a score point of view) position (
ComputerMove function).
For games played by Huo Chess and for an
analytical explanation of its underlying logic, see
http://www.codeproject.com/KB/game/cpp_microchess.aspx. (that page refers to the Huo Chess C++ version, however it applies to the C# version as well)
For a tutorial on how to develop a chess software application on your own see the
How to Develop a Chess Program for Dummies tutorial at
http://knol.google.com/k/how-to-develop-a-chess-program-for-dummies#. This tutorial is based on the Huo Chess and it is written by the creator of Huo Chess himself.
Huo to customizeUse Microsoft Visual Studio 2008 or Visual Studio 2010 to customize the code.
You can use the
Huo Chess Opening Book Edition to create your personalized Opening Book for Huo Chess. You can find the Opening Book Editor at
https://archive.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=huochess&ReleaseId=404 at the MSDN Huo Chess C++ edition home page. The folder with the opening book entries must be in the same folder as the Huo Chess executable (see the Huo Chess Opening Book Editor page for more instructions).
You can also add more thinking depth capability, by adding new ComputerMove functions (like ComputerMove2, ComputerMove4 etc.), change the value of ThinkingDepth variable and make the necessary adjustments to the HumanMove function (add another if at the point where it calls the ComputerMove functions). Moreover, you can also optimize the way Huo Chess thinks by changing the CountScore function and the way the computer values the pieces or the chessboard position. For example, if you change the score of the Queen in the CountScore function from 9 to 12, then the HY will play aggressively to attack the opponent's queen and at the same time try harder to defend its own queen. You can also — for example — give a high scoring to the existence of an opening column with a rook controlling it, so as to make the computer play more with its rooks and try to take over columns with them. Any FEEDBACK is WELCOME with better configurations of the Opening Book or the CountScore function!
Prerequisites: The program requires .NET Framework 2.0 or higher to operate.