Discuss Scratch

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

It is off-topic, but I have to say it. @Grijfland, Austria is 1:0 vs Netherlands, Possession 63% vs. 37% at minute 14
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
Yes, I am French and I live in France, and I conclude that you must be in Austria? I am not interested in football… Otherwise, during tests on Destructor, I added 1 to the maximum depth of search for quiescence, and the time went up to 200 seconds (3 minutes) despite the transpositions tables… Do you have an explanation of why time believes so much (lol, Austria in English does not look at all like ‘Autriche’ in French, I thought it was a lost corner of America)

I have heard some ppl outside Europe mix us up with Australia, but France - hey, we have been fighting each other for centuries!

I took a quick look at Destructor 1.4.2 CompMode, please don't use listIndexOf() in inner loops / functions or on large lists, it is a performance killer with O(N) runtime complexity. Most of your CPU cycles are burnt there. There is always an alternative implementation. GoK only applies listIndexOf() at one place, not an inner loop, and the list is of size 4.
Frankly, I don’t even know where I used this or that… I would look at this, thank you for your advice! (Which I have no idea to apply), is there an alternative?

It's listIndexOf (list-indexOf or list-contains, e.g. In “Vérifier board 2 avec roi” for example), also indexOf (string-contains, e.g. in “Essayer de bouger et validation” and “”WEssayer de bouger 2“). If you are looking for the king index on your board, have a variable dedicated for that and update it when kings moves, but don't scan the board for the king each time. Scratch doesn't simply look for a value in a list (which would be bad enough), internally it does type conversions, tries to trail whitespaces, and more on each and every element comparison.

And the way to find these things is to use browser F12 dev tools on TurboWarp. E.g. on Chrome, press F12, click the record button in ”Performance" tab, then make move and let Destructor run a search, then stop recording, click Performance / Bottom Up, and sort the list of functions by total time. You can then click the .js source link and investigate each line of code on how much time is spent.

More info, string-contains is invoked 50 million times alone by “Essayer de bouger et validation 2”, and this is what it has to do on each of them:
https://github.com/scratchfoundation/scratch-vm/blob/8814c1762f9b67d0710b2ed51b7954222d404df0/src/blocks/scratch3_operators.js#L111

It casts everything to a string, then converts two strings to lower case (means allocating new strings), then invokes includes() on them. What you want to have performance-wise in the innermost code, are operations on scalar numeric values (including comparisons), without any conversions. That is the idea that GoK is built upon.

And list-contains / list-indexOf is even worse, overhead-wise.

Another problem are those busy loops waiting for user input. Please use when-clicked or when-key-pressed instead.

And sorry, I actually wanted to link to TurboWarp github code, which looks the same:
https://github.com/TurboWarp/scratch-vm/blob/dff3c2f6bab2fec3c9cebbdb91fae75f9a50af51/src/blocks/scratch3_operators.js#L114

Last edited by ArnoHu (Yesterday 06:25:14)

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

GoK NNUE (10sec, black) vs. White Dove (P2), GoK wins: https://lichess.org/qanbjD8d#128


GoK NNUE (Medium, black) vs. Element (6+8), double-blunder by Element early on, loses in 14 moves: https://lichess.org/VF7AWBLw#28

Last edited by ArnoHu (Yesterday 05:32:30)

ScratchChessChampion
Scratcher
95 posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

HasiLover_Test wrote:

ScratchChessChampion wrote:

Hey guys, I'm back from my exam! Hope I can get A's in my subjects.

I plan to organize a tournament for July. Should I organize a chess championship match or something else? Let me know what you think!
Maybe a Blitz Tournament? Where the Engines have to play on time?

Yes, that would be interesting (and fair), requires less time for the organizer. Also, it is cool to watch online with other creators, maybe we find a schedule suitable for most of us?

And: Could you please add GoK NNUE to the Scratch Chess Foundation? Thanks!

Sure, i will add it in the July update.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ScratchChessChampion wrote:

ArnoHu wrote:

