-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevaltest.py
30 lines (24 loc) · 858 Bytes
/
evaltest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from game import Game
from algorithms import evaluate
"""
Starts a game in the console.
Both player actions are controlled by the user.
Prints the score of the evaluation function for each game state.
"""
if __name__ == "__main__":
print("Starting game...")
g = Game()
while not g.state.isTerminal():
print(f"Current player: {g.state.currentPlayer}")
print(f"Evaluation score for current player: {evaluate(g.state)}")
print(g.state.board)
actions = g.state.getLegalActions()
print(f"Possible actions: {actions}")
action = -1
while action not in actions:
action = input("Please select one of these actions: ")
try:
action = int(action)
except:
print("Please enter an integer.")
g.place(action)