Search code examples
matrixmapleautomaton

Matrix represented as blocks - Maple - Cellular automaton


I only have very basic Maple skills and unsure how to represent a matrix as graphically as blocks, where 1 in the matrix corresponds to a block and a 0 corresponds to an empty space.

Please see my code below where I am adding a "1" i.e. a block to the central column in a loop. I was wondering whether this is any way this could be animated in maple, with the "1"s as solid squares.

This is a picture of what someone achieved with a different software. Any help would be much appreciated, thanks.

restart;
with(LinearAlgebra):
with(MTM);
with(RandomTools);


M := Matrix([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]);


for a to 4 do if (sum(M, 1))[3] < 5 
then z := max(ListTools[SearchAll](0, M..., 3))); 
M(z, 3) := M(z, 3)+1 
end if; 
print(M):
end do;

Solution

  • I believe the Maple command plots:-sparsematrixplot will get you most of the way there. An sequence of such plots could be animated with the plots:-display command and its insequence option. For example, 10 random matrices:

    L := NULL;
    to 10 do
        L := L, plots:-sparsematrixplot(LinearAlgebra:-RandomMatrix(6, 6, generator = 0 .. 1));
    end do;
    
    plots:-display(L, insequence)