Monte Carlo Tree Search

These images are from the movie ‘Avengers: Infinity War’. One of the “good guys” manipulates time to look into the future and see if they successfully defeat the “bad guys.”

The joke is that “How?” is probably intended to mean, “How did we defeat the bad guys in that one future?” But it’s taken to mean, “How did you find the winning future?” A Monte Carlo tree search, or MCTS, is how a computer scientist or data scientist might do it.

The Monte Carlo method is a way of making predictions that’s a big deal in any field that uses a lot of data and statistics – economics, physics, artifical intelligence, meteorology, etc. It’s named after the famous casino in the South of France, where players might think they’re winning because of skill or chance, but really the house is always winning.

First let’s look at what Monte Carlo isn’t. Let’s say you’re playing Tic Tac Toe against a computer. Whenever you make a move, the computer can calculate every possible sequence of moves that would let the computer win the game. That is, it can simulate every possible way the game could go. The next move it actually makes is the one that leads to a victory in the most simulations. This is an example of a brute-force search, where the computer keeps hammering away until it knows everything that can happen, and you basically can’t win.

There are 255,168 different ways a game of Tic Tac Toe can go. That’s a big number, but not very big for computers. Now let’s say you’re playing Chess against a computer. There’s a near-infinite number of ways a game of Chess can go – actually infinite if you don’t play with the 50-move rule. Even a supercomputer can’t count to infinity, so the brute-force approach won’t work.

But the computer knows two things: (1) There are only so many moves that can be made during one turn of chess, and (2) It doesn’t have to figure out the best possible sequence of moves, it just has to figure out a sequence that’s good enough to beat you.

So, whenever you take a turn, the computer randomly simulates the next couple of moves. It can’t simulate more than a couple moves without running out of memory. But it can simulate several thousand different sequences of a couple moves, and tell which of those sequences are “good” (it doesn’t lose too many pieces and/or takes a lot of yours). The next move it makes is the one that starts the greatest number of “good” sequences.

This is MCTS. Monte Carlo methods are all about randomly simulating what could happen a bunch of times until you have a pretty good idea of what’s most likely to actually happen. It’s can’t give you 100% certainty the way brute-force can, but when you’re trying to predict the weather, or how a stock will perform, or how long a project will take, there’s too much going on to get 100% certainty anyway.

This 'Avengers’ meme jokes that the good guys can win the war against the bad guys by running a Monte Carlo tree search, as if it was a board game. An MCTS might be pretty accurate if your “war” is a game of Chess or Risk, which has strict rules that you have to follow, but real-life war (let alone a fictional Marvel Comics war) has all sorts of people making all sorts of crazy decisions every all the time.

(Source: reddit.com)