r/programming • • Dec 02 '14

Deep learning for… chess

http://erikbern.com/?p=841
99 Upvotes

15 comments sorted by

9

u/Awesan Dec 02 '14

So this assumes a pretty substantial knowledge of AI techniques. If you don't have that you will get a lot less out of the article. The basic result is that this is a technique that is both new (not used in the best chess engines) and works well (or can at least be improved to work well). There is some interesting analysis of the results and what can be done to improve them. Overall interesting project. I hope someone follows through with some of the suggested improvements.

5

u/Felicia_Svilling Dec 02 '14

Seems like you could represent a board in fewer bits by noting the coordinate for each piece rather than the piece for each square. I wonder what affect that would have on the method.

7

u/TheBB Dec 02 '14

Bitboards, as described in the article, have some serious advantages because they let you leverage bitwise operations more easily. See e.g. magic bitboards, a lightning fast way to compute attack sets of a piece from its location and the occupancy pattern.

2

u/this_little_dutchie Dec 02 '14

My impression is that this would make an incomplete representation of a chessboard, since the empty spaces are as important as the occupied spaces (for movement and such). An incomplete representation would lead to a worse evaluation function. But this might make the function so much faster, that it might compensate by allowing a deeper search. I think it will not, but only experimentation can prove this.

4

u/Felicia_Svilling Dec 02 '14

You could just have a coordinate (or bit) representing that the piece isn't on the board.

-1

u/this_little_dutchie Dec 02 '14

But then you will still be missing the information about 32 empty fields. But it's indeed more complete.

4

u/maximecb Dec 02 '14

It's not just that IMO. My experience leads me to believe that it's better to have a pre-chewed, more decomposed, "map-like" representation that you feed your neural network. If you feed it coordinates, you have the same information, but the neural network needs to re-decompose that into something that's easier to work with. It's really not helping the machine learning process. In general, I'd say the more "independent pieces of information" you can feed your network, the better.

TL;DR: intuitively, chess is not about piece coordinates, it's about visual patterns that intersect. Representing the data in a way that a neural network can efficiently process is an art.

12

u/Purple_Haze Dec 02 '14

Still, even an amateur player probably makes near-optimal moves for most time.

One can hardly take seriously someone who can make this statement. Except in the opening where he could be following distilled grandamster practice, an amateur is not likely to have played one of the three best moves in a position even half the time. This can easily be proved by running a collection of amateur games through a strong chess engine in analysis mode.

12

u/jelos98 Dec 02 '14

an amateur is not likely to have played one of the three best moves

First off: he really should have defined near optimal. In many positions, there will be 10 moves all within a pawn of each other, score wise, and often times several choices that are within 10 or 20 centipawns. For toying around with machine learning for chess? It's what I'd call, in my professional opinion, "optimal enough".

Even at a measly 1200 rating (chess.com) when I analyze games, I wind up with something like 2 moves that were 1 pawn or more away from the best move, 6 more moves that are .5 pawns or more away, in a 40 move game. Meaning that of the 40 moves, roughly 32 of them are "near optimal" (on each side), for some definition of "near optimal"

3

u/ssylvan Dec 03 '14

Maybe generate training data using another AI. So basically your NN approximates the "score" algorithm of an expensive AI would give you (e.g. by searching 10 moves ahead).

So then if you use this to search 10 moves ahead you effectively get "almost" twenty moves of searching for cheap because the leaf score function approximates another 10 levels.

Then you could use that algorithm to train another NN in the same way. Repeat recursively until things stop improving.

5

u/sacundim Dec 03 '14 edited Dec 03 '14

I don't get the impression that the author is very familiar with present day chess engines like Stockfish or Komodo, the current kings of the heap. For example in the bit where it says it's not practical to look deeper than 5-10 positions ahead—Stockfish routinely gets to depths of 40+. (Admittedly this is not a full breadth search—in fact it's an extremely selective search.)

Some links:

2

u/EsotericNinja Dec 02 '14

I'm really interested in contributing to this but I'm not that familiar with python or deep learning. What are some good resources to learn more about deep learning in python?

3

u/SkaveRat Dec 02 '14

not python, but machine learning in general

I've yet to find a cource that actually uses a common programming language for teaching. as a "simple"programmer, the math stuff is really exhausting, even if I can get behind most of the stuff after a while

-1

u/billconan Dec 03 '14

but this feels like a greedy algorithm where each step you only look at the immediate best choice.