Jump to content

myro simulator help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
masterinthesith

masterinthesith

    Newbie

  • Members
  • Pip
  • 2 posts
Hello ladies, and gentlemen. I am looking for some help on a school assignment that i have. I have been bumping heads with this assignment for quite some time, and cannot figure it out. I asked my teacher for help and this was his response.

"Use two if statements. One to test to see if the random integer is a 1, then turn left, move forward, and count. The second to test if the random integer is 2, then turn right and move forward. You only need to return either the left or right count, since the function can only return one thing. "

It is pretty straight forward but i just couldn't get it here is what i have so far.

# Programmer : Nicholas Fallon

# May 28, 2010

# movement401.py


from myro import*

init("simulator")

def pressC():

askQuestion( "Click on C to continue!" ,[ "C", "Quit"])

speak("Lets Begin")


def dfdfd():

s= input("Enter a speed (' -1 ' - '1' respectively): ")

t=input("How many seconds should the robot move:?")

return s,t


def movement(speed):



for d in range(s):

result = randint(1,2)

if (result <= 1):

turnLeft(s,t)

forward(s,t)



def movement2(time):


for d in range(t):

result = random()

if(result <= 2):

turnRight(t,s)

forward(t,s)





def main():



dfdfd()

pressC()


speed = movement(s)

time = movement2(t)

main()

I get a few errors, and like i said Ive been bumping heads with this thing for a while I have tried many different tricks but could not get it.

Oh yea i forgot It keeps saying " s " is not defined but when the program prompts the user for numeric input it should be passed through. If you get what i am saying

#2
Root23

Root23

    Programmer

  • Members
  • PipPipPipPip
  • 144 posts
Assuming that the code you posted is what you're trying to run, I'd start by making sure everything is indented to the correct blocks, and then go from there.
Posted Image