Discuss Scratch

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Samueldora wrote:

I managed to load your file into “Game of Kings” but didn't get Black to move then.

I always export the board before a white move, same here. The white king has to move out of the check, then black will continue.

Thanks for trying. Interesting, “Game of Kings” won against “The Turk” this time. I will make it play the white side too, this will be easier. Thanks for your patience. There is performance tuning potential. I always run it on my best hardware, if not I get impatient too.

Last edited by ArnoHu (April 15, 2017 10:39:28)

Samueldora
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

Samueldora wrote:

ArnoHu wrote:

And finally, what about https://scratch.mit.edu/projects/569176/ - it seems to be the oldest and most commonly used chess game on Scratch.

Thanks once more!

I very much appreciate Midecah's project. It was a great achievement in the early Scratch days, but when testing it recently I experienced correctness problems as well as very limited search depth, so I decided to not include it in this competition.

To complete the bunch of AIs, here's a game with Midecah's Chess:

Event “AI Test Game”
Site “Scratch”
Date “2017.04.15”
Round “?”
White “Bonsai Chess (Samueldora)”
Black “Chess (Midecah)”
Result “1-0”

1.d4 h5 2.e4 h4 3.Nf3 e6 4.Bb5 Rh7 5.e5 b6 6.O-O f5 7.Bg5 Qxg5 8.Nxg5 Rh6 9.Qf3 c6 10.Ba4 g6 11.c4 a6 12.Qb3 Rh5 13.Nf3 Ne7 14.Qxb6 and here the Nb8 disappeared from the board. 1-0
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

OK nice, now the comparison is complete.

Finally I found some time to let Game of Kings play against Bonsai. Here Game of Kings won. I am no expert, but for me this was the most interesting Scratch-vs-Scratch game I have seen so far (Bonsai is white):

c2-c4
e7-e5
b1-c3
f8-c5
e2-e3
b8-c6
c3-d5
g8-f6
d1-c2
h7-h6
g1-f3
e8-g8
e3-e4
d7-d6
d2-d3
c8-e6
d5xf6
d8xf6
c1-d2
e6-g4
b2-b4
c6xb4
c2-b1
a7-a5
d3-d4
e5xd4
b1-b2
f6-e7
b2-b1
f8-e8
h2-h3
g4xf3
g2xf3
e7-h4
f1-g2
d4-d3
d2xb4
h4xf2
e1-d1
f2xg2
h1-e1
g2xf3
d1-c1
a5xb4
a2-a4
e8xe4
e1xe4
f3xe4
c1-d2
c5-e3
d2-e1
e4-h1
Samueldora
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

Congratulations! Well played by “Game of Kings”. After 11.b2-b4? Bonsai is rapidly going downhill.

Frodewin has suggested to build a player, where two chess engines can play a game without a human interface like you or me transfering the moves. Good idea, I think. Maybe this is interesting for you (and others) as well.

German language forum on Coder Dojo Linz.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Samueldora wrote:

Congratulations! Well played by “Game of Kings”. After 11.b2-b4? Bonsai is rapidly going downhill.

Frodewin has suggested to build a player, where two chess engines can play a game without a human interface like you or me transfering the moves. Good idea, I think. Maybe this is interesting for you (and others) as well.

German language forum on Coder Dojo Linz.

That sounds interesting. I will have a look at it!
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

I re-implemented move ordering for an average speedup of 50%. The change was pretty huge. I played one game side-by-side with the old implementation, and it acted identical. Still, if you encounter any strange behavior, please let me know! Thank you!

Last edited by ArnoHu (April 17, 2017 05:15:30)

Samueldora
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

The speed gain is impressive. And it is important, because there have been many complaints about the needed thinking time in the comments on the elder Scratch chess Projects. Chess on Scratch has made good progress during the last weeks. Here's another game of Bonsai against Game of Kings. Both projects play interesting chess and turn a symmetrical and super solid Four-Knights-Opening into an open fight.

Event “AI Test Game”
Site “Scratch”
Date “2017.04.17”
White “Bonsai Chess (Samueldora)”
Black “Scratch Chess (ArnoHu)”
Result “1-0”

