Spaces:
Runtime error
Runtime error
module App # Needed for Genie to use loadapp() | |
using Genie.Renderer.Html, Stipple, StippleUI | |
using ImpCatcher | |
using Chess | |
const C = Chess | |
mutable struct Model <: ReactiveModel | |
process::R{Bool} = false | |
rollout::R{Bool} = false | |
reset::R{Bool} = false | |
output::R{String} = "" | |
input::R{String} = "" | |
boardstr::R{String} = repr(C.startboarddark()) | |
board::R{Board} = C.startboarddark() | |
end | |
function handlers(model) | |
on(model.process) do _ | |
if (model.process[]) | |
model.output[] = model.input[] |> reverse | |
model.board[] = C.domove(model.board[!], model.input[!]) | |
model.boardstr[] = repr(model.board[!]) | |
model.process[] = false | |
end | |
end | |
on(model.reset) do _ | |
if (model.reset[]) | |
model.board[] = C.startboarddark() | |
model.boardstr[] = repr(model.board[!]) | |
model.reset[] = false | |
end | |
end | |
model | |
end | |
function ui(model) | |
page(model, class="container", [ | |
p([ | |
"Input Move in UCI format (e.g \"d2d4\") == Move(SQ_D2, SQ_D4)" | |
input("", (:input), ("keyup.enter", "process = true")) | |
]) | |
p([ | |
button("Action!", ("process = true")) | |
]) | |
p([ | |
"Output: " | |
span("", (:output)) | |
]) | |
p([ | |
"{{ boardstr }}" | |
]) | |
p([ | |
button("Reset Game", ("reset = true")) | |
]) | |
p([ | |
button("CESPF Greedy Rollout", ("rollout = true")) | |
]) | |
] | |
) | |
end | |
route("/") do | |
model = Model |> init |> handlers | |
html(ui(model), context = | )|
end | |
end # module | |
#Genie.isrunning(:webserver) || up() | |