Top Banner
Game Playing
23

Wumpus World Description

Dec 31, 2015

Download

Documents

Wumpus World Description. Let’s play another game. Review : Knowledge Bases. Review:Knowledge-Based Agent. Logic. When we have too many states, we want a convenient way of dealing with sets of states. The sentence “It’s sunny” stands for all the states of the world in which it is sunny. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Wumpus World Description

Game Playing

Page 2: Wumpus World Description

REVIEW - MiniMax

• Games with two players MIN and MAX are a search problem with:– Initial state

– Successor function

– Terminal test / state

– Utility function (objective / payoff)

Page 3: Wumpus World Description

REVIEW - MiniMax

• Utility function– Is assumed to be in relation with Max

• What is good for max is always bad for min.• E.g. if max wins then min lose

– In chess the utility function might be.• -1 if min wins• 0 for a draw• 1 if max wins

– In other games, e.g. Othello the utility function might be more advanced.

• utility = number of my pieces – number of his pieces

Page 4: Wumpus World Description

REVIEW - MiniMax

• Simple Games– If we play e.g. TicTacToe or NIM, we can

generate a complete search tree– Some leafs in the tree will end up with max

winning and some with min winning

Page 5: Wumpus World Description

REVIEW - MiniMax

• Searching with minimax– We use depth first search to reach down to the leafs

first

– When we reach a leaf, we evaluate the current state by a utility function and then returns the result to the parent node.

– If we are not in a leaf and have evaluated all children.• If it, from this state, is max move, then return the highest

utility

• If it is a min move return the lowest utility.

Page 6: Wumpus World Description

REVIEW - MiniMaxfunction MiniMax(State s, Event e, boolean isMax) {

State s1 = updateState(s, e); if (isLeaf(s1)) return eval(s1);if (isMax) {

int highest = 0;foreach (Event e1 in maxmoves(s1)) {

int tmp = MiniMax(s1, e1, !isMax);if (tmp > highest) highest = tmp;

}return highest;

} else {int lowest = 100;foreach (Event e1 in minmoves(s1)) {

int tmp = MiniMax(s1, e1, !isMax);if (tmp < lowest) lowest = tmp;

}return lowest;

}

Page 7: Wumpus World Description

MiniMax

• Example of MiniMax – 1st version of NIM– The rules of NIM are as follows

• We start with a number of sticks in a group

• On each move, a player must divide a group into two smaller groups

• Groups of one or two sticks can’t be divided

• The last player to make a legal move wins

Page 8: Wumpus World Description

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 9: Wumpus World Description

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 10: Wumpus World Description

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 11: Wumpus World Description

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 12: Wumpus World Description

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 13: Wumpus World Description

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 14: Wumpus World Description

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 15: Wumpus World Description

MiniMax

• NIM Search tree

1-1-1-1-2

1-1-1-3 1-1-2-2

2-2-21-2-31-1-4

1-5 2-4

6

3-3

Max moves

Min moves

Max moves

Min moves

Page 16: Wumpus World Description

MiniMax

• Example of MiniMax – 2nd version of NIM– The rules of NIM are as follows

• We start with a number of sticks in a group (7)

• On each move, a player may pick up 1, 2, or 3 sticks

• The last player to make a legal move wins

Page 17: Wumpus World Description

What does the search tree look like?

Page 18: Wumpus World Description

Properties of Minimax

• Complete?

Page 19: Wumpus World Description

Properties of Minimax

• Complete?– … yes, provided following are finite:

• Number of possible legal moves (generative breadth of tree)

• “Length of game” (depth of tree) – more specifically?

Page 20: Wumpus World Description

Properties of Minimax

• Complete?– … yes, provided the tree is finite:

• Number of possible legal moves (generative breadth of tree)

• “Length of game” (depth of tree) – more specifically?

• Optimal?

Page 21: Wumpus World Description

Properties of Minimax

• Complete?– … yes, provided the tree is finite

• Optimal?– … yes, provided perfect info (evaluation function) and

opponent is optimal!

• Time Complexity?

Page 22: Wumpus World Description

Properties of Minimax• Complete?

– … yes, provided the tree is finite:

• Optimal?

– … yes, provided perfect info (evaluation function) and opponent is optimal!

• Time Complexity?

– Depth of tree: m

– Legal moves at each point: b

– O(bm) – NB, m 100, b 35 for chess!

• Space Complexity?

Page 23: Wumpus World Description

Properties of Minimax• Complete?

– … yes, provided the tree is finite:

• Optimal?

– … yes, provided perfect info (evaluation function) and opponent is optimal!

• Time Complexity?

– Depth of tree: m

– Legal moves at each point: b

– O(bm) – NB, m 100, b 35 for chess!

• Space Complexity? O(bm) – why?