Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please only write the program in Python. I dont know how to use any other programming languages. 2. Terra Mystica (6 points) In the board
Please only write the program in Python. I dont know how to use any other programming languages.
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 l, ll, and lll (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 IlI to bowl I i. If bowl ll is empty, nothing happens. b. To gain a unit of power: i. If all 12 units are already in bowl IlI, nothing happens. Otherwise i. If there is a unit in bowl I, move it to bowl I. iii. Otherwise, if bowl l is empty but there is a unit in bowl ll, move one unit from bowl 11 to bowl 111 iv. If bowls I and II are both empty, then nothing happens. Stony Brook University CSE 101: Introduction to Computers (Section 01) Fall 201 Complete the updatePower ) function in the "mystica.py skeleton file. This function takes two arguments: a three-element list of integers (representing bowls l, ll, and Ill, 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 I) updatePower (3, 4, 5], 6) ("gain 6 units of power) would update the list contents to [0, 4,8 (move 3 units from bowl 1 to bowl ll, then move 3 units from bowl 11 to bowl lll). . updatePower ( [ 2, 7, 3 ] , -2) ("spend 2 units of power") would update the list contents to [4,7,1] (move 2 units from bowl Ill to bowl I). . update Power ( [ 7, 5, 0 ] , -4 ) ("spend 4 units of power") would leave the list unchanged (bowl in is empty, so there are no units to move to bowl Step 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