SlideShare a Scribd company logo
1 of 52
人 工 知 能 特 論
第五章 ゲーム探索
17646104岩佐幸翠
5.1 ゲーム
ゲーム ⊂ 競争的環境
 マルチエージェント環境
他のエージェントが自分の将来に影響する
競争的 協調的
ゲーム
ゲーム理論におけるゲーム
 手番交代
 2人プレイヤ
 決定的
 環境の次の状態が完全に現在の状態から決定
 エージェントだけが行為する
 完全情報
 全てのエージェントは環境の全ての情報を知る
 零和
 片方が勝てば片方が負ける
本章におけるゲーム
 複数プレイヤ
麻雀など、ゲームは二人とは限らない
 零和
 決定的も非決定的も扱う
 偶然の要素を含むゲームも扱う
ゲームを解くことの難しさ①
探索しなければならない手数が膨大
 チェス
 平均分岐数は35手
 一局の手数は先手後手各50手
 一局の探索木のノード数は10154
ゲームを解くことの難しさ②
10倍速く探索Aくん
Bくん
 普通の探索 - 迷路
目的: ゴールすること
Aくんは時間をかけてもゴールできる
 ゲームの探索 - オセロ
目的: 勝利すること
Aくんはおそらく1回も勝てない
ゲームでは時間を有効に使って
よりマシな解を探さないと何も得られない場合がある
最適な解を見つけるには
 枝刈り
探索してもしなくても最終選択に影響しない
枝は探索しない
 評価関数
そのノードの評価値を完全に探索しなくても
近似的に求めることができる
ゲームの定式化
 𝑺 𝟎 : 初期状態
 𝐏𝐋𝐀𝐘𝐄𝐑(𝒔)
状態s に遷移したプレイヤを定義する
 𝐀𝐂𝐓𝐈𝐎𝐍𝐒(𝒔)
状態s にいるプレイヤが次に指せる手の一覧を返す
 𝐑𝐄𝐒𝐔𝐋𝐓(𝒔, 𝒂) : 遷移モデル
状態s から手a を指した場合に遷移する状態を返す
 𝐓𝐄𝐑𝐌𝐈𝐍𝐀𝐋𝐓𝐄𝐒𝐓(𝒔) : 終端テスト
ゲームが終了していればtrueを返す
 𝐔𝐓𝐈𝐋𝐈𝐓𝐘(𝒔, 𝒑) : 効用関数
プレイヤpにとっての終端状態sにおける最終スコアを返す
ゲームの定式化: 図解
S0
S1
𝑨 𝟏 𝑨 𝟐
S2
S1 状態(= 盤面) 指し手(= 駒を動かすこと)
ゲームの定式化: 図解
S0
S1
𝑨 𝟏 𝑨 𝟐
S2
𝑨𝑪𝑻𝑰𝑶𝑵𝑺 𝑺 𝟎 = {𝑨 𝟏, 𝑨 𝟐}
ゲームの定式化: 図解
S0
S1
𝑨 𝟏 𝑨 𝟐
𝑹𝑬𝑺𝑼𝑳𝑻 𝑺 𝟎, 𝑨 𝟏 = 𝑺 𝟏
S2
ゲームの定式化: 図解
S0
S1
𝑨 𝟏 𝑨 𝟐
𝑹𝑬𝑺𝑼𝑳𝑻 𝑺 𝟎, 𝑨 𝟏 = 𝑺 𝟏
S2
𝑨𝑪𝑻𝑰𝑶𝑵𝑺 𝑺 𝟎 = {𝑨 𝟏, 𝑨 𝟐}
ゲームの探索木(ゲーム木)は
ACTIONS(s)とRESULT(s, a)で表すことが出来る
◯✕ゲーム
❌ ❌ ❌
❌
⭕
❌ ⭕
…
…
5.2 ゲームにおける意思決定
戦略
◯✕ゲームで⭕を勝たせたい
 普通の探索問題なら
⭕が勝ちとなる終端状態にたどり着ける
指し手ならばどの指し手でも良い
 ゲームの探索問題なら
❌も自分が勝ちとなるように反撃する
上記のようになることはない
❌
⭕ ⭕
❌
⭕ ⭕
❌
❌
⭕ ⭕ ⭕
状況に応じた「戦略」が必要
ミニマックス値
 ここからは…
MAXさんとMINさんがゲームする
MAXさんに勝たせたい
 ミニマックス値
