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.)
A probabilistic chess engine
Moderators: hgm, chrisw, Rebel
-
- Posts: 1
- Joined: Tue Mar 05, 2024 7:33 am
- Full name: Luke Salamone
-
- Posts: 12097
- Joined: Thu Mar 09, 2006 12:57 am
- Location: Birmingham UK
- Full name: Graham Laight
Re: A probabilistic chess engine
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.
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.
Want to attract exceptional people? Be exceptional.
-
- Posts: 1
- Joined: Wed May 08, 2024 3:41 pm
- Full name: James Lee
Re: A probabilistic chess engine
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
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
-
- Posts: 2025
- Joined: Wed Jul 13, 2011 9:04 pm
- Location: Madrid, Spain.
Re: A probabilistic chess engine.
Hello:
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.
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.
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.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...
[...]
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.
-
- Posts: 2650
- Joined: Tue Aug 30, 2016 8:19 pm
- Full name: Rasmus Althoff
Re: A probabilistic chess engine
[pgn]
[White "Ras"]
[Black "Chessmate"]
[Result "1-0"]
1. c4 e5
2. Nc3 Nf6
3. d3 Bc5
4. Nf3 Nc6
5. g3 Nd4
6. Bg2 d6
7. a3 c6
8. b4 Bxb4 {Losing a bishop}
9. axb4 O-O
10. O-O Re8
11. e4 Bg4
12. Be3 a5
13. bxa5 Rxa5
14. Bxd4 exd4
15. Ne2 Qa8
16. Nexd4 Bh5
17. Rxa5 Qxa5
18. Qa1 Ra8
19. Qxa5 Rxa5
20. Rb1 h6
21. Rxb7 c5
22. Nb3 Ra3
23. Nfd2 Be2
24. Rb6 Bd1
25. Bf1 Kf8
26. f3 Ke8
27. Kf2 Nd7
28. Rb5 Ra2
29. Be2 Bc2
30. f4 Kd8
31. Ke3 g5
32. Ra5 g4 {Losing a rook}
33. Rxa2 Bxb3
34. Nxb3 Ke7
35. Bxg4 Nf6
36. Bh3 h5
37. Ra7+ Ke8
38. Nd2 Ng4+
39. Bxg4 hxg4
40. f5 Kf8
41. Kf4 Ke8
42. Kxg4 f6
43. h4 Kf8
44. Kh5 Ke8
45. Kg6 Kd8
46. Kxf6 Kc8
47. Ke6 Kb8
48. Rh7 d5
49. exd5 Ka8
50. Kd6 Kb8
51. Kc6 Ka8
52. Kb6 Kb8
53. Rh8#[/pgn]
[White "Ras"]
[Black "Chessmate"]
[Result "1-0"]
1. c4 e5
2. Nc3 Nf6
3. d3 Bc5
4. Nf3 Nc6
5. g3 Nd4
6. Bg2 d6
7. a3 c6
8. b4 Bxb4 {Losing a bishop}
9. axb4 O-O
10. O-O Re8
11. e4 Bg4
12. Be3 a5
13. bxa5 Rxa5
14. Bxd4 exd4
15. Ne2 Qa8
16. Nexd4 Bh5
17. Rxa5 Qxa5
18. Qa1 Ra8
19. Qxa5 Rxa5
20. Rb1 h6
21. Rxb7 c5
22. Nb3 Ra3
23. Nfd2 Be2
24. Rb6 Bd1
25. Bf1 Kf8
26. f3 Ke8
27. Kf2 Nd7
28. Rb5 Ra2
29. Be2 Bc2
30. f4 Kd8
31. Ke3 g5
32. Ra5 g4 {Losing a rook}
33. Rxa2 Bxb3
34. Nxb3 Ke7
35. Bxg4 Nf6
36. Bh3 h5
37. Ra7+ Ke8
38. Nd2 Ng4+
39. Bxg4 hxg4
40. f5 Kf8
41. Kf4 Ke8
42. Kxg4 f6
43. h4 Kf8
44. Kh5 Ke8
45. Kg6 Kd8
46. Kxf6 Kc8
47. Ke6 Kb8
48. Rh7 d5
49. exd5 Ka8
50. Kd6 Kb8
51. Kc6 Ka8
52. Kb6 Kb8
53. Rh8#[/pgn]
Rasmus Althoff
https://www.ct800.net
https://www.ct800.net
-
- Posts: 28265
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: A probabilistic chess engine
I tried it against the Interactive Diagram. But because the I.D. would never think more than 1 sec even on its highest setting (4 ply) for an 8x8 game, and the demo applet uses about 17 sec/move, it lost the first few games dismally.
So I modified the script to allow 5.5 ply (using the experimental betzaNewer.js script). This made the I.D. think up to 7 sec, although for most of the game it was more like 2 sec. This produced the following game:
[pgn][White "Interactive Diagram"]
[Black "Chessmate Demo"]
[Result "1-0"]
1. Nc3 d5 2. d4 Nf6 3. Qd3 c5 4. dxc5 e6 5. Qb5 Nbd7 6. c6 d4 7. cxb7 Bxb7 8. Qxb7 Qc8 9. Qxc8 Rxc8 10. Nb5 e5 11. a4 Ne4 12. f3 Bb4 13. c3 dxc3 14. bxc3 Rxc3 15. Bd2 Nxd2 16. Nxc3 Bxc3 17. O-O-O Nc4 18. e4 Nb2 19. Rd5 Nxa4 20. Rxd7 a6 21. Ra7 O-O 22. Rxa6 Nc5 23. Ra3 Bb4 24. Re3 Rd8 25. Re2 Ra8 26. Nh3 Bc3 27. Kc2 Bd4 28. Nf2 Bxf2 29. h4 Rc8 30. Kd1 Nd3 31. Rd2 Rd8 32. Rxd3 Bd4 33. Be2 Rb8 34. Ra3 Bc5 35. Ra1 Bd4 36. Ra2 g5 37. Bd3 Kh8 38. hxg5 Rd8 39. Rh5 Kg7 40. Rc2 Ra8 41. Bc4 Kg6 42. Rh6 Kxg5 43. Rxh7 Kg6 44. Rxf7 Rc8 45. Re7 Kf6 46. Re6 Kg5 47. Bd3 Ra8 48. Rcc6 Kf4 49. Rf6 Ke3 50. Ba6 Rb8 51. Rf7 Rb2 52. Rc2 Rb6 53. Re2# 1-0 {chekmate!}[/pgn]
So I modified the script to allow 5.5 ply (using the experimental betzaNewer.js script). This made the I.D. think up to 7 sec, although for most of the game it was more like 2 sec. This produced the following game:
[pgn][White "Interactive Diagram"]
[Black "Chessmate Demo"]
[Result "1-0"]
1. Nc3 d5 2. d4 Nf6 3. Qd3 c5 4. dxc5 e6 5. Qb5 Nbd7 6. c6 d4 7. cxb7 Bxb7 8. Qxb7 Qc8 9. Qxc8 Rxc8 10. Nb5 e5 11. a4 Ne4 12. f3 Bb4 13. c3 dxc3 14. bxc3 Rxc3 15. Bd2 Nxd2 16. Nxc3 Bxc3 17. O-O-O Nc4 18. e4 Nb2 19. Rd5 Nxa4 20. Rxd7 a6 21. Ra7 O-O 22. Rxa6 Nc5 23. Ra3 Bb4 24. Re3 Rd8 25. Re2 Ra8 26. Nh3 Bc3 27. Kc2 Bd4 28. Nf2 Bxf2 29. h4 Rc8 30. Kd1 Nd3 31. Rd2 Rd8 32. Rxd3 Bd4 33. Be2 Rb8 34. Ra3 Bc5 35. Ra1 Bd4 36. Ra2 g5 37. Bd3 Kh8 38. hxg5 Rd8 39. Rh5 Kg7 40. Rc2 Ra8 41. Bc4 Kg6 42. Rh6 Kxg5 43. Rxh7 Kg6 44. Rxf7 Rc8 45. Re7 Kf6 46. Re6 Kg5 47. Bd3 Ra8 48. Rcc6 Kf4 49. Rf6 Ke3 50. Ba6 Rb8 51. Rf7 Rb2 52. Rc2 Rb6 53. Re2# 1-0 {chekmate!}[/pgn]
-
- Posts: 2650
- Joined: Tue Aug 30, 2016 8:19 pm
- Full name: Rasmus Althoff
Re: A probabilistic chess engine
Here a game between the CT800 V1.45, microcontroller version (GD32 Cortex-M4, 168MHz) at 5s/move, roughly matching the Chessmate. The CT800 with its about 30kNPS (yes, k not M) gets around 8 plies of main depth in the middle game. Chessmate sets up a nice tactical trap in move 8, but the CT800 sees through it.
[pgn][White "CT800 V1.45, 5s/move"]
[Black "Chessmate"]
[Result "1-0"]
1.d4 c5 2.e3 d5 3.Nf3 e6 4.c4 Nc6 5.cxd5 exd5 6.Bb5 Bd6 7.dxc5 Bxc5 8.O-O Bd6
9.Nc3 (9.Qxd5 $4 Bxh2+) 9...Nf6 10.Kh1 {no Bxh2+} Bb8 11.Qa4 Qd7 12.b3 O-O 13.Ba3 Re8 14.
Rad1 Qc7 15.Nxd5 Nxd5 16.Rxd5 Be6 17.Rd6 Qb6 18.Rxc6 Qd8 19.Rcc1 Re7 20.Rfd1
Qf8 21.Bd7 Bd6 22.Bxd6 Bxd7 23.Bxe7 Qxe7 24.Qxd7 Qd8 25.Qxd8+ Rxd8 26.Rxd8# 1-0[/pgn]
[pgn][White "CT800 V1.45, 5s/move"]
[Black "Chessmate"]
[Result "1-0"]
1.d4 c5 2.e3 d5 3.Nf3 e6 4.c4 Nc6 5.cxd5 exd5 6.Bb5 Bd6 7.dxc5 Bxc5 8.O-O Bd6
9.Nc3 (9.Qxd5 $4 Bxh2+) 9...Nf6 10.Kh1 {no Bxh2+} Bb8 11.Qa4 Qd7 12.b3 O-O 13.Ba3 Re8 14.
Rad1 Qc7 15.Nxd5 Nxd5 16.Rxd5 Be6 17.Rd6 Qb6 18.Rxc6 Qd8 19.Rcc1 Re7 20.Rfd1
Qf8 21.Bd7 Bd6 22.Bxd6 Bxd7 23.Bxe7 Qxe7 24.Qxd7 Qd8 25.Qxd8+ Rxd8 26.Rxd8# 1-0[/pgn]
Rasmus Althoff
https://www.ct800.net
https://www.ct800.net
-
- Posts: 28265
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: A probabilistic chess engine
The Interactive Diagram is similar (22knps). The depth of 5.5 ply is an under-estimate, though, as it has many extensions. And in particular extends the moves in the root that are tactically connected to the latest move in the game. OTOH it does not fully extend all captures in QS. Even good captures that do not recapture the last-moved piece only get extended by half a ply.
[Edit] Chessmate makes strange blunders. In the game below 57... Ra4? blunders away the Rook in a won position. I cannot imagine what move it would speculate on that would make Ra4 'win faster':
[pgn][White "Interactive Diagram"]
[Black "Chessmate Demo"]
[Result "1-0"]
1. e4 c5 2. Nf3 Nc6 3. Bd3 Nb4 4. O-O Nf6 5. h4 Qa5 6. Nc3 d6 7. Bc4 Bd7 8. d3 b5 9. Bb3 Nc6 10. Bd2 e6 11. Nd5 Qd8 12. Nxf6 Qxf6 13. Bc3 Nd4 14. Bxd4 cxd4 15. a4 b4 16. Qe1 Be7 17. Qxb4 d5 18. Qb7 Rd8 19. exd5 Bc5 20. dxe6 fxe6 21. Qa6 e5 22. Qxf6 gxf6 23. Rae1 Ke7 24. Nh2 Bc6 25. Re2 Rb8 26. Rd1 Rhc8 27. f4 e4 28. Nf3 h5 29. f5 Rf8 30. Nd2 e3 31. Ne4 Bd6 32. Nxd6 Kxd6 33. Rf1 Ke5 34. Be6 Rxb2 35. a5 Bb5 36. Rfe1 Rh8 37. c4 dxc3 38. Rxe3 Kd4 39. Bc4 Bxc4 40. dxc4 Rd8 41. Re4 Kc5 42. Rc1 Rbd2 43. Rxc3 Kb4 44. Rc1 Rg8 45. Rb1 Kc3 46. Re3 Kd4 47. Rf3 Rdxg2 48. Kh1 R2g4 49. Rd1 Ke4 50. Rh3 a6 51. Rf1 Rf4 52. Rxf4 Kxf4 53. Rh2 Kxf5 54. Rf2 Ke6 55. Kh2 Rc8 56. Kg3 Rxc4 57. Rf4 Ra4 58. Rxa4 Kd6 59. Kf4 Kc5 60. Kf5 Kc6 61. Kxf6 Kb5 62. Ra2 Kb4 63. Ke5 Kb3 64. Re2 Ka4 65. Kd4 Kxa5 66. Kc5 Ka4 67. Ra2 Kb3 68. Rxa6 Kc3 69. Kd5 Kd3 70. Ra3 Ke2 71. Ke4 Kd2 72. Rd3 Ke2 73. Rd5 Kf2 74. Rxh5 Kg3 75. Ke3 Kh2 76. Kf2 Kh1 77. Kg3 Kg1 78. Rh6 Kh1 79. Re6 Kg1 80. Re1# {checkmate}[/pgn]