-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.jl
More file actions
executable file
·48 lines (43 loc) · 1.43 KB
/
Copy pathbootstrap.jl
File metadata and controls
executable file
·48 lines (43 loc) · 1.43 KB
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
(pwd() != @__DIR__) && cd(@__DIR__) # allow starting app from bin/ dir
using ProbkerApp
using SimpleWebsockets
using JSON
include("Probker.jl/src/Probker.jl")
using .Probker
# using Pkg
# Pkg.add(url="https://github.com/brunbjerg/Probker.jl")
# using Probker
# This will not work without the Probker package
function Extract_Game_And_Load_Into_Struct(game_dict)
game = Game(
game_dict["number_of_players"],
[game_dict["player_cards"];
game_dict["shared_cards"]],
game_dict["folded_cards"],
game_dict["simulations"])
return game
end
server = WebsocketServer()
listen(server, :client) do ws
listen(ws, :message) do message
try
# println(@__LINE__, message, "CHECKPOINT")
game_dict = JSON.parse(message)
# println(@__LINE__, game_dict, "CHECKPOINT")
game = Extract_Game_And_Load_Into_Struct(game_dict)
# println(@__LINE__, game, "CHECKPOINT")
probabilities = Simulate(game)
# println(@__LINE__, probabilities, "CHECKPOINT")
probabilities_JSON = JSON.json(probabilities)
# println(@__LINE__, probabilities_JSON, "CHECKPOINT")
send(ws, probabilities_JSON)
catch err
println(@__LINE__, err, "CHECKPOINT")
@info err
# send(ws, "")
end
end
end
@async serve(server, 8082, "0.0.0.0")
const UserApp = ProbkerApp
ProbkerApp.main()