Saturday 2:30 p.m.–2:50 p.m.

Using Machine Learning to play chess

Aubhro Sengupta

Audience level:


Today, chess engines contain many lines of code handcrafted under the guidance of grandmasters. Are you interested in being knee deep in chess theory just to crank out a half decent engine? No? This talk is for you. Why not create an engine that learns to improve itself?


Chess Engine Basics - 10 mins How do chess engines work? If you mean The Turk, a late 18th century automaton chess player who once played Napoleon, turns out it was a hoax. There was a human chess player hidden inside the whole time. Thankfully, computer chess has gotten better since then. A modern chess engine consists of several main components, an evaluation function, and a depth searching algorithm. A depth searching algorithm will look ahead a few moves and try to get to the best position possible, assuming the opponent plays well. Commonly an algorithm such as Minimax will be used to accomplish this. The evaluation function does exactly what the name implies. It takes a position on the chessboard and evaluates it for how good it is for a certain player. Basic evaluation functions sum up all the pieces on the board and subtract the sum of the opponent’s pieces, assigning a weight to each piece. This is where the handcrafted code from a human chess player gets put in. More complex evaluation functions can have many static lines of code that evaluate the board based on traditional chess strategy. This is where the hidden man lies in the automaton.

Applying Machine Learning to Create Better Evaluation Functions - 15 - 20 mins How do we make a chess engine come up with it’s own evaluation function based on its own strategy? With machine learning, we can do just that. With Python, we can utilize Tenserflow to create a neural network that takes in each square of the board as inputs and outputs how favorable the position would be to a specific player. Since chess is a win/loss game, over time, the network will learn what works and what doesn’t to be more effective. The cost function in this situation would be number of losses, and the algorithm would try to minimize it.

Questions/Demo - 5 mins I will take any questions and demo a chess engine I have built if time permits.