Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

As described in section 2.2, the recursive method essentially creates the game tree node by node in a depth-first fashion. For the case where there

As described in section 2.2, the recursive method essentially creates the game tree node by node in a depth-first fashion. For the case where there are two packets for each player (so the game is on a 4x4 board), how many nodes are in the entire game tree?image text in transcribedimage text in transcribedimage text in transcribed

Consider the following simple two-player game played on an nx n square grid with a border of squares; let's call the players Horace Fahlberg-Remsen and Vera Rebaudi.? Each player has n tokens that they move across the board from one side to the other. Horace's tokens start in the left border, one in each row, and move horizontally to the right; symmetrically, Vera's tokens start in the top border, one in each column, and move vertically downward. The players alternate turns. In each of his turns, Horace either moves one of his tokens one step to the right into an empty square, or jumps one of his tokens over exactly one of Vera's tokens into an empty square two steps to the right. If no legal moves or jumps are available, Horace simply passes. Similarly, Vera either moves or jumps one of her tokens downward in each of her turns, unless no moves or jumps are possible. The first player to move all their tokens off the edge of the board wins. (It's not hard to prove that as long as there are tokens on the board, at least one player can legally move, and therefore someone eventually wins.) Figure 2.4. Vera wins the 3 x 3 fake-sugar-packet game. Equivalently, a non-leaf node in the game tree is good if it has at least one bad child, and a non-leaf node is bad if all its children are good. By induction, any player that finds the game in a good state on their turn can win the game, even if their opponent plays perfectly; on the other hand, starting from a bad state, a player can win only if their opponent makes a mistake. This recursive definition was proposed by Ernst Zermelo in 1913.4 3If you have, please tell me where! 4In fact, Zermelo considered the more subtle class of games that have a finite number of states, but that allow infinite sequences of moves. (Zermelo defined infinite play to be a draw.) CKTRACKING This recursive definition immediately suggests the following recursive back- tracking algorithm to determine whether a given game state is good or bad. At its core, this algorithm is just a depth-first search of the game tree; equivalently, the game tree is the recursion tree of the algorithm! A simple modification of this backtracking algorithm finds a good move (or even all possible good moves) if the input is a good game state. PLAYANYGAME(X,player): if player has already won in state X return GOOD if player has already lost in state X return BAD for all legal moves X my Y if PLAYANYGAME(Y, player) = BAD return GOOD ((X ms Y is a good move) return BAD (There are no good moves All game-playing programs are ultimately based on this simple backtracking PLAYANYGAME(X,player): if player has already won in state X return GOOD if player has already lost in state X return BAD for all legal moves X my Y if PLAYANYGAME(Y, player) = BAD return GOOD ((x us Y is a good move) return BAD (There are no good moves >> All game-playing programs are ultimately based on this simple backtracking strategy. However, since most games have an enormous number of states, it is not possible to traverse the entire game tree in practice. Instead, game programs employ other heuristics5 to prune the game tree, by ignoring states that are obviously (or obviously') good or bad, or at least better or worse than other states, and/or by cutting off the tree at a certain depth (or ply) and using a more efficient heuristic to evaluate the leaves. Consider the following simple two-player game played on an nx n square grid with a border of squares; let's call the players Horace Fahlberg-Remsen and Vera Rebaudi.? Each player has n tokens that they move across the board from one side to the other. Horace's tokens start in the left border, one in each row, and move horizontally to the right; symmetrically, Vera's tokens start in the top border, one in each column, and move vertically downward. The players alternate turns. In each of his turns, Horace either moves one of his tokens one step to the right into an empty square, or jumps one of his tokens over exactly one of Vera's tokens into an empty square two steps to the right. If no legal moves or jumps are available, Horace simply passes. Similarly, Vera either moves or jumps one of her tokens downward in each of her turns, unless no moves or jumps are possible. The first player to move all their tokens off the edge of the board wins. (It's not hard to prove that as long as there are tokens on the board, at least one player can legally move, and therefore someone eventually wins.) Figure 2.4. Vera wins the 3 x 3 fake-sugar-packet game. Equivalently, a non-leaf node in the game tree is good if it has at least one bad child, and a non-leaf node is bad if all its children are good. By induction, any player that finds the game in a good state on their turn can win the game, even if their opponent plays perfectly; on the other hand, starting from a bad state, a player can win only if their opponent makes a mistake. This recursive definition was proposed by Ernst Zermelo in 1913.4 3If you have, please tell me where! 4In fact, Zermelo considered the more subtle class of games that have a finite number of states, but that allow infinite sequences of moves. (Zermelo defined infinite play to be a draw.) CKTRACKING This recursive definition immediately suggests the following recursive back- tracking algorithm to determine whether a given game state is good or bad. At its core, this algorithm is just a depth-first search of the game tree; equivalently, the game tree is the recursion tree of the algorithm! A simple modification of this backtracking algorithm finds a good move (or even all possible good moves) if the input is a good game state. PLAYANYGAME(X,player): if player has already won in state X return GOOD if player has already lost in state X return BAD for all legal moves X my Y if PLAYANYGAME(Y, player) = BAD return GOOD ((X ms Y is a good move) return BAD (There are no good moves All game-playing programs are ultimately based on this simple backtracking PLAYANYGAME(X,player): if player has already won in state X return GOOD if player has already lost in state X return BAD for all legal moves X my Y if PLAYANYGAME(Y, player) = BAD return GOOD ((x us Y is a good move) return BAD (There are no good moves >> All game-playing programs are ultimately based on this simple backtracking strategy. However, since most games have an enormous number of states, it is not possible to traverse the entire game tree in practice. Instead, game programs employ other heuristics5 to prune the game tree, by ignoring states that are obviously (or obviously') good or bad, or at least better or worse than other states, and/or by cutting off the tree at a certain depth (or ply) and using a more efficient heuristic to evaluate the leaves

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

Why could the Robert Bosch approach make sense to the company?

Answered: 1 week ago