Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #init
- PEG = 'O'
- HOLE = ' '
- BLANK = '#'
- game3 = []
- game3.append([BLANK,BLANK,PEG,PEG,PEG,BLANK,BLANK])
- game3.append([BLANK,BLANK,PEG,PEG,PEG,BLANK,BLANK])
- game3.append([PEG,PEG,PEG,PEG,PEG,PEG,PEG])
- game3.append([PEG,PEG,PEG,HOLE,PEG,PEG,PEG])
- game3.append([PEG,PEG,PEG,PEG,PEG,PEG,PEG])
- game3.append([BLANK,BLANK,PEG,PEG,PEG,BLANK,BLANK])
- game3.append([BLANK,BLANK,PEG,PEG,PEG,BLANK,BLANK])
- row = ['A |','B |','C |','D |','E |','F |','G |']
- def print_welcome():
- print("Hello this is the Peg Solitaire Game")
- print("There are three different games you can play\n")
- print("1 = Choose your own empty cell on default layout")
- print("2 = Different layout")
- print("3 = Default layout")
- print("exit = Quit this game\n")
- def check_get():
- if game3[get_row][get_column] != PEG:
- print("please change your input")
- else:
- i += 1
- def check_put():
- if game3[put_row][put_column] != HOLE:
- print("Incorrect move, please try again")
- def show_game3():
- print ("\nBoard:\n")
- print (" 0 1 2 3 4 5 6")
- print (" -------------")
- count = 0
- for x in game3:
- print(row[count],end=' ')
- for y in x:
- print(y,end=' ')
- count += 1
- print(end='\n')
- print("\n")
- terminate = False
- print_welcome()
- while not terminate:
- which_game = input("Which game do you want to play? ")
- if which_game == "1":
- print()
- elif which_game == "2":
- print()
- elif which_game == "3":
- i = 0
- x = 0
- show_game3()
- while i != 1:
- get_row = int(input("Enter row to get peg (A-G) "))
- get_column = int(input("Enter column to get peg (0-6)"))
- check_get()
- while x != 0:
- put_row = int(input("Enter row to put peg (A-G)"))
- put_column = int(input("Enter column to put peg (0-6)"))
- check_put()
- elif which_game == "exit":
- terminate = True
- else:
- print("Incorrect input is given, please choose (1,2,3 or exit) ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement