The project is still in pretty early stages, so don't expect it won't take down any strong chess players yet, but I'm hoping that with a bit of effort it will be possible for neural networks to do for chess what they have recently done for Go.
1) Its not open source. I'll consider releasing the code at some point when the project is more mature.
2) The Go engine has a lot of pieces I don't have yet. What I have is similar to the policy network from the Go engine, but right now I don't have anything like the value network or the rollout parts. Also,
3) The current engine has no search at all. Behind the scenes the network ranks all of the moves, and then I walk down the list and choose the highest ranked legal move. The top ranked move is almost always valid, but occasionally one or two need to be rejected. It's very very rare to need to search outside of the top 5.
Search is definitely on the agenda, but I am pleasantly surprised at how well it plays without it.
Very interesting! It played very natural, "human" positional moves and defended against most obvious threats. There was one exception, where it played a move that looked normal for the position--developing a piece in the opening--but it also hung the piece. That was the only serious blunder, every other mistake was in tactical lines more than one or two moves deep.
That seems to make sense for being trained by a NN, still impressive how well it was able to spot concrete threats! Thank you for sharing.
I've noticed it making quite a few errors like the one you mention. I think that a little bit of search (say just one or two ply) will help a lot with avoiding this kind of mistake, because the network seems very good at recognizing when a piece is in trouble if you show it the position.
One remark: although I'm admittedly a poor chess player, I managed easily to get a draw by threefold repetition even though Spawkfish could have avoided that easily (and still destroy me). Am I correct to assume Spawkfish don't take past moves into accounts?
4R2k/p5p1/7p/n4Q2/7q/2PP1P2/Pr3P1P/5RK1 b - - 6 27
EDIT - for context, I was about 1900 USCF in my prime 20 years ago - still do puzzles daily.
In any case, I think this is cool. I was also surprised it managed to play efficiently given the load you must be feeling from HN. Thanks for making this and showing it!
Normally against a chess computer, you try to play positionally and avoid tactical situations - i.e. you avoid its strengths and target its (relative) weakness.
It is nice (and also rather uncanny) to be in the opposite situation here. Positionally it looks good, tactically, not so good.
That was really impressive. Other than playing very accurately, I felt it played far more human-like than most computer chess engines.
I've written several chess engines, and have often wondered for some time whether or not there was a chance for a more AI/pattern-driven approach.
Are you using your AI just for evaluation? E.g. do you have a traditional PVS/negascout (or similar) search? Presumably an 'extreme Type C' (no search) would fail to recognise various draws (50 move/repetition)?
Right now I have just about as close to an "extreme type C" engine as possible. There is a neural network that maps from a board position directly to a ranked list of moves it wants to make., and a little bit of logic on top of that to reject illegal moves.
The recognition of wins/draws/losses is actually done in a layer around the engine, which doesn't understand these things yet. One of "tricks" it is vulnerable to right now is being forced into a draw by repetition, because doesn't know that is a thing to avoid.
Adding a more traditional search (augmented by the network, of course) is on my todo list, and I think it will improve the playing strength a lot. I am pleasantly surprised though, at how well it plays without any of that.
It would be interesting to see how strength and "human like play" scales with the depth of the search.
There's also a really interesting possibility in training policy networks with different attributes by using games from players with certain styles of play.
Training different policies in different styles is a really interesting idea. You could then have a gating process that first chooses the "style" of move to make and then uses the style-specific network to select a move.
I think getting data for this could be difficult though. I wonder how easy it would be to automatically categorize a game record by "style"?
I don't know a lot about chess, but I would try picking several prolific players with what seem to you to be different styles, and training a classifier to identify the player, as an experiment in viability.
Or, rather than multiple policies, one policy that takes a player vector as an input along with the board position. Players that you predict will make the same move from a given board have their vectors adjusted toward each other and away from a random sample of other player vectors.
If it works, you would be able to perform player vector math ala word2vec. (No idea if it will work)
Very nice! The only thing missing is a Back button to allow me to back out of mistakes. :-)
I believe that chess follows the state of the art in AI. The first wave of success was based on brute force of computing better than people. Now it's harnessing insight. Keep up the interesting work!
In my game[0] it played well until it hit a position where it seemed to run out of ideas. At that point, it let me take its queen for a rook. The strange thing was that it felt like playing my five year old, who also plays well until he runs out of ideas and then just sacrifices a piece.
It also missed the kind of tactics that my kid misses and played surprisingly human like mistakes. Note move 35... Rxf2, as if it forgot about the bishop because it had moved to the other end of the board. That's the kind of mistake a human player might make and computers never do.
It strikes me that this would be a great engine for my five year old to practice against. I'd love to see it added to lichess or put into a phone app for that purpose.
I won (hardly, after I had 3 pawns against a knight during mid game) and I don't think I'd reach 1600 elo if I were to play in tournaments. My elo is about 1620 on chesstempo, where I solve tactics quite often (daily, during the last 8 weeks or so)
Very nice! It may be annoying, but I think at some point you really will need to keep track of castling rights and en-passant (position repetition is much harder but I don't think it is so necessary). Some evaluations depend very heavily on them.
Seems very interesting, I really think these approaches will work rather well on a variety of games. Very exciting times. Btw, there is another already Open Source Neural Network Chess engine that might be worth exploring for similar ideas. That codebase already has a minmax search based on the network evaluation. Paper is at: http://arxiv.org/abs/1509.01549 Code is at: https://bitbucket.org/waterreaction/giraffe
27 comments
[ 3.0 ms ] story [ 71.7 ms ] threadI lost, but I'm bad at chess.
The project is still in pretty early stages, so don't expect it won't take down any strong chess players yet, but I'm hoping that with a bit of effort it will be possible for neural networks to do for chess what they have recently done for Go.
1) Is it open source? Link to github?
2) Is the architecture similar to the go engine?
3) is there an alpha-beta pruning search tree at the core? If so, is that part from an exising engine?
4) do you have an estimate of its elo rating?
5) are you training or have you trained on available data sets? Are you training on user games? Are opening and closing libraries used?
2) The Go engine has a lot of pieces I don't have yet. What I have is similar to the policy network from the Go engine, but right now I don't have anything like the value network or the rollout parts. Also,
3) The current engine has no search at all. Behind the scenes the network ranks all of the moves, and then I walk down the list and choose the highest ranked legal move. The top ranked move is almost always valid, but occasionally one or two need to be rejected. It's very very rare to need to search outside of the top 5.
Search is definitely on the agenda, but I am pleasantly surprised at how well it plays without it.
4) Not yet :)
5) I'm using kingbase for training data (http://www.kingbase-chess.net/)
That seems to make sense for being trained by a NN, still impressive how well it was able to spot concrete threats! Thank you for sharing.
(My elo is 2150ish)
I've noticed it making quite a few errors like the one you mention. I think that a little bit of search (say just one or two ply) will help a lot with avoiding this kind of mistake, because the network seems very good at recognizing when a piece is in trouble if you show it the position.
One remark: although I'm admittedly a poor chess player, I managed easily to get a draw by threefold repetition even though Spawkfish could have avoided that easily (and still destroy me). Am I correct to assume Spawkfish don't take past moves into accounts?
4R2k/p5p1/7p/n4Q2/7q/2PP1P2/Pr3P1P/5RK1 b - - 6 27
EDIT - for context, I was about 1900 USCF in my prime 20 years ago - still do puzzles daily.
In any case, I think this is cool. I was also surprised it managed to play efficiently given the load you must be feeling from HN. Thanks for making this and showing it!
It is nice (and also rather uncanny) to be in the opposite situation here. Positionally it looks good, tactically, not so good.
A great project!
I've written several chess engines, and have often wondered for some time whether or not there was a chance for a more AI/pattern-driven approach.
Are you using your AI just for evaluation? E.g. do you have a traditional PVS/negascout (or similar) search? Presumably an 'extreme Type C' (no search) would fail to recognise various draws (50 move/repetition)?
Good work :-)
Right now I have just about as close to an "extreme type C" engine as possible. There is a neural network that maps from a board position directly to a ranked list of moves it wants to make., and a little bit of logic on top of that to reject illegal moves.
The recognition of wins/draws/losses is actually done in a layer around the engine, which doesn't understand these things yet. One of "tricks" it is vulnerable to right now is being forced into a draw by repetition, because doesn't know that is a thing to avoid.
Adding a more traditional search (augmented by the network, of course) is on my todo list, and I think it will improve the playing strength a lot. I am pleasantly surprised though, at how well it plays without any of that.
There's also a really interesting possibility in training policy networks with different attributes by using games from players with certain styles of play.
I think getting data for this could be difficult though. I wonder how easy it would be to automatically categorize a game record by "style"?
If it works, you would be able to perform player vector math ala word2vec. (No idea if it will work)
I believe that chess follows the state of the art in AI. The first wave of success was based on brute force of computing better than people. Now it's harnessing insight. Keep up the interesting work!
It also missed the kind of tactics that my kid misses and played surprisingly human like mistakes. Note move 35... Rxf2, as if it forgot about the bishop because it had moved to the other end of the board. That's the kind of mistake a human player might make and computers never do.
It strikes me that this would be a great engine for my five year old to practice against. I'd love to see it added to lichess or put into a phone app for that purpose.
0. http://en.lichess.org/beOA0Q2T#68
Cool project but not hard to beat.