{
  "source_file": "0930",
  "source_platform": "Dev.to",
  "author": "zeromathai",
  "title_listed": "How Game AI Makes Decisions — From Minimax to Alpha-Beta Pruning",
  "keywords": "",
  "domain": "大模型算法",
  "content_type": "技术教程",
  "is_paid_flag": "否",
  "url": "https://dev.to/zeromathai/how-game-ai-makes-decisions-from-minimax-to-alpha-beta-pruning-5d9b",
  "publish_date": "2026-05-09",
  "corpus_stage": "",
  "notes": "",
  "id": "d08df347fc66",
  "collected_at": "2026-10-02T13:51:03",
  "title": "How Game AI Makes Decisions — From Minimax to Alpha-Beta Pruning - DEV Community",
  "body_markdown": "Game AI is different from ordinary search.\nYou are not just finding a path.\nYou are making a move while another player is trying to block you.\nThat is why game decision-making needs a different structure.\nCore Idea\nIn game search, every move creates a new state.\nBut unlike simple pathfinding, the next state is not fully under your control.\nYour opponent also chooses.\nSo the algorithm must ask:\n“What is my best move if the opponent also plays well?”\nThat question is the heart of Minimax.\nThe Key Structure\nA simple game decision flow looks like this:\nCurrent Board → Possible Moves → Opponent Responses → Score Positions → Choose Best Move\nMinimax expresses this idea:\nMAX player tries to maximize the score\nMIN player tries to minimize the score\nthe final decision assumes both players play optimally\nSo Game AI is not only about choosing a good move.\nIt is about choosing a move that survives the opponent’s best response.\nImplementation View\nAt a high level, Minimax works like this:\nfunction minimax(state, depth, maximizing_player):\n    if state is terminal or depth is 0:\n        return evaluate(state)\n\n    if maximizing_player:\n        best_score = -infinity\n\n        for each possible move:\n            score = minimax(next_state, depth - 1, false)\n            best_score = max(best_score, score)\n\n        return best_score\n\n    else:\n        best_score = +infinity\n\n        for each possible move:\n            score = minimax(next_state, depth - 1, true)\n            best_score = min(best_score, score)\n\n        return best_score\nEnter fullscreen mode\nExit fullscreen mode\nThis is why Minimax is useful.\nIt turns opponent-aware decision-making into a recursive search problem.\nConcrete Example\nImagine a simple board game.\nYou have three possible moves.\nMove A looks good immediately.\nMove B looks average.\nMove C looks risky.\nA naive AI may choose Move A because the current board score looks highest.\nBut Minimax asks a deeper question:\n“What can the opponent do after I choose Move A?”\nIf Move A allows the opponent to win next turn, it is not actually good.\nMinimax avoids that trap by looking ahead.\nNaive Choice vs Minimax\nThis is the key difference.\nNaive choice:\nevaluates only the current move\nignores the opponent’s best response\ncan fall into obvious traps\nMinimax:\nevaluates future states\nassumes the opponent plays optimally\nchooses the move with the best worst-case outcome\nSo Minimax is not just “pick the move with the highest score.”\nIt is:\nPick the move whose worst-case result is still the best.\nThat is the core idea.\nWhy Heuristics Matter\nIn small games, you might search all the way to the end.\nIn real games, the game tree becomes too large.\nYou cannot evaluate every possible future.\nSo you stop at a limited depth and estimate the position.\nThat estimate is a heuristic function.\nFor example, in a board game, the evaluation function may consider:\nmaterial advantage\nboard control\nking safety\nmobility\nthreat level\nThe heuristic does not guarantee perfect truth.\nBut it gives the search a useful scoring rule.\nThis is what makes game search practical.\nWhy Alpha-Beta Pruning Matters\nMinimax can be expensive.\nIt explores many branches.\nBut some branches do not need to be explored fully.\nAlpha-Beta Pruning removes branches that cannot change the final decision.\nThe idea is simple:\nIf a branch is already worse than a known alternative, stop exploring it.\nThe result is the same as Minimax.\nBut the search can be much faster.\nMinimax vs Alpha-Beta Pruning\nMinimax:\nsearches the game tree\nassumes optimal play\nfinds the best move under the search limit\ncan be computationally expensive\nAlpha-Beta Pruning:\nkeeps the same decision result\nskips branches that cannot matter\nimproves efficiency\nmakes deeper search more realistic\nSo Alpha-Beta is not a different goal.\nIt is an optimization of Minimax.\nSame answer.\nLess wasted search.\nHow This Connects to Broader Search\nGame search also connects to general AI search.\nMinimax is about adversarial decisions.\nA* is about pathfinding with cost and heuristic estimates.\nBoth use search.\nBoth rely on state spaces.\nBoth become more practical when heuristics guide the process.\nThe difference is the problem structure.\nA* asks:\n“What path gets me to the goal efficiently?”\nMinimax asks:\n“What move is best when another agent fights back?”\nRecommended Learning Order\nIf game decision-making feels abstract, learn it in this order:\nState Space Search\nMinimax Algorithm\nHeuristic Function\nAlpha-Beta Pruning\nInformed Search\nA* Algorithm\nThis order works because you first understand game states.\nThen you learn opponent-aware search.\nThen you learn how to make the search efficient.\nTakeaway\nGame AI is not just about finding a good move.\nIt is about finding a move that still works after the opponent responds.\nMinimax gives the decision structure.\nHeuristics make limited-depth search usable.\nAlpha-Beta Pruning removes unnecessary work.\nThe shortest version is:\nMinimax = opponent-aware search\nAlpha-Beta = faster Minimax\nIf you remember one idea, remember this:\nGood game AI does not only evaluate your move; it evaluates the opponent’s best reply.\nDiscussion\nWhen building game AI, do you prefer a simple Minimax implementation first, or do you add Alpha-Beta Pruning from the beginning?\nOriginally published at zeromathai.com.\nOriginal article:\nhttps://zeromathai.com/en/game-decision-making-hub-en/\nGitHub Resources\nAI diagrams, study notes, and visual guides:\nhttps://github.com/zeromathai/zeromathai-ai",
  "metadata": {
    "title": "How Game AI Makes Decisions — From Minimax to Alpha-Beta Pruning - DEV Community",
    "description": "Game AI is different from ordinary search.  You are not just finding a path.  You are making a move... Tagged with algorithms, ai, gamedev, programming.",
    "keywords": "algorithms, ai, gamedev, programming, software, coding, development, engineering, inclusive, community",
    "author": null,
    "og:type": "article",
    "og:url": "https://dev.to/zeromathai/how-game-ai-makes-decisions-from-minimax-to-alpha-beta-pruning-5d9b",
    "og:title": "How Game AI Makes Decisions — From Minimax to Alpha-Beta Pruning",
    "og:description": "Game AI is different from ordinary search.  You are not just finding a path.  You are making a move...",
    "og:site_name": "DEV Community",
    "og:image": "https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe1r9oupaoch9bucplsyu.png",
    "twitter:site": "@thepracticaldev",
    "twitter:creator": "@",
    "twitter:title": "How Game AI Makes Decisions — From Minimax to Alpha-Beta Pruning",
    "twitter:description": "Game AI is different from ordinary search.  You are not just finding a path.  You are making a move...",
    "twitter:card": "summary_large_image",
    "twitter:widgets:new-embed-design": "on",
    "twitter:image:src": "https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe1r9oupaoch9bucplsyu.png"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 200,
    "error": ""
  },
  "code_blocks": [
    {
      "file": "attachments/d08df347fc66/code/body-000.txt",
      "chars": 553,
      "language": "text"
    }
  ],
  "images": [],
  "audio": [],
  "videos": [],
  "links": [
    {
      "href": "https://zeromathai.com/en/game-decision-making-hub-en/",
      "label": "https://zeromathai.com/en/game-decision-making-hub-en/",
      "type": "a"
    },
    {
      "href": "https://github.com/zeromathai/zeromathai-ai",
      "label": "https://github.com/zeromathai/zeromathai-ai",
      "type": "a"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-14T10:48:22Z",
  "source_url": "https://dev.to/zeromathai/how-game-ai-makes-decisions-from-minimax-to-alpha-beta-pruning-5d9b",
  "papers": [],
  "actual_video_files": [],
  "body_chars": 5490,
  "expected_body_images": 0,
  "discovery_status": "ok",
  "delivery_status": "ok",
  "missing_reason": "",
  "raw_html": "attachments/d08df347fc66/pages/source.html",
  "local_html": "attachments/d08df347fc66/pages/article.html",
  "body_base_path": "attachments/d08df347fc66/pages/",
  "body_markdown_path": "attachments/d08df347fc66/pages/article.md"
}