HasiLover_Test wrote:

ScratchChessChampion wrote:

Hey guys, I'm back from my exam! Hope I can get A's in my subjects.

I plan to organize a tournament for July. Should I organize a chess championship match or something else? Let me know what you think!
Maybe a Blitz Tournament? Where the Engines have to play on time?

Yes, that would be interesting (and fair), requires less time for the organizer. Also, it is cool to watch online with other creators, maybe we find a schedule suitable for most of us?

And: Could you please add GoK NNUE to the Scratch Chess Foundation? Thanks!

Sure, i will add it in the July update.


For the rating, I have posted test games here, worth mentioning is it only has reached full potential recently.
ababoin07
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

ArnoH wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

It is off-topic, but I have to say it. @Grijfland, Austria is 1:0 vs Netherlands, Possession 63% vs. 37% at minute 14
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
Yes, I am French and I live in France, and I conclude that you must be in Austria? I am not interested in football… Otherwise, during tests on Destructor, I added 1 to the maximum depth of search for quiescence, and the time went up to 200 seconds (3 minutes) despite the transpositions tables… Do you have an explanation of why time believes so much (lol, Austria in English does not look at all like ‘Autriche’ in French, I thought it was a lost corner of America)

I have heard some ppl outside Europe mix us up with Australia, but France - hey, we have been fighting each other for centuries!

I took a quick look at Destructor 1.4.2 CompMode, please don't use listIndexOf() in inner loops / functions or on large lists, it is a performance killer with O(N) runtime complexity. Most of your CPU cycles are burnt there. There is always an alternative implementation. GoK only applies listIndexOf() at one place, not an inner loop, and the list is of size 4.
Frankly, I don’t even know where I used this or that… I would look at this, thank you for your advice! (Which I have no idea to apply), is there an alternative?

It's listIndexOf (list-indexOf or list-contains, e.g. In “Vérifier board 2 avec roi” for example), also indexOf (string-contains, e.g. in “Essayer de bouger et validation” and “”WEssayer de bouger 2“). If you are looking for the king index on your board, have a variable dedicated for that and update it when kings moves, but don't scan the board for the king each time. Scratch doesn't simply look for a value in a list (which would be bad enough), internally it does type conversions, tries to trail whitespaces, and more on each and every element comparison.

And the way to find these things is to use browser F12 dev tools on TurboWarp. E.g. on Chrome, press F12, click the record button in ”Performance" tab, then make move and let Destructor run a search, then stop recording, click Performance / Bottom Up, and sort the list of functions by total time. You can then click the .js source link and investigate each line of code on how much time is spent.

What I also noticed are busy loops, checking for user input. I suggest to turn all of that off, there are message handlers for what, e.g. when-clicked, when-key-pressed. Loops scanning for input will keep your CPU busy and slow down everything else.
Okay, I 'll see that
ababoin07
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

It is off-topic, but I have to say it. @Grijfland, Austria is 1:0 vs Netherlands, Possession 63% vs. 37% at minute 14
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
Yes, I am French and I live in France, and I conclude that you must be in Austria? I am not interested in football… Otherwise, during tests on Destructor, I added 1 to the maximum depth of search for quiescence, and the time went up to 200 seconds (3 minutes) despite the transpositions tables… Do you have an explanation of why time believes so much (lol, Austria in English does not look at all like ‘Autriche’ in French, I thought it was a lost corner of America)

I have heard some ppl outside Europe mix us up with Australia, but France - hey, we have been fighting each other for centuries!

I took a quick look at Destructor 1.4.2 CompMode, please don't use listIndexOf() in inner loops / functions or on large lists, it is a performance killer with O(N) runtime complexity. Most of your CPU cycles are burnt there. There is always an alternative implementation. GoK only applies listIndexOf() at one place, not an inner loop, and the list is of size 4.
Frankly, I don’t even know where I used this or that… I would look at this, thank you for your advice! (Which I have no idea to apply), is there an alternative?

It's listIndexOf (list-indexOf or list-contains, e.g. In “Vérifier board 2 avec roi” for example), also indexOf (string-contains, e.g. in “Essayer de bouger et validation” and “”WEssayer de bouger 2“). If you are looking for the king index on your board, have a variable dedicated for that and update it when kings moves, but don't scan the board for the king each time. Scratch doesn't simply look for a value in a list (which would be bad enough), internally it does type conversions, tries to trail whitespaces, and more on each and every element comparison.

And the way to find these things is to use browser F12 dev tools on TurboWarp. E.g. on Chrome, press F12, click the record button in ”Performance" tab, then make move and let Destructor run a search, then stop recording, click Performance / Bottom Up, and sort the list of functions by total time. You can then click the .js source link and investigate each line of code on how much time is spent.

What I also noticed are busy loops, checking for user input. I suggest to turn all of that off, there are message handlers for what, e.g. when-clicked, when-key-pressed. Loops scanning for input will keep your CPU busy and slow down everything else.
Okay, I 'll see that , thank you
AZURUS41
Scratcher
57 posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

It is off-topic, but I have to say it. @Grijfland, Austria is 1:0 vs Netherlands, Possession 63% vs. 37% at minute 14
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
France played crazy bad during all the 3 games, I hope we'll do better in the next games…
birdracerthree
Scratcher
500+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

GoK NNUE (10sec, black) vs. White Dove (P2), GoK wins: https://lichess.org/qanbjD8d#128


GoK NNUE (Medium, black) vs. Element (6+8), double-blunder by Element early on, loses in 14 moves: https://lichess.org/VF7AWBLw#28
GoK NNUE has found exploits in the Scotch and the Four Knights Scotch against Element. This is the fastest anyone has defeated Element.

The dev version plays the superior move 8. Qf3 instead of 8. Qe1?! Feel free to try it and tell me if the positional play is better (although the Scorch Game exploit is not patched in the Dev version) Edit : I have finally patched all of the opening issues in both versions.

The ONE TIME I leave the house and touch grass, there is something I have to patch in Element…

Last edited by birdracerthree (Today 04:18:29)

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

GoK NNUE (10sec, black) vs. White Dove (P2), GoK wins: https://lichess.org/qanbjD8d#128


GoK NNUE (Medium, black) vs. Element (6+8), double-blunder by Element early on, loses in 14 moves: https://lichess.org/VF7AWBLw#28

White Dove (P3, white) with a strange queen blunder against GoK NNUE (Medium), loses in 39 moves: https://lichess.org/UFiV2iLs#78
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ababoin07 wrote:

ArnoH wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

It is off-topic, but I have to say it. @Grijfland, Austria is 1:0 vs Netherlands, Possession 63% vs. 37% at minute 14
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
Yes, I am French and I live in France, and I conclude that you must be in Austria? I am not interested in football… Otherwise, during tests on Destructor, I added 1 to the maximum depth of search for quiescence, and the time went up to 200 seconds (3 minutes) despite the transpositions tables… Do you have an explanation of why time believes so much (lol, Austria in English does not look at all like ‘Autriche’ in French, I thought it was a lost corner of America)

I have heard some ppl outside Europe mix us up with Australia, but France - hey, we have been fighting each other for centuries!

I took a quick look at Destructor 1.4.2 CompMode, please don't use listIndexOf() in inner loops / functions or on large lists, it is a performance killer with O(N) runtime complexity. Most of your CPU cycles are burnt there. There is always an alternative implementation. GoK only applies listIndexOf() at one place, not an inner loop, and the list is of size 4.
Frankly, I don’t even know where I used this or that… I would look at this, thank you for your advice! (Which I have no idea to apply), is there an alternative?

It's listIndexOf (list-indexOf or list-contains, e.g. In “Vérifier board 2 avec roi” for example), also indexOf (string-contains, e.g. in “Essayer de bouger et validation” and “”WEssayer de bouger 2“). If you are looking for the king index on your board, have a variable dedicated for that and update it when kings moves, but don't scan the board for the king each time. Scratch doesn't simply look for a value in a list (which would be bad enough), internally it does type conversions, tries to trail whitespaces, and more on each and every element comparison.

