Discuss Scratch

internet44
Scratcher
78 posts

Scratch Chess Engine - Game of Kings

grkw2020 wrote:

Does anyone know why Storm runs so slowly? Like, in terms of NPS? waabooboo says it's because I use string operations, but I feel like there's something else slowing it down.

do you know how to profile your engine? I only had a quick look and apparently “hash board” and your eval script take up the most time. the hash board thing makes sense, you should look into incremental hash updates, much faster. index to file and rank can easily become a lookup table, same for its counterpart file and rank to index. in addition to that, waabooboo is right of course, string ops are slow. I'm looking at that ordered moves to variable block in your negamax, that's going to be pretty tough for performance. there are better (i.e. faster) way to store moves by ply, but I have to say that's a really creative solution lol
grkw2020
Scratcher
500+ posts

Scratch Chess Engine - Game of Kings

internet44 wrote:

grkw2020 wrote:

Does anyone know why Storm runs so slowly? Like, in terms of NPS? waabooboo says it's because I use string operations, but I feel like there's something else slowing it down.

do you know how to profile your engine? I only had a quick look and apparently “hash board” and your eval script take up the most time. the hash board thing makes sense, you should look into incremental hash updates, much faster. index to file and rank can easily become a lookup table, same for its counterpart file and rank to index. in addition to that, waabooboo is right of course, string ops are slow. I'm looking at that ordered moves to variable block in your negamax, that's going to be pretty tough for performance. there are better (i.e. faster) way to store moves by ply, but I have to say that's a really creative solution lol
Wow, thanks! I'll try those!
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

grkw2020 wrote:

Does anyone know why Storm runs so slowly? Like, in terms of NPS? waabooboo says it's because I use string operations, but I feel like there's something else slowing it down.

Depends what you mean by slow. Profiling with F12 browser dev tools helps on a pure code execution level, you can check there e.g. how costly your string operations are.

But let's face it, most slowness is caused by insufficient pruning, with a lot of nodes visited to reach certain search depth. For that, engine statistics help, like the ones we have seen here: How many nodes per search depth.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

GoK Classic vs. White Dove, 96% vs. 97%. That was a great game to watch!
https://lichess.org/study/J41kjRR3/OcOnnCZZ
waabooboo
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

grkw2020 wrote:

Does anyone know why Storm runs so slowly? Like, in terms of NPS? waabooboo says it's because I use string operations, but I feel like there's something else slowing it down.

That was my guess, but it could be many things.
waabooboo
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

I can't reproduce the strategically stupid 15… Rf8 in the second game. From 1-30 seconds Wolverine always prefers to castle, although Rf8 is sometimes considered the second best. I guess maybe the history ordering affects Wolverine's decision there.

I may need some extra castling incentives, I've seen it do that kind of thing more than once

Last edited by waabooboo (Sept. 2, 2025 22:18:16)

grkw2020
Scratcher
500+ posts

Scratch Chess Engine - Game of Kings

waabooboo wrote:

grkw2020 wrote:

Does anyone know why Storm runs so slowly? Like, in terms of NPS? waabooboo says it's because I use string operations, but I feel like there's something else slowing it down.

That was my guess, but it could be many things.
Yeah, well string operations is certainly part of it, and I will remove those.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

waabooboo wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

I can't reproduce the strategically stupid 15… Rf8 in the second game. From 1-30 seconds Wolverine always prefers to castle, although Rf8 is sometimes considered the second best. I guess maybe the history ordering affects Wolverine's decision there.

I may need some extra castling incentives, I've seen it do that kind of thing more than once

In every single GoK game there are moves I cannot reproduce. As mentioned, non-deterministic engines.
grkw2020
Scratcher
500+ posts

Scratch Chess Engine - Game of Kings

waabooboo wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

I can't reproduce the strategically stupid 15… Rf8 in the second game. From 1-30 seconds Wolverine always prefers to castle, although Rf8 is sometimes considered the second best. I guess maybe the history ordering affects Wolverine's decision there.

I may need some extra castling incentives, I've seen it do that kind of thing more than once
Maybe you just need to change the king's piece square table?
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

GoK Classic vs. White Dove, 96% vs. 97%. That was a great game to watch!
https://lichess.org/study/J41kjRR3/OcOnnCZZ

GoK Classic vs. Delta, 96% vs. 91%:
https://lichess.org/study/J41kjRR3/aDABBbjK
waabooboo
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

waabooboo wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

I can't reproduce the strategically stupid 15… Rf8 in the second game. From 1-30 seconds Wolverine always prefers to castle, although Rf8 is sometimes considered the second best. I guess maybe the history ordering affects Wolverine's decision there.

