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()) boardhtml::R{String} = repr(C.MIME.html(C.startboarddark())) board::R{Board} = C.startboarddark() end function handlers(model) on(model.process) do _ if (model.process[]) model.output[] = model.input[] model.board[] = C.domove(model.board[!], model.input[!]) model.boardstr[] = repr(model.board[!]) model.boardhtml[] = repr(C.MIME.html(model.board[!])) model.process[] = false end end on(model.reset) do _ if (model.reset[]) model.board[] = C.startboarddark() model.boardstr[] = repr(model.board[!]) model.boardhtml[] = repr(C.MIME.html(model.board[!])) model.reset[] = false end end on(model.rollout) do _ if (model.rollout[]) model.board[], _ = ImpCatcher.simulate_rollout(model.board[!], ImpCatcher.CESPF, 0) model.boardhtml[] = repr(C.MIME.html(model.board[!])) model.rollout[] = false end end model end function ui(model) page(model, class="container", [ h1("Building Dark Chess Engines for SOTA Performance") h3("By Anooj Patel") 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([ "Last Move Processed" pre("", @text(:output)) ]) span( var"v-html" = "boardhtml" # magic to summon vue js ) #p([ # model.boardhtml[!] # ], @on("keyup.enter"," boardhtml = repr(C.MIME.html(model))") #p([ # pre("{{ boardstr }}") #]) p([ button("Reset Game",@click("reset = true")) ]) "CESPF is a Capture / Escape, Stronger Piece First Heuristic when trying to roll out perfect information chess boards." p([ button("CESPF Greedy Rollout", @click("rollout = true")) ]) ], @iif(:isready) ) end route("/") do model = Model |> init |> handlers html(ui(model), context = @__MODULE__) end end # module #Genie.isrunning(:webserver) || up()