Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- #rock -1, paper - 2, scissors - 3
- def x1():
- print "Ax......B"
- def x2():
- print "A.x.....B"
- def x3():
- print "A..x....B"
- def x4():
- print "A...x...B"
- def x5():
- print "A....x..B"
- def x6():
- print "A.....x.B"
- def x7():
- print "A......xB"
- def roll():
- return random.randrange(3)+1
- def play():
- while True:
- a = roll()
- b = roll()
- if a == 1 and b == 2:
- return "b"
- elif a == 1 and b == 3:
- return "a"
- elif a == 2 and b == 1:
- return "a"
- elif a == 2 and b == 3:
- return "b"
- elif a == 3 and b == 1:
- return "b"
- elif a == 3 and b == 2:
- return "a"
- def positionshow():
- if position == 1:
- x1()
- elif position == 2:
- x2()
- elif position == 3:
- x3()
- elif position == 4:
- x4()
- elif position == 5:
- x5()
- elif position == 6:
- x6()
- elif position == 7:
- x7()
- def winners():
- global position
- while True:
- positionshow()
- raw_input("Press enter to play")
- result = play()
- if result == "a":
- print "A wins!"
- position = position - 1
- else:
- print "B wins!"
- position = position + 1
- if position == 1:
- positionshow()
- print "A wins the game!"
- break
- elif position == 7:
- positionshow()
- print "B wins the game!"
- break
- #main
- position = 4
- winners()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement