diff --git a/README.md b/README.md index b5943f5..ca72ca1 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +- 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 \ No newline at end of file diff --git a/cli/game.py b/cli/game.py index 3452a6d..2f474da 100644 --- a/cli/game.py +++ b/cli/game.py @@ -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 -""" \ No newline at end of file diff --git a/cli/settings.json b/cli/settings.json index b4b8139..d8c5202 100644 --- a/cli/settings.json +++ b/cli/settings.json @@ -1,4 +1,4 @@ { "display_mode": "emojis", - "cpu_search_depth": 6 + "cpu_search_depth": 5 } \ No newline at end of file diff --git a/gui/game.py b/gui/game.py index a1e8e50..0c07503 100644 --- a/gui/game.py +++ b/gui/game.py @@ -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