When programming a chess engine, one of the main things one should take into account is to find a way to create solid positions that are safe for the computer, even without the computer “consciously” knowing it.
After every move, the position should be solidified in every possible way so that even if the algorithm does not compute a specific dangerous variant, the computer will still be OK. And the basic principle for doing that is only one: Interconnecting all the pieces!
Every single piece should be connected and defended by other pieces. All the pieces should form a web of protection for each other so that even if a move is misplayed, the danger is minimized.
Pawns should defend each other. Knights and rooks and bishops all connected.
Programming this interconnection in the chess program algorithm is a must if you are to create a successful program,. That being said, “Huo Chess” should be improved in that sense because this interconnection is not yet part of the algorithm yet (not everything fits within the few KB of the program).
In essence, the chess algorithm should assign more points to a position where the ‘interconnection’ is stronger and fewer points where the pieces are disconnected to each other.
Huo Chess note: The CountScore function is responsible for counting the score of each position. This function should be improved to count the interconnectedness of the pieces in the position.
There is a great chess game example that shows how important this notion of connecting your pieces is. One can view the game of Carlsen against Anish Giri in the Meltwater CCT Finals in 2021.
During that game, Carlsen sacrificed a queen for three pieces. In the moves that followed, Carlsen showed an excellent talent in connecting and orchestrating all his pieces together in such a brilliant way that the queen of Giri could do nothing to stop him from losing the game.
A study of the game in Lichess here can help you see the mastery of this principle by the former world champion.

In every move, Carlsen made sure that his knights were protecting each other, that the bishop was protecting the rook or vice versa and that the king was inside a protective cocoon, thus making it impossible for the queen and the rook of Giri to make any threats.


After some moves, the game was over and Carlsen won. This game is a must for studying how a chess program should play and position its pieces so as to have maximum safety after every move.
Interconnecting your pieces is the simplest and yet most effective way of playing good chess even if at some moves you might not play the best possible moves.
Chess programming tip: Coding the principle of interconnecting the pieces into a chess program is a matter of counting the ways pieces protect each other in the function related to counting the score of a position. The algorithm should scan the chessboard, find the pieces of the computer, find by how many pieces of the same color they are connected to and increase the ‘interconnectedness’ score accordingly.
Try to replay the Carlsen-Giri chess game with your chess engine and check how well it plays the moves according to the principle analyzed here. This would be a great test for how effective your coding is.
Keep experimenting…
Keep coding!
Leave a comment