a is a 200x200 array of integers where two “walkers” take random walks. An element gets a 1 if Walker 1 steps there, a 2 for Walker 2, and a 3 if they both step there. The goal is to count the number of intersections. There is a syntax error at (if CurrentVal1==0:). I’m trying to get the value of the element into CurrentVal1 to test, and then set it accordingly - 1, 2, or 3.
“”"# Reset the variable that holds the value of the current position
# i.e. 0,1, 2, or 3 to 0.
# 0 = no one has stepped here
# 1 = walker 1 has stepped here
# 2 = walker 2 has stepped here
# 3 = both walkers have stepped here (intersection)
CurrentVal1=0
# If the new position is within the array
if startPos1[0]>=0 and startPos1[1]>=0 and startPos1[0]<200 and startPos1[1]<200:
#Get the current value of the new step location
CurrentVal1=a[(startPos1[0],startPos1[1])]
else:
# else go 1 step back and choose again
startPos1=startPos1-np.array(step1)
if CurrentVal1==0:
a[startPos1[0],startPos1[1]]=1
elif CurrentVal1=2:
a[startPos1[0],startPos1[1]]=3
XCount+=1
elif CurrentVal1=3:
XCount+=1"""