C#, C# programming, Chess, chess algorithm, chess source code in Java, free chess, how to create a chess program, how to program, Huo Chess, Java source code, open source, open source chess, open source chess in Java, programming
Huo Chess News
- 2019-02-21: The v0.992 has received initial operational capability. The algorithm now works for thinking depth of 5 half-moved, with thinking tree trimming applied. Still in progress.
- 2019-02-12: Huo Chess version 0.991 published. Now the algorithm performs as planned. Thinking depth limited to 3 half-moves.
Huo Chess Overview
The Huo Chess is one of the smallest open source chess programs in C#. It has heavily commented source code so that it can be used for teaching purposes on how to develop a chess program (or a program in general). It can be easily reused in other applications, e.g. to use it as a chess engine for a robot playing chess (see here).
Feel free to re-use it as you see fit (including changing it or selling it), as long as the source is cited properly. The goal is to spread the knowledge on the basics of chess programming, so sharing is important. Feel free also to contribute to the project, by contacting Harmonia Philosophica with ideas or code that can be used.
Tutorials on how to develop a chess program:
- How to develop a chess program for dummies series
- How to code a chess program in one day (C# and Java examples)
- Programming for kids: Developing a chess program in BASIC
Version 0.991 highlights
The new version of Huo Chess (v0.991) is small in size (as all the previous ones) and much more capable. The official edition with Windows Forms user interface is 78 KB in size, the Console application with a chessboard User Interface (UI) edition is 48 KB and the Console application with no chessboard UI edition is 45 KB in size.
Issues with the MiniMax thinking algorithm are fixed and now the computer makes logical moves in every circumstance (at least for the depth of 3 half-moves in which it thinks). Capability of thinking at depth of 5 half-moves is added but not activated (must change Thinking_Depth to 4 for that; note that the thinking starts from move 0). Opening book capability has been added again (this capability existed but was removed in version 0.980) (must have positions in the “Opening Book” folder to use it).
Additional to the above, a Developers Edition has been created, which includes analytic logs of the thinking mechanism for debugging (for teaching purposes). The logs can be easily activated or deactivated. This edition also takes a small step towards showing the variant which the computer thinks to the user interface.
The Opening Book editor is distributed separately. Along with the editor, a library of some sample opening book positions is also included in the distribution files.
Huo Chess editions
There are various Huo Chess editions, each one with slightly different User Interface, plus one for developing purposes.
Huo Chess v0.991 editions
- Huo Chess 0.991 with GUI: This version is the main version with a Windows Forms chessboard User Interface.
- Huo Chess 0.991 cs: Console application (text only).
- Huo Chess 0.991 cs with graphics: Console application, with minimum text-graphics to depict the chessboard.
- Huo Chess 0.991 Developers version: Full developers version with Windows Forms chessboard and logs to show the thinking mechanism. (Attention: Remember to delete the logs when needed, since their size can increase significantly)
The table here summarizes the features and the differences between the various v0.991 Huo Chess available editions.
Future versions candidate improvements
There is already a list of potential improvements for the next version of Huo Chess (0.992), which can be found below:
- Make it think up to a depth of 5 half-moves (this is actually equal to Thinking_Depth 4, since the thinking starts from move 0)
- Reduce size by improving ‘peripheral’ functions (like CheckForBlackMate, ElegxosNomimotitas et cetera).
- Update CountScore to calculate the score not as an integer but as a double, so that more fine-grained differences in the counting of the chessboard score can be introduced.
- Increase efficiency of MiniMax algorithm, by taking into account the average score of each branch. (code already in place, but commented out)
- Add neural network capability: This will be achieved at a very primitive level by having key points of the MiniMax algorithm (the inequalities at each node level analysis in ComputerMove) being dependent of values stored in external configuration files and by updating those files every time a game is played (increase ‘score’ if the game is a win, decrease if it resulted in defeat). This is still in preliminary stage, but I will try to have a relative Developer edition ready in the next version (without compromising the size).
- Improve CountScore function, to take into account the position of the chessboard, whether you move the same piece twice in the opening et cetera.
Distribution files include the following:
- Huo Chess 0.991 with GUI
- Huo Chess 0.991 cs
- Huo Chess 0.991 cs with graphics
- Huo Chess 0.991 Developers version
- Opening Book editor
- Opening Book
Feel free to contact me for anything regarding the code or the project in general. Remember that the goal is not only to create the smallest chess program but also to create a good basis for educational purposes.
Di mi se mai fu fatta alcuna cosa
(Tell me if anything was ever done to completion)
~ Leonardo da Vinci
Huo Chess v0.992 (Draft)
The version 0.992 of Huo Chess is in progress. Take a look at the progress of the project exclusively here at Harmonia Philosophica!
2019-02-21: Huo Chess v0.992 operational for 5 half-moves thinking depth, with thinking tree trimming. Need to optimize the trimming.
Note that this is a draft version which is still under development. Also please remember to delete the logs after some moves, or disable them completely if you want to play a full game. The size of the logs of the Developers edition can increase significantly after only some moves.
Huo Chess Java edition
The Java edition of Huo Chess is also developed in parallel with the C# versions. Currently, only the core engine with text interface with the user is developed in Java. Anyone willing to provide a GUI is more than welcome to do so. (I will try to do that as soon as I have time)
This code can be the basis for an Android Huo Chess application. I am currently working with Visual Studio and Xamarin framework to build it.
Instead of epilogue…
The ultimate goal is to go back to where I begun programming and fulfill my child dream: to create a chess program for Commodore 128. The porting of the current Huo Chess version to QBasic is currently in progress and then the road to porting to Commodore BASIC v7.0 is open…
And remember: Huo Chess was not made to be completed. But exactly the opposite: It is here to remind us all the constant struggle to perfection. A struggle so vain as any other human struggle and yet, a struggle so familiar and lovely.
Huo Chess will constantly be upgraded…
By me… By you… By everyone…
And year by year it will constantly be better and smaller…
Until there is nothing left…
Because at the end, the best chess game I will ever play will be that game I played as a child, with my father, trying to learn how to play…