I may need some extra castling incentives, I've seen it do that kind of thing more than once

In every single GoK game there are moves I cannot reproduce. As mentioned, non-deterministic engines.

Yeah I understand, it's just frustrating when it does something stupid and I can't make it happen again. At least in this case Rf8 is usually move #2, so it makes sense that some small variation caused by hash, history, etc. could push it to #1.

I considered a penalty for a king blocking a rook on the back rank. But Wolverine might avoid that penalty by moving the king off of the back rank, which is even worse. I will look into it…
waabooboo
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

grkw2020 wrote:

waabooboo wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

I can't reproduce the strategically stupid 15… Rf8 in the second game. From 1-30 seconds Wolverine always prefers to castle, although Rf8 is sometimes considered the second best. I guess maybe the history ordering affects Wolverine's decision there.

I may need some extra castling incentives, I've seen it do that kind of thing more than once
Maybe you just need to change the king's piece square table?

King piece square table already gives a better score for king on g8 than king on e8. Usually that alone is enough to entice Wolverine to castle, but in some cases, like this one, it isn't.
grkw2020
Scratcher
500+ posts

Scratch Chess Engine - Game of Kings

waabooboo wrote:

grkw2020 wrote:

waabooboo wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

I can't reproduce the strategically stupid 15… Rf8 in the second game. From 1-30 seconds Wolverine always prefers to castle, although Rf8 is sometimes considered the second best. I guess maybe the history ordering affects Wolverine's decision there.

I may need some extra castling incentives, I've seen it do that kind of thing more than once
Maybe you just need to change the king's piece square table?

King piece square table already gives a better score for king on g8 than king on e8. Usually that alone is enough to entice Wolverine to castle, but in some cases, like this one, it isn't.
So perhaps you need to give a larger bonus for a king on g8 than you already have? I had to do that with Storm.
iceysnowman
Scratcher
58 posts

Scratch Chess Engine - Game of Kings

waabooboo wrote:

grkw2020 wrote:

waabooboo wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

I can't reproduce the strategically stupid 15… Rf8 in the second game. From 1-30 seconds Wolverine always prefers to castle, although Rf8 is sometimes considered the second best. I guess maybe the history ordering affects Wolverine's decision there.

I may need some extra castling incentives, I've seen it do that kind of thing more than once
Maybe you just need to change the king's piece square table?

King piece square table already gives a better score for king on g8 than king on e8. Usually that alone is enough to entice Wolverine to castle, but in some cases, like this one, it isn't.
Maybe try reducing the score for the rook on f8 so it’s not as enticed to move the rook w/o castling? It’ll usually want to move to a central file later anyway.
waabooboo
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

iceysnowman wrote:

waabooboo wrote:

grkw2020 wrote:

waabooboo wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

I can't reproduce the strategically stupid 15… Rf8 in the second game. From 1-30 seconds Wolverine always prefers to castle, although Rf8 is sometimes considered the second best. I guess maybe the history ordering affects Wolverine's decision there.

I may need some extra castling incentives, I've seen it do that kind of thing more than once
Maybe you just need to change the king's piece square table?

King piece square table already gives a better score for king on g8 than king on e8. Usually that alone is enough to entice Wolverine to castle, but in some cases, like this one, it isn't.
Maybe try reducing the score for the rook on f8 so it’s not as enticed to move the rook w/o castling? It’ll usually want to move to a central file later anyway.

Castling replaces the scores for king on e8 and rook on h8 with scores for king on g8 and rook on f8. The rook on f8 gets scored either way.

I know how I'll fix it, I'm not going to fiddle with the piece-square tables.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

GoK Classic vs. White Dove, 96% vs. 97%. That was a great game to watch!
https://lichess.org/study/J41kjRR3/OcOnnCZZ

GoK Classic vs. Delta, 96% vs. 91%:
https://lichess.org/study/J41kjRR3/aDABBbjK

GoK Classic vs. White Dove, 89% vs. 87% (given the clear GoK win, with both of its mistakes not seen by WD, the accuracy is a bit strange):
https://lichess.org/study/J41kjRR3/uTytLBS0

GoK Classic vs. Wolverine 2, 92% vs. 89%:
https://lichess.org/study/J41kjRR3/uhjdOorE

Could it be that Wolverine LMR is too aggressive? Search depth during endgame was 12 for GoK, 16 for Wolverine, still GoK saw promotion and checkmate several moves earlier.

Last edited by ArnoHu (Sept. 3, 2025 16:20:02)

internet44
Scratcher
78 posts

Scratch Chess Engine - Game of Kings

grkw2020 wrote:

internet44 wrote:

grkw2020 wrote:

Does anyone know why Storm runs so slowly? Like, in terms of NPS? waabooboo says it's because I use string operations, but I feel like there's something else slowing it down.

do you know how to profile your engine? I only had a quick look and apparently “hash board” and your eval script take up the most time. the hash board thing makes sense, you should look into incremental hash updates, much faster. index to file and rank can easily become a lookup table, same for its counterpart file and rank to index. in addition to that, waabooboo is right of course, string ops are slow. I'm looking at that ordered moves to variable block in your negamax, that's going to be pretty tough for performance. there are better (i.e. faster) way to store moves by ply, but I have to say that's a really creative solution lol
Wow, thanks! I'll try those!

no problem. but don't expect a magical 5x speedup or something- I don't think there's one single thing that slows Storm down, but more like a lot of little things combined that together make for low nps. what I said are the first things I would start with personally, but that's not all by any means you'll figure it out- I have no doubt about that
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

GoK Classic vs. White Dove, 96% vs. 97%. That was a great game to watch!
https://lichess.org/study/J41kjRR3/OcOnnCZZ

GoK Classic vs. Delta, 96% vs. 91%:
https://lichess.org/study/J41kjRR3/aDABBbjK

GoK Classic vs. White Dove, 89% vs. 87% (given the clear GoK win, with both of its mistakes not seen by WD, the accuracy is a bit strange):
https://lichess.org/study/J41kjRR3/uTytLBS0

GoK Classic vs. Wolverine 2, 92% vs. 89%:
https://lichess.org/study/J41kjRR3/uhjdOorE

Could it be that Wolverine LMR is too aggressive? Search depth during endgame was 12 for GoK, 16 for Wolverine, still GoK saw promotion and checkmate several moves earlier.

GoK Classic vs. Shallow Blue 3, 94% vs. 89%:
https://lichess.org/study/J41kjRR3/Csii0mTG
waabooboo
Scratcher
100+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

GoK Classic vs. White Dove, 96% vs. 97%. That was a great game to watch!
https://lichess.org/study/J41kjRR3/OcOnnCZZ

GoK Classic vs. Delta, 96% vs. 91%:
https://lichess.org/study/J41kjRR3/aDABBbjK

GoK Classic vs. White Dove, 89% vs. 87% (given the clear GoK win, with both of its mistakes not seen by WD, the accuracy is a bit strange):
https://lichess.org/study/J41kjRR3/uTytLBS0

GoK Classic vs. Wolverine 2, 92% vs. 89%:
https://lichess.org/study/J41kjRR3/uhjdOorE

Could it be that Wolverine LMR is too aggressive? Search depth during endgame was 12 for GoK, 16 for Wolverine, still GoK saw promotion and checkmate several moves earlier.

I don't use check extensions, I just don't allow reductions in check – that may be part of it. But yes, I do think my LMR is too aggressive. It needs some fine-tuning.
ArnoHu
Scratcher
1000+ posts

Scratch Chess Engine - Game of Kings

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

ArnoHu wrote:

GoK Classic vs. Wolverine 2, 94% vs. 90%:
https://lichess.org/study/J41kjRR3/KA4ZYsjT

GoK Classic vs. Wolverine 2, 91% vs. 85%:
https://lichess.org/study/J41kjRR3/u73LI2Ga

GoK Classic vs. White Dove, 96% vs. 97%. That was a great game to watch!
https://lichess.org/study/J41kjRR3/OcOnnCZZ

GoK Classic vs. Delta, 96% vs. 91%:
https://lichess.org/study/J41kjRR3/aDABBbjK

GoK Classic vs. White Dove, 89% vs. 87% (given the clear GoK win, with both of its mistakes not seen by WD, the accuracy is a bit strange):
https://lichess.org/study/J41kjRR3/uTytLBS0

GoK Classic vs. Wolverine 2, 92% vs. 89%:
https://lichess.org/study/J41kjRR3/uhjdOorE

Could it be that Wolverine LMR is too aggressive? Search depth during endgame was 12 for GoK, 16 for Wolverine, still GoK saw promotion and checkmate several moves earlier.

GoK Classic vs. Shallow Blue 3, 94% vs. 89%:
https://lichess.org/study/J41kjRR3/Csii0mTG

GoK Classic vs. Black Crow, 96% vs. 96%:
https://lichess.org/study/J41kjRR3/8oarBjzd

GoK NNUE vs. Black Crow, 93% vs. 89%:
https://lichess.org/study/J41kjRR3/KnL7D401

GoK NNUE vs. Black Crow, 98% vs. 92%:
https://lichess.org/study/J41kjRR3/Gz51awDM

Last edited by ArnoHu (Sept. 4, 2025 05:22:40)

Powered by DjangoBB