# Dynamic Update for 2D Random Walk

I have code for a random walk

pt = Accumulate[{Sin@#, Cos@#} & /@ RandomReal[{0, 2 Pi}, 1000]];
boundary = {Min@pt, Max@pt};
Norm@Last@pt;
ListLinePlot[pt, PlotRange -> {boundary, boundary}, AspectRatio -> 1]


which produces something like this: I want to try to animate this, so that I can see how the random walk updates step by step with each new coordinate. I tried using DynamicUpdating but I couldn't really get it to work. Is there any way to achieve this? Any help is extremely appreciated!

## 1 Answer

Use ListAnimate. Also, you can make your path generation a bit simpler with AnglePath and your bounds are not correct as Min/Max will read from any coordinates, so I've used BoundingRegion instead:

pt = AnglePath[RandomReal[{0, 2 Pi}, 1000]];
bbox = Transpose[BoundingRegion[pt] /. Cuboid -> List];
ListAnimate[
ListLinePlot[Take[pt, #], PlotRange -> bbox, AspectRatio -> 1] & /@
Range[1, Length@pt]
] Or alternatively, use a Manipulate:

Manipulate[
ListLinePlot[Take[pt, i], PlotRange -> bbox, AspectRatio -> 1],
{i, 1, Length[pt], 1}
]