# Options for simple board game GUI

**URL:** https://discourse.julialang.org/t/options-for-simple-board-game-gui/119851
**Category:** General Usage
**Tags:** makie, gui, deep-learning
**Created:** [September 25, 2024, 9:13am UTC](https://discourse.julialang.org/t/options-for-simple-board-game-gui/119851 "2024-09-25T09:13:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)
#### Post date: [September 25, 2024, 9:13am UTC](https://discourse.julialang.org/t/options-for-simple-board-game-gui/119851/1 "2024-09-25T09:13:23Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [September 25, 2024, 9:41am UTC](https://discourse.julialang.org/t/options-for-simple-board-game-gui/119851/2 "2024-09-25T09:41:53Z")

</div>

This is a simple implementation in Makie you could play around with:

```julia
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

```

---

<div class="post-metadata">

### Author: ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)
#### Post date: [September 26, 2024, 7:04am UTC](https://discourse.julialang.org/t/options-for-simple-board-game-gui/119851/3 "2024-09-26T07:04:50Z")

</div>

@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.
