I’d like to explore ReinforcementLearning.jl and AlphaZero.jl for playing board games with AI, and I’d like to visualize the games and allow a human player to place pieces on the board. Therefore, I’d like to make an extremely simple GUI - no widgets except for a 2D graphical display of the board, and the only allowed user interaction (at least for a first version) is the left mouse-click for placing a piece on the board. What will be the easiest option for this, with good documentation for beginners of GUI programming? Is Makie.jl a good choice?
This is a simple implementation in Makie you could play around with:
chars = ['♛', '♚', '♜', '♜', '♝', '♝', '♞', '♞', fill('♟', 8)...]
pieces = [tuple.(chars, :black); tuple.(chars, :white)]
f = Figure()
ax = Axis(f[1, 1], aspect = 1)
hidedecorations!(ax)
hm = heatmap!(ax, isodd.((1:8) .+ (1:8)'), colormap = [:black, :white])
for int in keys(interactions(ax))
deactivate_interaction!(ax, int)
end
mevents = addmouseevents!(ax.scene, hm)
function place_random_piece!(square)
isempty(pieces) && return
i = rand(eachindex(pieces))
(marker, color) = splice!(pieces, i)
scatter!(ax, square; marker, color,
strokecolor = color === :white ? :black : :white,
strokewidth = 1,
markersize = 0.8, markerspace = :data
)
return
end
onmouseleftclick(mevents) do event
square = round.(Int, event.data)
place_random_piece!(square)
end
f
14 Likes
@hhaensel has created an awesome playable Monopoly clone with Genie/Stipple. I’m sure he has lots of helpful insights for building such a project.