仓库源文站点原文


layout: post title: "AI 笔记 Week 01-02 Game Playing" date: "2017-10-12 02:23:24" categories: 计算机科学 excerpt: "Course schedule syllabus Week01学习内容: Game Playing through Depth-limited ..."

auth: conge

Week01学习内容:

  1. Game Playing through Depth-limited Search;
  2. review/learn Python; play each other in Isolation;
  3. Chapter 1-2; Chapter 5.0-5.2
  4. R&N slides on Game Playing

Week 01 任务清单:

Book used in the class Artificial Intelligence: A Modern Approach (3rd edition) by Russell and Norvig (R&N). 下载链接一11111.pdf)下载链接二(expired)


Lesson 1: Game Playing

Intro

Couse outline

Goal of the lesson

Challenging Quiz

Quiz 1: mark the branches of the tree that can be pruned out using probabilistic alpha-beta pruning, i.e., do not need to be explored any further.

The Isolation Game

Building a Game Tree

game tree

MiniMax

Open book

quiz

quiz 2


Optional Reading: Artificial Intelligence - A Modern Approach (AIMA): Chapter 5.1-5.2

Minimax

The minimax algorithm performs a complete depth-first exploration of the game tree. If the maximum depth of the tree is m and there are b legal moves at each point, then the time complexity of the minimax algorithm is O(b^m). The space complexity is O(bm) for an algorithm that generates all actions at once or O(m) for an algorithm that generates actions one at a time.

Multiplayer, non-zero sum games are more complicated

for each state, its minimax value becomes a vector which contains the value for all the players there will be dynamically forming alliances, for example, A and B play against C. collaboration can also occur with just two players in a non-zero sum game.


Max Number of Nodes Visited

Quiz 3

the branching factor

Quiz 4

an average branching factor can be calculated through game simulation.

average branching factor

Now the question becomes "at level 9, how can we tell which node is good or bad" based on the level 10 nodes.

Quiz

Quize

Quiz: testing the evalutation function with level 3 tree

Quize: test evaluation question with level 2 of the tree

The results do not agree with the results of level 3 tree. Which means when to search for level 2 and level 3, the evaluation function will give a different answer.

A problem

interactive deepening.

As we deepen the search, the number of nodes on the tree and the interactive deepening nodes increase

Quize: Exponential B

interactive deepening on Isolation game

  1. branching factor of the Isolation game varies
  2. at the beginning of the game, branching factor (B) is large, and searching needs more time.
  3. at the end of the game B is smaller, and searching is shallow. So, we might need to develop strategies to allow the player to take more time at the beginning or the middle of the game, but less time in the end game.

Horizon Effect

In the above situation, it is very easy for a human player to observe that O takes the move next to X will when because it will allow X to have 6 moves but O has seven (because a partition is created).

But it will take the computer to search 13 levels to figure this out (which we don't have enough time to do).

This is the horizon effect.

So we need evaluation functions. to check partition. but it might increase the search time. So good evaluation function need to balance between dealing with horizon effect and simplicity or effectiveness.

Quiz: Good Evaluation Functions

Alpha-Beta Pruning

Alpha-Beta Pruning allows the AI to skip a section of the game tree but still get the same answer of the minimax algorithm. [More efficient than minimax]

It can reduce the search time to b<sup>d/2</sup> ~ b<sup>3d/4</sup> image.png

minimax

image.png

Alpha-Beta Pruning Quiz 1

Alpha-Beta Pruning Quiz 2

Searching Complex Games

Reading AIMA: Chapter 5.3-5.4 [Done, did not track time]

Solving 5x5 Isolation

Some strategies for the 5x5 game: open game search table; check for reflections to minimize the open game; occupy center; reflex move; minimax and alpha-beta pruning.

3-Player Games

3-Player Games

3-Player Games quize

3-Player Alpha-Beta Pruning

E.g., shallow pruning and Immediate pruning are possible, but not deep pruning (why?)

alpha-beta pruning

3 player pruning

Probabilistic games

One type of probabilistic games is that each action might lead to two or more states with a certain probability. Sloppy isolation is an example:

Sloppy Isolation

Sloppy Isolation

Sloppy isolation with constrain

In this version of isolation, the player might overshoot or undershoot with a 10% chance for each error, and the player will have 80% chance meet the goal.

This can be complicated as the player's moves were limited by available of squares. E.g., sometimes there will be no chance of undershoot or overshoot (see pic above). In this case, the change of hitting the target will be 90%, and the chance of overshoot/undershoot will still be 10%.

expectedMax

expectedMax

When populating the game tree, we need to generate branch and leaves based on a probability of hit or miss the target.

Pruning might still work.

Expectimax Alpha-Beta Pruning

Further Reading

Peter Norvig and Sebastian Thrun’s lectures on Game Playing and Game Theory.


Games

Games type and techniques

Quize: match games with features

Single Player Game

Single player game

Two Player Game

Chess as an example

Function and pseudo code for two player games

Quiz: Time Complexity Question

Space Complexity Question

Complexity of the Chess game

Complexity reduction

Queston review of miniMax

reduce B

Pruning

Qize: which node can be pruned?

Reduce M

Reduce M

Updating the pseudo code for the value function

Updating the pseudo code for maxValue function

 Horizon Effect

Dealing with stochastics

Dealing with Stochastic Games

Game tree of example of a Stochastics game

Quiz: fill out the values for each node

possible end note of the game if players play rationally

Evaluation Function 1

Evaluation Function 2

Conclusion

components of solution of games

Example codes for Games, or Adversarial Search. (Chapters 6)


``` 2017-09-10 First draft, took 6 hours To do: all the readings in the section. Notes of the reading should be done.