# How to represent target variable for chess AI

Inspired by Google's recent AlphaGo project, I've decided that as a fun personal challenge I'd like to use deep learning and convoluted neural networks to build an algorithm that can beat an ordinary chess program when the difficulty is set to expert. I'm awful at chess and generally can't beat a computer beyond easy/medium, so making something that's a lot smarter than I am (at chess, at least) sounds fascinating.

Question: What should the target variable look like for predicting the next best chess move?

I've been building predictive models for a long time, but I can't wrap my head around this question. Some things that have me confused:

• I believe the target variable for Go is simply the entire grid of spaces on the board. In chess there are a limited number of legal moves, which continuously diminish as pieces are removed from the board throughout the game. How do I represent a shrinking target space?
• Not all pieces have the same set of rules (ex: queen vs knight). Do I need to somehow explicitly code these rules or will deep learning automatically learn them?

Notes:

• I know that alpha-beta pruning and quasi-brute-force search techniques have been shown to do well in chess, however, I specifically want to use deep learning instead.

• AlphaGo started with supervised learning (SL) on documented expert human moves to make a policy network, among other things. In my case, I'm just trying to do the supervised learning part, and when I do that, the target variable is difficult for me to define. That's the root of my question.

• What is the shape of your data? How are you representing a game or a single step in a game? Jun 27, 2016 at 21:08
• That's my question -- how I should shape my target data. Each record will be a single move. Jun 27, 2016 at 21:15
• I was surprised to see "convolutional neural networks" in your list. These neural networks were made for image classification, and I know they have been extended for things like text. But I see wikipedia says they have been used for Go. Impressive stuff! Jun 30, 2016 at 17:19
• Yeah, they're useful when spatial closeness is important. For example, a pawn on a square next to a queen Jun 30, 2016 at 18:21

See the following paper:

Giraffe: Using Deep Reinforcement Learning to Play Chess - Lai

• I just get a blank page when I click the link. Can you re-post it? Jun 27, 2016 at 21:46
• Thanks. It looks like a good study, and I've up-voted accordingly. I am still looking for a more explicit supervised learning representation of the target variable though Jun 28, 2016 at 0:11
• @RyanZotti: Take some time to actually read the above reference as there is a precise notion of score. Jun 28, 2016 at 0:13
• This is a link only answer. To make it a viable answer for the site, please summarise the key points that address the question. Jun 28, 2016 at 6:59

In a basic model, the target variable will be the score for a particular board position.

So let's have a closer look at the various parts of this sentence.

For score you could take any number, but the Giraffe paper suggests taking the winning chances in a given board position ( for instance a number between -1 and 1 ).

You will first need to determine all possible (legal) moves. Let's say you find 42 candidate moves. Each move corresponds to one board position. Each board position has one score ( = the target variable ).

So, you will have to predict a score for 42 board positions, and, in a simplified model, take the move which results in the highest score.

Before training a model, you will have to assign a score to board positions in a train set, in order to build your model and be able to make predictions on new board positions. So you will have to find a way to assign scores, either manually or by existing chess engines, or a combination of both.

By the way, the chess rules determine the possible legal moves, which is the first step and it's important.

There is more to it, but i hope this answers the question. This description will by itself not make for a high-ranking engine, but it might be a start for reasoning on how to build one.