Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import random
  2. #rock -1, paper - 2, scissors - 3
  3. def x1():
  4. print "Ax......B"
  5. def x2():
  6. print "A.x.....B"
  7. def x3():
  8. print "A..x....B"
  9. def x4():
  10. print "A...x...B"
  11. def x5():
  12. print "A....x..B"
  13. def x6():
  14. print "A.....x.B"
  15. def x7():
  16. print "A......xB"
  17. def roll():
  18. return random.randrange(3)+1
  19. def play():
  20. while True:
  21. a = roll()
  22. b = roll()
  23. if a == 1 and b == 2:
  24. return "b"
  25. elif a == 1 and b == 3:
  26. return "a"
  27. elif a == 2 and b == 1:
  28. return "a"
  29. elif a == 2 and b == 3:
  30. return "b"
  31. elif a == 3 and b == 1:
  32. return "b"
  33. elif a == 3 and b == 2:
  34. return "a"
  35. def positionshow():
  36. if position == 1:
  37. x1()
  38. elif position == 2:
  39. x2()
  40. elif position == 3:
  41. x3()
  42. elif position == 4:
  43. x4()
  44. elif position == 5:
  45. x5()
  46. elif position == 6:
  47. x6()
  48. elif position == 7:
  49. x7()
  50. def winners():
  51. global position
  52. while True:
  53. positionshow()
  54. raw_input("Press enter to play")
  55. result = play()
  56. if result == "a":
  57. print "A wins!"
  58. position = position - 1
  59. else:
  60. print "B wins!"
  61. position = position + 1
  62. if position == 1:
  63. positionshow()
  64. print "A wins the game!"
  65. break
  66. elif position == 7:
  67. positionshow()
  68. print "B wins the game!"
  69. break
  70. #main
  71. position = 4
  72. winners()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement