Search Wiki:

Huo Chess by Spiros (Spyridon) Kakos ( is a micro chess program in CLI C++ v8.0 that attempts to be smaller in size than the Commodore-era Microchess. The goal is to create the smallest chess program that exists. More versions are to come in the future.

I started developing the program in CLI C++ v8.0 (with Visual Studio 2008) and I named it "Huo Chess" for personal reasons.

Currently Huo Chess is 51.5 KB in size. The respective emulation of Microchess (the first microchess from the Commodore era) in C is 56 KB.
However, it must be noted that the original Microchess, written in pure Assembly, was about 1 KB (…something I believe no one will ever match!.
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.

For games played by Huo Chess and for an analytical explanation of its underlying logic, see

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

IMPORTANT NOTE by Author [Spyridon I. Kakos]: Huo Chess is intelligently designed, but it also evolves. Currently, the program is at version 0.5. If you happen to play with Huo Chess and find any problems (e.g. the program plays an illegal move in a certain position), make sure to tell me the moves played so that I can see what the problem is and try to fix it. Thanks in advance!
Last edited Feb 12 2008 at 3:27 PM  by Kakos, version 20
hgm wrote  Feb 5 2008 at 6:13 PM  
Why do you think 51KB is small for a chess program? I know many programs that are much smaller! What size aspect do you consider anyway? Is it the size of the source code, the size of the executable, memory footprint while running?

My own engine micro-Max 1.6 has a C source code of only 1,433 (non-blank) characters, and its (Windows 32-bit) executable measures only 7,144 bytes. (And more than half of that is C standard-I/O library; the uMax object file before linking is only 3KB.) And if Huo Chess is at the level of Microchess, then uMax 1.6 will eat it alive! Another small engine, which has an execuatble of 9.2KB (but is not open source) is PikoSachy. It plays at master level! So you still have a long way to go...

Kakos wrote  Feb 6 2008 at 12:35 AM  
First of all, thanks for the comments.
Secondly, you are right in saying that there are chess programs smaller than 51KB, such as the Microchess I mentioned above. That is what I am trying to achieve and surely a long way is ahead...
However you must bear in mind that the language in which the chess program is developed plays a vital role in the size: When developing in pure assembly for example, you will have a much smaller size, since no nonsence, non-needed libraries are incorporated in the final executable.
Huo Chess is only in version 0.5 because a lot of issues have not been dealt with yet. Future versions will come when I find time to improve the source code.
Again thanks for the time you spent seeing the code.

hgm wrote  Feb 6 2008 at 12:03 PM  
Well, I use gcc under cygwin, and you can limit the essential overhead to about 4KB there. (That gives you the run-time system, and library routines like printf() and getchar(). There is also an option there to optimize for most-compact code (rather than speed). Note that most people do not consider the 1.125KB version of Microchess a true Chess program, as it did not fully implement FIDE rules. For things like castling and e.p. capture you had to leave the program, and make use of the KIM-1 monitor routines to edit the board position. So one could argue that the monito ROM actually formed an integral part of the Chess program, so that it was not really 1.125KB at all. Note also that the Chess program for the Sinclair ZX81 was still smaller than Microchess (but also incomplete). The impressive thing about these early programs, on the other hand, was that this was not just code size, but total RAM usage.
How would a Windows program that had an 512-byte executable, but used 128MB of hash table fit your aim? Would you consider that smaller than Microchess, or larger?

Kakos wrote  Feb 6 2008 at 1:48 PM  
Your considerations are more than correct.
To sum up: The GOAL is to develop a fully-functional micro chess program with minimum source code size, executable size and memory footprint.
Chess programs extremely small in size but incomplete are certainly out of the way.
Chess programs developed in Assembly or C are again certainly the most possible winners...
What I am trying to achieve (but I am far away as we speak now...) is at least to minimize the source code size in C++/CLI 8.0, optimize the algorithm implemented and share the code WITH COMMENTS to the open source community. I know that 1KB is utopic for a program in a High Level Language...

hgm wrote  Feb 6 2008 at 2:55 PM  
For each of the targets (source, executable and footprint), you would probably have to make a different program. I only briefly considered the latter two goals: the executable size seemed a rather meaningless metric, as it is so platfom dependent. The footprint I only considered when someone asked me if I could write a Chess program for a micro-controller Chip (for in a game) that had only 256 (or even 128) bytes of RAM (but lots of ROM). So I concentrated on source code size as the most meaningful metric, in these modern days. And I always measure that size without the comments (although the micro-Max C source contains lots of comments).
Within those self-imposed rules, I have two developments. The one I consider most important (and most interesting) is the one that optimizes the strength (in Elo points) per character. That led to micro-Max 4.8, which has an Elo rating of slightly over 2000, (on the CCRL rating list) with only 1,965 characters. (Playing for a week on an Internet Chess Server against Humans it even reached a rating of 2260, both in blitz and 25-min games!) The other development goes for the minimum source size regardless of strength. That is currently micro-Max 1.6, where I eliminated the hash table (so that it also has a quite small footprint) and most of the search refinements and evaluation terms. That left 1,433 characters. It can still be made smaller, but I could not get myself to remove the alpha-beta pruning, as that uses only a dozen characters or so, and tremendously increases playing strength. Same for the Pawn-structure evaluation term, as removing that ~30 characters really makes it play like an idiot in the opening. The dissatisfying thing of only going for small size is that at some point it will just play like a random move generator (or worse yet, always play the first move with the leftmost piece, such as Akiba). But I don't think I could make even a random move generator of under 1,024 characters source in C. I am not sure about the footprint, though. It might be possible to get below 1KB when programming in x386 assembler.

Kakos wrote  Feb 11 2008 at 6:59 PM  
I am currently in the process of improving the AI algorithm as much as I can in C++ CLI. When I do that, then I will probable try to transfer the code to C to see how this port affects total source code and executable size, as well as the memory usage when the computer thinks its next move.

Hieronymus wrote  Jul 3 2008 at 7:17 PM  
Nice to see such a tiny chess program in C#. I am writing my own which runs on a GPU ( NVIDIA GeForce 8800) using CUDA ( see )

Kakos wrote  Jul 8 2008 at 2:53 PM  
The C# version of Huo Chess was posted yesterday on Happy reading and greetings! :)

Skurmedel wrote  Jul 16 2008 at 11:00 AM  
Arrogancy levels high on hgm. Constructive remarks: zero.

Anyway, this is a good engine, at least for someone with as mediocre chess skills as me. It could do with a good UI though, but that is not in the scope of this project I guess.

Kakos wrote  Aug 30 2008 at 9:24 PM  
Thanks for the feedback!
Indeed, a UI is at this moment out of the scope of the project. However, when the chess engine is developed beyond the point of 1.0 version (i.e. out of "beta" status), then a UI will be added to facilitate wider use.

motrek wrote  Nov 5 2008 at 9:38 PM  
It's nice to see someone get excited about chess programming. Instead of Microchess I would suggest Tom Kerrigan's Simple Chess Program (TSCP) as a tutorial. It's much smaller than your program by any metric (although it isn't designed to be small) and it's also much stronger.

Kakos wrote  Feb 1 2009 at 11:40 AM  



Date: 2009-01-25
Place: Athens, Greece
White: Microchess (as provided by BenLo Park)
Black: HuoChess v0.82 (with Opening Book)
Result: Draw by threefold repetition

1. e4 e6
2. Qh5 Qe7
3. Bc4 Kd8
4. d4 a6
5. Bf4 d5
6. exd5 f5
7. dxe6 Bxe6
8. Bxe6 g6
9. Qe2 Nd7
10. Bxc7+ Kxc7
11. Qc4+ Nc5
12. dxc5 Qg7
13. Qf4+ Kc6
14. Qf3+ Kxc5
15. Qd5+ Kb6
16. Qb3+ Kc7
17. Qc4+ Kd6
18. Qd5+ Kc7
19. Qc4+ Kd6
20. Qd5+ Kc7
21. Qc4+ Kd6
22. Qd5+ draw by threefold repetition

Huo Chess played a good game. It did not give up pieces without reason and did not lose chances to kill opponent’s pieces when possible.

Ladas wrote  Jun 22 2010 at 8:56 AM  
Hi Spyros, I love Huo chess and well done :) I was wondering how does it stand against other similar software? Why don't you plan a mobile version of the game? It can even make you good money ;)

Page view tracker