forked from udacity/AIND-Isolation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagent_debug.py
52 lines (34 loc) · 1.5 KB
/
agent_debug.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
import timeit
from isolation import Board
from sample_players import (RandomPlayer, open_move_score,
improved_score, center_score)
from game_agent import (MinimaxPlayer, AlphaBetaPlayer, custom_score,
custom_score_2, custom_score_3)
# Create the test players
player1 = AlphaBetaPlayer(score_fn=improved_score)
player2 = RandomPlayer()
# Create an isolation board (by default 7x7)
game = Board(player1, player2, 8, 8)
forfeited_match = [[2, 3], [4, 4], [0, 4], [5, 6], [2, 5], [6, 4],
[1, 3], [4, 5], [0, 1], [2, 6], [2, 2]]
for move in forfeited_match:
game.apply_move(move)
# print(game.get_legal_moves())
# print(len(game.get_legal_moves()))
score = custom_score_2(game, player1)
time_millis = lambda: 1000 * timeit.default_timer()
move_start = time_millis()
time_left = lambda: 100 - (time_millis() - move_start)
# next_move = player1.get_move(game, time_left)
# print(next_move)
failed_test_case_7 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1,
1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 51, 23]
game1 = Board(player1, player2, 9, 9)
game1._board_state = failed_test_case_7
next_move = player1.get_move(game1, time_left)
print(next_move)
print(game1.get_legal_moves())