134 points · by MereGurudev · 4y ago · 102 comments
At the core I’m using an AlphaZero / Leela Chess Zero style neural network that I have trained on 1 billion human games from the lichess.org open database. Around this network I have built a chess engine in Rust with algorithms that use the outputs from the NN to produce human-like moves at a given rating from beginner to world champion, as well as predicting the level of the opponents play.
I want to develop this into kind of an AI coach that you can spar certain positions against and get feedback suited for your level. Happy for any suggestions!
But what's even more impressive is that the game felt great to play, I didn't get this feeling that the AI would pick on every of my smallest mistakes like you have with Stockfish. I know there has been several research work [0,1] recently to improve the human-ness of chess AIs, but it's even more impressive that you are able to do it "online", in the course of a single game, bravo. I'd be interested in a blog post with details on the underlying algorithm
-Why does the bot get +20 seconds every move and you get +5 seconds?
-It seems like you have to wait a few seconds before making a move before the bot gets stuck
You can check out the VOD of him playing noctie on his channel if you want to see the full thing.
It was a bit unsettling to play because as a human you were expecting to get crushed any moment but somehow I salvaged a draw on move 116. I've played thousands of games versus computer opponents (and tens of thousands versus humans).
Rating estimates were off by 200 points, probably because I was too cautious. Real FIDE 2300 - estimate 2100. Maybe I am getting too old :)
If the engine really becomes more human like it will be a big step forward.
EDIT: 2nd game (after registering) was broken UI wise - could not move pawns 2 spots and many legal moves were not allowed, so I had to resign
As I was playing I felt like I had a definite advantage, which I did as it turns out. But because I was playing a computer I kept second-guessing myself as I didn't yet know it was programmed to blunder. I then managed to resign in a drawn pawn endgame - I wonder if this was used as signal to estimate my rating.
It got my lichess rating right within 300 points after just one game.
edit: the computer now flagged on my screen, but I did not get any message of a result
Does noctie treat the opening any differently when factoring in ratings. I had two very different estimes - higher one (2100) was from an opening line i knew and lower one (1500) I left the opening more quickly but I don't think I played a much worse middle game. I'm closer to 1500. [edit: from your other comment it does look like it takes the opening into account - I'm guessing as some sort of calibration - if you create an account does it use the results from previous games instead?]
Also curios if this could theoretically be applied to historical games as well or does it require noctie to be a participant. I'd love to see an analysis of how player strength has increased over time. [edit: from your other comment it looks like it does require play]
To answer your questions: Noctie takes every move into account. Especially in short games or very one-sided games, a lot of the rating estimate will come from your opening play. If you play a bad opening, Noctie adapts and you will get an easier game, which may lead to simpler positions where you have less risk of making a mistake that would lower your rating. So what opening you play definitely has a big impact when trying to judge the rating from one game only.
If you create an account and log in, Noctie will accumulate information from several games to give a more balanced difficulty and more accurate rating estimate (and show how it changes over time).
Noctie's involvement isn't strictly required for the rating estimate although it creates good conditions for it by making the game balanced, not dominated by time trouble or trying to flag the opponent, etc.
This happened twice now (at move 3 the second time).
I'm not sure it should take that long especially in opening moves.
Is it doing very deep analysis? Am I up against depth 40 stockfish calculations here?
Was this in the rate-me page or as a logged in user? You can mail me with the e-mail in my profile if you'd like to help debug!
I'm using Chrome on Android and was only using the rate me page.
Yea it definitely took way more than 10 seconds.
Nice peoject tho! I'm interested in how it'd rate me.
My only major grip with it is the color scheme. As is often the case, you seem to want to add your own 'flavor' to the UI by having this almost post-apocalyptic color vibe... and as usually happens, it makes it more difficult to distinguish for people accustomed to the standard high contrast board.
Another grip, the click to move that is standard would be very nice to implement. Dragging to move as the only option is an oversight.
both the machine and i played with elan (reckless abandon), rarely thinking more than a few seconds per move
crazy game that convinced me to sign up
i love that it ostensibly tried to stalemate me at the end, that's what i'd do too and often draw back when i played chess
i stopped because F** zero-sum games
but against noctie i'm not releasing stress hormones into someone's brain so i can like chess again
chess.com analysis
accuracy 75.4 vs 70.6 so it did a measurably good job matching performance
there is something very lifelike and appealing about an AI that blunders at the same rate as you
best chess engine, good job
The promotion menu disappears so I couldn't promote.
It also draws wrong if I preemove a recapture and then change to a new move. More generally, it allows infinite premoves and crashes.
Also, the clock is distracting, especially because the proportional font keeps moving the digits. Besides that, pretty good. And the colors are mushy and low contrast.
Most importantly, what I actually wanted to do was get the game out and analyse it. But now the text was no longer selectable so I had to go grubbing around in devtools.
Turns out the "forget me and play again" button just dismissed the popup and didn't actually start a new game but I had no way of knowing this short of playing another test game in another tab.
Suggestions: (a) don't use modal dialog boxes! Let me create an account in the middle of a game if I want. Let me copy and paste the moves at any time, including after the game is over. Don't have a button to "play again" if it's not actually going to play again.
(b) asking for email addresses annoys the hell out of people. Let me play again without forgetting who I am. If I want my identity to persist across browser sessions then sure, let me create a username and password. If I want to be sure I don't forget the password, sure, let me tie it to an email address. But it should be step three, not step one. Otherwise people will just never come back.
(c) "excited", "Thanks for the game", the eyebrows? It's a bot, it's not capable of excitement or gratitude or facial expressions. Pretending it is seems, well, patronizing. It's reminiscent of chess.com with its cutesy bots (and persistent nagging).
Another option is to consider 3rd party OAuth like Google.
Its prediction was about 300 points low compared to actual lichess rating (1800). But online chess is very different; you see a lot of unsound openings that an engine wouldn't ever play.
According to https://lichess.org/analysis#1, for blitz and rapid games played on lichess with 1.e4, 1...e5 is 33%, 1...c5 is 25% and 1...e6 is 10%. And 35% is some other nonsense.
Computer chess tournaments solve this problem by requiring the computers to play specific openings.
I posted these stats in another thread:
According to https://lichess.org/analysis#1, for blitz and rapid games played on lichess with 1.e4, 1...e5 is 33%, 1...c5 is 25% and 1...e6 is 10%. And 35% is some other nonsense.
The other issue is that the AI weighs weak openings way very heavily for both elo and responses. I enjoy chess960 and am weak on my openings, my elo is estimated to be between 1000 and 1400 standard otb 10+5, and my lichess puzzle elo is 1600. Noctie gave me an elo of 500ish even when I won. The response moves weren't challenging and it felt like the game went directly to endgame after a series of aggressive exchanges. Look forward to seeing where this goes.
https://i.imgur.com/g6R1FM5.png
I didn't even know the rules of chess allowed for that, so I've actually learned quite a bit!
This feels like a great thing for beginners.
Although, there was an unfortunate bug... I couldn't promote a pawn, and that severely impacted the endgame. I'm on mobile Brave, and attempting to promote presumably tried to bring up some modal, but instead it just glitched.
On the user side - I think the review area would benefit from principle-based analysis similar to what is seen in chess.com. I am guessing that for it to happen, there needs to be a separate analysis engine that can detect positional motifs. I think chess.com did a decent job with that (better and more actionable than decodechess in my opinion).
On the tech side - I’m curious how this project differs from existing neural nets trained for lc0 such as bad gyal and maia?
On the tech side, what Maia is doing I think is similar to our NN component. It turns out to get realistic play (include randomness, avoid too many one-move blunders, same level of tactical play as positional play, realistic endgame play, etc.) you have to do quite a lot on top of that – much more than I initially thought. I have tested the AI over the last year with friends of different strengths to try to make the gameplay more realistic and engaging. I also think the automatic adaptation to your level of play, and predicting the rating, is unique. Bad gyal AFAIK uses a different training method where Stockfish evaluations is involved, but I haven't really tested it enough to know how it stands vs. Maia.
Played a few games and variation was between 828 and 1251, and in all but the 828 I received a good drubbing.
So far, this seems to fit the bill very well! I hope this is a success and will definitely consider supporting it with a paid account. Well done!
Its way off (I range around 1200-1700 ELO depending on sober I wanna be when I play). I do play relatively eccentrically with a penchant for sacrifices and a insatiable desire for tempo and exploration of lines I am unfamiliar with but its still way off with its initial assessment.
1. It got down to my White King on b3, my Knight on h6 vs its King on h2 and its Pawn on g5, with it to move.
It had around 6:50 on the clock and I had 3:36.
It spent nearly 3.5 minutes on the move so its clock was around 3:20 when it moved (Kh3)...and then it got so much increment back that it ended up somewhere round 6:55.
Here's the game score in case it helps [1]. The score does not show the one take-back I used. If that's relevant it was on move 27, right after the first Rook trade.I completely overlooked that the Bishop on c4 was hitting my Rook on f1 and moved the Knight to c3 intending to then move the Rook to c1. Oops...took that back to instead move the Rook first and then the Knight.
2. The game continued 46. Kc3 g4 47. Nxg4 and draw due to insufficient mating material on both sides. I then got the modal dialog telling me my rating estimate (17something FIDE, 20something Lichess) [2]. With that modal up I could not select the game score to copy it, and it sounded like all the options to dismiss the model would likely take me to somewhere new.
I ended up taking a screen shot, opening the screen shot in Preview on my Mac, and selecting the text in the screen shot and copying that.
If the modal at the end indeed cannot be dismissed without going somewhere else, it would be nice to provide a way to copy the game score before leaving.
[1] 1. e4 c5 2. Nf3 Nc6 3. d4 cxd4 4. Nxd4 e5 5. Nxc6 bxc6 6. Bd3 Nf6 7. 0-0 Bc5 8. Qe2 0-0 9. Nc3 d6 10. Bg5 h6 11. Bxf6 Qxf6 12. Kh1 a5 13. a4 Be6 14. f3 Rab8 15. b3 Bd4 16. Qe1 Rfc8 17. Rd1 d5 18. Nb1 c5 19. c3 c4 20. cxd4 cxd3 21. dxe5 Qxe5 22. Rxd3 dxe4 23. Qxe4 Qxe4 24. fxe4 Bxb3 25. Rd4 Rc4 26. Rxc4 Bxc4 27. Rc1 Be6 28. Nc3 Rb4 29. Kg1 Kh7 30. Kf2 Kg6 31. Ke3 Kf6 32. Ra1 Ke5 33. Rb1 Bb3 34. Rb2 Bxa4 35. Rxb4 axb4 36. Nxa4 f5 37. exf5 Kxf5 38. Kd4 b3 39. Kc3 Kf4 40. Kxb3 Ke3 41. Nc3 Kf2 42. Nd1+ Kxg2 43. Ne3+ Kxh2 44. Nf5 g5 45. Nxh6 Kh3 46. Kc3 g4 47. Nxg4
[2] Seems plausible. I haven't played tournament chess in ~30 years. When I did my USCF rating had a high of 1611 and was mid 1500s when I stopped, so 17something FIDE seems a bit high. On the other hand I have done a ton of tactical puzzles in the last few years, so it is possible I'm better than I was 30 years ago (except I've forgotten everything I knew about openings). My Lichess puzzle rating is around 2100. I haven't played any online games with humans so don't have an online rating anywhere.
Unfortunately, wildly off, I was ~1800 FIDE even when I used to play. Will try a few more games to see whether that was a fluke or whether I should consider getting into chess again.
All in all, great submission, thank you
> Equivalent lichess.org rating: 965
I like chess, I know i'am not good but it was nice to beat a AI once ;)
FYI this sequence of moves leads to the AI timing out:
1. e4 c5 2. c3 d6 3. d4 cxd4 4. cxd4 Nf6 5. Nc3 g6 6. Bd3 Bg7 7. Nf3 O-O 8. O-O Nc6 9. d5 Ne5 10. Nxe5 dxe5 11. b4 a6 12. a4 Qb6 13. Rb1 Ng4 14. h3 Nf6 15. a5 Qc7 16. Bb2 Bd7 17. Na4 Bxa4 18. Qxa4
1176
Ouch, I did beat the AI.
I've played probably 10,000 anonymous games. My chess puzzle rating is currently around 2100, peak of 2400. Playing against stockfish 4 I can generally win every game. Stockfish 5 is hard.
When I do rated games, I will crush each person in placements and usually get to 2200 or so before I lose the ?
The last time I did a rating run. I won each game and placed at 1977. Then I went on a losing streak of 20 games down to 1300. I am playing 1300s which play like stockfish 5 or harder. These 1300s are playing ridiculously strong compared to stockfish 4.
I wonder what I'm doing wrong.
Yes.
Stockfish 2 is pretty easy, play solid and it eventually does something ridiculous to earn its lower rating. The trick, you have to see the mistake. Basically punches itself in the face, you have to survive until it does this. Make sure everything is defended.
Stockfish 3 is when it starts playing reasonably and only makes a mistake when you've put enough pressure on it.
Stockfish 4 you have to play against it. You need to see depth of about 3-4 moves for both of you and you should beat it every time.
Stockfish 5 is hard, it's seemingly giving you tricks, but if you look at the trick its a crazy computer line where they manage to barely hold on or in most cases you shouldn't have taken what it was giving.
>I've found stockfish at these lower levels doesn't play like humans at all. It will play a near perfect game for 25 moves and then all of a sudden make a horrible and senseless move. If your style is slow and defensive I think you probably fair better. My style is hyper aggressive and stockfish crushes me :)
From my experience stockfish never plays like a human. I do recall there are some bots on lichess which were machine learning to play like a human.
Alas I'm 1100 rated according to op.
Opening theory and tactics are a good place to start.
An easy step is make sure you know a few common openings and have at least one response prepared to each. But also a good understanding of principles. Opening principles are more important, you can wing it if you don't know the theory. There are thousands of videos on YouTube about these topics.
And obviously just don't hang pieces and take your opponent's hung pieces. At 1300 on lichess, your opponent will make a bunch of tactical mistakes which you can just take if you see them, after you can just win if you play solidly for the rest of the game. The way to study here is with puzzles.
Sorry to patronize. I have played thousands of 1300's on lichess and improved after I sat down and studied. But I can tell you, if you're actually 1300 you are not strong enough in some of these areas.
P.S. I don't believe the comment above yours. The dude went from 2200 to 1300??
I play chess because I find it fun, relaxing and a great way to blow off stress. Studying opening and caring too much about rating ruins that. Rated play is awesome because I always get paired with someone of similar skill. I do feel I'm improving slowly, even if my rating does change much. I like to mix things up and often play strategies I know are bad because it leads to fun and novel positions.
And yes, I understand that I'm not a "strong" player. It's pretty obvious when lichess tells me directly I'm in the bottom ~30% lol.
Like I could provide links to my games. I'm not a liar. I estimate I am a 1800-2000 player.
The thing I don't seem to know, it would seem to me when I play against a 1300 who never makes a blunder or mistake. It then happens 20 games straight. They certainly play various inaccuracies, and I hold myself as well as I do compared to stockfish 5.
In 1 game I was up 2 pieces and the computer didnt think they made a mistake nor blunder. >90% accuracy as a 1300...
I guess, I'm missing some fundamental thing.
Nitpick: "20% higher" doesn't work when talking about Elo ratings, since it's a system based on rating differences between players (i.e. subtraction).
In particular, if two players are ranked x and y respectively, that's equivalent to them being ranked x+k and y+k for any value of k. On the other hand, multiplying ratings by a constant has no meaning.