samedi 18 avril 2015

self-avoiding random walk and no turning back in MATLAB

There is a two-dimensional array, 8X8 cube =



-1 -1 -1 -1 -1 -1 -1 -1
-1 **2** **2** **2** **2** **2** **2** -1
-1 **2** 2 2 2 2 **2** -1
-1 **2** 2 2 2 2 **2** -1
-1 **2** 2 2 2 2 **2** -1
-1 **2** 2 2 2 2 **2** -1
-1 **2** **2** **2** **2** **2** **2** -1
-1 -1 -1 -1 -1 -1 -1 -1


For this array, a particle could move in the lattice, It starts from one side to the other side. Choose a site randomly from the outermost layer of value 2, as the starting point of particle moving. The particle then moves forward, it can turn left or right or go ahead, but no turning back, we can determine the moving direction by a random number. When the next site is -1, the particle stops moving. When the first moving route finishes, choose another site randomly from the outermost layer of value 2, do the same operation.


How to realize above-mentioned algorithm in MATLAB. The difficulty of programming is that the particle couldn’t turn back, which is difficult for coding.


enter image description here



One possible result, start direction B and C


enter link description here



self-avoiding random walk, and I need no turning back




Aucun commentaire:

Enregistrer un commentaire