entering 8 doesnt crash it anymore lmao
This commit is contained in:
parent
e19f0411c2
commit
f17c76d072
|
|
@ -33,3 +33,7 @@ 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.
|
||||
|
||||
### GUI
|
||||
|
||||
- Make all the menus a big ol dict for cleanliness
|
||||
44
cli/game.py
44
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,15 +253,13 @@ 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
|
||||
|
||||
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
|
||||
"""
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"display_mode": "emojis",
|
||||
"cpu_search_depth": 6
|
||||
"cpu_search_depth": 5
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user