Skip to content

Instantly share code, notes, and snippets.

@Roboneet Roboneet/alphaGoServer.jl
Last active Jun 12, 2018

Embed
What would you like to do?
using AlphaGo
using HttpServer
using JSON
config = Dict()
function _deploy(f)
handler= HttpHandler(f)
server = Server(handler)
run(server, 3000)
server
end
function transform(req,res)
if typeof(req.method) == GETDict
return handleGET(req, res)
else if typeof(req.method) == POSTDict
return handlePOST(req, res)
res
end
function __init__()
# load neural network and configure env
# add nn and other env variables to config dict
# ...
_deploy(transform)
end
struct MCTSPlayer__
# all the info without the common ones ( like nn )
root
qs::Vector{Float32}
searches_π::Vector{Vector{Float32}}
result::Int
position
# .....
end
function MCTSPlayer__(m::MCTSPlayer)
MCTSPlayer__(m.root, m.qs, m.searches_π, m.result, m.position)
end
function handleGET(req, res)
# create MCTSPlayer
player = initialise_player()
player__ = MCTSPlayer__(m)
res.data = JSON.json(Dict(mctsPlayer=>player__))
return res
end
function makeMCTSPlayer(p::MCTSPlayer__)
# make from p and config dict
end
function handlePOST(req, res)
dict = JSON.parse(String(req.data))
player__ = MCTSPlayer__(dict["mctsPlayer"])
player = makeMCTSPlayer(player__)
# add user action to env
# .....
move = pick_move(player)
play_move!(player, move)
# get current env info and current player__ info
# env = player.position?
# player__ = MCTSPlayer__(player)
data = Dict("env"=>env, "mctsPlayer"=>player__)
res.data = JSON.json(data)
return res
end
__init__()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.