(Game) C# / C++ CLI Micro Chess (Huo Chess)
Game Development : C# / C++ CLI Micro Chess (Huo Chess)
Summary
Huo Chess is a chess program of just 52.5 KB in size. Three editions currently exist: two without graphical user interface (one in C++, one in C#) and one with Graphical User Interface (XNA based). Its current version (Huo Chess v0.82) can think up to 20 moves depth (10 half-moves for white and 10 half-moves for black pieces) and has an opening book capability. Huo Chess plays decent chess and has managed to draw Microchess, the first microchess from the Commodore era (see the Huo Chess Games Archive below).
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 heavily commented and easily customized). The source code is continually improving and is distributed under The Code Project Open License. In this article, I also analyze its programming logic, with emphasis on the general flow inside the computer’s "mind," from the initial scanning of the chessboard up to the final decision on which move to play. Any comments are welcome!
Versioning
Huo Chess is intelligently designed, but it also evolves. Currently, the program is at version 0.82. The timeline of versions and the respective changes conducted in the program's code are depicted below.
|
Version 0.82 |
Changed the ComputerMove, HumanMove, CountScore, ElegxosOrthotitas functions. Increased thinking depths from 8 to 20. Reduced the size by using a template ComputerMove function for all thinking depths (instead of ComputerMove2, ComputerMove4, ComputerMove6 etc). The C++ edition is still in 0.81 version (separate ComputerMove functions still exist), for educational purposes. Size of C# edition: 52.5 KB. |
|
Version 0.722 XNA |
Huo Chess (C# edition) with Graphical User Interface based on XNA. |
|
Version 0.722 cs |
Huo Chess port in C# programming language. |
|
Version 0.722 |
Fixed some issues with the HumanMove function. |
|
Version 0.721 |
More thinking depth analysis capability has been added to the program. Huo Chess uses the ComputerMove2, ComputerMove4, ComputerMove6 and ComputerMove8 functions to think at a depth of 8 moves (4 half-moves for the white and 4 half-moves for the black pieces). Size: 56.5 KB |
|
Version 0.6 (Micro edition) |
It was based on version 0.6. Reduced all string/text (i.e. "White Rook" => "WR"). Reduced the length of variable names (in every variable in the program, specific strings were replaced with smaller ones). Icon was replaced with smaller one. Removed all unnecessary files (resources, assembly.cpp, stdafx, etc.). Size: 47.5 KB |
|
Version 0.6 |
Removed the empty try...catch statement in line 3959 at HumanMove, which caused the bug at ElegxosNomimotitas not to show. Optimized the CountScore function. Fixed the bug at ElegxosNomimotitas in the part that checks moves of Rook-Queen-Bishop at lines 3143-32173. Added penalty in case the computer moves its pieces next to an opponent’s pawn. Made the computer eat the opponent’s queen when there is a chance. Lowered the value of the opponent’s king, so as to avoid the computer continuously going after him and sacrifice pieces for that. Optimized the CountScore_Human function. Size: 53.5 KB |
|
Version 0.5 |
Fixed HumanMove function. Optimized CountScore and ComputerMove functions. Size: 51.5 KB |
|
Version 0.4 |
Added random playing capability. Optimized CheckForWhiteCheck and CheckForBlackCheck functions. Size: 51.0 KB |
|
Version 0.3 |
Stronger playing capabilities. Added opening book capability. Optimized ElegxosNomimotitas and ElegxosOrthotitas functions. Size: 91.5 KB |
|
Version 0.2 |
Fixed some bugs due to which computer played illegal moves. Thanks to everyone who gave me feedback! Size: 99.5 KB |
|
Version 0.1 |
Initial version. Known problems: the program plays some illegal moves sometimes. Not too strong at all. 49.0 KB |
Courtesy: Codeproject.Com
- guru's blog
- Login or register to post comments

