Adversarial Search

26
Chapter 6 Section 1 – 4

description

Adversarial Search. Chapter 6 Section 1 – 4. Outline. Optimal decisions α-β pruning Imperfect, real-time decisions. Games vs. search problems. "Unpredictable" opponent  specifying a move for every possible opponent reply prisoner dilemma - PowerPoint PPT Presentation

Transcript of Adversarial Search

Page 1: Adversarial Search

Chapter 6Section 1 – 4

Page 2: Adversarial Search

Optimal decisions α-β pruning Imperfect, real-time decisions

Page 3: Adversarial Search

"Unpredictable" opponent specifying a move for every possible opponent reply

Time limits (35^100) unlikely to find goal, must approximate

prisoner dilemma

A\B betray persist

betray 0\0 1\-1

persist -1\1 2\2

Page 4: Adversarial Search

tic-tac-toe

Page 5: Adversarial Search

Perfect play for deterministic games Idea: choose move to position with highest

minimax value = best achievable payoff against best play

E.g., 2-ply game:

Page 6: Adversarial Search
Page 7: Adversarial Search

Complete? Yes (if tree is finite) Optimal? Yes (against an optimal opponent) Time complexity? O(bm) Space complexity? O(bm) (depth-first exploration)

For chess, b ≈ 35, m ≈100 for "reasonable" games exact solution completely infeasible

Page 8: Adversarial Search
Page 9: Adversarial Search
Page 10: Adversarial Search
Page 11: Adversarial Search
Page 12: Adversarial Search
Page 13: Adversarial Search

Pruning does not affect final result

Good move ordering improves effectiveness of pruning

With "perfect ordering," time complexity = O(bm/2) doubles depth of search

A simple example of the value of reasoning about which computations are relevant (a form of metareasoning)

Page 14: Adversarial Search

α is the value of the best (i.e., highest-value) choice found so far at any choice point along the path for max

If v is worse than α, max will avoid it prune that branch

Define β similarly for min

Page 15: Adversarial Search
Page 16: Adversarial Search
Page 17: Adversarial Search

Suppose we have 100 secs, explore 104 nodes/sec 106 nodes per move

Standard approach: cutoff test:

e.g., depth limit (perhaps add quiescence search) evaluation function

= estimated desirability of position

◦◦

Page 18: Adversarial Search

For chess, typically linear weighted sum of features

Eval(s) = w1 f1(s) + w2 f2(s) + … + wn fn(s)

e.g., w1 = 9 with

f1(s) = (number of white queens) – (number of black queens), etc.

Page 19: Adversarial Search

First, the evaluation function should order the terminal states in the same way as the true utility function;

Third, for nonterminal states, the evaluation function should be strongly correlated with the actual chances of winning.

Second, the computation must not take too long!

Page 20: Adversarial Search

MinimaxCutoff is identical to MinimaxValue except1. Terminal? is replaced by Cutoff?2. Utility is replaced by Eval

TERMINAL-TIEST-->if CUTOFF-TEST(stated, depth) then return EVAL(state)

Does it work in practice?bm = 106, b=35 m=4

4-ply lookahead is a hopeless chess player!◦ 4-ply ≈ human novice◦ 8-ply ≈ typical PC, human master◦ 12-ply ≈ Deep Blue, Kasparov

Page 21: Adversarial Search
Page 22: Adversarial Search

Backgammon

Page 23: Adversarial Search
Page 24: Adversarial Search

Checkers: Chinook ended 40-year-reign of human world champion Marion Tinsley in 1994. Used a precomputed endgame database defining perfect play for all positions involving 8 or fewer pieces on the board, a total of 444 billion positions.

Chess: Deep Blue defeated human world champion Garry Kasparov in a

six-game match in 1997. Deep Blue searches 200 million positions per second, uses very sophisticated evaluation, and undisclosed methods for extending some lines of search up to 40 ply.

Othello: human champions refuse to compete against computers, who are too good.

Go: human champions refuse to compete against computers, who are too bad. In go, b > 300, so most programs use pattern knowledge bases to suggest plausible moves.

Page 25: Adversarial Search

Games are fun to work on! They illustrate several important points

about AI perfection is unattainable must

approximate good idea to think about what to think

about

Page 26: Adversarial Search

规则

