{"id":226,"date":"2026-11-13T12:35:10","date_gmt":"2026-11-13T04:35:10","guid":{"rendered":"https:\/\/hoho.live\/luda\/index.php\/2026\/11\/13\/how-minimax-values-a-perfect-information-game\/"},"modified":"2026-11-13T21:53:11","modified_gmt":"2026-11-13T13:53:11","slug":"how-minimax-values-a-perfect-information-game","status":"publish","type":"post","link":"https:\/\/hoho.live\/luda\/index.php\/2026\/11\/13\/how-minimax-values-a-perfect-information-game\/","title":{"rendered":"How minimax values a perfect-information game"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Short answer:<\/strong> <strong>Minimax<\/strong> values a two-player zero-sum game of perfect information by recursion on the game tree. A terminal position returns its payoff to the player about to move, or a fixed score for the player who just lost. A maximizing node takes the maximum of its children. A minimizing node takes the minimum. With optimal play the root value is the value of the game. The time is proportional to the number of leaves, which is <strong>O(b^d)<\/strong> for branching factor b and depth d.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>What the problem actually asks<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">If both players play perfectly, the player to move chooses the child whose backed-up value is best for them, and the opponent will do the same on their turn. That alternation is the max and the min. No probability is involved. A chance node, as in a dice game, would average over outcomes and is expectiminimax, not this algorithm.<\/p>\n\n\n<p class=\"wp-block-paragraph\">The tree is usually too large to expand. Depth-limited search replaces a leaf at the horizon with a static evaluation. That evaluation is an approximation. The minimax value of the truncated tree is exact only for the truncated tree, not for the real game.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>What the algorithm guarantees<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">On a finite tree with true terminal payoffs, the backed-up root value equals the game value under optimal play, and the argmax child is an optimal move. Time and memory of a depth-first implementation are O(b^d) time and O(d) memory. Alpha-beta pruning computes the same value and skips branches that cannot change it. Negamax is the same recurrence written so both layers maximize, by negating the child&#8217;s value.<\/p>\n\n\n<p class=\"wp-block-paragraph\">The algorithm assumes alternating turns, perfect information, and a zero-sum payoff. Simultaneous moves, hidden cards, or a non-zero-sum payoff need a different solution concept.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>The working steps<\/strong><\/h4>\n\n<ol class=\"wp-block-list\">\n<li>If the position is terminal, return its payoff to the maximizing player.<\/li>\n<li>If the player to move is the maximizer, return the maximum of the minimax values of the legal children.<\/li>\n<li>If the player to move is the minimizer, return the minimum of those values.<\/li>\n<li>The move to play is any child that attains the root value.<\/li>\n<li>At a depth limit, return a heuristic evaluation instead of a terminal payoff, and treat that number as exact only inside the truncated tree.<\/li>\n<\/ol>\n\n\n<p class=\"wp-block-paragraph\">The exponential cost is the full tree. Alpha-beta is the pruning that preserves the value. A depth limit plus an evaluation is an approximation. Expectiminimax inserts chance nodes. Minimax itself is deterministic perfect-information backup.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Approaches that look simpler and fail<\/strong><\/h4>\n\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>Approach<\/th>\n<th>Why it fails when a depth-limited evaluation is treated as the game value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Stop at a fixed depth and call the evaluation the true value<\/td>\n<td>The number is the minimax value of a different, shorter game whose leaves were labeled by the heuristic. The real game can disagree.<\/td>\n<\/tr>\n<tr>\n<td>Average the children<\/td>\n<td>An average is a chance node or a policy that plays randomly. Optimal play selects the extreme, not the mean.<\/td>\n<\/tr>\n<tr>\n<td>Maximize at both layers<\/td>\n<td>The opponent&#8217;s layer then cooperates. Negamax maximizes both layers only after negating the returned value.<\/td>\n<\/tr>\n<tr>\n<td>Explore the whole tree when alpha-beta is available<\/td>\n<td>The value is identical and the work is larger. Alpha-beta is the same theorem with pruned branches.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n<p class=\"wp-block-paragraph\">Pruning that preserves the minimax value is alpha-beta. A sampled tree with rollouts is Monte Carlo tree search. Minimax is the exact backup of a perfect-information tree.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>A working example<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">This Python fragment alternates max and min down a complete game tree. On the same leaves 3, 5, 2, 9 the root value is <code>3<\/code>.<\/p>\n\n<pre><code class=\"language-python\">leaves = [3, 5, 2, 9]\n\ndef minimax(i, depth, maximizing):\n    if depth == 2:\n        return leaves[i]\n    kids = (minimax(i * 2, depth + 1, not maximizing), minimax(i * 2 + 1, depth + 1, not maximizing))\n    return max(kids) if maximizing else min(kids)\n\nassert minimax(0, 0, True) == 3\nprint(minimax(0, 0, True))\n<\/code><\/pre>\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Where it is used<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">Minimax values a two-player game such as chess or tic-tac-toe by assuming both sides play perfectly. Engines do not search the full tree: <strong>alpha-beta<\/strong> cuts it. Monte Carlo tree search is the sampling alternative used when the branching factor makes the full value impossible.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>When you can drop this algorithm<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">Drop a full minimax expansion of a deep game. Use alpha-beta, a depth limit, or a sampling search, and label a heuristic leaf as a heuristic. Keep full minimax for a small tree whose leaves are true terminals.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Why this stays published<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">We publish this so a search for minimax returns the alternating max and min and the exponential size of the unpruned tree. <strong>Minimax backs up a perfect-information game tree by alternating maximum and minimum, and the root value is the game value when the leaves are true terminal payoffs.<\/strong><\/p>\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u7531 HoHo \u8207 AI \u5354\u4f5c\u6574\u7406\uff0c\u6700\u5f8c\u66f4\u65b0\u65bc 2026 \u5e74 11 \u6708 13 \u65e5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Short answer: Minimax values a two-player zero-sum game of perfect information by recursion on the game tree. A terminal position returns its payoff to the player about to move, or a fixed score for the player who just lost. A maximizing node takes the maximum of its children. A&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,39],"tags":[],"class_list":["post-226","post","type-post","status-publish","format-standard","hentry","category-algorithms","category-games"],"_links":{"self":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/comments?post=226"}],"version-history":[{"count":2,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":625,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/226\/revisions\/625"}],"wp:attachment":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/media?parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/categories?post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/tags?post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}