A probabilistic chess engine

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

one_thousand_lakes
Posts: 1
Joined: Tue Mar 05, 2024 7:33 am
Full name: Luke Salamone

A probabilistic chess engine

Post by one_thousand_lakes »

Hi everyone, I am working on a probabilistic engine which uses opponent modeling to play the move which has the best expected value given an accurate model of the opponent. Currently it uses a neural net model of lichess 1500 elo players for the opponent model, and stockfish as an oracle for the value of a position under consideration.

For minimax, my understanding is we are essentially playing the best move under the assumption that the opponent will play their best move. But this isn't necessarily the fastest path to victory or the most engaging to play with. If we have a model of the opponent's behavior, we might be able to beat them faster. And from the player's perspective, it is possible to beat such an engine by playing moves which are better and out of distribution. In practical terms, this engine will try to trap you, but learning to play better moves will let you beat it.

Here is a demo: https://chessmate-demo.s3.amazonaws.com/play.html

(Technical note: the model is around 33mb, so it may take a minute to load depending on your connection. Unfortunately I don't have a loading bar for that yet. But the whole thing should run from your browser, no server necessary.)
User avatar
towforce
Posts: 11659
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK

Re: A probabilistic chess engine

Post by towforce »

Loved the fact that I could play it in the browser, like a chess.com bot!

Can't say how good it's probabilistic feature is - it simply outplayed me: got its pawns into good positions, trapped my bishop, made a lethal attack against my king. I'd have to concentrate more to give it a competitive game:

[pgn]1. e4c52. Bc4Nf63. Nc3e64. Nf3a65. O-OBe76. d3Nc67. Be3O-O8. Qe2d59. exd5exd510. Bxd5Nxd511. Nxd5Qxd512. Rfd1Rd813. Rd2Bd614. c4Qh515. h3Bxh316. g3Bg417. Kg2Ne518. Rh1Bxf3+[/pgn]


Edit: just uncovered a bug: the PGN output isn't usable at this site.
Writing is the antidote to confusion.
It's not "how smart you are", it's "how are you smart".
Your brain doesn't work the way you want, so train it!
reallyturborandom
Posts: 1
Joined: Wed May 08, 2024 3:41 pm
Full name: James Lee

Re: A probabilistic chess engine

Post by reallyturborandom »

really cool idea, but the engine feels too weak? (I'm 1300-1400 on chess.com for reference, and was winning fairly comfortably, occasionally it would trick me but i would recover after pretty easily)

also the pgn is missing spaces between moves, and it would be nice to be able to play with black...

I'm interested to see how this progresses, and towforce is right, I can definitely see this becoming a chess.com bot in the future
User avatar
Ajedrecista
Posts: 1974
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: A probabilistic chess engine.

Post by Ajedrecista »

Hello:
towforce wrote: Wed Apr 10, 2024 9:38 pm[...]

[pgn]1. e4c52. Bc4Nf63. Nc3e64. Nf3a65. O-OBe76. d3Nc67. Be3O-O8. Qe2d59. exd5exd510. Bxd5Nxd511. Nxd5Qxd512. Rfd1Rd813. Rd2Bd614. c4Qh515. h3Bxh316. g3Bg417. Kg2Ne518. Rh1Bxf3+[/pgn]


Edit: just uncovered a bug: the PGN output isn't usable at this site.
reallyturborandom wrote: Sat May 11, 2024 4:39 pm[...]

also the pgn is missing spaces between moves, and it would be nice to be able to play with black...

[...]
Yes, it should be fixed. Meanwhile, there must be some regex expression to add spaces after certain patterns {[a-h][1-8] with optional + (from check), O (from castlings), p (from en passant) and so on}. An interesting combination would be en passant with check (exf6+ ep or how? SF 16.1 under Arena displays e5xf6/ep+), just like in the proof game 1. e4 e6 2. Nc3 d5 3. Nxd5 exd5 4. e5 Bc5 5. Qe2 f5 and the en passant with check now. Wikipedia suggest exf6 e.p.+ in this case.

I simply added spaces manually to towforce's game this time:

[pgn][Event ""]
[Site ""]
[Date ""]
[Round ""]
[White ""]
[Black ""]
[Result ""]

1. e4 c5 2. Bc4 Nf6 3. Nc3 e6 4. Nf3 a6 5. O-O Be7 6. d3 Nc6 7. Be3 O-O 8. Qe2 d5 9. exd5 exd5 10. Bxd5 Nxd5 11. Nxd5 Qxd5 12. Rfd1 Rd8 13. Rd2 Bd6 14. c4 Qh5 15. h3 Bxh3 16. g3 Bg4 17. Kg2 Ne5 18. Rh1 Bxf3+[/pgn]

Regards from Spain.

Ajedrecista.