十五子游戏是一种两人游戏。左图显示了游戏棋盘的四个象限。棋子所占据的三角形的空间称为“点”。棋盘上端和下端的数字表示了不同点的名称。例如,右下端的点是白方的 1 号点,而三个红色棋子开始的地方是红方的 8 号点。在游戏中,第一个将其所有棋子走出棋盘的玩家取胜。 每位玩家在游戏开始时有 15 个棋子。左图显示了棋子的排列方式。 入门 游戏开始时,每位玩家掷一个骰子。点数高的一方先走。在雅虎游戏站点,玩家可单击“掷骰子”按钮来掷骰子。 每位玩家轮流掷两个骰子,然后按骰子上显示的点数走各自的棋子。一个棋子所走的点数正好是一个骰子显示的数字,另一个棋子 - 或刚刚走过的棋子 - 所走的点数应是另一个骰子上显示的数字。(在雅虎游戏站点走棋的方法是,单击该棋子,将将它拖到目标点,然后松开鼠标。) 两个骰子点数相同 如果掷出的两个骰子点数相同,(即每个骰子显示的点数一样),则按平常点数的两倍走棋。例如,如果掷出的两个骰子点数都是三,那么就可以走四次(每次走三个点),而不是只走两次。这四次走棋可以最多用四个棋子来走,也可以一个棋子走四次。 红方的棋子按顺时针方向走,白方的棋子按逆时针方向走。棋子必须走满骰子上显示的点数,除非是收棋的一步(请参见游戏结束)。棋子可不受限制地通过已占据的点,停在空位上、同色的其它棋子占据的位置,或由对手的一个棋子占据的位置(在这种情况下对手的棋子将被移至分界栏,请参见弱棋子和分界栏)。但是棋子不能停在两个或更多对手棋子占据的点。 在确定某一步走棋是否犯规时,每个骰子上的点数都被认为是单独的一步,即使同一个棋子走两次。例如,如果掷出的骰子为 3 和 4 ,并且距棋子三点和四点的点都被对手的棋子所占据,则棋子不能走 7 个点 - 即便距棋子七点的点是空的。 如果棋子落在一个点中,而该点由对手的一个棋子(即弱棋子)所占据,则对手的棋子将被从该点上移走,放入分界栏。分界栏是将棋盘的左半边和右半边分开的垂直条带。一个棋子有可能在一轮中攻击两个弱棋子(使用两个骰子的点数各攻击一个);如果所掷两个骰子的点数相同,一个棋子最多可能攻击四个弱棋子。 在左图所示的情况中,如果红方掷出 4 和 1 ,被标记的棋子可先走 1 点,然后走 4 点,将对手的两个棋子挤到分界栏。 如果一个玩家在分界栏上有一个或更多棋子,那么在走棋盘上的其它棋子之前,该玩家必须先将分界栏上的棋子走进棋盘。棋子从分界栏进入对手的内棋盘,其进入的点数按照骰子的点数计。例如,在此情况下,如果白方掷出 2 和 4 ,则分界栏中的棋子可走 2 ,进入 X ,或走 4 ,进入 Y 。未用的点数随后用于走同一个棋子,或走另一个棋子。 必须尽可能地使用两个骰子的点数,而且如果可以避免的话,不要使一个骰子的点数用完后,无法使用另一个骰子的点数。如果只能使用一个骰子的点数,则玩家可以这样做,但应尽可能地使用较大的点数。如果没有能够不犯规的走法,则玩家失去这次走棋的机会。 双数骰子的使用为十五子游戏增加了更大的战略空间。双数骰子与普通骰子的大小相似,它的各个面上显示的数字为 2 、 4 、 8 、 16 、 32 和 64 。游戏开始时,双数骰子的 64 那面朝上。在游戏进行过程中的任何时候,要准备掷骰子的一方可将双数骰子带 2 的那面朝上,交给对手。对手则必须决定是否放弃,也就是认输,还是接受,同意赌注加倍,继续玩。接受加倍的玩家控制(或称占有)双数骰子。在游戏中的任何时候,掷骰子前,持有双数骰子的玩家可将骰子数字更大的一面朝上,交给对手,提出赌注再加倍,而对手可以放弃(即输掉双数骰子的当前值),或接受(同意新的赌注,并获得对双数骰子的控制)。在雅虎游戏站点加倍和再加倍的方法是,单击“加倍”按钮。 十五子游戏通常可作为一场比赛、或几局来进行。第一个达到某个特定分数的玩家为赢家。赢得一个普通的不加倍的局将获得 1 分。假设在一局结束时双数骰子的点数为 4 ,则赢家得到 4 分;如果结果同时是“两倍分数取胜”的话,则赢家得 8 分。在多数比赛中,玩家遵循克劳福德规则,即在只剩一分就可赢得比赛的情况下,禁止赌注加倍。 在将棋子走出棋盘前,玩家必须先将全部棋子走进自己的内棋盘。随后,通过掷骰子,将棋子移至棋盘上的最后一点之外,也就是走出棋盘。 不必严格按点数将棋子走出棋盘。例如,在 4 号点上的棋子可以通过走 4 、 5 或 6 走出棋盘。但是,作为一条规则,玩家应尽可能地用完骰子上的所有点数。因此在以下情况下,如果两个骰子的点数分别为 4 和 3,则不可以拿掉 2 号点或 1 号点的棋子。相反,必须走 6 号点和 5 号点的棋子(一个走 4 ,另一个走 3 )。 向上 返回页首 在相同情况下,如果骰子的点数为 6 和 1 ,通常的走法是拿走 6 号点和 1 号点上的棋子,但也可以将 6 号点上的棋走 1 ,然后将 5 号点的棋子走 6 ,拿掉该棋子。这并不是在可以使用两个骰子时只使用一个的犯规走法。因为尽管点数为 1 的骰子没有发挥效力,但实际上两个骰子上的点数都用上了。在出现左图所示的位置时,使用这种走法是可取的。此时,红方有一个棋子在分界栏: 红方如果掷 1 ,使分界栏上的棋子进入棋盘,则白方拿掉两个棋子就会使红方有机会击中 1 号点上的棋子。如改为先走 1 而浪费掉点数为 1 的骰子的效力,则在 1 号点上保留了一个安全位置,也就是说无论下一次掷几点,两个棋子都可以走出棋盘。 两倍分数取胜和三倍分数取胜 在游戏中,如果一个玩家在其对手的棋子一个也没有拿出棋盘前就使其全部棋子离开棋盘的情况称为两倍分数取胜。这种情况按两局记分,也就是说,赢家赢一局算赢两局,或如果使用了双数骰子,即双数骰子的值的两倍。如果除没有将任何棋子走离棋盘外,输家还至少有一个棋子留在赢家的内棋盘,其结果就是一个 三倍分数取胜。三倍分数取胜在美国和雅虎游戏站点是按三倍取胜记分,但在多数国家,它和两倍分数取胜的记分是相同的。