Forums

How do engines decide which openings to play?

Sort:
sammyL1108

I was looking at some recent games from the 2016 computer world chess championship. I realize that computers have opening books but how does the computer decide which opening and which continuation to go with? It seemed like, some losses were simply due to weak choices in the opening tree.

Yigor

Engines use evaluations and always choose one of optimal moves with the best evaluation. explorer.pngwink.png

JSLigon

If you're asking how they choose from opening book moves in positions where multiple options are available, a common way to get a variety of openings would be to consult a random number generator (or pseudo-random number generator if we're being technical and pedantic). Maybe for white's first move the opening book says to play e4 40% of the time, d4 30%, c4 20%, Nf3 10%. If the program has access to a function that generates a random real (floating point) number r with a uniform distribution such that 0 <= r < 1, the move choice will be e4 if r < 0.4, d4 if 0.4 <= r < 0.7, c4 if 0.7 <= r < 0.9, and Nf3 otherwise. And you'll have move frequencies defined for every position covered by the opening book, with the random number generator consulted every time a choice needs to be made.

mgx9600

Maybe not entirely random.  Maybe using some heuristics like, "what opens has my opponent played, then pick an equal-scoring open that is different".

 

sammyL1108

Interesting. So It seems in engine tournaments, the makers of the engine would want to take out 'weaker' moves from their opening books perhaps?

JSLigon

If an opening book is meant for competing against other engines, of course the designers would want to avoid directing their engine to make "weak" moves. But how to determine which moves are weak? One way would be to look at the historical results of each move in a database of games (checking how many times the player who made that move won / lost / drew). For this you'd want a large games database to produce a statistically meaningful sample size for as many positions as possible, but you'd also want to filter it to only include games between sufficiently strong players / engines, which unfortunately reduces the sample size. Alternately or additionally, the designers could check the engine evaluations for positions in the database, but if the number of positions is very large (as it will be for any practically useful opening book), and since you want deep evaluations in order for this to be helpful, this approach would be extremely computationally demanding. A third approach would be to have a human expert (ideally a grandmaster) curate the database by hand. But again as the size of the opening book increases, this becomes impractical.

On the other hand, if the opening book is being used as a training tool for people to practice against, you might want the engine to play a wide variety of openings, some of them unsound. You might even want it to make occasional blunders that human players tend to make (a database of games between players of all levels would be useful for this purpose).