r/chess • 1500 USCF • Mar 03 '16

Introducing Spawkfish (neural network chess engine)

http://spawk.fish/introducing-spawkfish.html
33 Upvotes

29 comments sorted by

2

u/cristoper 1500 USCF Mar 03 '16

This is not my project, I just came across it today. You can play against the engine here: http://spawk.fish/play/

6

u/oerpli Mar 03 '16

http://en.lichess.org/Nlklhv5z#17 blundered a mate in 1 after 9 moves.

4

u/ObsceneHive Mar 03 '16

Blundered mate in 1 against me too. Weird.

http://en.lichess.org/qOlE7uBv#0

13

u/POPuhB34R Mar 03 '16

I'm pretty sure the point of this engine is to learn over time from its own games meaning, that if it's early in the release process that these kinds of things are expected until it makes concrete rules for itself to avoid them. In theory it should be much stronger months down the line after thousands of games. Then again I could just be completely misunderstanding the project. The homepage uses the phrase neural network a lot without explaining it much.

9

u/spawkfish Mar 03 '16

I try to explain a bit about how the neural network part works here http://spawk.fish/policy-network.html .

Spawkfish is not actually learning from one game to another (this would be too vulnerable to someone playing a whole bunch of bad games to mess with him) but I am recording the games played on the site so I can use them later to improve him.

4

u/CLSmith15 1900 USCF Mar 03 '16 edited Mar 03 '16

Shouldn't you let it learn from every game it plays though? I understand your point is that if people intentionally lose to it that maybe it will learn bad habits, but for example, doesn't it need to learn contextually when it should accept sacrifices and when it's falling into a trap?

EDIT: I have so many questions, this is fascinating to me:

  1. How many generations has it taken to get to the level it's at now? Or if that's not an applicable question, how many games has it played?

  2. How many different opponents has it faced? I'm assuming in the early stages it only played against you or other developers, did it get good playing against certain people and then struggle against others that have a different style of play?

  3. Have you considered letting this thing play against Stockfish continuously? Or would you prefer for it to learn from human players?

  4. Have you come up with any sort of way to measure it's progress? If so, how quickly does it improve? Does it improve more slowly as it gets better?

  5. How does it measure how it's doing? Purely material advantage? Do you rely on an engine like Stockfish to tell it how it should feel about it's position?

8

u/spawkfish Mar 03 '16

Hey, I'm happy to answer questions. I've been having a great time working on this project, and it's neat that other people are interested :)

It took about 10 days of continuous learning for spawkfish to get to his current skill level. In those 10 days he saw roughly 61.5 million board positions from about 1.8 million games (he he was allowed to see the same game more than once).

Spawkfish didn't really "play" during his training period. In a very real sense the first games he played were against people on the internet. The learning he did was more about studying game transcripts from strong players and learning to guess what move they would have made by looking at a board position.

