Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to program a neural network for chess?

I want to program a chess engine which learns to make good moves and win against other players. I've already coded a representation of the chess board and a function which outputs all possible moves. So I only need an evaluation function which says how good a given situation of the board is. Therefore, I would like to use an artificial neural network which should then evaluate a given position. The output should be a numerical value. The higher the value is, the better is the position for the white player.

My approach is to build a network of 385 neurons: There are six unique chess pieces and 64 fields on the board. So for every field we take 6 neurons (1 for every piece). If there is a white piece, the input value is 1. If there is a black piece, the value is -1. And if there is no piece of that sort on that field, the value is 0. In addition to that there should be 1 neuron for the player to move. If it is White's turn, the input value is 1 and if it's Black's turn, the value is -1.

I think that configuration of the neural network is quite good. But the main part is missing: How can I implement this neural network into a coding language (e.g. Delphi)? I think the weights for each neuron should be the same in the beginning. Depending on the result of a match, the weights should then be adjusted. But how? I think I should let 2 computer players (both using my engine) play against each other. If White wins, Black gets the feedback that its weights aren't good.

So it would be great if you could help me implementing the neural network into a coding language (best would be Delphi, otherwise pseudo-code). Thanks in advance!

like image 344
caw Avatar asked Apr 15 '09 22:04

caw


People also ask

Can a neural network learn chess?

Yes, although the idea of a neural network is that it should be able to generalise given a limited training set. A lot depends on the complexity of the function you are trying to fit, which in the case of chess will be insane.

How do chess neural networks work?

This just means that a neural network is given a chess position, and is designed to output a move and an evaluation. Math-folk might recognize that what we require is a function with a domain of chess positions, and a range of legal moves and evaluations. Obviously, a physical chessboard can't be used in an engine.


1 Answers

In case somebody randomly finds this page. Given what we know now, what the OP proposes is almost certainly possible. In fact we managed to do it for a game with much larger state space - Go ( https://deepmind.com/research/case-studies/alphago-the-story-so-far ).

like image 97
siemanko Avatar answered Sep 27 '22 21:09

siemanko