And the way to find these things is to use browser F12 dev tools on TurboWarp. E.g. on Chrome, press F12, click the record button in ”Performance" tab, then make move and let Destructor run a search, then stop recording, click Performance / Bottom Up, and sort the list of functions by total time. You can then click the .js source link and investigate each line of code on how much time is spent.

What I also noticed are busy loops, checking for user input. I suggest to turn all of that off, there are message handlers for what, e.g. when-clicked, when-key-pressed. Loops scanning for input will keep your CPU busy and slow down everything else.
Okay, I 'll see that

OK, did you see the latest message at https://scratch.mit.edu/discuss/post/8029714/ ?

The question is also, why is a block invoked 50 million times within a 40sec search? I think you said it runs at 10k NPS? That would be 125 invocations per node…
birdracerthree
Scratcher
500+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

GoK NNUE (10sec, black) vs. White Dove (P2), GoK wins: https://lichess.org/qanbjD8d#128


GoK NNUE (Medium, black) vs. Element (6+8), double-blunder by Element early on, loses in 14 moves: https://lichess.org/VF7AWBLw#28

White Dove (P3, white) with a strange queen blunder against GoK NNUE (Medium), loses in 39 moves: https://lichess.org/UFiV2iLs#78
Certified White Dove Moment©

Jokes aside, can you reproduce this move? I have seen White Dove play a poor move inexplicably in a tournament, so maybe it’s a type-1 Zobrist key collision
ababoin07
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

It is off-topic, but I have to say it. @Grijfland, Austria is 1:0 vs Netherlands, Possession 63% vs. 37% at minute 14
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
Yes, I am French and I live in France, and I conclude that you must be in Austria? I am not interested in football… Otherwise, during tests on Destructor, I added 1 to the maximum depth of search for quiescence, and the time went up to 200 seconds (3 minutes) despite the transpositions tables… Do you have an explanation of why time believes so much (lol, Austria in English does not look at all like ‘Autriche’ in French, I thought it was a lost corner of America)

I have heard some ppl outside Europe mix us up with Australia, but France - hey, we have been fighting each other for centuries!

I took a quick look at Destructor 1.4.2 CompMode, please don't use listIndexOf() in inner loops / functions or on large lists, it is a performance killer with O(N) runtime complexity. Most of your CPU cycles are burnt there. There is always an alternative implementation. GoK only applies listIndexOf() at one place, not an inner loop, and the list is of size 4.
Frankly, I don’t even know where I used this or that… I would look at this, thank you for your advice! (Which I have no idea to apply), is there an alternative?

It's listIndexOf (list-indexOf or list-contains, e.g. In “Vérifier board 2 avec roi” for example), also indexOf (string-contains, e.g. in “Essayer de bouger et validation” and “”WEssayer de bouger 2“). If you are looking for the king index on your board, have a variable dedicated for that and update it when kings moves, but don't scan the board for the king each time. Scratch doesn't simply look for a value in a list (which would be bad enough), internally it does type conversions, tries to trail whitespaces, and more on each and every element comparison.

And the way to find these things is to use browser F12 dev tools on TurboWarp. E.g. on Chrome, press F12, click the record button in ”Performance" tab, then make move and let Destructor run a search, then stop recording, click Performance / Bottom Up, and sort the list of functions by total time. You can then click the .js source link and investigate each line of code on how much time is spent.

What I also noticed are busy loops, checking for user input. I suggest to turn all of that off, there are message handlers for what, e.g. when-clicked, when-key-pressed. Loops scanning for input will keep your CPU busy and slow down everything else.
Okay, I 'll see that

OK, did you see the latest message at https://scratch.mit.edu/discuss/post/8029714/ ?

The question is also, why is a block invoked 50 million times within a 40sec search? I think you said it runs at 10k NPS? That would be 125 invocations per node…
What block plz?

