Guest User

Untitled

a guest
Apr 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. def main():
  2. import os, time
  3. menu_selection = 0
  4. while menu_selection != 5:
  5. clear_screen()
  6. mainmenu()
  7. if menu_selection == 1:
  8. clear_screen()
  9. print_instructions()
  10. elif menu_selection == 2:
  11. prep_game()
  12. while grid_check(grid_list) == 0:
  13. clear_screen()
  14. display_grid(list)
  15. selection = in_game_menu()
  16. if selection == 1:
  17. set_buffer()
  18. set_list(input("Cell: "), input("Value: ")
  19. elif choice == 2:
  20. undo()
  21. elif selection == 3:
  22. clear_screen()
  23. mainmenu()
  24. if menu_selection == 1:
  25. clear_screen()
  26. print_instructions()
  27. elif menu_selection == 2:
  28. prep_game()
  29. elif menu_selection == 3:
  30. return(3)
  31. elif menu_selection == 4:
  32. clear_screen()
  33. display_scores()
  34. elif menu_selection == 5:
  35. print("Thanks for playing!")
  36. time.pause(1)
  37. exit()
  38. elif selection == 4:
  39. exit()
  40. print("Congratulatons! you win!")
  41. time.pause(2)f
  42. elif menu_selection == 3:
  43. raw_input("You must have started a gave first.")
  44. elif menu_selection == 4:
  45. clear_screen()
  46. display_scores()
  47. exit()
  48. exit()
  49.  
  50. def set_list(location, value):
  51. grid_list[location] = value
  52.  
  53. def prep_game():
  54. grid_list = [0,0,0,0,0,0,0,0,0]
  55. set_list(RANDOM NUMBER1-3, RANDOM NUMBER 0-8)
  56.  
  57. def in_game_menu():
  58. print("1. Enter symbol/square")
  59. print("2. Undo previous move")
  60. print("3. Pause game")
  61. print("Quit game")
  62. return(input("\nSelection: "))
  63.  
  64. def display_scores():
  65. return()
  66.  
  67. def set_buffer():
  68. grid_list_buffer = grid_list
  69.  
  70. def undo():
  71. grid_list = grid_ist_buffer
  72.  
  73. def display_grid(list):
  74. print(" _________ ")
  75. print("| | | |")
  76. print("| %d | %d | %d |" % (list[0],list[1],list[2])
  77. print("|___|___|___|")
  78. print("| | | |")
  79. print("| %d | %d | %d |" % (list[3],list[4],list[5])
  80. print("|___|___|___|")
  81. print("| | | |")
  82. print("| %d | %d | %d |" % (list[6],list[7],list[8])
  83. print("print("|___|___|___|")")
  84.  
  85. def grid_check(list):
  86. x1 = (list[0] + list[1] + list[2])
  87. x2 = (list[3] + list[4] + list[5])
  88. x3 = (list[6] + list[7] + list[8])
  89. y1 = (list[0] + list[3] + list[6])
  90. y2 = (list[1] + list[4] + list[7])
  91. y3 = (list[2] + list[5] + list[8])
  92. if (x1 + x2 +x3 + y1 + y2 +y3) == 36:
  93. return(1)
  94. else:
  95. return 0
  96.  
  97. def clear_screen():
  98. for i in (75):
  99. print("\n")
  100.  
  101. def mainmenu():
  102. clear_screen():
  103. print("Welcome to Latin Squares!!!\n\n")
  104. print("Main Menu:\n")
  105. print("1. Game overview/instructions")
  106. print("2. Start new game")
  107. print("3. Resume current game")
  108. print("4. View (top 5) high scores")
  109. print("5. Quit")
  110. menu_selection = input("\nSelection: ")
  111.  
  112. def print_instructions():
  113. print("Well, this is the game's instructions....")
  114. print("\nPress enter to contine....")
  115. raw_input("\n")
  116.  
  117. main()
Add Comment
Please, Sign In to add comment