When two chess algorithms play each other why isn’t every game the same?

860 views

When two supercomputers or chess analysis programs like stock fish or alpha zero play each other why don’t they always end up playing the same moves? If every computer is attempting to play the best possible move on every turn then shouldn’t every game end up the same because the best move for each position is always the same? If for example one engine determines that the best possible opening move is 1. e4 and the other engine decides that the move that gives it the best chance of winning is e5 or c5 or some other move then the first engine would play the best possible move and the game would proceed identically every time with the exact same move order and result.

In: Mathematics

11 Answers

Anonymous 0 Comments

It most chess program vs chess program matches, the first few moves are often chosen.

In addition, computers may add a level of randomness: if it calculates 2 moves to be identical in value, it may chose either one with 50% probability.

Anonymous 0 Comments

At the start of the game, engines typically don’t calculate their moves, they play moves selected from an opening book with some degree of randomness. They do this both to be more interesting and to be harder to predict. If an engine always played c5 in response to e4, a competing engine could be tuned with that in mind, forcing the first one into an unfavorable line with preselected moves.

Also, there are many positions where there are several good moves, the difference between them is negligible. An engine might flip-flop between moves, and which one is chosen when it is time can be almost random.

Anonymous 0 Comments

Computers use algorithms to make decision. In order to mimic uncertainty the desisions are made psudo randomly.

So say any given opening move is weighted equally. The computer will pick one at a predetermined random rate.

You can see how this then spirals into, what can seem a unique game. But I assure you it is predictable.

Anonymous 0 Comments

Because Chess is a state-based game. To be really good at chess, you have to make a series of moves that increase your odds of victory. A computer is the ultimate memory machine. It not only doesn’t need to use intuition, it’s fully incapable of doing so. Each state of chess can lead to a limited number of subsequent states – each move a player *could* make is a different state, and each of those has a cascade of subsequent states. The computer basically assigns values to each state, based on how much the move affects the computer’s chance of winning. Often, especially in the early game where there are lots of possible states and big cascades, multiple moves are assigned the same value – they have the same effect on the computer’s chance of winning. In this case, the computer simply picks which move to make at random.

IIRC the exact nature of these values is usually calculated based on a combination of the material value of a board – ie, the total value of all the pieces you still have in play – and the relative value of having a piece in any given position. The chess computer will make moves which increase its overall board value as far as its bothered to analyze the possible subsequent plays.

A particular place in where randomness arises is in the beginning. A single different move at the beginning leads to a very different game, and a lot of computers as far as I’m aware determine their opening move pretty much at random from a book of all the good opening moves real players have used.

Anonymous 0 Comments

**Preface**

Almost all the answers that I see here as per the time of me writing this answer, are wrong or miss part of the answer.

First I should warn you that this might get very technical and might not be an ELI5 answer due to the nature of question and the amount of details required to understand why the answer is the way it is. The TL;DR will be very much an ELI5 answer but won’t really answer your question.

I also will not be touching on machine learning since that is a very extremely difficult topic and people aren’t fully able to understand why chess AIs built with machine learning play the way they do. I also can’t comment on them since they also rely heavily on what their inputs are and what their inputs are, are typically not public knowledge.

**The answer**

*Part 1 – The nature of Chess*

With chess, each move changes how the board is laid out. When a chess piece is moved, the new layout is a new *state*. So given a starting chess board, the first player can make 20 different opening moves. So that gives 20 different board *states*. The other player than can do 20 opening moves themselves. Overall after the first two moves, this gives us a total of 400 different *states*. This continues till the end of the game.

After the 10th move, there are 69,352,859,712,417 different positions for the pieces to be in. Or 69,352,859,712,417 different *states*. We don’t know exactly how many possible board *states* there are.

*Part 2 – Computers and Chess*

With the large amount of states and the nature of computers, the possible board states are not able be regenerated and saved to be used in a later date. So when a chess program plays chest. It creates what is known as a tree. It takes the current board layout and generates all the possible moves that can be done. All those states are grouped up are known as a *layer*.

Now from those states, the next *layer* is created. This is done by creating all the possible moves for each state in the layer above.

