| Mosel
code to generate sparsity visualisation of permissible
moves matrix |
|
model 'display matrix A'
uses 'mmxprs', 'mmive'
parameters
s = 8 ! number of squares per side
end-parameters
declarations
S = 1..s ! range of squares per side
n = s*s ! number of squares
N = 1..n ! range of squares per board
sq1, sq2: integer
x: dynamic array(N,N) of mpvar ! 1 if we leap from i to j
end-declarations
forall(i1,j1,i2,j2 in S) do ! for each pair of squares
if( (i1-i2)^2+(j1-j2)^2 = 25) then ! if there is a legal move between them
sq1:= j1+s*(i1-1) ! create the x
sq2:= j2+s*(i2-1)
create( x(sq1,sq2) )
end-if
end-do
GRAPH:= IVEaddplot("A", IVE_RGB(0,0,160))
forall(i,j in N | exists(x(i,j) ) IVEdrawpoint(GRAPH, i, j)
end-model
|
|
|