Question: Several games rely on collecting and exchanging resources for objects worth points. These games are often referred to as resource management games. One famous example

Several games rely on collecting and exchanging resources for objects worth points. These games
are often referred to as "resource management games." One famous example is Settlers of Catan,
where players are challenged to build settlements on an island. In this game, players collect five
types of resources in the form of cards:
Brick,
Wood,
Ore,
Wheat, and
Sheep.
With these resources, players can purchase the following items:
You will write code that attempts to calculate the amount victory points a person can achieve with a certain number of resources.
The end user is asked to input the resource cards they have available and the program returns the points for the number of resource cards and possibly, any left over resources.
It should effectively utilize lists, for loops, and conditionals to provide one conversion from resources to victory points.
DESCRIPTION OF FUNCTIONS
1. Write a function called subtract_lists which takes in two lists as parameters and returns a list. This function will
check that the lists are the same size and can be subtracted, then
subtract the second list provided from the first.
It will return the list that reflects this difference.
2. Write a function called add_lists which takes in two lists as parameters and returns a list. The function will
check that the lists are the same size and can be added, then
add the two lists together element-by-elemebt.
It will return the list that reflects the sum.
3. Write a function called is_nonnegative, which takes in a list as a parameter and returns a boolean value. The function will verify that each entry is not less than 0. If it finds an entry is less than 0, it will return False. If it does not, it will return True. Hint: Test this function with lots of different cases--many new programmers set this up incorrectly.
4. Write a function called tabulate_resources, which takes in one list that is assumed to hold the names of the resources as strings and returns a list with the numbers of each resource. Within the function,
prompt the user to enter how many of these resource cards are held.
Store the resulting counts in another list.
Return the list with resource counts.
5. Write a function called vpoint_count_Catan which takes in one list of resource counts and returns a float reflecting the total victory points possible according to the table provided. The function should print how many of each item (e.g., cities, roads, etc) should be purchased with the resources. Within this function, expect to define four lists:
1.A list tracking the number of each item that can be purchased.
2. A list of the items as strings, e.g.["City", "Settlement", "Development Card", "Road" ]
3. A list of lists, where each entry is a list of the resources required *in the correct order!*, e.g.,[[1,1,3,3,1],[1,1,0,1,1],...]
4. A list of the victory points for each item, e.g.,[1,2,0.75,0.25]
The idea of this function will be to go through the items, subtract the amount of resources needed to purchase the maximal amount starting from the highest points (cities) to the lowest points (roads). Once you know the number to purchase, store and print that. Convert each count to points and return the points. Expect to use some or all of the previous functions written.
Finally, copy and past the following function, called exchange, into your file. You may have to fix the tabs. When you test the final product, call this function to run your code.
def exchange():
"""finds the points for the number of resource cards in Settlers of Catan without exchanges"""
res_counts =[0,0,0,0,0]
resources =["Brick", "Wood", "Ore", "Wheat", "Sheep"]
res_counts = tabulate_resources(resources)
points = vpoint_count_Catan(res_counts)
print("Expected points will be ", points)
print("Left over resources are...")
for i in range(len(resources)):
if res_counts[i]!=0:
print(resources[i], res_counts[i])
(PART 2)
It is important to note that four resource cards of any kind can be converted into 1 card another resource. For example, 4 sheep =1 wood. Write an extra function that performs these exchanges to increase the total number of victory points earned.
Several games rely on collecting and exchanging

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 Programming Questions!