Questions tagged [monte-carlo-tree-search]

Monte-Carlo Tree Search is a best-first, rollout-based tree search algorithm. It gradually improves its evaluations of nodes in the trees using (semi-)random rollouts through those nodes, focusing a larger proportion of rollouts on the parts of the tree that are the most promising. This tag should be used for questions about implementation of this algorithm.

Monte-Carlo Tree Search (MCTS) is a best-first tree search algorithm. "Best-first" means that it focuses the majority of the search effort on the most promising parts of a search tree. This is a popular algorithm for automated game-playing in Artificial Intelligence (AI), but also has applications outside of AI.

For an introduction into the types of search trees that MCTS is typically used for, see minimax.

Older algorithms, such as minimax and alpha-beta-pruning, evaluate a node by systematically searching all the nodes below it, which can be very computationally expensive. The basic idea of MCTS is to rapidly approximate such systematic evaluations of nodes by using (semi-)random rollouts and averaging the evaluations at the end of those rollouts. Over time, the algorithm will focus a larger amount of search effort on parts of the search tree that appear promising based on the earlier rollouts. This enables the algorithm to gradually improve the approximations of the evaluations in those parts of the tree. Additionally, the algorithm gradually grows a tree by storing a number (typically 1) of nodes in memory for every rollout. The parts of the tree that are stored in memory are not traversed using a (semi-)random strategy, but using a different ("Selection") strategy. This guarantees that, given an infinite amount of computation time, the algorithm converges to optimal solutions.

An extensive survey, describing many enhancements and applications of the algorithm, can be found in:

  • Browne, C., Powley, E., Whitehouse, D., Lucas, S., Cowling, P. I., Rohlfshagen, P., Tavener, S., Perez, D., Samothrakis, S., and Colton, S. (2012). A Survey of Monte Carlo Tree Search Methods. Computation Intelligence and AI in Games, IEEE Transactions on, Vol. 4, No. 1, pp. 1-43.

The algorithm was originally proposed in:

  • Kocsis, L. and Szepesvári, C. (2006). Bandit Based Monte-Carlo Planning. Proceedings of the 17th European Conference on Machine Learning (ECML 2006) (eds. J. Fürnkranz, T. Scheffer, and M. Spiliopoulou), Vol. 4212 of Lecture Notes in Computer Science, pp. 282-293, Springer Berlin Heidelberg.
  • Coulom, R. (2007). Efficient Selectivity and Backup Operators in Monte-Carlo Tree Search. Computers and Games (eds. H. J. van den Herik, P. Ciancarini, and H. H. L. M. Donkers), Vol. 4630 of Lecture Notes in Computer Science, pp. 72-83, Springer Berlin Heidelberg.
79 questions
1
vote
1 answer

AlphaZero: which nodes visited during self-play?

Reading this article was very helpful in getting a good understanding of the principles behind AlphaZero. Still, there is something I am not completely sure about. Below is the author's UCT_search method, as can be consulted in his code on Github:…
1
vote
1 answer

Monte Carlo Tree Search Expansion

I hope you are doing well. I am currently working on a project where we need to implement a connect4-agent by using Mcts (Monte Carlo tree search). As far as I've understood, mcts basically consists on four stages: 1) Tree construction 2) Selection…
1
vote
0 answers

ValueError: The truth value of an array ... but it's just an int

I have an array self.N of ints, and I'm trying to write self.N[node] +=1, but whenever I just write self.N[node] it gives me a value error for having more than one element, which it can't. def __init__(self, exploration_weight=1): self.Q =…
Saxt
  • 27
  • 5
1
vote
1 answer

UCB formula for monte carlo tree search when score is between 0 and n

I'm implementing an AI that plays 2048 using monte carlo tree search. According to wikipedia https://en.wikipedia.org/wiki/Monte_Carlo_tree_search and all other sources that I have checked in the expansion step you should use the UCB formula in…
1
vote
1 answer

Parallelizing Monte Carlo Tree Search

I have a Monte Carlo Tree Search implementation that I need to optimize. So I thought about parallelizing the rollout phase. How to do that? (Is there a code example). Are there any python modules etc that you would recommend? I apologize if this…
1
vote
1 answer

Eligibility trace algorithm, the update order

I am reading Silver et al (2012) "Temporal-Difference Search in Computer Go", and trying to understand the update order for the eligibility trace algorithm. In the Algorithm 1 and 2 of the paper, weights are updated before updating the eligibility…
1
vote
0 answers

Faster python treesearch implementation

I have a treesearch implementation in Python that is just way to slow for my use. How can I run this faster? I've read there is numba but I can't get my head around how it would works and what it can support and what not. Did anybody use numba for…
user9468014
  • 479
  • 2
  • 6
  • 20
1
vote
0 answers

Is it meaningful to give more weight to the result of monte carlo search with less turn win?

I'm programming on Connect6 with MCTS. Monte Carlo Tree Search is based on random moves. It counts up the number of wins in certain moves. (Whether it wins with 3 turns or 30 turns) Is the move with less turns more powerful than the move with more…
1
vote
2 answers

How does MCTS work with 'precise lines'

So I am familiar with more basic tree search algorithms like game search w/ minimax, but I've been trying to learn more about the Monte-Carlo Tree Search algorithm, and was wondering how it deals with 'precise lines.' In the context of chess, where…
1
vote
0 answers

Monte Carlo Optimization

I am trying to do Monte Carlo minimization to solve for parameters of a given equation. My equation has 4 parameters, making my iteration about 4**n when I try iteration n = 100, I saw it is not a good idea to search all the parameter space. Here is…
1
vote
1 answer

Taking into account information on opponent's likely moves in MCTS?

I'm creating a MCTS (Monte Carlo Tree Search) program for a 2 player game. For this I create nodes in the tree, from alternating perspectives (the first node is from the perspective of player 1, any child nodes are from the perspective of player 2,…
1
vote
2 answers

JAVA - Array copy in constructor unexpectedly slow after large number of calls

I am currently trying to improve the performance of a Java code. After digging a bit to see where optimization was required I ended up with the following setup (simplified for clarity). The Board constructor which is called a large number of times…
Goujon
  • 37
  • 1
  • 7
1
vote
1 answer

How to Share Object in multiprocesing, python

Thanks to read this. I have developed chess AI like AlphaGo Lee or AlphaGo Zero. I have used Python and tensorflow. The chess AI is consist of Montecarlo-Tree-Search, policy network and value network. I did learning for policy and value network…
1
vote
1 answer

Reinforcement Learning: fine-tuning MCTS node selection and expansion stage with inaccurate values

I am implementing a Go playing program roughly according to the architecture of earlier versions of AlphaGo(AlphaGo Fan or AlphaGo Lee), e.g. using policy network, value network, and Monte Carlo tree search(MCTS). Currently I have trained a decent…
0
votes
0 answers

Simulation in R (loop for)

I am creating a simulation where n2 represents the sample size in the original dataset (a total of 800 observations), and probability represents the calculated proportion for each row (there are 19 rows in total). I would like to generate a value…
Olesia
  • 1
  • 1