1.e4 e5 2.Nc3 Nc6 3.Nf3 Bc5 4.Bc4 Nf6 5.h3 O-O 6.O-O Bb4 7.d3 d6 8.Bg5 h6 9.Bxf6 gxf6 10.Nd5 a6 11.c3 Bc5 12.b4 b5 13.Bb3 Ba7 14.Qd2 Kg7 15.Rad1 Be6 16.d4 exd4 17.cxd4 f5 18.exf5 Bxf5 19.Qc3 Qd7 20.Rc1 Bxd4 21.Qxc6 Qxc6 22.Rxc6 Bb2 23.Rxc7 Rac8 24.Rxc8 Bxc8 25.Rb1 Ba3 26.Rd1 Bb7 27.Rd4 f5 28.g3 h5 29.h4 Kf7 30.Ng5+ Kg6 31.Nf4+ Kh6 32.Rxd6+ Kg7 33.Nxh5+ Kh8 34.Rh6# 1-0

Last edited by Samueldora (April 17, 2017 18:01:00)

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Yes, due to last week's performance tuning, part of the pawn evaluation had disappeared, I merged it back into the code.
Grijfland
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

The king on the walk

“The Game of Kings” 1 e4-e6 2 Qf3-e5 3 Bc4-Nh6 4 Qh5-d6 5 Nf3-c5 ? (Bg4!) 6 Ng5-Kd7 (Bg4!) 7 Nxf7-Nxf7 8 Qxf7-Kc6 9 Bd5-Kb6 10 a4-Nc6
11 Na3-a5 12 Nc4+ -Ka6 … etc.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Grijfland wrote:

The king on the walk

“The Game of Kings” 1 e4-e6 2 Qf3-e5 3 Bc4-Nh6 4 Qh5-d6 5 Nf3-c5 ? (Bg4!) 6 Ng5-Kd7 (Bg4!) 7 Nxf7-Nxf7 8 Qxf7-Kc6 9 Bd5-Kb6 10 a4-Nc6
11 Na3-a5 12 Nc4+ -Ka6 … etc.

Uh, seems I have to increase its penalty even more then. Thanks for reporting this!
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Thanks for 1000 players in the first seven weeks since “Chess - Game of King”'s inception! I hope you enjoy the game.

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

I implemented a fourth difficulty level, which switches to ply5 on interesting boards, e.g. pieces being taken at move 4. Think time went up to 30-60 seconds. Here is a first test game against Bonsai (white):

e2e4 e7e5, Nb1c3 Nb8c6, Ng1f3 Ng8f6, Ke1e2 Bf8b4, Ke2d3 O-O, Nc3d5 Nf6xd5, e4xd5 Nc6e7, Kd3c4 Bb4d6, Qd1e2 c7c6, d5xc6 Ne7xc6, Qe2d3 Qd8f6, Kc4b5 Nc6b4, Qd3b3 e5e4, a2a3 Qf6f5, Kb5a4 e4xf3, a3xb4 f3xg2, Bf1xg2 Qf5xf2, Qb3d5 Rf8e8, Qd5xd6 Qf2xg2, Rh1d1 Re8e6, Qd6c7 Re6a6, Qc7a5 Qg2c6, Ka4b3 Qc6f3, Kb3c4 Qf3e2, Kc4c5 d7d6, Kc5d5 Bc8e6, Kd5d4 Ra6xa5, b4xa5 Qe2xd1, Kd4c3 Ra8c8, Kc3b4 Rc8xc2, d2d3 h7h5, a5a6 b7xa6, Ra1xa6 Qd1xc1, Ra6xa7 Qc1xb2, Kb4a5 Qb2a3, Ka5b6 Rc2b2, Kb6c7 Qa3c5, Kc7d8 Qc5xa7, h2h3 Rb2b8

More testing and fine-tuning required.

Last edited by ArnoHu (April 28, 2017 13:20:44)

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Thanks to Grijfland, Chess - GoK now has a new opening book (the old one was a proof of concept, not more). That surely was a lot of work and should improve the opening game significantly - highly appreciated, Grijfland!


Samueldora
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

I implemented a fourth difficulty level, which switches to ply5 on interesting boards, e.g. pieces being taken at move 4. Think time went up to 30-60 seconds. Here is a first test game against Bonsai (white):

