todo list

This commit is contained in:
Vincent Rodley 2025-08-02 10:51:13 +12:00
parent eb184b9a7d
commit 498c4c453b
2 changed files with 9 additions and 5 deletions

View File

@ -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 will make and train the AI myself.
I might make a GUI in Pygame, depends if i cbs 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

11
main.py
View File

@ -29,9 +29,8 @@ def printBoard(board):
{Colours.BOLD}==1===2===3===4===5===6===7=={Colours.END}""") {Colours.BOLD}==1===2===3===4===5===6===7=={Colours.END}""")
def getIntInput(prompt): def getIntInput(prompt):
success = False
inp = "" inp = ""
while not success: while True:
inp = input(prompt) inp = input(prompt)
try: try:
inp = int(inp) inp = int(inp)
@ -39,7 +38,7 @@ def getIntInput(prompt):
except: except:
clear() clear()
printBoard(board) printBoard(board)
print("Only integers allowed") print("Only positive integers 1-7 allowed")
return inp return inp
@ -109,17 +108,19 @@ while playing:
while True: while True:
try: try:
chosenColumn = getIntInput(f"{colourTile(player)} where do you want to drop your tile? 1-7.\n>>> ") - 1 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") tile = board[chosenColumn].index("O")
break break
except ValueError: except ValueError:
clear() clear()
printBoard(board) 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 = "" tile = ""
except IndexError: except IndexError:
clear() clear()
printBoard(board) 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 = "" tile = ""
board[chosenColumn][tile] = player board[chosenColumn][tile] = player