Games/second Engines

Discussion of chess software programming and technical issues.

Moderator: Ras

jhaglund2
Posts: 66
Joined: Mon Jan 16, 2017 6:28 pm

Re: Games/second Engines

Post by jhaglund2 »

Thank you for the recognition. :) Yes, win loss draw counts can be used. However, a finer level of control is possible with bonus/penalties because they can vary in importance according to depth. At lower ply they are very small so the the root move does not change that easily. At higher ply the bonus/penalties are less small to cause the algorithm to switch to another move quickly. Therefore the search through the search space happens top down. If 1. a move is best according to the eval and it also scores well in the games it may never change to another move. There is a million ways to do everything it seems!
Yes, many ways to reach a complete game. At lower ply, just iterate through all the root moves, similar to how a Perft does, but start chess games.
How many Perfts 4 or 5 can you do before you reach the end of a game? A lot of different chess games at one time. Let statistics determine the move.

perft 4
total moves=197281 time=0.00
perft 5
total moves=4865609 time=0.07
perft 6
total moves=119060324 time=1.80

6k1/8/6PP/3B1K2/8/2b5/8/8 b
perft 5
total moves=79772 time=0.00
perft 6
total moves=1302053 time=0.02
perft 7
total moves=13763111 time=0.27
perft 8
total moves=223455144 time=3.90

I talked to Bob a while ago. PV jumping I called it. E.g., ply 20 search. Jump to the end of that PV line, and do another 20 ply search, and repeat this until you reach end of game. Then go to the next root move and do the same. 20 seemed like a good number before Crafty started to use more time. That, of course, is just an example without testing or tuning. Anything 1 to 20. Completing games for all the moves up to a e.g., Perft 5 would generate IMO significant statistics.

Also, a debug mode for PGN output could be added to generate large databases of the games / second.
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Games/second Engines

Post by Mike Sherwin »

jhaglund2 wrote: Wed Jul 06, 2022 12:14 pm
Thank you for the recognition. :) Yes, win loss draw counts can be used. However, a finer level of control is possible with bonus/penalties because they can vary in importance according to depth. At lower ply they are very small so the the root move does not change that easily. At higher ply the bonus/penalties are less small to cause the algorithm to switch to another move quickly. Therefore the search through the search space happens top down. If 1. a move is best according to the eval and it also scores well in the games it may never change to another move. There is a million ways to do everything it seems!
Yes, many ways to reach a complete game. At lower ply, just iterate through all the root moves, similar to how a Perft does, but start chess games.
How many Perfts 4 or 5 can you do before you reach the end of a game? A lot of different chess games at one time. Let statistics determine the move.

perft 4
total moves=197281 time=0.00
perft 5
total moves=4865609 time=0.07
perft 6
total moves=119060324 time=1.80

6k1/8/6PP/3B1K2/8/2b5/8/8 b
perft 5
total moves=79772 time=0.00
perft 6
total moves=1302053 time=0.02
perft 7
total moves=13763111 time=0.27
perft 8
total moves=223455144 time=3.90

I talked to Bob a while ago. PV jumping I called it. E.g., ply 20 search. Jump to the end of that PV line, and do another 20 ply search, and repeat this until you reach end of game. Then go to the next root move and do the same. 20 seemed like a good number before Crafty started to use more time. That, of course, is just an example without testing or tuning. Anything 1 to 20. Completing games for all the moves up to a e.g., Perft 5 would generate IMO significant statistics.

Also, a debug mode for PGN output could be added to generate large databases of the games / second.
All I can add is once someone successfully adds RTRL or maybe just RTL to their engine the next era of chess engines will begin.
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Games/second Engines

Post by op12no2 »

jhaglund2 wrote: Fri Jul 01, 2022 9:07 pm A lot of creativity can be used here to complete a game. Not to overthink it, just random moves to get it working.
play: https://op12no2.github.io/roller
repo: https://github.com/op12no2/roller

