Polyglot Opening Book of Random Moves?

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Steve Maughan
Posts: 1273
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Polyglot Opening Book of Random Moves?

Post by Steve Maughan »

Has anyone created a Polyglot opening book of the first "x" random moves? It's relatively simple to do — just do a perft for "x" depth and add each position to the opening book. Just wondered if it's already been done.

Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine
MOBMAT
Posts: 396
Joined: Sat Feb 04, 2017 11:57 pm
Location: USA

Re: Polyglot Opening Book of Random Moves?

Post by MOBMAT »

That would created a very large book with very little depth. After the first 3 full moves there are almost 120,000,000 positions. doesn't seem it would gain you very much.

If you are developing your own engine, you could add a command to play random moves for the next X numbers of plies.
i7-6700K @ 4.00Ghz 32Gb, Win 10 Home, EGTBs on PCI SSD
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K
User avatar
Steve Maughan
Posts: 1273
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Polyglot Opening Book of Random Moves?

Post by Steve Maughan »

The use-case is to create a large number of games with a huge variety of positions that will be used to train a neural network.

Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Polyglot Opening Book of Random Moves?

Post by hgm »

Why do this through a book? Just let the engine pick the first N moves randomly. In Fairy-Max I add a random value to the score in the root for the first N moves to create diversity. But there I limited it to 50cP, so that it would not blunder away material because of it. But if you would make it asymptotically large, you would get pure random play.
chrisw
Posts: 4624
Joined: Tue Apr 03, 2012 4:28 pm
Location: Midi-Pyrénées
Full name: Christopher Whittington

Re: Polyglot Opening Book of Random Moves?

Post by chrisw »

Steve Maughan wrote: Thu Feb 09, 2023 6:35 pm The use-case is to create a large number of games with a huge variety of positions that will be used to train a neural network.

Steve
If all you want are labelled positions you could write a self-play with random book for any UCI engine in Python in about 20 lines of code.
User avatar
Steve Maughan
Posts: 1273
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Polyglot Opening Book of Random Moves?

Post by Steve Maughan »

Hi Chris — that looks like the best option. Python Chess looks excellent.

— Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine
User avatar
Steve Maughan
Posts: 1273
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Polyglot Opening Book of Random Moves?

Post by Steve Maughan »

hgm wrote: Thu Feb 09, 2023 10:44 pm Why do this through a book? Just let the engine pick the first N moves randomly. In Fairy-Max I add a random value to the score in the root for the first N moves to create diversity. But there I limited it to 50cP, so that it would not blunder away material because of it. But if you would make it asymptotically large, you would get pure random play.
Hi H.G. — that'll work for Maverick but what about the other side?

— Steve
http://www.chessprogramming.net - Juggernaut & Maverick Chess Engine
JoAnnP38
Posts: 253
Joined: Mon Aug 26, 2019 4:34 pm
Location: Clearwater, Florida USA
Full name: JoAnn Peeler

Re: Polyglot Opening Book of Random Moves?

Post by JoAnnP38 »

Steve Maughan wrote: Fri Feb 10, 2023 9:36 pm
hgm wrote: Thu Feb 09, 2023 10:44 pm Why do this through a book? Just let the engine pick the first N moves randomly. In Fairy-Max I add a random value to the score in the root for the first N moves to create diversity. But there I limited it to 50cP, so that it would not blunder away material because of it. But if you would make it asymptotically large, you would get pure random play.
Hi H.G. — that'll work for Maverick but what about the other side?

— Steve
So, you are not doing self-play to generate your positions? If so, then random move scores in the engine seems like the way to go. If you are wanting to use another engine that you don't control the source to then I better understand your dilemma. However, I don't know enough to say whether that's necessary or not.
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Polyglot Opening Book of Random Moves?

Post by hgm »

Steve Maughan wrote: Fri Feb 10, 2023 9:35 pm Hi Chris — that looks like the best option. Python Chess looks excellent.

— Steve
Well, there isn't any need to program anything yourself for this. You can just use an engine like Brutus Random to play a zillion games, and convert the resulting PGN to a pook using Polyglot.
chrisw
Posts: 4624
Joined: Tue Apr 03, 2012 4:28 pm
Location: Midi-Pyrénées
Full name: Christopher Whittington

Re: Polyglot Opening Book of Random Moves?

Post by chrisw »

hgm wrote: Sat Feb 11, 2023 11:01 am
Steve Maughan wrote: Fri Feb 10, 2023 9:35 pm Hi Chris — that looks like the best option. Python Chess looks excellent.

— Steve
Well, there isn't any need to program anything yourself for this. You can just use an engine like Brutus Random to play a zillion games, and convert the resulting PGN to a pook using Polyglot.
Well, there isn’t any need to go downloading external stuff, working out how to get it to work, clogging up your HD with humungous PGN data and humungous book binaries for this. Just use Python, keep the whole thing under your own control (like add filters in the future if desired), generate depth programmable random moves on the fly and dump the resulting data as PGN or EPD.