Question: Dynamic Programming; Algorihm; Python 3. In the two-player game Pandas Peril, an even number of cards are laid out in a row, face up. On

Dynamic Programming; Algorihm; Python

Dynamic Programming; Algorihm; Python 3. In the two-player game "Pandas Peril", an

3. In the two-player game "Pandas Peril", an even number of cards are laid out in a row, face up. On each card, is written a positive integer. Players take turns removing a card from either end of the row and placing the card in their pile. The player whose cards add up to the highest number wins the game. One strategy is to use a greedy approach and simply pick the card at the end that is the largest. However, this is not always optimal, as the following example shows: (The first player would win if she would first pick the 4 instead of the 5.) 4 2 10 5 (a) (10 pts) Write a dynamic programming algorithm for a strategy to play Pandas Player 1 will use this strategy and Player 2 will use a greedy strategy of choosing the largest card. (b) (10 pts) Prove that your strategy will do no worse than the greedy strategy for maximizing the sum of each hand. (c) (10 pts) Implement your strategy and the greedy strategy in Python and simulate a game, or two, of Pandas Peril. Your simulation should include a randomly generated collection of cards and show the sum of cards in each hand at the end of the game. 3. In the two-player game "Pandas Peril", an even number of cards are laid out in a row, face up. On each card, is written a positive integer. Players take turns removing a card from either end of the row and placing the card in their pile. The player whose cards add up to the highest number wins the game. One strategy is to use a greedy approach and simply pick the card at the end that is the largest. However, this is not always optimal, as the following example shows: (The first player would win if she would first pick the 4 instead of the 5.) 4 2 10 5 (a) (10 pts) Write a dynamic programming algorithm for a strategy to play Pandas Player 1 will use this strategy and Player 2 will use a greedy strategy of choosing the largest card. (b) (10 pts) Prove that your strategy will do no worse than the greedy strategy for maximizing the sum of each hand. (c) (10 pts) Implement your strategy and the greedy strategy in Python and simulate a game, or two, of Pandas Peril. Your simulation should include a randomly generated collection of cards and show the sum of cards in each hand at the end of the game

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!