-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathevaluate.py
More file actions
28 lines (21 loc) · 768 Bytes
/
evaluate.py
File metadata and controls
28 lines (21 loc) · 768 Bytes
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
from game2048.game import Game
from game2048.displays import Display
def single_run(size, score_to_win, AgentClass, **kwargs):
game = Game(size, score_to_win)
agent = AgentClass(game, display=Display(), **kwargs)
agent.play(verbose=True)
return game.score
if __name__ == '__main__':
GAME_SIZE = 4
SCORE_TO_WIN = 2048
N_TESTS = 10
'''====================
Use your own agent here.'''
from game2048.agents import ExpectiMaxAgent as TestAgent
'''===================='''
scores = []
for _ in range(N_TESTS):
score = single_run(GAME_SIZE, SCORE_TO_WIN,
AgentClass=TestAgent)
scores.append(score)
print("Average scores: @%s times" % N_TESTS, sum(scores) / len(scores))