-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagent.spec.py
53 lines (37 loc) · 1.19 KB
/
agent.spec.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#
# Test that agent makes moves, either deterministically
# or stochastically, as desired.
#
import unittest
from abstractgame import AbstractGame
from connectgame import ConnectGame
from agent import Agent
from mcts import MCTS
#
# Unfortunately, I'd either need to write a gigantic
# stub for AbstractGame, or do integration tests,
# so for now I'm just doing integration test
#
agent_creators = [
lambda: Agent(MCTS)
]
game_creators = [
lambda: AbstractGame(ConnectGame())
]
class TestAbstractGame(unittest.TestCase):
# Can make some kind of instance
def test_agent_creation_new(self):
for creator in agent_creators:
inst = creator()
self.assertTrue(True)
def test_can_make_moves(self):
for a_creator in agent_creators:
for g_creator in game_creators:
g = g_creator()
a = a_creator()
while not g.game_over():
move, _ = a.move(g)
g = g.move_immutable(move)
self.assertTrue(True)
if __name__ == '__main__':
unittest.main()