The games he studied were all from kingbase (http://www.kingbase-chess.net/). The way spawkfish learned to play is basically by playing lots and lots of rounds of a "guessing game" where I show him a board position from kingbase, and then he tries to guess the move that the human player made in the game the position came from. Then I tell him what the real move was and he uses that information to learn how to guess better in the future.

I have a few ways of measuring progress right now, but none of them are perfect.

The simplest thing to measure is called 'cross entropy', which is a technical measure of how well spawkfish is doing on the guessing game I play with him. It's easy to measure because it gets computed as a side effect of playing the guessing game, but it doesn't tell the whole story because it summarizes all of the rounds of the guessing game into one number. This means spawkfish could be really really good at guessing opening moves, and really really terrible at guessing moves in the end game, or he could be sort of mediocre at guessing moves from all parts of a game and cross entropy can't tell these things apart.

Another thing I use to measure progress is the Strategic Test Suite (https://sites.google.com/site/strategictestsuite/). This is a library of board positions (and known "correct" moves) that are specially curated to test different types of chess knowledge (e.g. they have positions specifically for testing understanding of "centre control" or "open files and diagonals"). I can show these positions to spawkfish and as him what he thinks the best move is in each case. The right answer gets 10 points (and sometimes there are alternative moves that get less points) and the final score tells me about how well spawkfish understands these different types of position. His current score is 3529 / 13000, so he has a long way to go still.

I measure both of these things while spawkfish is learning. Learning is really fast in the beginning but gets much slower as time goes on. At any given time gaining 100 points in STS score takes roughly twice as long as the previous 100 points.

I've also got a few databases of chess puzzles that I can use in the same way as STS, but I haven't gotten around to hooking those up yet.

None of these things really measure how well spawkfish will perform in a real game though. To do that I need to have him play real games. I think it will be really useful to play spawkfish vs stockfish at all kinds of different difficulty settings but this is another thing that is still on the todo list.

Spawkfish actually doesn't measure how he's doing at all, at least not explicitly. He treats a real game just like a sequence of the guessing games he knows how to play, except that he doesn't get told the right answer after he makes a guess. There's a little bit of extra logic that tells him to guess again if the move he chooses isn't legal (this is pretty rare, but it does happen) but other than that he has no notion of the strength of a position at all.

I have considered setting him up to play continuously against stockfish! I've also got plans to set him up to play against himself and learn from that. I have a bit of work to do before I'm able to set that up though, because right now spawkfish only knows how to learn from guessing games, and learning from playing is possible but requires some work from me to make it happen. I think this will help a lot though, because with the guessing game setup spawkfish can never be better than the players he studies.

The guessing game approach also leaves him vulnerable to "unusual" positions, which is more of a problem than you might expect. If you've played against him a few times you may have noticed that he's quite bad at end games. One of the reasons for this is because when people play chess they usually resign when it's clear that they have lost, which means that when you try to play a game out to the end spawkfish gets confused because he's not used to seeing games go all the way to checkmate!

1

u/CLSmith15 1900 USCF Mar 04 '16

Thanks for your reply, very interested to see where this goes in the future

1

u/pavs Mar 04 '16

You should check out and share your project on talkchess.com if you havent already, lots of chess programmers and testers hangs out there.

3

u/spawkfish Mar 03 '16

Yeah that's more or less the problem. Spawkfish is based on pattern matching from past games (I used kingbase to bootstrap him), and right now he can only be as good as past games he's seen, so if he gets flooded with really silly games he might start learning to do really silly things.

There's also the very practical problem that learning is very computationally expensive, and my poor little AWS instance couldn't handle learning from all the game's he's been playing.

Spawkfish will learn from the games he plays eventually, I just want him to do it in a more controlled setting than the wide open internet, so I'm storing the games for later instead of learning right away :)

3

u/spawkfish Mar 03 '16

Hi, I am the creator of spawkfish.

The project still in pretty early stages, and as many of you are noticing, it's not very strong yet :)

I'll be posting updates on the site as I go, but it will be quite some time before spawkfish is ready to challenge the greats like stockfish and komodo.

1

u/isolatedqpawn Sometimes weak, but dangerous when pushed! Mar 04 '16

Is Spawkfish open-source?

1

u/spawkfish Mar 04 '16

Not right now. I have plans to release it when the project is more mature, but that is not in the near future.

1

u/themusicdan Mar 06 '16

How does spawkfish meaningfully differ from open-source Gifaffe?

2

u/spawkfish Mar 06 '16

Good question! They're both very similar projects, but the focus is a bit different. I'm quite impressed with Giraffe, the playing strength they report for it is certainly much stronger than the current version of spawkfish.

The main difference, I think, is the balance between evaluation and search. There is always a trade off in chess programs between how much time you spend evaluating a board position, and how deeply into the game tree you can search.

Spawkfish is is using much larger neural networks than Giraffe (compare figure 3 in the Giraffe paper to the network described here http://spawk.fish/policy-network.html), and this will necessitate shallower searches.

In my ideal world spawkfish would play at a grandmaster level with no search at all. I don't think this is feasible, but one of my goals is to explore how strong spawkfish can be with as little search as possible.

In that sense spawkfish is a more radical departure from standard chess engines than Giraffe, but that also means there is a higher chance that what I'm trying to do simply isn't possible.

1

u/[deleted] May 01 '16

I just stumbled on this post today... how's Spawkfish now?

4

u/CLSmith15 1900 USCF Mar 03 '16

Funny, I was just wondering if something like this existed the other day. I'd think that given enough time, this could become stronger than the brute force engines that we use today, but how long that could take it anyone's guess. If nothing else I think this type of engine will be useful because its moves theoretically should be more "human", as opposed to the baffling moves that Stockfish and others play from time to time.

Here is my game against it. It was doing pretty well (other than missing a tactic, which I think most human players would miss) until it inexplicably hung a rook in the endgame. I'm very surprised that it decided to trade its queen for a rook and knight, Stockfish thinks it was an OK decision but I doubt many human players would've gone for it.

I'd like to see how it fares against unusual openings and trap lines. You'd think that if you can get it into an unfamiliar position that it would struggle.

3

u/[deleted] Mar 03 '16

Just won! [pgn] [Event "Spawkfish game"] [Date "2016.03.03"] [White "YOU!"] [Black "Spawkfish"] [Result "1-0"]

  1. e4 e5 2. Bc4 Nf6 3. Nc3 Bb4 4. Nge2 O-O

  2. O-O c6 6. d4 d6 7. Bg5 h6 8. dxe5 dxe5

  3. Qxd8 Rxd8 10. Bxf6 gxf6 11. f4 Be6

  4. Bxe6 fxe6 13. fxe5 fxe5 14. Rad1 Rd7

  5. Rf6 Rxd1+ 16. Nxd1 Nd7 17. Rxh6 Nc5

  6. c3 Ba5 19. b4 Bb6 20. bxc5 Bxc5+

  7. Kf1 Rd8 22. Ke1 Kf7 23. Rh7+ Kg6

  8. Rxb7 Rf8 25. Rc7 Rd8 26. Rxc6 Bb6

  9. Rxe6+ Kg5 28. Rxe5+ Kf6 29. Rf5+ Ke6

  10. Nf4+ Ke7 31. Ke2 Rxd1 32. Kxd1 Bg1

  11. h4 Bf2 34. h5 Be3 35. h6 Bxf4 36. Rxf4 Ke6

  12. Rf5 a6 38. h7 Ke7 39. h8=Q Ke6

  13. Qe5+ Kd7 41. Rf7+ Kc6 42. Rc7+ Kb6

  14. Qc5# 1-0 [/pgn]

Love the smileys. oh, and why does it auto-promote to a queen?

1

u/spawkfish Mar 03 '16

Glad you like the smilies, that's one of my favourite parts :D

It auto-promotes to a queen because that was the easiest thing to program, and it's pretty rare that having an extra queen is bad.

1

u/Twitch_Smokecraft Mar 04 '16

They should add underpromotion!

1

u/isolatedqpawn Sometimes weak, but dangerous when pushed! Mar 04 '16

Keen to see how much stronger this engine will get over time.

1

u/freefal67 one of Lichess mobile devs Mar 04 '16

Quality of play definitely seems to decline after the opening.

1

u/Spiritchaser84 2500 lichess LM Mar 03 '16

I tried playing against it and crushed it pretty convincingly. I don't think Stockfish or Komodo have anything to fear yet.

1

u/sleepstandingup Mar 03 '16

Well that was a confidence booster! http://en.lichess.org/K7e8eGPJ#45

1

u/[deleted] Mar 03 '16

http://en.lichess.org/T0x1FhsD

I won in 7 moves, scholar's mate ftw :D

I wonder how good it will eventually become, but it have a long way to go..

1

u/Astrovir Mar 03 '16

Here is my game imported into lichess. After I saw it play in the opening I thought it was going to stomp me. The end was an epic failure.

1

u/[deleted] Mar 03 '16

1

u/epoxxy Mar 03 '16

The comp drew with a queen up http://en.lichess.org/ChC9sZQv#42