Skip to content

Instantly share code, notes, and snippets.

@humachine humachine/Ant_Grid
Created Sep 15, 2014

Embed
What would you like to do?
Ant_Prob
import sys
import numpy as np
prev=np.zeros((7,7))
now=np.zeros((7,7))
prev[3,3]=1
N=15
for i in range(N):
# print prev
for x in range(1,6):
for y in range(1,6):
now[x,y]=0.2*(prev[x-1, y] + prev[x+1, y] + prev[x,y-1] + prev[x,y] + prev[x,y+1])
# print x,y, prev[x-1, y] ,prev[x+1, y],prev[x,y-1],prev[x,y],prev[x,y+1], now[x,y], prev[x,y]
for x in range(1,6):
now[1, x]+=0.2*prev[1,x]
now[5, x]+=0.2*prev[5,x]
now[x, 1]+=0.2*prev[x,1]
now[x, 5]+=0.2*prev[x,5]
some=1*prev
prev[:]=now
print now[3,3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.