Answered step by step
Verified Expert Solution
Question
1 Approved Answer
section 2.2, describes a game played with artificial sweetener packets on an nxn board. Assuming you could see the entire tree, how would you determine
section 2.2, describes a game played with artificial sweetener packets on an nxn board. Assuming you could see the entire tree, how would you determine whether it is possible for the first player to win?
This is section 2.2:
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 leavesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started