Any way to randomize openings when not using a book?

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

JohnW
Posts: 407
Joined: Thu Nov 22, 2012 12:20 am
Location: New Hampshire

Any way to randomize openings when not using a book?

Post by JohnW »

If I match two engines and configure the match to not use an opening book, a lot of engines when select the same opening over and over.
For example, I can't get Patricia 5 or Lc0 v0.32.1 to play anything other than e4. Why they won't select d4 or even c4 once and a while I don't understand. I don't want to use an opening book because they'll make 10-20 moves until they run out of book and I want to watch a game as if it were two humans playing on my Chessnut Move. Any idea how I can make the engines randomly select an opening? Thanks for your help..
ImNotStockfish
Posts: 57
Joined: Tue Sep 14, 2021 12:29 am
Full name: .

Re: Any way to randomize openings when not using a book?

Post by ImNotStockfish »

Yes, there is a way, by using a book, literally, unironically, seriously, actually, for real.
Rowen
Posts: 122
Joined: Tue Nov 15, 2016 1:19 pm
Location: Cheshire, England

Re: Any way to randomize openings when not using a book?

Post by Rowen »

Most engines if not using a book will always play their best moves but sometimes an engines' parameters can be tweaked so the engine varies its moves, randomisation etc, I mainly use the Fritz GUI but using that there are many opening books that can be downloaded that vary in move length (and variety) , some as few as 1 to 3 moves long. Even with longer books the moves can be shortened to zero and upwards, and variety of moves can be adjusted. I don't have chessnut .Presumably that doesn't allow you change opening book parameters? Or use other books?
JohnW
Posts: 407
Joined: Thu Nov 22, 2012 12:20 am
Location: New Hampshire

Re: Any way to randomize openings when not using a book?

Post by JohnW »

ImNotStockfish wrote: Sat Feb 07, 2026 9:35 pm Yes, there is a way, by using a book, literally, unironically, seriously, actually, for real.
Ok, so now tell me how to make them move like a human would instead of 20 moves in 3 seconds
JohnW
Posts: 407
Joined: Thu Nov 22, 2012 12:20 am
Location: New Hampshire

Re: Any way to randomize openings when not using a book?

Post by JohnW »

Rowen wrote: Sun Feb 08, 2026 12:50 pm Most engines if not using a book will always play their best moves but sometimes an engines' parameters can be tweaked so the engine varies its moves, randomisation etc, I mainly use the Fritz GUI but using that there are many opening books that can be downloaded that vary in move length (and variety) , some as few as 1 to 3 moves long. Even with longer books the moves can be shortened to zero and upwards, and variety of moves can be adjusted. I don't have chessnut .Presumably that doesn't allow you change opening book parameters? Or use other books?
Oh, I didn't realize there opening books like that or you can make them shorter. That's a good idea, thank you!
tapio
Posts: 90
Joined: Thu May 30, 2024 10:33 am
Full name: Adsche Tönnsen

Re: Any way to randomize openings when not using a book?

Post by tapio »

Move timing humanization is something that can be done with LucasChess.
MOBMAT
Posts: 413
Joined: Sat Feb 04, 2017 11:57 pm
Location: USA

Re: Any way to randomize openings when not using a book?

Post by MOBMAT »

When I implemented the lookup when using a (.bin) book, I had 3 settings.
1. Best move (based on the score associated with the available moves)
2. Pure random (of the available moves for the position)
3. Weighed random.

#3 looks at all the moves in the book for the current position and randomizes based on the book value. For example, if the book has e4 and d4 as the only first move for white, and their book value are 10000 for e4 and 8000 for d4, then my algorithm adds up the scores of all the available moves (18000), generates a random number between 1 and 18000. it then scans across the accumulated move score values to see which move the random number falls in.

Pretty easy to implement in an engine, but not a common feature. As was stated, you probably wouldn't want to use this in an engine to engine battle, but it is nice to mix it up when it is human vs engine.
i7-6700K @ 4.00Ghz 32Gb, Win 10 Home, EGTBs on PCI SSD
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K
User avatar
pohl4711
Posts: 2911
Joined: Sat Sep 03, 2011 7:25 am
Location: Berlin, Germany
Full name: Stefan Pohl

Re: Any way to randomize openings when not using a book?

Post by pohl4711 »

JohnW wrote: Sun Feb 08, 2026 1:15 pm
Rowen wrote: Sun Feb 08, 2026 12:50 pm Most engines if not using a book will always play their best moves but sometimes an engines' parameters can be tweaked so the engine varies its moves, randomisation etc, I mainly use the Fritz GUI but using that there are many opening books that can be downloaded that vary in move length (and variety) , some as few as 1 to 3 moves long. Even with longer books the moves can be shortened to zero and upwards, and variety of moves can be adjusted. I don't have chessnut .Presumably that doesn't allow you change opening book parameters? Or use other books?
Oh, I didn't realize there opening books like that or you can make them shorter. That's a good idea, thank you!
I made some very short (balanced) opening books (all 8 plies deep), long time ago, you can try these:
https://www.sp-cc.de/files/8_plies_book.zip

Additionally, when all game results are set to 1/2-1/2 and this pgn database is used for making a FritzGUI opening book, all played moves have the same probability of being played, despite their frequency.