You are currently viewing How do computers play chess?

How do computers play chess?

“Ugh! I can’t believe I lost AGAIN!” Rita growled at her computer screen. Her younger sister, who had just walked into the room, looked curious. “What are you upset about? What did you lose?” she asked. Rita turned to her and whined, “I thought I would improve my chess skills by practicing against the computer, but I’ve already played three games and haven’t won ONCE!” Her sister giggled. “You never won a game against our cousin Raju either!” Rita glared at her. “I may be playing against a computer, but it plays just as well as Raju does!” 

Have you ever been in Rita’s shoes? Lost a game of chess against a computer? If you have, then did you ever question the reason behind it? A computer doesn’t have hands or fingers, but it can play chess with you like a pro! It’s time to uncover the answer as to why that is the case!

A Mechanical Turk
| Photo Credit:
WIKIMEDIA COMMONS

Chess-playing Turk

Before we uncover the mechanisms and programming behind computer chess, let’s take a few steps back in time to discover how the gameplay was first automated. There was once a chess-playing machine known as the Mechanical Turk, first displayed in the year 1770. It showcased what appeared to be an automated chess game with a life‑size figure of a human in robes and a turban seated on the opposing side. This mechanical figure would be pitted against participants in games of chess and would display head movements to signal the opponent’s threatened queen and whether its pawn was in ‘check’. This machine is said to have won in an exhibition against Benjamin Franklin! However, the secret behind it was discovered to be a hoax, as the chess movements by the constructed figure were actually being controlled by a chessmaster hidden within a compartment in the machine, who had secret visual access to the chessboard and would use a system of levers to make the move. The secret of this trickery had been kept for many decades. 

The interior of El Ajedrecista

The interior of El Ajedrecista
| Photo Credit:
WIKIMEDIA COMMONS

The first machines

The actual first automated chess-playing device was El Ajedrecista, which was built in 1912 by Leonardo Torres Quevedo, a Spanish engineer. Here, the game was simplified with only three chess pieces (two white pieces, including a rook and a king, against a black piece of the king), and no concealed humans! The machine could detect the moves of an opponent through the electric contacts under the board. Based on what it detected, it would move its own pawn through an internal mechanism. Following this, many attempts were made by chess enthusiasts and computer engineers to develop chess-playing programmes. In the year 1950, mathematician Claude Shannon published Programming a Computer for Playing Chess, one of the first papers that dove into the methods and mechanisms incorporated in computer chess. The following year, computer scientist and mathematician Alan Turing created and published ‘Turochamp’, the first ever programme that could play a full game of chess!

1990s pressure-sensory chess computer with LCD screen

1990s pressure-sensory chess computer with LCD screen
| Photo Credit:
WIKIMEDIA COMMONS

Breakdown 

Now that we have seen the history, it is time to discover exactly how a computer can observe, analyse, and implement opposing moves in a chess game. The answer to that lies in two words: “chess engine”. It is a computer programme that analyses and calculates the strongest and most efficient moves, as well as future sequences. There are four main parts involved in the composition of this engine: 

The board, which stores the positions of all the chess pieces internally within the engine.

The move generator, which is responsible for coding and generating all the legal moves based on the positioning of the pieces on the board. This part of the engine is normally designed to be fast. The code is also always checked for bugs.

The evaluator calculates the current score of the state of the board. If it shows a score of 0, then that means that there is an equal chance of a favour for each side. Numbers and scores are assigned to chess positions. 

The search algorithm, which is what allows the computer to scan across millions of possible movement options within mere seconds. It utilises the Minimax Algorithm, where it explores a ‘game tree’ to select the move to use against the opponent. 

Databases

While calculation and analysis are major contributors to a computer’s programming to play chess, it must also be understood that chess engines require pre-existing knowledge of the gameplay. For this, they utilise databases that hold information to improve speed and accuracy. There are two main sources involved: The first is the opening book, which consists of a compiled list of strong and efficient opening moves, which helps the engine understand the opening phase of the game. With this database, it won’t need to calculate the opening moves from scratch with no prior knowledge. The second database is the endgame tablebase, which provides assistance in the final stages of the game. It contains a list of the calculated outcomes of every possible position with very few pieces remaining on the board. It will help the engine understand whether a certain position means a win, loss, or a draw. 

David Levy, the chess champion who made a bet that he would not be beaten in a chess match with a computer in the following 10 years.

David Levy, the chess champion who made a bet that he would not be beaten in a chess match with a computer in the following 10 years.
| Photo Credit:
WIKIMEDIA COMMONS

Computer vs human

While the prediction of a computer beating the world human chess champion by 1967 was made in 1957 by a team at Carnegie Mellon University, it was a year following that deadline in 1968 that Scottish International Master (chess champion) David Levy made a famous bet with computer scientist John McCarthy and AI researcher Donald Michie that he would not be beaten in a chess match with a computer in the following 10 years. Within this time span, many developments had been made to the engine, to the point where it began defeating incredibly skilled humans in matches by the 1970s! It soon seemed like the software was turning into a threat against Levy’s win, but believe it or not…he won the bet! In the year 1978, he secured his double victory by winning against the Chess 4.7 programme in a six-game match by a score of 4.5-1.5! However, despite its ultimate loss, the programme still secured a legendary victory of its own by becoming the first computer to win against a Master-class player at the tournament level, as it had beaten Levy in one of the six games under blitz conditions (speed chess). Levy secured the victory in his bet that day, but there were, in fact, two legends at that tournament!

Published – July 20, 2026 08:00 am IST

Leave a Reply