Advertisement
Guest User

23123

a guest
Mar 5th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. #init
  2. PEG = 'O'
  3. HOLE = ' '
  4. BLANK = '#'
  5.  
  6. game3 = []
  7. game3.append([BLANK,BLANK,PEG,PEG,PEG,BLANK,BLANK])
  8. game3.append([BLANK,BLANK,PEG,PEG,PEG,BLANK,BLANK])
  9. game3.append([PEG,PEG,PEG,PEG,PEG,PEG,PEG])
  10. game3.append([PEG,PEG,PEG,HOLE,PEG,PEG,PEG])
  11. game3.append([PEG,PEG,PEG,PEG,PEG,PEG,PEG])
  12. game3.append([BLANK,BLANK,PEG,PEG,PEG,BLANK,BLANK])
  13. game3.append([BLANK,BLANK,PEG,PEG,PEG,BLANK,BLANK])
  14.  
  15. row = ['A |','B |','C |','D |','E |','F |','G |']
  16.  
  17. def print_welcome():
  18. print("Hello this is the Peg Solitaire Game")
  19. print("There are three different games you can play\n")
  20. print("1 = Choose your own empty cell on default layout")
  21. print("2 = Different layout")
  22. print("3 = Default layout")
  23. print("exit = Quit this game\n")
  24.  
  25. def check_get():
  26. if game3[get_row][get_column] != PEG:
  27. print("please change your input")
  28. else:
  29. i += 1
  30.  
  31. def check_put():
  32. if game3[put_row][put_column] != HOLE:
  33. print("Incorrect move, please try again")
  34.  
  35. def show_game3():
  36. print ("\nBoard:\n")
  37. print (" 0 1 2 3 4 5 6")
  38. print (" -------------")
  39. count = 0
  40. for x in game3:
  41. print(row[count],end=' ')
  42. for y in x:
  43. print(y,end=' ')
  44. count += 1
  45. print(end='\n')
  46. print("\n")
  47.  
  48. terminate = False
  49. print_welcome()
  50. while not terminate:
  51. which_game = input("Which game do you want to play? ")
  52. if which_game == "1":
  53. print()
  54. elif which_game == "2":
  55. print()
  56.  
  57. elif which_game == "3":
  58. i = 0
  59. x = 0
  60. show_game3()
  61. while i != 1:
  62. get_row = int(input("Enter row to get peg (A-G) "))
  63. get_column = int(input("Enter column to get peg (0-6)"))
  64. check_get()
  65. while x != 0:
  66. put_row = int(input("Enter row to put peg (A-G)"))
  67. put_column = int(input("Enter column to put peg (0-6)"))
  68. check_put()
  69.  
  70. elif which_game == "exit":
  71. terminate = True
  72. else:
  73. print("Incorrect input is given, please choose (1,2,3 or exit) ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement