Question: Q 2 ( g ) Upon their turn, a player can attack an adjoining territory by rolling a die against the defender s die. If
Qg
Upon their turn, a player can attack an adjoining territory by rolling a die against the defenders die. If they win, their armies can move into the new territory. The mechanics of attacking are not important in this question. A player cannot move through or attack their own territories. Therefore, regardless of how many armies they have in a given territory, the territories they can move into from a given starting point may be limited
imageIn the image above, the owners are designated by different colours.
Eastern Australia is owned by a player designated yellow.
New Guinea and Western Australia are owned by a player designated orange.
Indonesia is owned by a player designated pink.
Siam is owned by a player designated green.
Ignoring the number of armies as written on the map, the orange player could, from Western Australia:
attack Eastern Australia, but that is as far as they could go
attack Indonesia and then Siam.
imageIn this example, from Western Australia the orange player can only attack into Eastern Australia. As they own Indonesia, Siam now becomes inaccessible from Western Australia. Again, in this image we have to ignore the number of armies as the image is for illustration only.
Create a function, possibleroutes, which, given a graph and a starting node, will return a graph with one of the possible routes to all connected territories other than their own.
When you run the test you should get something that looks like this, based on the first illustration of Australia above:image
NOTE: There are multiple different solutions. This is indicative only!
REMEMBER to only use data typesstructures constructs, methods, functions or operations listed in the chapter summaries.
run i mdigraph #The M undirected graph code
run i mungraph #The M directed graph code
run i mterritories #Create the territories
def possibleroutesgraph: DiGraph, start: Hashable DiGraph:
#Write your answer here
pass
#If your code works, the following should draw a path:
#Siam Indonesia Western Australia Eastern Australia New Guinea
# or
#Siam Indonesia New Guinea Western Australia Eastern Australia
# or
#Siam Indonesia New Guinea Eastern Australia Western Australia
path possibleroutesaustralasiaIndonesia
path.draw
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
