Discuss Scratch

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Remes_ wrote:

Hi. Can anybody create game 8pawns player VS 8 pawns computer? Who first get last row - winner.

A similar remix exists already here: https://scratch.mit.edu/projects/161096332/

It should be easy to adapt.

Scratch Chess - Game of Kings

Last edited by ArnoHu (July 20, 2017 06:25:16)

Remes_
Scratcher
27 posts

Scratch Chess Engine - Game of Kings

No. In this remix I made a king + pawns against the king + pawns + figures. The goal is to mate the king. In a new project, i would like that there were no kings. Only 16 pawns. And the goal is to take to the last line. Algorithms will be different.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Remes_ wrote:

No. In this remix I made a king + pawns against the king + pawns + figures. The goal is to mate the king. In a new project, i would like that there were no kings. Only 16 pawns. And the goal is to take to the last line. Algorithms will be different.

I think you can re-use the existing one. Simply change the value for queens in InitBoard() to something like 19999 resp. -19999. Reaching the other side will lead to a pawn promotion, and with those values the board will be interpreted as checkmate. Haven't tried, but that could work.

Scratch Chess - Game of Kings
Remes_
Scratcher
27 posts

Scratch Chess Engine - Game of Kings

I again can not find a function where the initial arrangement of the figures
(I accidentally wiggled my finger on the touchpad, and all the code of the old project broke. Now I do not know what I changed and how to get it back.)

Last edited by Remes_ (July 21, 2017 17:19:23)

astroboy2009
Scratcher
13 posts

Scratch Chess Engine - Game of Kings

Hey
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Remes_ wrote:

I again can not find a function where the initial arrangement of the figures
(I accidentally wiggled my finger on the touchpad, and all the code of the old project broke. Now I do not know what I changed and how to get it back.)

The board is set up in the “InitBoard” function block (sprite “Board”)

Scratch Chess - Game of Kings
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Another nice feature would be a two-player mode for Scratch Chess - Game of Kings. But I am not talking about the simple approach some other projects took, namely both players sitting in front of the same screen. I refer to remote players, signed-in on Scratch.

This is possible by applying cloud variables. I have done something similar before (including cloud-variable encoding of more complex data - as cloud-variables can only contain numeric values) within my Highscore List project. I don't even think it would be too much effort. One drawback: only users at Scratcher level can use cloud variables. I wonder which percentage of the user base is at Scratcher level?

Would you like to play chess with remote users on Scratch? Do you have specific ideas / requests for such an implementation? Thank you!

Scratch Chess - Game of Kings
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

Another nice feature would be a two-player mode for Scratch Chess - Game of Kings. But I am not talking about the simple approach some other projects took, namely both players sitting in front of the same screen. I refer to remote players, signed-in on Scratch.

This is possible by applying cloud variables. I have done something similar before (including cloud-variable encoding of more complex data - as cloud-variables can only contain numeric values) within my Highscore List project. I don't even think it would be too much effort. One drawback: only users at Scratcher level can use cloud variables. I wonder which percentage of the user base is at Scratcher level?

Would you like to play chess with remote users on Scratch? Do you have specific ideas / requests for such an implementation? Thank you!

Scratch Chess - Game of Kings

I did some initial research on this, and a remote-player chess game via cloud variables seems feasible. I will start working on a prototype as soon as time allows for it, and post a project link here when available for testing.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Great news, @Grijfland has extended his opening book again! Highly appreciated, and this shows how teamwork can help to improve Scratch projects. Do you want to give it a try by playing another game of Scratch Chess - Game of Kings? Thanks @Grijfland!

Scratch Chess - Game of Kings
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Thanks to user @blueking24, who pointed out a performance regression that happened due to some refactoring (parameter renaming). This affected move ordering and led to a longer think time. The bug has been fixed, and think time is back what it used to be before.

Scratch Chess - Game of Kings

Last edited by ArnoHu (Sept. 14, 2017 21:42:51)

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

I have been working on another “Scratch Chess - Game of Kings” version in parallel that applies a transposition table for caching search tree results. The cache is implemented as a hashmap, and with hashing being inherently slow on Scratch due to the lack of bitwise operators, this poses quite a challenge. The current prototype is already slightly faster than the original version, which lacks such a cache. And there is still a lot of performance tuning potential left..

Please give the Chess Transposition Table Prototype a try and let me know what you think. Feedback and bug reports are welcome here or in the comments section. Thank you!

Scratch Chess - Game of Kings
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Test game

Chess GoK Ply6 prototype ( https://scratch.mit.edu/projects/172091160/ ) vs. Bonsai ( https://scratch.mit.edu/projects/86498104/ ): e2-e4,e7-e5,f1-c4,g8-f6,b1-c3,f6xe4,c3xe4,d7-d5,g1-f3,d5xc4,d1-e2,b8-c6,e2xc4,c8-e6,c4-b5,a7-a6,b5-f1,f8-b4,a2-a3,c6-d4,f3xd4,d8xd4,e4-g5,e6-c4,f1-g1,d4-g4,g5-f3,g4-e4,e1-d1,e4-e2
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

I tuned the Ply6 prototyp at https://scratch.mit.edu/projects/172091160/ furthermore, so it now provides a swift playing experience at around 30sec think time. Playing strength should have stayed the same. After some code cleanup and another round of testing, I will merge Ply6 back into the main project.

Scratch Chess - Game of Kings
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

I recorded the Kochy-Richter checkmate in three moves via Scratch video. Thanks to @Grijfland for pointing that out

Scratch Chess - Game of Kings
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

The latest Chess - Game of Kings version adjusts the playing strength at level “Difficult” automatically, so that think-time always is around one minute (depending on the hardware performance). It toggles between search depth 4 + quiescence, depth 5 resp. depth 5 + quiescence on modern hardware.

Scratch Chess - Game of Kings
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

As some people asked in the project comments (where you can't post external links), here is the chess programming tutorial from CoderDojo Linz, for which this project was originally created: http://coderdojo-linz.github.io/trainingsanleitungen/scratch/scratch-chess.html (in German). I will provide an English version soon. In the meantime, this is Google's translation (and when it states “train”, it actually means “move” ): https://goo.gl/2iErTa

Scratch Chess - Game of Kings
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

Kochy-Richter checkmate by Scratch Chess - Game of Kings in three moves - simply click on the picture to play the video:


ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

I implemented a promotion piece selection prototype at https://scratch.mit.edu/projects/186569686.

Board definition for testing:

0,0,0,0,0,0,0,0,
0,0,0,0,0,-100,0,0,
0,0,0,0,0,0,0,0,
0,0,20000,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,-20000,0,0,
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

With the latest Scratch Chess - Game of Kings version, we have reached a search depth of 6 to 8 moves (including quiescence search) on level Difficult. Thinktime is between 30 and 60 seconds (depending on board and hardware).

It has been quite a leap forward compared to the 3 moves the first version back form March could look ahead.

Scratch Chess - Game of Kings

Powered by DjangoBB