e2e4 e7e5, Nb1c3 Nb8c6, Ng1f3 Ng8f6, Be1e2 Bf8b4, Be2d3 O-O, Nc3d5 Nf6xd5, e4xd5 Nc6e7, Bd3c4 Bb4d6, Qd1e2 c7c6, d5xc6 Ne7xc6, Qe2d3 Qd8f6, Bc4b5 Nc6b4, Qd3b3 e5e4, a2a3 Qf6f5, Bb5a4 e4xf3, a3xb4 f3xg2, Bf1xg2 Qf5xf2, Qb3d5 Rf8e8, Qd5xd6 Qf2xg2, Rh1d1 Re8e6, Qd6c7 Re6a6, Qc7a5 Qg2c6, Ba4b3 Qc6f3, Bb3c4 Qf3e2, Bc4c5 d7d6, Bc5d5 Bc8e6, Bd5d4 Ra6xa5, b4xa5 Qe2xd1, Bd4c3 Ra8c8, Bc3b4 Rc8xc2, d2d3 h7h5, a5a6 b7xa6, Ra1xa6 Qd1xc1, Ra6xa7 Qc1xb2, Bb4a5 Qb2a3, Ba5b6 Rc2b2, Bb6c7 Qa3c5, Bc7d8 Qc5xa7, h2h3 Rb2b8

More testing and fine-tuning required.

Feedback:

0) Stronger play, good work!

1) Above move list is not readable: Bb5-a4 moves the white-squared bishop to a4, and a few moves lates it appears on f1 to take on g2.

2) 3 move repetition is sometimes claimed after 2 repetitions: Example in FEN/PGN: r1b4r/1p3kpp/p2Bp3/4P3/2P5/P1n2N2/2P3PP/R1K2R2 b follows 1…Ne2+ 2.Kb1 Nc3+ 3.Kb2 Na4+ 4.Kc1 Nc3 (same position, but white to move) 5.Ne1 Ke8 6.Nf3 Kf7 (same position, again white to move, so this is a second repetiion, not a third, as Game of Kings Claims).

3) Bug in the opening book: 1.e4 e6 2.d4 d5 3.e5 c5 4.c3 Nf6?
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Samueldora wrote:

1) Above move list is not readable: Bb5-a4 moves the white-squared bishop to a4, and a few moves lates it appears on f1 to take on g2.
Thanks, bug in algebraic notation where kings were labeled with “B”. I corrected it in the message above. Yes, the king was out for a walk :-)

Last edited by ArnoHu (April 28, 2017 13:27:21)

Grijfland
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

Ahh Samueldora, yes indeed 4. c3 Nf6 is a bug. 4. ce Nc6 is the right move. "The last error will never be found".

It will be corrected.

And there are comming more moves in the opening book.

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Grijfland wrote:

Ahh Samueldora, yes indeed 4. c3 Nf6 is a bug. 4. ce Nc6 is the right move. "The last error will never be found".

Thanks, fixed!
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

I implemented a fourth difficulty level, which switches to ply5 on interesting boards, e.g. pieces being taken at move 4. Think time went up to 30-60 seconds. Here is a first test game against Bonsai (white):

e2e4 e7e5, Nb1c3 Nb8c6, Ng1f3 Ng8f6, Ke1e2 Bf8b4, Ke2d3 O-O, Nc3d5 Nf6xd5, e4xd5 Nc6e7, Kd3c4 Bb4d6, Qd1e2 c7c6, d5xc6 Ne7xc6, Qe2d3 Qd8f6, Kc4b5 Nc6b4, Qd3b3 e5e4, a2a3 Qf6f5, Kb5a4 e4xf3, a3xb4 f3xg2, Bf1xg2 Qf5xf2, Qb3d5 Rf8e8, Qd5xd6 Qf2xg2, Rh1d1 Re8e6, Qd6c7 Re6a6, Qc7a5 Qg2c6, Ka4b3 Qc6f3, Kb3c4 Qf3e2, Kc4c5 d7d6, Kc5d5 Bc8e6, Kd5d4 Ra6xa5, b4xa5 Qe2xd1, Kd4c3 Ra8c8, Kc3b4 Rc8xc2, d2d3 h7h5, a5a6 b7xa6, Ra1xa6 Qd1xc1, Ra6xa7 Qc1xb2, Kb4a5 Qb2a3, Ka5b6 Rc2b2, Kb6c7 Qa3c5, Kc7d8 Qc5xa7, h2h3 Rb2b8

