bhouston

10 years 3 months ago

Here's the script for Rock, Paper, Scissors. The program picks which one, it's totally random. So if you are spending too much time alone in your "Robot Lab" now you can entertain yourself with this. Have fun!!

def rockpaperscissors():
    for y in range(0, 5):
        x = (random.randint(1, 3))
        if x == 1:
            ready()
            sleep(2)
            rock()
            sleep(2)
        if x == 2:
            ready()
            sleep(2)
            paper()
            sleep(2)
        if x == 3:
            ready()
            sleep(2)
            scissors()
            sleep(2)
    thatwasfun()

def ready():
    i01.mouth.speak("ready")
    i01.mouth.speak("go")
    i01.moveHead(90,90,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    
    

def rock():
    
    i01.moveHead(90,90,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.setHeadSpeed(.8,.8)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    
    sleep(.3)
    
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    
    sleep(.3)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(90,90,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,140)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.mouth.speakBlocking("rock")

def paper():
    i01.moveHead(90,90,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.setHeadSpeed(.8,.8)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(90,90,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",0,0,0,0,0,165)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.mouth.speakBlocking("paper")

def scissors():
    i01.moveHead(90,90,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.setHeadSpeed(.8,.8)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(60,107,80,90,75)
    i01.moveArm("left",65,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",40,171,180,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.moveHead(90,90,80,90,75)
    i01.moveArm("left",49,90,75,10)
    i01.moveArm("right",5,90,30,10)
    i01.moveHand("left",50,0,0,180,180,90)
    i01.moveHand("right",2,2,2,2,2,90)
    sleep(.3)
    i01.mouth.speakBlocking("scissors")

def thatwasfun():
  i01.mouth.speak("that was fun")
  i01.moveHead(90,90,80,90,75)
  i01.moveArm("left",5,90,30,10)
  i01.moveArm("right",5,90,30,10)
  i01.moveHand("left",2,2,2,2,2,90)
  i01.moveHand("right",2,2,2,2,2,90)

kmcgerald

10 years 3 months ago

Great script. I like that you used a random function to decide his play.  You could wrap a bit of looping in there where he asks if you want to play again and then listens for your answer or he could wait for you to just say again after each play.  We just need a way for him to figure out what you played so he could tell if he won.  :)

GroG

10 years 3 months ago

Great work B!

I agree with kmc - with the exception.. I think he should cheat ;)

kmcgerald

10 years 3 months ago

In reply to by GroG

I saw a video somewhere (youtube?) where there was a RPS robot that could cheat because it could react faster than a person.