-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.jl
57 lines (45 loc) · 1.36 KB
/
tests.jl
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
54
55
56
57
push!(LOAD_PATH, @__DIR__)
using TicTacToe
include("TreeWalker.jl")
using Traceur
function next_board!(board = empty_board())
all(board .== Ref(O)) && return nothing
increments = Dict(empty_square=>(X, false), X=> (O, false), O => (empty_square, true))
carry=false
for (index, item) in pairs(IndexLinear(), board)
new_value, carry = increments[item]
board[index] = new_value
carry || return board
end
end
function test_walker()
board = empty_board()
Xboard = copy(board)
Oboard = copy(board)
data = []
sizehint!(data, 19683)
i=0
#open("test_data.serialized", "w") do data_file
while board != nothing
# make a copy of the board in case it's modified
Xboard[:] .= board[:]
Oboard[:] .= board[:]
x_time = @elapsed pick_move(Xboard, X)
o_time = @elapsed pick_move(Oboard, O)
#Serialization.serialize(data_file, board=>(x_time, o_time))
push!(data, copy(board)=> (x_time, o_time))
board = next_board!(board)
i > 20000 && error("over run iteration limit")
i +=1
end
return data
end
function f(x)
s=0
for n in 1:10
s *= x
end
return s
end
width_first_search(empty_board(), X)
@trace width_first_search(empty_board(), X)