diff --git a/README.md b/README.md index f61fd7c..694c8b7 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,6 @@ This will eventually become a connect-4 game written in Python with an AI oppone I will make and train the AI myself. I might make a GUI in Pygame, depends if i cbs + +todo list: +3 gamemodes total. ~~player vs player on the same device~~, player vs player lan, and player vs computer diff --git a/main.py b/main.py index 7cb9775..5642cd7 100644 --- a/main.py +++ b/main.py @@ -29,9 +29,8 @@ def printBoard(board): {Colours.BOLD}==1===2===3===4===5===6===7=={Colours.END}""") def getIntInput(prompt): - success = False inp = "" - while not success: + while True: inp = input(prompt) try: inp = int(inp) @@ -39,7 +38,7 @@ def getIntInput(prompt): except: clear() printBoard(board) - print("Only integers allowed") + print("Only positive integers 1-7 allowed") return inp @@ -109,17 +108,19 @@ while playing: while True: try: chosenColumn = getIntInput(f"{colourTile(player)} where do you want to drop your tile? 1-7.\n>>> ") - 1 + if chosenColumn <= 0: + raise IndexError tile = board[chosenColumn].index("O") break except ValueError: clear() printBoard(board) - print(f"{Colours.BOLD}You chose a column that is full.{Colours.END} Try again") + print(f"{Colours.BOLD}You chose a column that is full. Try again{Colours.END}") tile = "" except IndexError: clear() printBoard(board) - print(f"{Colours.BOLD}You chose a column outside of the board.{Colours.END} Try again") + print(f"{Colours.BOLD}You chose a column outside of the board. Try again{Colours.END}") tile = "" board[chosenColumn][tile] = player