using MuZero
import Zygote 

include("game.jl")

learner = Learner(Connect4)

# Play a quick game to make sure 
# the basic game dynamics are working
#learner |> play

learner |> tests |> svg
learner |> test_results |> svg

selfplay!(learner; limit=10)

learner |> randgame |> svg

# still a fence post problem here
s = learner |> randtrainingsample
learner |> randtrainingsample |> svg

learner |> randtrainingbatch |> show

using Base.Threads: @spawn
for i = 1:num_actors(learner)
    @spawn selfplay!(learner)
end

length(learner.replay_buffer)

@time fit!(learner, steps=1)