Download - Wumpus World Description
![Page 1: Wumpus World Description](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/1.jpg)
Game Playing
![Page 2: Wumpus World Description](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/2.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/3.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/4.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/5.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/6.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/7.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/8.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/9.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/10.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/11.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/12.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/13.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/14.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/15.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/16.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/17.jpg)
What does the search tree look like?
![Page 18: Wumpus World Description](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/18.jpg)
Properties of Minimax
• Complete?
![Page 19: Wumpus World Description](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/19.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/20.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/21.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/22.jpg)
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](https://reader035.vdocuments.us/reader035/viewer/2022081421/56812faa550346895d952cf6/html5/thumbnails/23.jpg)
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?