Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Process Moves
#1
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'])]
Reply
#2
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  moves in Tic-Tac-Toe marek12 3 1,857 Nov-23-2019, 09:33 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020