Animated image to illustrate sequence of moves

Using Plots.jl, you could do:

Plots_scatter_CartesianIndices

Code
#  ... resuming here from your code:
n = 5
init = CartesianIndex(1,1)
tab = CartesianIndices((1:n,1:n))
y = branch(init)

using Plots
t0 = Tuple(init)
scatter(vec(Tuple.(tab)), mc=:white, msc=:black, ms=10, lims=(0.5,n+0.5), ratio=1)
anim1 = @animate  for (i,yi) in pairs(y[1])    # consider first sequence y[1] of 25 moves
    scatter!(t0, mc=:grey, msc=:red, ms=10)
    ti = Tuple(yi)
    scatter!(ti, c=:red, msc=:red, ms=10)
    global t0 = ti
    annotate!((t0 .+ (0,-1/n))...,text("$i","Computer Modern",8,:top,:black))
end
gif(anim1, "Plots_scatter_CartesianIndices.gif", fps=1)
1 Like