[That tree ends up looking something like this](https://9ba9b83c-a-62cb3a1a-s-sites.googlegroups.com/site/qgchess/chess-algorithms/minmaxtree.JPG?attachauth=ANoY7coInsZ2RkZjE2N1qwTghHMenTMG_c4jRxD4bad6sVxKCBeDaBRTyrvi_PI9B-9KwwnhCg6EnA-NMA1lLrzoBCSPw0ZQ8vaiiq5xlSWy9y750xZDG8uHBUZnvtRvGqPSWIsF4w1_TlCTG8IS2ucYj5ULSJezJbC46c9MCVNrw8cp5s1GBBMyqddDdePqlKaNIQooyPDDI9lhHqUZIjN6ED37LV3uDth-IFtKcpUxN7kIQUJYPLg%3D&attredirects=0)

Now as mentioned in part 1, there are a lot of possibilities for where chess pieces can be. A you don’t really want the chess program to take hours, months, years or even till the end of time to come back with what move it will play. So the chess program will have a certain time limit for how long it should take to generate the tree.

With that generated tree, the software assigns a score to each state that is generated. This score is generated based on an algorithm that determines how good that state is for program. The algorithm is different for each chess program.

After the tree is created with the board states and their scores, the program searches through the tree to find the very best state that the tree has. It then backpedals back up the tree to find what move it should play to move towards that desired state.

The program does this for every move.

*Part 3 – Conclusion?*

Now with this understanding, if two chess programs are pitted against each other, they will play the same moves each time they play the game. But as you have noticed, that isn’t always the case.

The reason behind that is due to the nature of chess, the farther a head you can look, the better you will do in chess. But a computer can only do so much.

*Part 4 – Monte Carlo*

A solution was created to allow a chess program to look farther a head in the same amount of time. This solution is called the *Monte Carlo Algorithm*. This algorithm is done during the tree generation of the board states. Instead of generating all of the states in a given layer, each state is given a random chance to not be generated and added to the tree. This means any moves done after that state, will not be computed.

So the first layer on the first move in a game might have 15 different states instead of the full 20 opening moves. The 2nd layer might only have 150 states instead of the full 400 states.

This allows the same amount of states to be generated in the same time frame, but have the program look farther ahead.

Because of that randomness, in one game, a move that was done by the program might not be an option in another game.

**TL;DR**

The computer can only do so much work, so some randomness is added to allow the computer to do less work to allow it to look a head farther, allowing the computer to play better.

Anonymous 0 Comments

To be fair very early chess routines did play the same game every time if you made the same moves.

Anonymous 0 Comments

**Because Chess is not solved.**
The computer doesn’t know the best possible move because you can’t know that unless you understand every possible consequence of every move you could make. Since Chess involves more possibilities than even modern computers can handle thinking about, nobody can have a perfect understanding of the consequences of any given move.
Computers can perfectly understand endgame situations where many of the pieces (and therefore possibilities) have been removed and they can even do well in the early game because the possibilities are fairly tightly constrained until the game develops but that leaves a large portion of the mid-game where the possibility space explodes beyond the capabilities of any known mind (except maybe Bobby Fischer).
One of these days, we’re likely to build a system complex enough to solve Chess and the solution might tell us something interesting about the nature of the game or it might not but until then, it’s as big and exciting a mystery as it ever has been.
For more information (and perhaps some tricky math), check out [this page](https://en.wikipedia.org/wiki/Game_complexity) on game complexity.

Anonymous 0 Comments

For Stockfish-like engines: Yes, but only on specific conditions.
Usually computer chess games are limited by time, and the amount of calculations done within that time can change according to the computer CPU load, memory conditions and even CPU heat.
That lead to seemingly random changes between games.
So if you specify node calculation limit instead of time limit, this will actually happen.

Side note: in chess engine competitions, it is common to tell the engines the first 3-7 moves, do they won’t repeat the same opening over and over

Anonymous 0 Comments

In theory, if you put two computer players against each other and let the same player start each time, the game should play out exactly the same.

The moment you change something – letting a different program start, or using different algorithms then everything will changep.

This of course assumes that the computers are programmed to follow pretty strict rules – with this board state, the most efficient move is this.
As soon as you start using more advanced software this can all change – by watching for patterns in the plays and attempting to counteract those, using learning from previous games and other adjustments it can be that even if there is one theoretically efficient move that is best, a suboptimal move may be better *against that opponent* and with both players adapting and changing, games will keep on varying.

It will all depend on the software you use – the software used with a free chess program will probably be fairly predictable and rigid, while the top supercomputer powered ai systems that they are pitching against the chess grand masters will be something else entirely.

Anonymous 0 Comments

Let me try to actually ELI%

The number of possible ways pieces can move in a game is really huge and can be compared to the number of ways notes could be played to make music. In this sense, a chess game is more like a complex piece of music than a game of Monopoly.

The same way that no one has written every possible song, no one has computed every possible chess game, so there is still room for combinations that are new to everyone.