from abc import ABCMeta, abstractmethod from random import randint def main(): widthSet = False heightSet = False while not widthSet: try: width = int(input("Enter the width of your game board (10-26):")) print() if width >= 10 and width <= 26: widthSet = True else: print("The width must be an integer from 10-26. Please try again.") except: print("The width must be an integer from 10-26. Please try again.") while not heightSet: try: height = int(input("Enter the height of your game board (10-26):")) print() if height >= 10 and height <= 26: heightSet = True else: print("The height must be an integer from 10-26. Please try again.") except: print("The height must be an integer from 10-26. Please try again.") player1 = HumanPlayer(1, width, height) player2 = ComputerPlayer(2, width, height) board1 = player1.getBoard() board2 = player2.getBoard() while True: print() print("It's your turn:") makeShot = False while not makeShot: result = input("Would you like to take a shot(1), look at the computer's board(2), or look at your board(3)?:") print() if result == "1": makeShot = True elif result == "2": board2.display(player1.getNumber()) elif result == "3": board1.display(player1.getNumber()) else: print("That is not a valid option!") board2.display(player1.getNumber()) player1.takeShot(board2) if board2.checkWinner(): print() board2.display(player1.getNumber()) input("You have won!") return print() print("It's the computer's turn:") player2.takeShot(board1) board1.display(player1.getNumber()) if board1.checkWinner(): print() board1.display(player1.getNumber()) input("You have lost!") return if __name__ == '__main__': main()