Last edited by ababoin07 (Yesterday 19:48:36)

AZURUS41
Scratcher
57 posts

Scratch Chess Engine - Game of Kings

https://lichess.org/hdBAo0nZ#0
Average game against GoK… Good opening, decide to sack a pawn for some reason cuz it thinks there is an attack, the attack is countered, and then the bot known for its offensive play lose to a sacrifice leading to checkmate.
Is there a way to modify the NNUE, even just a bit, so it stops giving away pawns ?
GoK NNUE TB Difficult btw

Last edited by AZURUS41 (Yesterday 19:51:24)

ababoin07
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

It is off-topic, but I have to say it. @Grijfland, Austria is 1:0 vs Netherlands, Possession 63% vs. 37% at minute 14
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
Yes, I am French and I live in France, and I conclude that you must be in Austria? I am not interested in football… Otherwise, during tests on Destructor, I added 1 to the maximum depth of search for quiescence, and the time went up to 200 seconds (3 minutes) despite the transpositions tables… Do you have an explanation of why time believes so much (lol, Austria in English does not look at all like ‘Autriche’ in French, I thought it was a lost corner of America)

I have heard some ppl outside Europe mix us up with Australia, but France - hey, we have been fighting each other for centuries!

I took a quick look at Destructor 1.4.2 CompMode, please don't use listIndexOf() in inner loops / functions or on large lists, it is a performance killer with O(N) runtime complexity. Most of your CPU cycles are burnt there. There is always an alternative implementation. GoK only applies listIndexOf() at one place, not an inner loop, and the list is of size 4.
Frankly, I don’t even know where I used this or that… I would look at this, thank you for your advice! (Which I have no idea to apply), is there an alternative?

It's listIndexOf (list-indexOf or list-contains, e.g. In “Vérifier board 2 avec roi” for example), also indexOf (string-contains, e.g. in “Essayer de bouger et validation” and “”WEssayer de bouger 2“). If you are looking for the king index on your board, have a variable dedicated for that and update it when kings moves, but don't scan the board for the king each time. Scratch doesn't simply look for a value in a list (which would be bad enough), internally it does type conversions, tries to trail whitespaces, and more on each and every element comparison.

And the way to find these things is to use browser F12 dev tools on TurboWarp. E.g. on Chrome, press F12, click the record button in ”Performance" tab, then make move and let Destructor run a search, then stop recording, click Performance / Bottom Up, and sort the list of functions by total time. You can then click the .js source link and investigate each line of code on how much time is spent.

What I also noticed are busy loops, checking for user input. I suggest to turn all of that off, there are message handlers for what, e.g. when-clicked, when-key-pressed. Loops scanning for input will keep your CPU busy and slow down everything else.
Okay, I 'll see that

OK, did you see the latest message at https://scratch.mit.edu/discuss/post/8029714/ ?

The question is also, why is a block invoked 50 million times within a 40sec search? I think you said it runs at 10k NPS? That would be 125 invocations per node…
As specified two weeks ago, I DO NOT HAVE ACCESS to my pc, so I can not change the code of Destructor, so I do not read all the messages of this forum, I would read the messages when I have access to my pc again
ababoin07
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

AZURUS41 wrote:

https://lichess.org/hdBAo0nZ#0
Average game against GoK… Good opening, decide to sack a pawn for some reason cuz it thinks there is an attack, the attack is countered, and then the bot known for its offensive play lose to a sacrifice leading to checkmate.
Is there a way to modify the NNUE, even just a bit, so it stops giving away pawns ?
GoK NNUE TB Difficult btw
Too difficult i Guess but possible if he use python or an alternative langage

Last edited by ababoin07 (Yesterday 19:53:41)

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

GoK NNUE (10sec, black) vs. White Dove (P2), GoK wins: https://lichess.org/qanbjD8d#128


GoK NNUE (Medium, black) vs. Element (6+8), double-blunder by Element early on, loses in 14 moves: https://lichess.org/VF7AWBLw#28

White Dove (P3, white) with a strange queen blunder against GoK NNUE (Medium), loses in 39 moves: https://lichess.org/UFiV2iLs#78

Congratulations to White Dove (P3, black) for this high quality win against GoK NNUE (Medium), 95% vs 90% accuracy. The effects of GoK's one early mistake were impossible to be foreseen, even on competition mode. https://lichess.org/jjQrrf4v#90
S_P_A_R_T
Scratcher
500+ posts

Scratch Chess Engine - Game of Kings

birdracerthree wrote:

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

GoK NNUE (10sec, black) vs. White Dove (P2), GoK wins: https://lichess.org/qanbjD8d#128


GoK NNUE (Medium, black) vs. Element (6+8), double-blunder by Element early on, loses in 14 moves: https://lichess.org/VF7AWBLw#28

White Dove (P3, white) with a strange queen blunder against GoK NNUE (Medium), loses in 39 moves: https://lichess.org/UFiV2iLs#78
Certified White Dove Moment©

Jokes aside, can you reproduce this move? I have seen White Dove play a poor move inexplicably in a tournament, so maybe it’s a type-1 Zobrist key collision

I personally cannot reproduce this. Maybe it is just a very very rare key collision, because on my system, the queen blunder is not considered even for a moment.

Check out Space Program Simulator!





In it, you can build your own rockets from a variety of parts!
Then fly it with realistic orbital mechanics.

Go to orbit, explore different planets, share your save codes, and do so much more!

If you would like to help out on the project or chat about space or really anything else, check out the offical SPS Studio!

For more information & tutorials, check out the offical forum post!

birdracerthree
Scratcher
500+ posts

Scratch Chess Engine - Game of Kings

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

*snip*
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
*snip*

I have heard some ppl outside Europe mix us up with Australia, but France - hey, we have been fighting each other for centuries!

I took a quick look at Destructor 1.4.2 CompMode, please don't use listIndexOf() in inner loops / functions or on large lists, it is a performance killer with O(N) runtime complexity. Most of your CPU cycles are burnt there. There is always an alternative implementation. GoK only applies listIndexOf() at one place, not an inner loop, and the list is of size 4.
Frankly, I don’t even know where I used this or that… I would look at this, thank you for your advice! (Which I have no idea to apply), is there an alternative?

It's listIndexOf (list-indexOf or list-contains, e.g. In “Vérifier board 2 avec roi” for example), also indexOf (string-contains, e.g. in “Essayer de bouger et validation” and “”WEssayer de bouger 2“). If you are looking for the king index on your board, have a variable dedicated for that and update it when kings moves, but don't scan the board for the king each time. Scratch doesn't simply look for a value in a list (which would be bad enough), internally it does type conversions, tries to trail whitespaces, and more on each and every element comparison.

And the way to find these things is to use browser F12 dev tools on TurboWarp. E.g. on Chrome, press F12, click the record button in ”Performance" tab, then make move and let Destructor run a search, then stop recording, click Performance / Bottom Up, and sort the list of functions by total time. You can then click the .js source link and investigate each line of code on how much time is spent.

What I also noticed are busy loops, checking for user input. I suggest to turn all of that off, there are message handlers for what, e.g. when-clicked, when-key-pressed. Loops scanning for input will keep your CPU busy and slow down everything else.
Okay, I 'll see that

OK, did you see the latest message at https://scratch.mit.edu/discuss/post/8029714/ ?

The question is also, why is a block invoked 50 million times within a 40sec search? I think you said it runs at 10k NPS? That would be 125 invocations per node…
What block plz?
Item#Of is the main block, list-contains is secondary. Although in the custom block Arno mentioned, it looks like the item#of block is only used for the king’s index on the board. Element does the same thing (although it checks if the king’s index variable isn’t already correct because the king tends to stay in the same place). I can’t profile right now because I’m on mobile, I can take a look when I can.

Arno, not everyone knows what “IndexOf” means. A while ago I was explaining why I needed it for piece-square tables, but I thought it meant the item-of block

ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

birdracerthree wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoHu wrote:

ababoin07 wrote:

ArnoH wrote:

*snip*
Just off topic XD XD is this for soccer?

Sure, what else? You are from France, no?

We won 3:2, and qualified for knockout rounds as 1st in the group, ahead of France and the Netherlands - incredible, everyone is going crazy here!
*snip*

I have heard some ppl outside Europe mix us up with Australia, but France - hey, we have been fighting each other for centuries!

I took a quick look at Destructor 1.4.2 CompMode, please don't use listIndexOf() in inner loops / functions or on large lists, it is a performance killer with O(N) runtime complexity. Most of your CPU cycles are burnt there. There is always an alternative implementation. GoK only applies listIndexOf() at one place, not an inner loop, and the list is of size 4.
Frankly, I don’t even know where I used this or that… I would look at this, thank you for your advice! (Which I have no idea to apply), is there an alternative?

It's listIndexOf (list-indexOf or list-contains, e.g. In “Vérifier board 2 avec roi” for example), also indexOf (string-contains, e.g. in “Essayer de bouger et validation” and “”WEssayer de bouger 2“). If you are looking for the king index on your board, have a variable dedicated for that and update it when kings moves, but don't scan the board for the king each time. Scratch doesn't simply look for a value in a list (which would be bad enough), internally it does type conversions, tries to trail whitespaces, and more on each and every element comparison.

And the way to find these things is to use browser F12 dev tools on TurboWarp. E.g. on Chrome, press F12, click the record button in ”Performance" tab, then make move and let Destructor run a search, then stop recording, click Performance / Bottom Up, and sort the list of functions by total time. You can then click the .js source link and investigate each line of code on how much time is spent.

What I also noticed are busy loops, checking for user input. I suggest to turn all of that off, there are message handlers for what, e.g. when-clicked, when-key-pressed. Loops scanning for input will keep your CPU busy and slow down everything else.
Okay, I 'll see that

OK, did you see the latest message at https://scratch.mit.edu/discuss/post/8029714/ ?

The question is also, why is a block invoked 50 million times within a 40sec search? I think you said it runs at 10k NPS? That would be 125 invocations per node…
What block plz?
Item#Of is the main block, list-contains is secondary. Although in the custom block Arno mentioned, it looks like the item#of block is only used for the king’s index on the board. Element does the same thing (although it checks if the king’s index variable isn’t already correct because the king tends to stay in the same place). I can’t profile right now because I’m on mobile, I can take a look when I can.

Arno, not everyone knows what “IndexOf” means. A while ago I was explaining why I needed it for piece-square tables, but I thought it meant the item-of block


Yes, list-contains() and list-item-of() can be very harmful, and indeed that is the case for Destructor, too. But here I referred to string-contains() in "Essayer de bouger et validation 2” (can be nearly as harmful, esp. when invoked that often).
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

S_P_A_R_T wrote:

birdracerthree wrote:

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

GoK NNUE (10sec, black) vs. White Dove (P2), GoK wins: https://lichess.org/qanbjD8d#128


GoK NNUE (Medium, black) vs. Element (6+8), double-blunder by Element early on, loses in 14 moves: https://lichess.org/VF7AWBLw#28

White Dove (P3, white) with a strange queen blunder against GoK NNUE (Medium), loses in 39 moves: https://lichess.org/UFiV2iLs#78
Certified White Dove Moment©

Jokes aside, can you reproduce this move? I have seen White Dove play a poor move inexplicably in a tournament, so maybe it’s a type-1 Zobrist key collision

I personally cannot reproduce this. Maybe it is just a very very rare key collision, because on my system, the queen blunder is not considered even for a moment.

Yes, that is the simple explanation :-)

But what I did lately, is a hash move sanity check before it is applied. Despite I had run automated tests w/o any problems, I lately saw scenarios where hash move was not valid, esp. castling. I must still investigate how it happens, as a workaround the sanity check is sufficient.

Powered by DjangoBB