SlideShare a Scribd company logo
1 of 10
Download to read offline
ゲーム




原案、問題文:宮村
解答:宮村、橋本
 解説:宮村
問題概要


   先手と後手が互いに列、行を指定しあって盤面の
    数字を回収していく。最終的に得点の多い方が勝
    ちになる。
   これ以降相手がどうやっても引き分け以上に持ち
    込めないときはその時点でゲームは終了する。
   両者が最善を尽くしたときどちらが勝って何ターン
    でゲームが終了するか求める。
前処理


   残っている列、行を状態として「接待プレイで最大何
    点差を獲得できるか」を求めておく。
   状態数は2^N * 2^N以下なのでビットDPで十分間
    に合う。
   この前処理を施しておくことにより、任意の局面で
    ゲームが打ちきられるかどうかの判定ができる。
ゲーム木探索の復習

   勝ち、負けだけが知りたいときは負けの状態に遷移
    することができればその状態は勝ち。
   評価値が2値以上とるときはminimax法を用いる。
   最短手数での勝ちを求めるタイプのゲーム木探索
    は、Mを適当に大きな数として
    勝ちの局面にM-(手数)
    引き分けの局面に0、
    負けの局面に-(M-(手数)) (あるいは手数そのもの)
    などの評価値を割り振ればminimax法が使える。
解法

   現状ではゲーム木のノード数が(8!)^2で全て探索し
    ては到底間に合わない。
   なので枝刈り探索を行う。
   Minimax法の枝刈りでよく知られているのは、
    α-β法、NegaScout、MDT-f
    などがあるが、今回はα-β法を用いるだけで十分間
    に合う。
α-β法

黄色が先手、後手
が緑とする。




                        4       8




9   7   10   4              5       6   8


                            末端ノードの評価値
                 9          は決まっている
α-β法

黄色が先手、後手
が緑とする。

                 9

                   9≦10なので
                   打ち切り!
    9            10 (βカット)      4       8




9       7   10       4              5       6   8


                                    末端ノードの評価値
                         9          は決まっている
α-β法

黄色が先手、後手                          9
が緑とする。

                 9                7   7≦9なので
                                      打ち切り!
                                      (αカット)


    9            10           7       4        8




9       7   10        4       7            5       6   8


                                          末端ノードの評価値
                          7               は決まっている
α-β法

黄色が先手、後手                          9
が緑とする。

                 9                7               8



    9            10           7       4       8




9       7   10        4       7           5           6   8


                                          末端ノードの評価値
                          7               は決まっている
解答例

   宮村: C++
    156行 3456 byte


   橋本: Java
    109行 3436 byte

More Related Content

Viewers also liked

Robes de cocktail en couleur blanche
Robes de cocktail en couleur blancheRobes de cocktail en couleur blanche
Robes de cocktail en couleur blancherobedesylviej
 
Preliminary task slide
Preliminary task slidePreliminary task slide
Preliminary task slideJeffrey24
 
Robes de cocktail en couleur rouge
Robes de cocktail en couleur rougeRobes de cocktail en couleur rouge
Robes de cocktail en couleur rougerobedesylviej
 
Robes de cocktail en couleur violette
Robes de cocktail en couleur violetteRobes de cocktail en couleur violette
Robes de cocktail en couleur violetterobedesylviej
 
Robes de cocktail en couleur noire
Robes de cocktail en couleur noireRobes de cocktail en couleur noire
Robes de cocktail en couleur noirerobedesylviej
 
ICI / IMU cosa cambierà sulla tassazione degli immobili
ICI / IMU cosa cambierà sulla tassazione degli immobiliICI / IMU cosa cambierà sulla tassazione degli immobili
ICI / IMU cosa cambierà sulla tassazione degli immobilicomunesanpietro
 
Robes de cocktail en couleur bleue
Robes de cocktail en couleur bleueRobes de cocktail en couleur bleue
Robes de cocktail en couleur bleuerobedesylviej
 
Palin
PalinPalin
Palinoupc
 
Trip
TripTrip
Tripoupc
 
Minimal invasive cardiothoracic surgery2
Minimal invasive cardiothoracic surgery2Minimal invasive cardiothoracic surgery2
Minimal invasive cardiothoracic surgery2escts2012
 
Front cover anaylsis
Front cover anaylsisFront cover anaylsis
Front cover anaylsisJeffrey24
 
Cube
CubeCube
Cubeoupc
 
Segpair
SegpairSegpair
Segpairoupc
 
Kth
KthKth
Kthoupc
 
One
OneOne
Oneoupc
 
Comment
CommentComment
Commentoupc
 

Viewers also liked (20)

Robes de cocktail en couleur blanche
Robes de cocktail en couleur blancheRobes de cocktail en couleur blanche
Robes de cocktail en couleur blanche
 
Preliminary task slide
Preliminary task slidePreliminary task slide
Preliminary task slide
 
Robes de cocktail en couleur rouge
Robes de cocktail en couleur rougeRobes de cocktail en couleur rouge
Robes de cocktail en couleur rouge
 
Robes de cocktail en couleur violette
Robes de cocktail en couleur violetteRobes de cocktail en couleur violette
Robes de cocktail en couleur violette
 
