r/MachineLearning • • Dec 02 '14

Deep learning for chess

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

22 comments sorted by

30

u/goltrpoat Dec 02 '14

Amateur chess engine programmer checking in. Very cool. A few suggestions:

  1. Add a transposition table, you should get an enormous speed boost with barely any work (it's kind of surprising that it does anything at all in any reasonable amount of time without it).

  2. Don't bother with MTD(f) -- there's no benefit over PVS. Even your plain alpha-beta should be sufficient, assuming you add transposition tables.

  3. If you add quiescence search, you'll beat Sunfish one hundred times out of a hundred, no matter what your evaluation function. Sunfish isn't even the "hello, world" of chess programming, it's missing crucial parts.

Finally, the FICS dataset is not the best idea, I think -- it consists of very poor quality games for the most part (beginners playing blitz). The best free option would be MillionBase, most of those are tournament games under classical time controls. It's a much smaller dataset, but not nearly as noisy, and ~2mil*80 or whatever positions is still a pretty decent amount of data.

4

u/Inori Researcher Dec 02 '14

How does one go from following articles on reddit to being a chess engine programmer? Serious question.

I'm okay at programming and math with minimal background in Stats/ML/AI. I tried going by looking up unfamiliar terms (like alpha-beta pruning and PVS), but it gets out of control so fast...

4

u/strealm Dec 02 '14

You should look up blog posts on general min-max alghoritm (or negamax version) then add alpha-beta pruning and then you can move to different methods that are often found in chess engines: quiescence, null-move, board representation, hash tables ... Someone posted series of video tutorials on this topic recently: https://www.youtube.com/watch?v=bGAfaepBco4

4

u/goltrpoat Dec 02 '14

In my case it didn't have much to do with articles on reddit -- I've been programming and playing chess for most of my life, so it was a pretty natural thing to try out.

The Chess Programming Wiki is an invaluable resource, contains just about every notable technique in existence. The programming forum on the Computer Chess Club is an excellent community, some of the smartest people in the field post there.

Other than that, it's like any other field -- just have to dig in.

1

u/thefrontpageofme Dec 02 '14

From what I understand, you can probably swap the sides and gain twice the amount of training data?

4

u/hookers Dec 02 '14 edited Dec 02 '14

Really interesting, but I agree that the crux is a better search rather than a good evaluation function.

Random idea on the topic of better search - how about training the neural network on a sequence of boards? This has some advantages:

  1. It makes use of the power of the internal feature representation - a deep enough network might be able to discover an underlying latent motive behind a sequence of moves and so pick the one with a better eventual payoff;

  2. It decreases the cost of the function per time unit - you could do something like an extremely cheap soft pruning function to discard completely irrelevant search paths, but then score whole branches of the search tree at once;

  3. Seems to make more sense in general - experienced chess players would think of moves as a unit (e.g. common tactics such as removing a defender, gaining tempo, zugzwang, etc)

Edit - formatting.

4

u/professor__doom Dec 02 '14

It’s possible to learn an evaluation function directly from raw data, with no preprocessing

That is indeed pretty cool.

1

u/GnomyGnomy7 Dec 02 '14

Wow, this is really nice, about six months ago, I set out to train an AI for an advanced version of tic-tac-toe( on a 9*9 board ), by pitching the AI against itself. But after writing the game, I did a quick calculation, which I must have done before the entire thing, and I concluded that it was not viable.

So I just ended up writing the game in Java, and nothing to do with the AI. I must admit though, I am a newbie to ML, let alone DL. So maybe, it's time for me to pick up that project again. :)

link to the game

Maybe if someone is interested in the code, and perhaps working on the AI with me, PM me :)

3

u/Ubermouser Dec 02 '14

What was it about the project that made you deem it not viable?

1

u/GnomyGnomy7 Dec 03 '14

I thought that the number of possibilities were way too high to effectively train my AI :(

1

u/nameBrandon Dec 02 '14

Coolest thing I've read all week.. thanks for sharing that! :)

1

u/test3545 Dec 02 '14

Why not to train net that simply predicts next board given a current one? 768 inputs and outputs, plus whatever hidden layers.

2

u/Felicia_Svilling Dec 02 '14

Wouldn't that just train the net to play like an average player?

1

u/test3545 Dec 02 '14

Yes. But I've got an impression that model trained above was playing weaker than humans chess players from 100m games dataset.

So why not to kill complexity while improving straight?

1

u/mosquit0 Dec 05 '14

This an interesting idea. The question is if an average move is the best one.

2

u/mhummel Dec 02 '14

My pet project is like this (with more inputs to capture metadata). In classifier mode it classifies the position as legal/illegal/win for white/draw etc; in generative mode it creates a new position and the next move is determined. At the moment, it's generating interesting, albeit illegal positions. If I can ever get it finished I'll post it if there's interest.

1

u/umustbetrippin Dec 02 '14

Why not switch to a game like Arimaa, which is superficially similar to chess (and therefore some of your work could be reused) but is still much more difficult for computers?

1

u/Felicia_Svilling Dec 03 '14

Do you have a database of Arimaa matches?

1

u/umustbetrippin Dec 04 '14

It's nowhere near as extensive as the chess matches, but here you go!

1

u/mosquit0 Dec 05 '14 edited Dec 05 '14
  1. Could convolutions be used here? I bet that there is some invariance in the positions.

  2. Another idea is about compressing outputs from a really strong engine. Take a position and try to predict the next move as predicted by the engine.

0

u/[deleted] Dec 02 '14

For speed, have you considered training a simpler classifier on the output of the deep nets? I.e. what Geoffrey Hinton calls 'dark knowledge'.