module App # Needed for Genie to use loadapp() using Genie.Renderer.Html, Stipple, StippleUI using ImpCatcher using Chess const C = Chess @reactive 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("", @bind(:input), @on("keyup.enter", "process = true")) ]) p([ button("Action!", @click("process = true")) ]) p([ "Output: " span("", @text(:output)) ]) p([ "{{ boardstr }}" ]) p([ button("Reset Game",@click("reset = true")) ]) p([ button("CESPF Greedy Rollout", @click("rollout = true")) ]) ] ) end route("/") do model = Model |> init |> handlers html(ui(model), context = @__MODULE__) end end # module #Genie.isrunning(:webserver) || up()