, , , , , , , , , , , , ,

Huo Chess News

  • 2021-01-06: Fixed initialization of nodes 3 and 4.
  • 2020-09-03: Minor updates.
  • 2020-08-10: Updated the countScore function that evaluates positions to include also qualitative criteria for the position.
  • 2020-08-03: Minor updates to the v0.992 Developers Edition. The trimming rules have been updated to enable deeper thinking.
  • 2019-02-21: The v0.992 has received initial operational capability. The algorithm now works for thinking depth of 5 half-moves, with thinking tree trimming applied.
  • 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.

Huo Chess sites

You can download the latest files via the relative sites:

Alternatively you can download it below.

Huo Chess-based tutorials

Over the years I have written several tutorials on how to develop a chess program based on the Huo Chess.

Tutorials on how to develop a chess program include:

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).

How to Develop a Chess Program for Dummies 3

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.
HUO Writer: A simple AI writer with basic Neural Network capabilities (QB64)

Distribution files

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!

2020-09-03: Minor updates.

2020-08-03: Huo Chess v0.992 operational for 5 half-moves thinking depth. Updated the trimming of the tree with three different set of rules.

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 Opening Editor

From the beginning of the Huo Chess project (well, almost from the beginning), an opening functionality was developed. The opening book of Huo Chess is edited with the help of a dedicated tool: the Huo Chess Opening Editor. Simply run the tool, play the moves by selecting “Opening mode” and all the moves will be stored as suggested moves for the computer in its opening book.

There is a C++ (cpp) and a C# (cs) version of the tool, which can be both downloaded below.

The tools generate txt files which hold the positions of the opening book, along with the suggested moves for each position. Note that there must exist a ‘Huo Chess Opening Book‘ folder in the same folder as the application for the latter to store the opening book files.

How to code a chess program in one day. (C# and Java examples)

Make sure you keep checking back in this page for more updates.

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.

Huo Chess QBasic edition

The Huo Chess has been written in QBasic as well. Yes, you read it right! The old friend from the past, BASIC, is still alive and kicking!

You can find the code below. Along with the games’ source code, an opening editor is also distributed. Both work in the same way the C# edition works.

Feel free to write to me for any comments or suggestions.

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…