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

@ -32,4 +32,8 @@ Both game modes include:
### 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}")
def getIntInput(prompt, board=None):
while True:
inp = input(prompt)
try:
inp = int(inp)
if not 1 <= inp <= 8:
if not 1 <= inp <= 7:
raise ValueError
return inp
except ValueError:
@ -254,16 +253,14 @@ def cpu_move_provider(player, board):
best_score = float('-inf') if player == 'R' else float('inf')
best_move = None
# try:
# with open("settings.json", "r") as f:
# settings = json.load(f)
# print(f"Settings: {settings}")
# search_depth = settings.get("cpu_search_depth", 5)
# print(f"search depth: {search_depth}")
# except (FileNotFoundError, json.JSONDecodeError):
# search_depth = 5
search_depth = 5
try:
with open("settings.json", "r") as f:
settings = json.load(f)
print(f"Settings: {settings}")
search_depth = settings.get("cpu_search_depth", 5)
print(f"search depth: {search_depth}")
except (FileNotFoundError, json.JSONDecodeError):
search_depth = 5
maximising = True if player == 'R' else False
@ -501,28 +498,3 @@ while True:
break
else:
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",
"cpu_search_depth": 6
"cpu_search_depth": 5
}

View File

@ -62,7 +62,7 @@ if __name__ == "__main__":
height = 75
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
hover_color = (51, 102, 145) # button hover