I am attempting to model a physical process I'm observing in the lab with a random walk generator. I need to find a way to impose a condition such that when the random walk runs into a point in the field it terminates. Then I need a way to measure the distance of the walk. I would like to have 4 of these points evenly spaced from the center of the circular area I am working in. The code I am using for the random walk (from this answer by C.E.) is the following:
step[position_, region_] :=
Module[{randomStep},
randomStep = RandomChoice[{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}];
If[Element[position + randomStep, region], position + randomStep,
position]]
randomWalk[region_, n_] := NestList[step[#, region] &, {0, 0}, n]
visualizeWalk[region_, n_] :=
Graphics[{White, region, Black, Line[randomWalk[region, n]]},
Background -> Black]
visualizeWalk[Disk[{0, 0}, 30], 10000]
This code produces the random walk. I'm new to mathematica but I understand the basic principles enough to run these codes.