-
Notifications
You must be signed in to change notification settings - Fork 21
/
test.py
33 lines (30 loc) · 963 Bytes
/
test.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
import checkers
import agent
import arthur
import random_agent
BLACK, WHITE = 0, 1
f = open('logfile', 'w')
for i in range(100):
print "game: " + str(i)
B = checkers.CheckerBoard()
cpu_1 = agent.CheckersAgent(lambda board: arthur.move_function(board, 4))
cpu_2 = agent.CheckersAgent(lambda board: arthur.move_function(board, 6))
current_player = B.active
turn = 1
while not B.is_over():
f.write(str(B))
if turn % 100 == 0:
print "# of turns: " + str(turn)
B.make_move(cpu_1.make_move(B))
if B.active == current_player:
continue
current_player = B.active
turn += 1
while not B.is_over() and B.active == current_player:
B.make_move(cpu_2.make_move(B))
current_player = B.active
if B.active == WHITE:
print "Congrats Black, you win!"
else:
print "Congrats White, you win!"
print "Game took %i turns" % turn