Currently my engine does not make use of an opening book.
Rather than doing a whole search routine immediately from move 1 (assuming the engine is playing as white), is it frowned upon to just hardcode possible common first moves and then randomly pick one of them (like e4, d4, Nc3, Nf3)? I could do a GetMoves at the start and randomly pick one from there, but I don't really want to be making something like 1. h3.
First move without opening book - search or hardcode?
Moderator: Ras
-
- Posts: 93
- Joined: Sun Aug 08, 2021 9:14 pm
- Full name: Kurt Peters
-
- Posts: 325
- Joined: Tue Aug 31, 2021 10:32 pm
- Full name: tcusr
Re: First move without opening book - search or hardcode?
if the first suggested move is h3 then there's something wrong with evaluation
-
- Posts: 608
- Joined: Sun May 30, 2021 5:03 am
- Location: United States
- Full name: Christian Dean
Re: First move without opening book - search or hardcode?
Don't see why this would be frowned upon. Uncommon maybe, but not frowned upon. I'd just make sure to have a way to disable it and make sure it wouldn't be used if the engine was given a position to start from beside the initial position. Although why not opt for just adding polyglot book support instead? Not to hard to get up and running and it gives you to freedom to not only develop a dedicated opening book for your engine in the future but also decouples the book from the engine making it easier to maintain the two in the long run since nothing is hard-coded.
That's what I've done with Blunder, and although right now I don't have a dedicated opening book for it, if I wanted to in the future, I'd just need to use the polyglot tools to create one and then ship it with the engine. And if the user wants to try a different opening book, no problem, just swap their favorite one in and Blunder will pull moves from there.
That's what I've done with Blunder, and although right now I don't have a dedicated opening book for it, if I wanted to in the future, I'd just need to use the polyglot tools to create one and then ship it with the engine. And if the user wants to try a different opening book, no problem, just swap their favorite one in and Blunder will pull moves from there.
-
- Posts: 1397
- Joined: Wed Mar 08, 2006 10:15 pm
- Location: San Francisco, California
Re: First move without opening book - search or hardcode?
Certainly not frowned upon. What you are essentially doing is making a VERY short custom opening book.
Just be sure your engine works properly if a GUI tries to force its own opening book moves on your engine, and you're fine.

Just be sure your engine works properly if a GUI tries to force its own opening book moves on your engine, and you're fine.
-
- Posts: 915
- Joined: Sun Dec 27, 2020 2:40 am
- Location: Bremen, Germany
- Full name: Thomas Jahn
Re: First move without opening book - search or hardcode?
I think it shouldn't be needed. The GUI usually takes care of playing the opening and if you play "from scratch" your engine will play what it thinks will lead to a good position. I found that as the engine goes stronger it will automatically start to play lines that can be found in an opening book, just as it learns to convert won endgames without a table-base.
-
- Posts: 93
- Joined: Sun Aug 08, 2021 9:14 pm
- Full name: Kurt Peters
Re: First move without opening book - search or hardcode?
Well, maybe then that's just what I'll look at doing and just do it right rather than trying to come up with some half-baked solution.algerbrex wrote: ↑Sat Aug 06, 2022 11:20 pm Don't see why this would be frowned upon. Uncommon maybe, but not frowned upon. I'd just make sure to have a way to disable it and make sure it wouldn't be used if the engine was given a position to start from beside the initial position. Although why not opt for just adding polyglot book support instead? Not to hard to get up and running and it gives you to freedom to not only develop a dedicated opening book for your engine in the future but also decouples the book from the engine making it easier to maintain the two in the long run since nothing is hard-coded.
That's what I've done with Blunder, and although right now I don't have a dedicated opening book for it, if I wanted to in the future, I'd just need to use the polyglot tools to create one and then ship it with the engine. And if the user wants to try a different opening book, no problem, just swap their favorite one in and Blunder will pull moves from there.
-
- Posts: 547
- Joined: Tue Feb 04, 2014 12:25 pm
- Location: Gower, Wales
- Full name: Colin Jenkins
Re: First move without opening book - search or hardcode?
There again, letting it search fills the TT.
-
- Posts: 4398
- Joined: Fri Mar 10, 2006 5:23 am
- Location: http://www.arasanchess.org
Re: First move without opening book - search or hardcode?
UCI engines generally defer opening book handling to the interface they're connected to (Chessbase, Fritz, cutechess, etc).
Arasan has its own opening book with a custom format, but that's mostly for historical reasons. (This can be disabled in case an external program is handling the book).
Arasan has its own opening book with a custom format, but that's mostly for historical reasons. (This can be disabled in case an external program is handling the book).
-
- Posts: 157
- Joined: Fri Apr 30, 2021 7:19 am
- Full name: Pedro Duran
Re: First move without opening book - search or hardcode?
leave it optional:
From UCI Protocol:
From UCI Protocol:
* option
* = OwnBook, type check
this means that the engine has its own book which is accessed by the engine itself.
if this is set, the engine takes care of the opening book and the GUI will never
execute a move out of its book for the engine. If this is set to false by the GUI,
the engine should not access its own book.
-
- Posts: 29
- Joined: Thu Jun 09, 2022 5:09 am
- Full name: Clayton Ramsey
Re: First move without opening book - search or hardcode?
Regarding your first suggested move being h3: I suspect that your leaf evaluation function isn't fine-grained enough, and so your engine is selecting either the first or last move generated, as the rest of the opening moves have the same leaf evaluation after search. Is your current evaluation function just pure material?
As soon as you add a good PST, this issue should go away.
As soon as you add a good PST, this issue should go away.