Roller plays like that - random games from the root picking the root move with most wins. Always does full move generation (to evenly distribute move possibilities), stalemate detection, no heuristic knowledge - so doesn't stop at KK etc., Javascript, one thread, but no 3 position draw detection. I would guess you could add a couple of zeros to the rollouts per second (kr/s) figure for something compiled and written with a bit more thought. Roller was a quick hack for my niece who was finding 1 ply too strong and it got her playing. I get about 4.5kr/s here. You'll see that at the start of a game rollouts average about 400 ply.
jhaglund2
Posts: 66
Joined: Mon Jan 16, 2017 6:28 pm

Re: Games/second Engines

Post by jhaglund2 »

op12no2 wrote: Tue Jul 12, 2022 8:39 am
jhaglund2 wrote: Fri Jul 01, 2022 9:07 pm A lot of creativity can be used here to complete a game. Not to overthink it, just random moves to get it working.
play: https://op12no2.github.io/roller
repo: https://github.com/op12no2/roller

Roller plays like that - random games from the root picking the root move with most wins. Always does full move generation (to evenly distribute move possibilities), stalemate detection, no heuristic knowledge - so doesn't stop at KK etc., Javascript, one thread, but no 3 position draw detection. I would guess you could add a couple of zeros to the rollouts per second (kr/s) figure for something compiled and written with a bit more thought. Roller was a quick hack for my niece who was finding 1 ply too strong and it got her playing. I get about 4.5kr/s here. You'll see that at the start of a game rollouts average about 400 ply.
Wow! Impressive Colin! You nailed it :!:
Let's review. You call Games/Second, Rollouts/second, clever :idea: :D

240 s | 1341.91 kr | 5.59 kr/s | Nf3

1. Nf3

h4 408 144 / 66996 (0.0021493820526598604)
h3 409 83 / 67178 (0.0012355235344904583)
g4 408 98 / 67405 (0.0014538980787775387)
g3 410 118 / 67086 (0.0017589362907313002)
f4 407 -125 / 67260 (-0.0018584597085935177)
f3 409 -18 / 67658 (-0.0002660439268083597)
e4 408 -96 / 67154 (-0.001429549989576198)
e3 412 -243 / 66592 (-0.0036490869774147045)
d4 409 -147 / 66872 (-0.0021982294532838856)
d3 411 113 / 67341 (0.0016780267593293832)
c4 408 34 / 66926 (0.0005080237874667544)
c3 410 79 / 66949 (0.0011800026886137208)
b4 408 -21 / 67104 (-0.00031294706723891273)
b3 409 58 / 66943 (0.0008664087357901499)
a4 407 -15 / 67498 (-0.00022222880677946012)
a3 409 38 / 66925 (0.0005677997758685095)
Nh3 410 -6 / 66981 (-0.0000895776414207014)
Nf3 408 243 / 66830 (0.0036360915756396828) ****
Nc3 408 166 / 67295 (0.0024667508730217697)
Na3 410 16 / 66912 (0.00023912003825920613)

From what I understand, after 4 minutes 1,341,910 games were played / 5,590 games per second, with games averaging 407-412 moves (ON 1 THREAD!).
243 / 66830 games were winning for Nf3. (0.0036360915756396828) or a rounded .36 was the winning percentage score for the best, selecting the move.

How come, some of the root move 67k games are negative in value? e.g., f4 -125 / 67260. I'm guessing it's the overall score.

I played against Roller 2 with 60 seconds.

[Event "Games Per Second - 60 seconds"]
[Site "https://op12no2.github.io/roller/index.htm"]
[Date "2022.07.12"]
[Round "1"]
[White "Haglund, Joshua"]
[Black "Roller 2"]
[Result "1 - 0"]
[WhiteElo "2700"]
[BlackElo "-"]
[WhiteTitle "GM"]
[BlackTitle "Computer"]
1. d4 a5 2. f4 g5 3. fxg5 h6 4.Nf3 hxg5 5. Bxg5 Rxh2 6. Rxh2 f5 7. e3 d5 8. Ne5 Be6 9. Qh5+ Bf7 10. Qxf7# 1-0

