I am working on a project where I take a chess board position (FEN string converted to binary) & it's evaluation score and feed it to a neural network. My aim is to make the neural network differentiate between good and bad positions.

How I encode the position : There are 12 unique pieces in chess i.e pawn, rook, knight, bishop, queen and king for white as well as black. I encode each piece using 4 bits with 0000 denoting an empty square. So the 64 squares are encoded into 256 bits and I use 6 more bits to denote game state like whose turn it is to move, king-castle status, etc.

Problem : Since the input space for chess positions is neither smooth nor uni-modal (one small change in the board position can result in a huge change in the evaluation score), the neural network doesn't learn well. Now, the next logical thing to somehow extract useful features (like material difference, center control, etc) and feed it to the network.

I do not want to hand pick the features as I want the network to learn everything by itself. Therefore I am thinking of extracting features automatically using autoencoders. Is there any better way to accomplish this?

Summary : What is the best way to automatically extract features from a chess board position so that it can be fed into a neural network?

UPDATE : To generate training data, I have modified Stockfish to dump it's evaluation process into a log file. So every new move(position) it considers is written to a file as an FEN string along with it's eval score

  • What are you using for training data? Game results from each given position?
    – Jacob
    Feb 3, 2014 at 21:27
  • Does "I do not want to hand pick features" imply that you don't want the method to contain any chess knowledge? If so, I'm not sure chess.SE is the best place to get answers.
    – JiK
    Feb 3, 2014 at 21:32
  • 1
    If you don't start with known positional features, you will be asking your network to recapitulate centuries of chess theory just to get back to where we are now. A more fruitful approach (it seems to me) would be to start with every known positional feature and have your network learn which ones are important and in which situations.
    – Kyle Jones
    Feb 3, 2014 at 23:25
  • 2
    I am not confident that this is a good application for neural networks.
    – Tony Ennis
    Feb 4, 2014 at 0:41
  • 1
    To be accurate, you'll need more bits, number of moves since the last pawn was moved or piece captured and a bit if a pawn can capture another en passant.
    – Tony Ennis
    Feb 4, 2014 at 0:45

2 Answers 2


To evaluate a chess position, you need to add code that understands different (e.g. dynamic and static) aspects of chess positions. Small changes (e.g. a blunder) will cause a big change in the Engine score and thus change the evaluation completely. I think that you need to make a survey about static and dynamic aspects of chess positions and write code that will extract this information from every FEN string.

Examples of what to extract:

  1. Material balance
  2. Number of open files
  3. Number of semi-open files
  4. Total number of heavy pieces
  5. Total number of light pieces
  6. Total number of pawns
  7. Number of own pieces and pawns within three steps from the Kings
  8. Number of enemy pieces and pawns within three steps from the Kings
  9. Opening system that has been played in the game
  • thanks for the input @Rauan. But I was hoping to avoid explicit extraction. In the sense, the computer should figure out these by itself. Maybe it's too much to ask for :)
    – Rahul
    Feb 5, 2014 at 16:34
  • 1
    @Rahul To figure it out itself, it has to still have a wide choise of parameters to figure it out from...? It cannot pull parameters from thin air, as far as I understand. You should then provide it with 100 parameters and let it decide which ones are more significant and then train the network on this subset.
    – user2001
    Feb 5, 2014 at 16:36

I do not want to hand pick the features as I want the network to learn everything by itself.

There is an AI-Koan concerning this situation:

In the days when Sussman was a novice, Minsky once came to him as he sat hacking at the PDP-6.

"What are you doing?", asked Minsky.

"I am training a randomly wired neural net to play Tic-Tac-Toe" Sussman replied.

"Why is the net wired randomly?", asked Minsky.

"I do not want it to have any preconceptions of how to play", Sussman said.

Minsky then shut his eyes.

"Why do you close your eyes?", Sussman asked his teacher.

"So that the room will be empty."

At that moment, Sussman was enlightened.

Think about it.

  • I really like this answer, although it's probably a comment. Why waste years of knowledge and experience and reinvent the wheel...
    – Rafiek
    Feb 7, 2014 at 8:59
  • I think the point is that you have always "preconceptions", even if they are "random", even if you decide not to look at them.
    – Landei
    Feb 7, 2014 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.