How Does Beth Harmon's Chess AI Work?

How Does Beth Harmon's Chess AI Work?

I play chess, albeit not all that well. I started when I was really young, around 6 or 7 years old, and reached a max rating of 1450 (more on this later). The Queens Gambit took the world by storm, reaching an unprecedented audience of 62 million within its first month. The show has brought a newfound love for chess, and chess.com has reported a staggering 160% increase in the number of chess games since last year. This may leave beginners wonder, how can I play the fictional Beth Harmon on chess.com? Let's dive into what defines a good chess player, a brief history of chess artificial intelligence, and how they work.

What constitutes a good chess player?

A game can end one of three ways: win, lose, or draw. Winning will increase your ranking, losing will decrease it, and drawing can do either (depending on your opponent's ranking). Now lies a common issue, how do we rank millions of people? ArpadElo.jpg

This is a photo of a chess master, Arpad Elo, who won the Wisconsin State Championship 7 times. He presented the ELO system in 1960 to provide a better way to rank players. The system uses some complicated algebra to calculate your new rating after every game. Players usually start at 1200 and can go up or down from there. At first, your initial ranking is very volatile as the number of games is an important factor in determining your rank. As you play more and more games, it is harder to move up or down. The diminishing returns make sense, as you play more games you should start to level out at your true ranking. Here is a distribution graph of USCF (United States Chess Federation) rankings: chessDistribution.png

0-1000: Beginner - players fall for simple traps, and are missing tactical and positional understanding.

1000-1400: Novice - players are learning better tactics, and likely learning some of the common openings.

1400-1800: Advanced - the strength range of players is definitely widening, and the differences in rating become much larger. The difference in skill between 1800 vs 1400 is much larger than 1400 vs 1000. This follows my earlier comment on the diminshing returns of chess rankings. Many strong club players fall into this range.

1800-2200: Expert - the competition at this level is fierce, and right below the master level. Knowledge of openings, tactics, and positioning are really cemented here.

2200-2500: Master - players with these ratings have been playing for a long time, and can read multiple moves ahead. They are multiple different mastery titles, including CM, FIDE, and IM (international master).

2500+: Grandmasters - these players reign supreme, usually with the prestigious title of Grandmaster. There are an estimated 800+ million chess players in the world, and only 1500 Grandmasters. That is a very, very small fraction of players. The best player in the world, Magnus Carlsen, achieved a peak rating of 2882 in 2014.

The History of Chess AI

How can machines play chess? Well, as you may have guessed, lots of complicated math and computer science. The first algorithm built to play chess was constructed in 1950 by the father of computer science, Alan Turing. Turing's algorithm never actually ran on a computer. The first program that could play a full-length game, beat a human, and run on a computer was the Mac Hack VI built by MIT student Richard Greenblatt in 1967. It was monumental, and the system achieved a ranking of 1529... the average for the USCF was 1500. Mac Hack VI became the world's real first chess engine.

How Chess Engines Work

Chess engines use many complex algorithms to find their desired move, but a general consensus is that they are trying to maximize their score and minimize their opponents. It's done by searching through the possible moves and then playing the move with the best score.

chessgif1.gif

Imagine a chess game as a path. Each move takes you down a different path, and each board state represents the potential for billions of different paths. If you're a bit confused, take a look at this tree structure. It is commonly used in computer science algorithms and can help us visualize what many chess engines do.

ternary tree.png

Here, each node could represent a move, and the value of the node is the score of the move. This is known as a tree data structure, and it has proven extremely valuable for computers. One example is the file system. Each folder leads to other folders and files, and then those folders lead to more files and folders, etc. Trees for chess games are insanely large, but through different tricks, we can reduce the size of the tree which allows the computer to run through more moves.

Computing power and sophisticated algorithms proved to be the bottlenecks for the evolution of chess AI. As they improved, chess engines' capability and rating proportionally increased. Then, 30 years after the first machine beat a human, Deep Blue defeated the world champion, Garry Kasparov, in 1997. The landmark event changed chess. Humans were no longer the best at it, and the best-known chess player is now Stockfish.

Can You Beat Beth Harmon?

By controlling the chess engine's parameters, we can change the strength of their play. Now, when you play against different versions of Beth Harmon, you can appreciate the chess engine behind it.

Thank you for the read!