Python Forum

Full Version: Process Moves
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
We have been given a canvas with 7x7 columns. Our aim goal is to draw 4 ‘competitors’ that will try to ‘grab land’ by occupying the spaces within the rectangles within the columns. The code contains a random_moves function that returns a randomized list of moves for each of the competitors with a range of the [competitor_identity, direction]. Furthermore, we are tasked with creating our own code to process the moves so rather than just seeing the random moves generated within the shell, we also see the competitors occupy the appropriate spaces within the canvas. I have attempted to create lists of both the various competitors and directions and tried to implement those in the process_moves function. Any advice would be greatly appreciated, cheers.

#Define 4 Competitors
def Competitor_A():
    tree()
def Competitor_B():
    grass()
def Competitor_C():
    flower()
def Competitor_D():
    tomato()


#Competitors List 
##competitors_identity = ['Competitor_A', 'Competitor_B', 'Competitor_C', 'Competitor_D']
def competitors():
    Competitor_A, Competitor_B, Competitor_C, Competitor_D

#Define movements for tokens
def Left():
    penup()
    setheading(0)
    backward(120)
def Right():
    penup()
    setheading(0)
    forward(120)
def Up():
    penup()
    setheading(90)
    forward(90)
def Down():
    penup()
    setheading(90)
    backward(90)

#Moves List
##directions = ['Left', 'Right', 'Up', 'Down']
def directions():
    Left, Right, Up, Down

moves = competitors , directions



#


# Draw competitors on the grid as per the provided data set
def process_moves(moves):
   for competitor in competitors:
       move = [competitor, choice(['Left', 'Right', 'Up', 'Down'])]
I'm unclear on your question. Can you frame it in terms of desired vs actual output? Or in terms of what result some variable should have?