その局面から最後まで両者が共に最善手を指すと
仮定した時の、その局面の効用
𝑴𝒊𝒏𝒊𝒎𝒂𝒙 𝒔 =
𝑼𝑻𝑰𝑳𝑰𝑻𝒀(𝒔)
𝒎𝒂𝒙 𝒂 𝑴𝒊𝒏𝒊𝒎𝒂𝒙(𝑹𝑬𝑺𝑼𝑳𝑻 𝒔, 𝒂 )
𝒎𝒊𝒏 𝒂 𝑴𝒊𝒏𝒊𝒎𝒂𝒙(𝑹𝑬𝑺𝑼𝑳𝑻 𝒔, 𝒂 )
… 𝒔が終端ノード
… 𝒔が𝑴𝑨𝑿のターン
… 𝒔が𝑴𝑰𝑵のターン
ミニマックス値
 ここからは…
MAXさんとMINさんがゲームする
MAXさんに勝たせたい
 ミニマックス値
その局面から最後まで両者が共に最善手を指すと
仮定した時の、その局面の効用
… 𝒔が終端状態
… 𝒔が𝑴𝑨𝑿のターン
… 𝒔が𝑴𝑰𝑵のターン
𝑀𝑖𝑛𝑖𝑚𝑎𝑥 𝑠 = 𝑈𝑇𝐼𝐿𝐼𝑇𝑌(𝑠)
最も𝑀𝑖𝑛𝑖𝑚𝑎𝑥 𝑠 の高い手が選択される
最も𝑀𝑖𝑛𝑖𝑚𝑎𝑥 𝑠 の低い手が選択される
 ミニマックス決定
最もミニマックス値が高くなるように手を指すこと
ミニマックス法
ミニマックス値を用いて最善手を求める
MAX
MIN
3 12 8 2 4 6 14 5 2
ミニマックス法
MAX
MIN
3 12 8
3
ミニマックス法
MAX
MIN
2 4 6 14 5 2
2
ミニマックス法
MAX
MIN
14 5 2
2
ミニマックスアルゴリズム
MAX
MIN
3 12 8 2 4 6 14 5 2
3 2 2
3
多人数ゲームので最適決定
今までは二人ゲームの話…
ミニマックス法を多人数ゲームに適用する
S0
S1
𝑨 𝟏 𝑨 𝟐
S2
𝒗 𝒂 = 𝟔
𝒗 𝒃 = 𝟐
𝒗 𝒄 = 𝟑
𝒗 𝒂 = 𝟒
𝒗 𝒃 = 𝟕
𝒗 𝒄 = 𝟔
𝒗 𝒂 = 𝟗
𝒗 𝒃 = 𝟏
𝒗 𝒄 = 𝟐
同盟関係
 多人数ゲーム特有の問題
 A・B・Cの三名がプレイするゲーム
 A・Bの立場は弱く、Cの立場は強い
 A・Bは協調してCを弱体化させる
 同盟関係の破棄
 Cが弱体化したらA・Bはいずれ約束を破る
 約束を破ると長期に渡って信用を失う
 約束を破ることにより失う信用と
得られる利益を天秤にかけることになる
5.3 α-β枝刈り
ミニマックス法の問題点と解決
時間計算量は𝑶(𝒃 𝒎)
 問題点: 膨大な時間計算量
 ゲーム木の最大の深さをm
 各局面において選択できる手の数をb
 解決策: α-β枝刈り
時間計算量を𝑶( 𝒃 𝒎)まで減らせる
α-β枝刈り
αとβはそれぞれ次の意味
 α:それまでのMAXにとっての最善の選択の値
 β:それまでのMINにとっての最善の選択の値
α-β枝刈りは以下の2つに分けられる
 αカット: MAXが手番の時にするカット
 βカット: MINが手番の時にするカット
α-β枝刈り: αカット
MINはMAXの効用を最小化させたい
MAX
MIN
? ? ? ?
α-β枝刈り: αカット
MINはMAXの効用を最小化させたい
MAX
MIN
8
8
α-β枝刈り: αカット
MINはMAXの効用を最小化させたい
MAX
MIN
8 10
8
α-β枝刈り: αカット
 MIN は MAX の評価値を最小化させるので
指し手B のミニマックス値は 2 が上限
 「?」がどうであれ MAX は指し手Bより
指し手Aを選ぶので、指し手Bは探索不要
MAX
MIN
8 10 2
8 ≦2
指し手A 指し手B
α-β枝刈り: βカット
 MAX は MAX の評価値を最大化させるので
指し手B のミニマックス値は 10 が下限
 「?」がどうであれ MIN は指し手Bより
指し手Aを選ぶので、指し手Bは探索不要
MAX
MIN
2 -1 10 ?
2 10>=
指し手A 指し手B
置換
 置換