More testing and fine-tuning required.

After some performance tuning the ply5-lookahead version performed at the same level as ply4 before, so I merged it into the main Chess - GoK project. Game strength improved and it played some fine games against Bonsai, which were fun to watch. I should have captured the game protocol - will provide more in the future.

So the project link mentioned above doesn't work any more, it is as always: https://scratch.mit.edu/projects/148769358/

Last edited by ArnoHu (April 30, 2017 02:56:26)

Grijfland
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

Bonsai (level3)-Game of Kings(level medium) 1-0 Move 29 Checkmate !

1 Nf3-Nf6 / 2 Nc3-d5 / 3 d4-Nc6 / 4 Bf4-Bg4 / 5 Ne5-Nxe5 / 6 dxe5 ?(Bxe5)-Nh5 / 7 Nxd5-Nxf4 / 8 Nxf4-Qxd1 ?(Loses a pace move) / 9 Rxd1-e6 /
10 a4?-Bb4 / 11 c3-Bc5 / 12 b4-Bb6 ? (crashes) / 13 Nd3- O-O-O !! / 14 a5 ! -Bxa5 / 15 bxa5-a6 / 16 f3-Bh5 / 17 g4-Bg6 / 18 e4- Rd7 /
19 Bg2 - Rg8 ? (Rd8 !) / 20 f4 - Kb8 ? / 21 O-O ! - Kc8 / 22 Nc5 ! - Rxd1 / 23 Rxd1 - Kb8 ? / 24 Rb1 ! - Ka7 ? / 25 Rxb7 - Ka8 / 26 Rxc7 - Kb8 (Tb8) /
27 Nxa6 - Ka8 / 28 f5 ! - exf5 / 29 exf5 + # 1-0
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Grijfland wrote:

Bonsai (level3)-Game of Kings(level medium) 1-0 Move 29 Checkmate !

1 Nf3-Nf6 / 2 Nc3-d5 / 3 d4-Nc6 / 4 Bf4-Bg4 / 5 Ne5-Nxe5 / 6 dxe5 ?(Bxe5)-Nh5 / 7 Nxd5-Nxf4 / 8 Nxf4-Qxd1 ?(Loses a pace move) / 9 Rxd1-e6 /
10 a4?-Bb4 / 11 c3-Bc5 / 12 b4-Bb6 ? (crashes) / 13 Nd3- O-O-O !! / 14 a5 ! -Bxa5 / 15 bxa5-a6 / 16 f3-Bh5 / 17 g4-Bg6 / 18 e4- Rd7 /
19 Bg2 - Rg8 ? (Rd8 !) / 20 f4 - Kb8 ? / 21 O-O ! - Kc8 / 22 Nc5 ! - Rxd1 / 23 Rxd1 - Kb8 ? / 24 Rb1 ! - Ka7 ? / 25 Rxb7 - Ka8 / 26 Rxc7 - Kb8 (Tb8) /
27 Nxa6 - Ka8 / 28 f5 ! - exf5 / 29 exf5 + # 1-0

OK, I would have to check in detail, but GoK can only compete with Bonsai's level 3 on level Difficult. It's already a tough nut then, the last games I played was one win each, and two draws. One draw was a particularly nice game, I should have kept the records. My feeling was that Bonsai still had a bit of an advantage (esp. creativity of moves), but GoK had about 1/3 lower think time, so that's something that could be used, e.g. for applying ply5 on more scenarios, or even ply6 on an otherwise chosen move (I saw GoK run into an open knife already twice as it didn't anticipate white's response to move 5).

And I finally added a defense strategy against pawn promotion, when the limited move depth didn't let it to catch up with an escaping pawn due to the board distance. Something I also saw Bonsai run into once as well, I think it would have tied the game otherwise.

BTW, I found one mistake in the opening book: 5236122863461220584313215236072253450219. There is a phantom move 1220, after already having moved 1228 before.

Last edited by ArnoHu (May 1, 2017 03:57:38)

Powered by DjangoBB