# How does the AlphaGo Zero policy decide what move to execute?

I was going through the AlphaGo Zero paper and I was trying to understand everything, but I just can't figure out this one formula:

$$\pi(a \mid s_0) = \frac{N(s_0, a)^{\frac{1}{\tau}}}{\sum_b N(s_0, b)^{\frac{1}{\tau}}}$$

Could someone decode how the policy makes decisions following this formula? I pretty much understood all of the other parts of the paper, and also the temperature parameter is clear to me.

It might be a simple question, but can't figure it out.

The formula in question uses a function N(state, action) that defines a visit count of a state-action pair (introduced on page 3). To describe how it is used, lets first describe the steps of AlphaGo Zero as a whole.

There are 4 "phases" to the Monte-Carlo tree search in AlphaGo Zero as depicted in Figure 2. The first 3 expand and update the tree and together are the "search" in Monte-Carlo tree "search" in AlphaGo Zero.

1. Select an edge (action) in the tree with maximum action-value Q (plus upper confidence bound U)

2. Expand and evaluate the leaf node using the network

3. Backup Action-values Q are updated to track the evaluations of the Value in the subtree.

4. Play - After the "search" is complete, the search probabilities are returned proportional to the visitation count of the nodes of the tree.*

* This is where the formula in question comes into play (pun intended). During the "search", nodes that looked good were expanded on and thus their visitation counts were updated. So the formula is essentially describing this logic:

Good nodes have higher counts, so choose the nodes with higher counts often

But what if there is a really good node but it hasn't been visited a lot so its not chosen?

This is where the temperature parameter comes in:

• If the temperature is 1, this selects moves proportionally to their visit counts.
• If the temperature is 0 (not actually but rather in infinitesimal that approaches 0), and with some added noise, it "ensures that all moves may be tried, but the search may still overrule bad moves."

So altogether, the formula is saying : Pick good things most of the time

The mathematical evaluation of the formula is described below:

AlphaGo Zero defines the probability of each action (aka the policy) by that formula. If there are 3 nodes, A, B and C, and they have each been visited 10, 70, and 20 times (100 times in total), respectively, then the probability of taking those actions is:

• P(A) = 10/100 = .10
• P(B) = 70/100 = .7
• P(C) = 20/100 = .2
• While I get that "good nodes have higher counts", it feels to me that the better way to pick the best move should have been argmax Q(s,a) which we already have. What do you think could be the reasoning for choosing count over the best Q? Oct 6, 2020 at 22:02

Intuitively:

1. Larger Q means larger probability that the node (s'|s,a) would be chosen. When we selected most visited node, we selected a node with good Q.
2. More visited count means more accurate estimation. And the chosen node proved itself as a good choice even after more trials than other nodes.
3. Less computation in some cases (integer/long vs float/double)
{"ft_lang_label":"__label__en","ft_lang_prob":0.92489237,"math_prob":0.90730774,"size":2005,"snap":"2023-40-2023-50","text_gpt3_token_len":469,"char_repetition_ratio":0.11794103,"word_repetition_ratio":0.0056179776,"special_character_ratio":0.24588528,"punctuation_ratio":0.09462915,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99616355,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-28T16:39:25Z\",\"WARC-Record-ID\":\"<urn:uuid:239fcab1-45f4-4ca1-91d9-2d11aa47497c>\",\"Content-Length\":\"157537\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6f51cb7a-df5f-40a8-afcd-9f87489c8bdd>\",\"WARC-Concurrent-To\":\"<urn:uuid:046c2f54-2af0-4a84-96bf-be1818febebc>\",\"WARC-IP-Address\":\"104.18.43.226\",\"WARC-Target-URI\":\"https://ai.stackexchange.com/questions/20983/how-does-the-alphago-zero-policy-decide-what-move-to-execute\",\"WARC-Payload-Digest\":\"sha1:PJKFHOGLVK6WVTIQOJU6DDSQ5CXNLXP3\",\"WARC-Block-Digest\":\"sha1:RPDHIH3BURJ7W4TS5M76DZBCYDLDO2YZ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679099892.46_warc_CC-MAIN-20231128151412-20231128181412-00117.warc.gz\"}"}