Robes de cocktail en couleur noire
Robes de cocktail en couleur noireRobes de cocktail en couleur noire
Robes de cocktail en couleur noire
 
ICI / IMU cosa cambierà sulla tassazione degli immobili
ICI / IMU cosa cambierà sulla tassazione degli immobiliICI / IMU cosa cambierà sulla tassazione degli immobili
ICI / IMU cosa cambierà sulla tassazione degli immobili
 
Robes de cocktail en couleur bleue
Robes de cocktail en couleur bleueRobes de cocktail en couleur bleue
Robes de cocktail en couleur bleue
 
Palin
PalinPalin
Palin
 
Trip
TripTrip
Trip
 
Minimal invasive cardiothoracic surgery2
Minimal invasive cardiothoracic surgery2Minimal invasive cardiothoracic surgery2
Minimal invasive cardiothoracic surgery2
 
Front cover anaylsis
Front cover anaylsisFront cover anaylsis
Front cover anaylsis
 
чехия республикасы
чехия республикасычехия республикасы
чехия республикасы
 
Chest wall
Chest wallChest wall
Chest wall
 
Қазақтың ою орнектері
Қазақтың ою орнектеріҚазақтың ою орнектері
Қазақтың ою орнектері
 
Cube
CubeCube
Cube
 
Segpair
SegpairSegpair
Segpair
 
Kth
KthKth
Kth
 
One
OneOne
One
 
Comment
CommentComment
Comment
 
1
11
1
 

More from oupc

Magical
MagicalMagical
Magicaloupc
 
Gcd
GcdGcd
Gcdoupc
 
Replace
ReplaceReplace
Replaceoupc
 
Goto
GotoGoto
Gotooupc
 
Paren
ParenParen
Parenoupc
 
Sort
SortSort
Sortoupc
 
Sharp2sat
Sharp2satSharp2sat
Sharp2satoupc
 
Permutation
PermutationPermutation
Permutationoupc
 
Knapsack
KnapsackKnapsack
Knapsackoupc
 
Four op
Four opFour op
Four opoupc
 
Divisor
DivisorDivisor
Divisoroupc
 
Division
DivisionDivision
Divisionoupc
 
Anagram
AnagramAnagram
Anagramoupc
 

More from oupc (14)

Magical
MagicalMagical
Magical
 
Gcd
GcdGcd
Gcd
 
Replace
ReplaceReplace
Replace
 
Goto
GotoGoto
Goto
 
Paren
ParenParen
Paren
 
Sort
SortSort
Sort
 
Sharp2sat
Sharp2satSharp2sat
Sharp2sat
 
Permutation
PermutationPermutation
Permutation
 
Knapsack
KnapsackKnapsack
Knapsack
 
Four op
Four opFour op
Four op
 
Divisor
DivisorDivisor
Divisor
 
Division
DivisionDivision
Division
 
Anagram
AnagramAnagram
Anagram
 
A
AA
A
 

Game

  • 2. 問題概要  先手と後手が互いに列、行を指定しあって盤面の 数字を回収していく。最終的に得点の多い方が勝 ちになる。  これ以降相手がどうやっても引き分け以上に持ち 込めないときはその時点でゲームは終了する。  両者が最善を尽くしたときどちらが勝って何ターン でゲームが終了するか求める。
  • 3. 前処理  残っている列、行を状態として「接待プレイで最大何 点差を獲得できるか」を求めておく。  状態数は2^N * 2^N以下なのでビットDPで十分間 に合う。  この前処理を施しておくことにより、任意の局面で ゲームが打ちきられるかどうかの判定ができる。
  • 4. ゲーム木探索の復習  勝ち、負けだけが知りたいときは負けの状態に遷移 することができればその状態は勝ち。  評価値が2値以上とるときはminimax法を用いる。  最短手数での勝ちを求めるタイプのゲーム木探索 は、Mを適当に大きな数として 勝ちの局面にM-(手数) 引き分けの局面に0、 負けの局面に-(M-(手数)) (あるいは手数そのもの) などの評価値を割り振ればminimax法が使える。
  • 5. 解法  現状ではゲーム木のノード数が(8!)^2で全て探索し ては到底間に合わない。  なので枝刈り探索を行う。  Minimax法の枝刈りでよく知られているのは、 α-β法、NegaScout、MDT-f などがあるが、今回はα-β法を用いるだけで十分間 に合う。
  • 6. α-β法 黄色が先手、後手 が緑とする。 4 8 9 7 10 4 5 6 8 末端ノードの評価値 9 は決まっている
  • 7. α-β法 黄色が先手、後手 が緑とする。 9 9≦10なので 打ち切り! 9 10 (βカット) 4 8 9 7 10 4 5 6 8 末端ノードの評価値 9 は決まっている
  • 8. α-β法 黄色が先手、後手 9 が緑とする。 9 7 7≦9なので 打ち切り! (αカット) 9 10 7 4 8 9 7 10 4 7 5 6 8 末端ノードの評価値 7 は決まっている
  • 9. α-β法 黄色が先手、後手 9 が緑とする。 9 7 8 9 10 7 4 8 9 7 10 4 7 5 6 8 末端ノードの評価値 7 は決まっている
  • 10. 解答例  宮村: C++ 156行 3456 byte  橋本: Java 109行 3436 byte