entering 8 doesnt crash it anymore lmao

This commit is contained in:
Vincent Rodley 2025-08-20 21:41:14 +12:00
parent e19f0411c2
commit f17c76d072
4 changed files with 16 additions and 40 deletions

View File

@ -33,3 +33,7 @@ Both game modes include:
### Player vs CPU ### Player vs CPU
- Fix priority issues: sometimes the CPU prefers a vertical 3-in-a-row instead of completing a horizontal win. - Fix priority issues: sometimes the CPU prefers a vertical 3-in-a-row instead of completing a horizontal win.
### GUI
- Make all the menus a big ol dict for cleanliness

View File

@ -85,13 +85,12 @@ def printBoard(board):
print(f"{top}\n{'\n'.join(rows)}\n{bottom}") print(f"{top}\n{'\n'.join(rows)}\n{bottom}")
def getIntInput(prompt, board=None): def getIntInput(prompt, board=None):
while True: while True:
inp = input(prompt) inp = input(prompt)
try: try:
inp = int(inp) inp = int(inp)
if not 1 <= inp <= 8: if not 1 <= inp <= 7:
raise ValueError raise ValueError
return inp return inp
except ValueError: except ValueError:
@ -254,15 +253,13 @@ def cpu_move_provider(player, board):
best_score = float('-inf') if player == 'R' else float('inf') best_score = float('-inf') if player == 'R' else float('inf')
best_move = None best_move = None
# try: try:
# with open("settings.json", "r") as f: with open("settings.json", "r") as f:
# settings = json.load(f) settings = json.load(f)
# print(f"Settings: {settings}") print(f"Settings: {settings}")
# search_depth = settings.get("cpu_search_depth", 5) search_depth = settings.get("cpu_search_depth", 5)
# print(f"search depth: {search_depth}") print(f"search depth: {search_depth}")
# except (FileNotFoundError, json.JSONDecodeError): except (FileNotFoundError, json.JSONDecodeError):
# search_depth = 5
search_depth = 5 search_depth = 5
maximising = True if player == 'R' else False maximising = True if player == 'R' else False
@ -501,28 +498,3 @@ while True:
break break
else: else:
input("Invalid choice. Press ENTER to try again...") input("Invalid choice. Press ENTER to try again...")
"""
RED Drawstring
3
4
4
3
5
3
3
3
5
1
1
1
7
7
7
2
2
2
6
6
6
"""

View File

@ -1,4 +1,4 @@
{ {
"display_mode": "emojis", "display_mode": "emojis",
"cpu_search_depth": 6 "cpu_search_depth": 5
} }

View File

@ -62,7 +62,7 @@ if __name__ == "__main__":
height = 75 height = 75
x = WINDOW_SIZE[0] / 2 - width / 2 # center of the screen horizontally x = WINDOW_SIZE[0] / 2 - width / 2 # center of the screen horizontally
y = (WINDOW_SIZE[1] / 2 - height / 2) # center of the screen vertically y = WINDOW_SIZE[1] / 2 - height / 2 # center of the screen vertically
primary_color = (70, 130, 180) # button background primary_color = (70, 130, 180) # button background
hover_color = (51, 102, 145) # button hover hover_color = (51, 102, 145) # button hover