import random
import turtle
happy=turtle.Screen()
turtle=turtle.Turtle()
happy.setup(700,468)


def mov(x,y):
    turtle.up()
    turtle.setposition(0,0)
    turtle.setheading(90)
    turtle.lt(90)
    turtle.fd(x)
    turtle.rt(90)
    turtle.fd(y)
    turtle.pendown()

def scissors():
    turtle.rt(60)
    turtle.fd(70)
    turtle.backward(70)
    turtle.rt(60)
    turtle.fd(70)
    turtle.backward(90)
    turtle.rt(90)
    for x in range(30):
        turtle.rt(12)
        turtle.fd(3)
    turtle.lt(90)
    turtle.fd(20)
    turtle.rt(120)
    turtle.fd(20)
    turtle.lt(90)
    for x in range(30):
        turtle.rt(12)
        turtle.fd(3)

def paper():
    turtle.begin_fill()
    turtle.rt(10)
    turtle.fd(150)
    turtle.rt(80)
    turtle.fd(130)
    turtle.rt(100)
    turtle.fd(150)
    turtle.rt(80)
    turtle.fd(130)
    turtle.end_fill()

   
def rock():
    turtle.begin_fill()
    turtle.lt(45)
    for x in range(4):
        turtle.fd(40)
        turtle.rt(45)
        turtle.fd(40)
        turtle.rt(45)
    turtle.end_fill()

def n():
    turtle.fd(60)
    turtle.lt(20)
    turtle.backward(64)  
    turtle.rt(20)  
    turtle.fd(60) 

def w():
    turtle.fd(60)
    turtle.backward(60)
    turtle.rt(25)
    turtle.fd(30)
    turtle.rt(130)
    turtle.fd(30)
    turtle.lt(155)
    turtle.fd(60)

def s():
    turtle.rt(90)
    turtle.fd(30)
    turtle.lt(90)
    turtle.fd(30)
    turtle.lt(90)
    turtle.fd(30)
    turtle.rt(90)
    turtle.fd(30)
    turtle.rt(90)
    turtle.fd(30)

def l():
    turtle.fd(60)
    turtle.backward(60)
    turtle.rt(90)
    turtle.fd(30)

def o():
    turtle.lt(45)
    turtle.fd(7)
    turtle.rt(45)
    turtle.fd(50)
    turtle.rt(45)
    turtle.fd(7)
    turtle.rt(45)
    turtle.fd(20)
    turtle.rt(45)
    turtle.fd(7)
    turtle.rt(45)
    turtle.fd(50)
    turtle.rt(45)
    turtle.fd(7)
    turtle.rt(45)
    turtle.fd(20)

def i():
    turtle.fd(60)
  
def e():
    turtle.fd(60)
    turtle.backward(60)
    turtle.rt(90)
    turtle.fd(30)
    turtle.rt(180)
    turtle.fd(30)
    turtle.rt(90)
    turtle.fd(30)
    turtle.rt(90)
    turtle.fd(30)
    turtle.rt(180)
    turtle.fd(30)
    turtle.rt(90)
    turtle.fd(30)
    turtle.rt(90)
    turtle.fd(30)
    turtle.backward(30)

def t():
    turtle.fd(60)
    turtle.lt(90)
    turtle.fd(30)
    turtle.rt(180)
    turtle.fd(60)


while True:
    happy.bgpic("rockpaperscissors.gif")
    turtle.shape("turtle")
    
    player=input("rock, paper, scissors?: ")
    computer=random.choice(['rock','paper','scissors'])
    if player==computer:
        mov(0,0)
        turtle.color("#666666")
        turtle.speed(9)
        rock()
        mov(-80,50)
        turtle.width(4)
        turtle.color("#ff0000")
        turtle.speed(9)
        scissors()
        mov(150,-20)
        turtle.color("white")
        turtle.speed(9)
        paper()
        turtle.color("blue")
        mov(40,-120)
        t()
        mov(0,-120)
        i()
        mov(-10,-120)
        e()
        happy.clear()
        print("tie")
        choice=input("To continue: press Y : ")
        if choice!=('y'or'Y'):
            break
    elif player=="rock":
        if computer=="paper":
            mov(0,0)
            turtle.color("#666666")
            turtle.speed(9)
            rock()
            mov(110,-20)
            turtle.color("white")
            turtle.speed(9)
            paper()
            mov(60,-120)
            turtle.color("blue")
            l()
            mov(20,-120)
            o()
            mov(-15,-120)
            s()
            mov(-55,-120)
            e()
            happy.clear()
            print("You LOSE!",computer,"covers",player)
        else:
            mov(40,50)
            turtle.width(4)
            turtle.color("#ff0000")
            turtle.speed(9)
            scissors()
            mov(0,0)
            turtle.color("#666666")
            turtle.speed(9)
            rock()
            mov(40,-120)
            turtle.color("blue")
            w()
            mov(0,-120)
            i()
            mov(-15,-120)
            n()
            happy.clear()
            print("You WIN!",player,"smashes",computer)
        choice=input("To continue: press Y : ")
        if choice!=('y'or'Y'):
            break
    elif player=="paper":
        if computer=="scissors":
            mov(110,-20)
            turtle.color("white")
            turtle.speed(9)
            paper()
            mov(40,50)
            turtle.width(4)
            turtle.color("#ff0000")
            turtle.speed(9)
            scissors()
            mov(60,-120)
            turtle.color("blue")
            l()
            mov(20,-120)
            o()
            mov(-15,-120)
            s()
            mov(-55,-120)
            e()
            happy.clear()
            print("You LOSE!",computer,"cuts",player)
        else:
            mov(0,0)
            turtle.color("#666666")
            turtle.speed(9)
            rock()
            mov(110,-20)
            turtle.color("white")
            turtle.speed(9)
            paper()
            mov(40,-120)
            turtle.color("blue")
            w()
            mov(0,-120)
            i()
            mov(-15,-120)
            n()
            happy.clear()
            print("You WIN!",player,"covers",computer)
        choice=input("To continue: press Y : ")
        if choice!=('y'or'Y'):
            break
    elif player=="scissors":
        if computer=="rock":
            mov(40,50)
            turtle.width(4)
            turtle.color("#ff0000")
            turtle.speed(9)
            scissors()
            mov(0,0)
            turtle.color("#666666")
            turtle.speed(9)
            rock()
            mov(60,-120)
            turtle.color("blue")
            l()
            mov(20,-120)
            o()
            mov(-15,-120)
            s()
            mov(-55,-120)
            e()
            happy.clear()
            print("You LOSE!",computer,"smashes",player)
        else:
            mov(110,-20)
            turtle.color("white")
            turtle.speed(9)
            paper()
            mov(40,50)
            turtle.width(4)
            turtle.color("#ff0000")
            turtle.speed(9)
            scissors()
            mov(40,-120)
            turtle.color("blue")
            w()
            mov(0,-120)
            i()
            mov(-15,-120)
            n()
            happy.clear()
            print("You WIN!",player,"cuts",computer)
        choice=input("To continue: press Y : ")
        if choice!=('y'or'Y'):
            break
    else:
        print("Check your spelling...")
        choice=input("To continue: press Y : ")
        if choice!=('y'or'Y'):
            break
