Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

develop python program 2. Terra Mystica (6 points) In the board game Terra Mystica, each player has exactly 12 power units to spend performing actions

develop python program

2. Terra Mystica (6 points) In the board game Terra Mystica, each player has exactly 12 power units to spend performing actions in the game. Power units are distributed across three "bowls", labeled I, II, and III (the sum of units in these bowls is always exactly 12). As the game progresses, power is gained or spent by shifting units between bowls according to the rules below. If you gain or spend multiple units at once, process them one at a time according to these rules (in other words, use a for loop to repeat your if-elif chain for each spending/gaining operation).

a. To spend a unit of power: i. If you have at least 1 unit in bowl III, move 1 unit from bowl III to bowl I. ii. If bowl III is empty, nothing happens.

b. To gain a unit of power: i. If all 12 units are already in bowl III, nothing happens. Otherwise: ii. If there is a unit in bowl I, move it to bowl II. iii. Otherwise, if bowl I is empty but there is a unit in bowl II, move one unit from bowl II to bowl III. iv. If bowls I and II are both empty, then nothing happens.

Complete the updatePower() function in the "mystica.py" skeleton file. This function takes two arguments: a three-element list of integers (representing bowls I, II, and III, in that order) and a non-zero integer representing the number of power units being gained or spent (a positive value indicates that power is being gained, while a negative value indicates that power is being spent). The function does not return anything, but directly modifies its list parameter according to the rules above.

Examples: updatePower([5, 7, 0], 3) ("gain 3 units of power") would update the list contents to [2, 10, 0] (just move 3 units from bowl I to bowl II). updatePower([3, 4, 5], 6) ("gain 6 units of power") would update the list contents to [0, 4, 8] (move 3 units from bowl I to bowl II, then move 3 units from bowl II to bowl III). updatePower([2, 7, 3], -2) ("spend 2 units of power") would update the list contents to [4, 7, 1] (move 2 units from bowl III to bowl I). updatePower([7, 5, 0], -4) ("spend 4 units of power") would leave the list unchanged (bowl III is empty, so there are no units to move to bowl I).

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

Describe two ways corporations make payouts to stockholders.

Answered: 1 week ago