This is the ideal example for other's to get started and build on the idea. Thanks for sharing!
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Games/second Engines

Post by op12no2 »

jhaglund2 wrote: Tue Jul 12, 2022 2:36 pm How come, some of the root move 67k games are negative in value? e.g., f4 -125 / 67260. I'm guessing it's the overall score.
Yes win, loss, draw are scored +1, -1, 0 so the net score can be -ve if more games are lost than won.
jhaglund2
Posts: 66
Joined: Mon Jan 16, 2017 6:28 pm

Re: Games/second Engines

Post by jhaglund2 »

op12no2 wrote: Tue Jul 12, 2022 2:57 pm
jhaglund2 wrote: Tue Jul 12, 2022 2:36 pm How come, some of the root move 67k games are negative in value? e.g., f4 -125 / 67260. I'm guessing it's the overall score.
Yes win, loss, draw are scored +1, -1, 0 so the net score can be -ve if more games are lost than won.
Have you tried or thought about adding just basic piece values? e.g., 1,3,3,5,9, inf
I'm curious of the immediate stength difference.

Working with fen, do you take into consideration the halve move counter for draws? A draw declared at 100 halve moves?
6k1/8/6PP/3B1K2/8/2b5/8/8 b 300 206
Been no progress, pawn moves or captures, for 300 moves, but at move 206 for black.

Also, you display only 1 PV move. Have you thought about adding more moves for the PV based on the results?
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Games/second Engines

Post by dangi12012 »

op12no2 wrote: Tue Jul 12, 2022 8:39 am
Roller plays like that - random games from the root picking the root move with most wins. Always does full move generation (to evenly distribute move possibilities), stalemate detection, no heuristic knowledge - so doesn't stop at KK etc.,
Good start.

If you pick a child by UCB1 then you will be much stronger 💪
The best move becomes the most often visited node. It's a solution for the multiarmed bandit problem.

Also detecting KK and not wasting 50 moves is a must.
6kgame/s is extremely slow
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
jhaglund2
Posts: 66
Joined: Mon Jan 16, 2017 6:28 pm

Re: Games/second Engines

Post by jhaglund2 »

dangi12012 wrote: Tue Jul 12, 2022 4:14 pm
op12no2 wrote: Tue Jul 12, 2022 8:39 am
Roller plays like that - random games from the root picking the root move with most wins. Always does full move generation (to evenly distribute move possibilities), stalemate detection, no heuristic knowledge - so doesn't stop at KK etc.,
Good start.

If you pick a child by UCB1 then you will be much stronger 💪
The best move becomes the most often visited node. It's a solution for the multiarmed bandit problem.

Also detecting KK and not wasting 50 moves is a must.
6kgame/s is extremely slow
Already noted. It was only 1 thread. How many games/sec do you think you'd be able to achieve?
jhaglund2
Posts: 66
Joined: Mon Jan 16, 2017 6:28 pm

Re: Games/second Engines

Post by jhaglund2 »

I'm also interested in the actual break down of w/l/d per move when it comes to sorting the move.
That should tell us more information how the move really is.

Some scenarios where you need to sort them better.
20 million games
move A: 1 million games 15% win, 25% lose, 60% draw
move B: 1 million games 30% win, 35% lose, 35% draw
move C: 1 million games 1% win, 15% lose, 84% draw
move D: 1 million games 40% win, 48% lose, 12% draw
...
Which move would you play?
op12no2
Posts: 547
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Games/second Engines

Post by op12no2 »

Yes Roller is supposed to detect 50 move rule, must be a bug. But I have no plans to develop it any further; its served it purpose at the time as a quick hack and was never built for speed nor strength. Obviously feel free to clone etc...