Last active
June 12, 2018 07:54
-
-
Save Roboneet/08a82f608534520f725e0781a6f39cb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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