同じ局面に達するような異なる手順の並び替え
同じ局面の評価値を何度も計算したくない
 置換表
局面をハッシュ化して表として保存
既に見たことがある局面
5.4 不完全リアルタイム決定
評価関数
 評価関数
与えられた局面からのゲームの期待される効用の
見積もりを返す
「この局面の効用は42」とか
最後まで探索しなくても効用を
近似的に求めることができる
特徴
 評価関数は、その状態における様々な特徴 を
計算することによって成り立っている
 それらの特徴がまとまってカテゴリを形成する
 実際は非常に多くのカテゴリを必要とするため、
カテゴリを考慮せず特徴そのものに得点を付ける場
合が多い
𝑬𝑽𝑨𝑳 𝒔 = 𝒘 𝟏 𝒇 𝟏 𝒔 + 𝒘 𝟐 𝒇 𝟐 𝒔 + ⋯ + 𝒘 𝒏 𝒇 𝒏 𝒔
EVAL: 評価関数 f: 特徴 w: 重み
探索の打ち切り
 これまでは終端テストで終端と判断された
場合に探索を終了していた
 しかし現実には終端までの探索は不可能
 ある程度の深さまで探索が進んだら or
持ち時間を経過したら探索を打ち切ればよい
 探索を打ち切るか否かを決定するテストを
切断テストと呼ぶ
静かな局面とその探索
 静かな局面
評価値が近い将来に大きく変化しない局面
 静かでない局面の探索
静かでない局面を探索している場合、
静かな局面に到達するまで探索を続ける
水平線効果
 探索の深さを有限とした時に発生
 短期的に見ればプラスに見えるが
長期的に見ればマイナスな指し手を
探索範囲が有限なせいで選んでしまう
 例: 将棋
10手先まで探索できるエージェント
ちょうど10手先に飛車を取られてしまう
→ 他の駒を捨てることで飛車が取られるのを
11手先まで先延ばしできるとしたら
その手を選んでしまう
前向き枝刈り
 ある状態からとりうる指し手候補の一部を
先読みなしにその場で枝刈りすること
 最善手をも刈る恐れがある危険な方法
 次のような安全な時に使う:
 2つの指し手が対称的
 2つの指し手がほぼ同じ
5.5 偶然の要素を含むゲーム
CHANCE
CHANCE
偶然があるゲームのゲーム木
MAX
MIN
MAX
 「CHANCE」層が作られる
偶然があるゲームの局面評価
 偶然節点
MINの手番とMAXの手番の間など、
偶然要素が入る部分には「偶然節点」を設ける
 期待ミニマックス値
ミニマックス値と生起確率を掛け合わせ
これを足し合わせる
 期待ミニマックス法
全ての偶然節点を校了する必要があるため
計算量は𝑂 𝑏 𝑚 𝑛 𝑚 を必要とする
5.6 不完全情報ゲーム
不完全情報ゲーム
「相手に見えない情報が存在する」ゲーム
 ババ抜き
相手に手札が見えない
 大富豪
相手に手札が見えない
 人狼
相手に役職が分からない
信念状態
 信念状態
誰がどのトランプをどの確率で持っているか
という信念(4章でやりました)
 状態推定
不完全情報ゲームでは信念状態を追跡する
これは状態推定の問題である
モンテカルロ木探索
 プレイアウトを沢山行い勝てそうな指し手を選ぶ
 プレイアウトの回数が閾値を超えたら木が生長
プレイアウト
ランダムに指し手を選択し、終端までプレイすること
引っ掻き回し・撹乱
自分のスコアが高くなるようなアルゴリズムを
組む方が簡単であることが判明(Gordon, 1994)
😏
あえて相手の思考のウラを突いた
動きをすれば相手は混乱するのでは?
5.7 最先端のゲーム問題
チェス
IBMのDEEP BLUEが勝利
 NULL MOVE
自分がパスしても十分に局面の評価値が高い場合
その局面を探索しない枝刈り法
 FUTILITY PLUNING
 以下の条件に当てはまる場合枝刈り
β値<=切断ノードの1つ前のノードの評価値−マージン
 マージンを動的に推定する手法もある
その他のゲーム
コンピュータが勝ったゲーム一覧
 オセロ
 囲碁
 バックギャモン
 ブリッジ
モンテカルロ木探索で勝ちました

More Related Content

Featured

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

エージェントアプローチ人工知能 第3版 五章

Editor's Notes

  1. 評価関数は一般的にはヒューリスティックであったが、将棋ソフトのPonanzaなどは自動で獲得する