I'm trying to run a MC simulator for a Markov Chain that is uniformly distributed among all NxN matrices that have no neighboring 1's. My algo is supposed to fill up the state space by running the chain a bunch of times. However there's something horribly wrong with my logic somewhere and the state space just isn't filling up. Any help would be greatly appreciated. Here is my code.
import random
import numpy
M=numpy.zeros((52,52),dtype=int)
z=0
State_Space=[]
for i in range(1,100):
x=random.randint(1,50)
y=random.randint(1,50)
T=M
if T[x][y]==1:
T[x][y]=0
if T[x][y]==0:
T[x][y]=1
if T not in State_Space:
if T[x+1][y+1]==0 and T[x+1][y-1]==0 and T[x-1][y-1]==0 and T[x-1][y+1]==0:
State_Space.append(T)
M=T
else:
if T[x+1][y+1]==0 and T[x+1][y-1]==0 and T[x-1][y-1]==0 and T[x-1][y+1]==0:
M=T
print State_Space