Menu

[Solved]Game Works Follows Player Starts Center Collapsing Building Consists Quadratic Grid 2n 1 X Q37085755

Question (a) is a non-code question regarding algorithm.

The game works as follows: The player starts in the center of a collapsing building, which consists of a quadratic grid of (2

The game works as follows: The player starts in the center of a collapsing building, which consists of a quadratic grid of (2n 1) x (2n 1) rooms. Each room contains 0-9 units of supplies. With each move the player can go up, down, left or right and collect the supplies in the room entered. The entire row or column of rooms he just left then collapses behind him and can no longer be entered. After 2n moves no further moves can be taken and the game ends. If the player has collected enough supplies to survive till the rescue team gets him after D days, he wins. If not he looses A basic implementation of the game is provided on the course website. Run with the command > python collapse.py To perform a speed test of your implementation, run > python optimizer.py Note: You can also specify the board size and casy/hard mode. E.g python collapse.py 3 hard will run the game with n 3 using separate food and water supplies Tasks [20 points] Currently the number of supplies needed to win the game is only based on n, and depending on how supplies are distributed (this is done at random) it may be very casy or impossible to win. requirement (number of days till rescue) to this number. You will only need to edit optimizer.py for that (a) Show that a greedy strategy (starting in the center or at one of the corners) will not work. For this, give a Your job is to calculate the maximum number of supplies that could be collected, and set the victory 3 × 3 example with a unique optimal solution which includes neither the highest-valued side-room nor the highest-valued corner room. Use each number from 1 to 8 once (center is empty) To illustrate, in the example to the right, the unique optimal solution is 7-8 which includes both the highest-valued side-room (7) and the highest valued corner room (8). Here a greedy algorithm w find the optimal solution. You need to create a different example where greedy fails l 23 Show transcribed image text The game works as follows: The player starts in the center of a collapsing building, which consists of a quadratic grid of (2n 1) x (2n 1) rooms. Each room contains 0-9 units of supplies. With each move the player can go up, down, left or right and collect the supplies in the room entered. The entire row or column of rooms he just left then collapses behind him and can no longer be entered. After 2n moves no further moves can be taken and the game ends. If the player has collected enough supplies to survive till the rescue team gets him after D days, he wins. If not he looses A basic implementation of the game is provided on the course website. Run with the command > python collapse.py To perform a speed test of your implementation, run > python optimizer.py Note: You can also specify the board size and casy/hard mode. E.g python collapse.py 3 hard will run the game with n 3 using separate food and water supplies Tasks [20 points] Currently the number of supplies needed to win the game is only based on n, and depending on how supplies are distributed (this is done at random) it may be very casy or impossible to win. requirement (number of days till rescue) to this number. You will only need to edit optimizer.py for that (a) Show that a greedy strategy (starting in the center or at one of the corners) will not work. For this, give a Your job is to calculate the maximum number of supplies that could be collected, and set the victory 3 × 3 example with a unique optimal solution which includes neither the highest-valued side-room nor the highest-valued corner room. Use each number from 1 to 8 once (center is empty) To illustrate, in the example to the right, the unique optimal solution is 7-8 which includes both the highest-valued side-room (7) and the highest valued corner room (8). Here a greedy algorithm w find the optimal solution. You need to create a different example where greedy fails l 23

Expert Answer


Answer to The game works as follows: The player starts in the center of a collapsing building, which consists of a quadratic grid … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *