i need help. what i think i have to do is choose a direction at random and then look at a direction i want to go to if it's empty then carry on. if the direction is used then you start another walk. 1000 walks and lenght 1 to 25. how do i calcalute the number of successful walks. the code i have is a random walk
r=[0 0];X=[0];Y=[0];fort= 1:1:100B=rand(1,1)*4;if B<1new_position=r+[1 0];elseif B<2new_position=r+[0 1];elseif B<3new_position=r+[-1 0];elsenew_position=r+[0 -1];endX=[X new_position(1)];Y=[Y new_position(2)];r=new_position;endplot(X,Y)
Best Answer