Ostrich





This is another random-walk-simulation program. When you try to simulate movements of running animals or moving vehicles, you know that they cannot stop on a dime, or suddenly change direction when they are moving fast.  This phenomenon is called momentum, and it means than when an object or an animal is moving fast, its ability to change its speed and direction is limited.
We will include this element in our "Ostrich" program by making the size and direction of the next step of our imaginary ostrich depend on the length and direction of the previous step.

 

 

 

 

 

 

 

 

 

 

 

The calculator environment for running your Ostrich program is the same as for the Flea:
 Set the MODE: CLASSIC, DEGREE, PARAMETRIC
 Set the FORMAT: CoordOff, Axes:Off
 Use ZOOM to set the window: ZStandard, ZSquare
 Set the window: Tmin=0, Tmax=360,Tstep=3
 Define a circle of radius 10,
\X1T=10cos(T)
 Y1T=10sin(T)

PROGRAM:OSTRICH
:0→A:0→B:0→N:0→V:0→W(1)
:ClrDraw(2)
:While A2+B2<100(3)
:360rand→Q:.2rand→F(4)
:.7V+Fcos(Q) →V(5) 
:.7W+Fsin(Q) →W(6)
:A+V→C:B+W→D(7)
:Line(A,C,D) (8)
:C→A:D→B:N+1→N(9)
:DispGraph:End(10)
:Pause:N(11)

 

Explanation of the program
 (1) A, B are coordinates of the location of the ostrich at the beginning of each step, and C, D are its coordinates at the end of the step. V = C - A and W = D - B describe the direction and the length of a step. We assume that each step takes approximately the same time, so V, W also represents the velocity of the ostrich. N is the number of steps taken.
 (2) The previous picture is erased               
 (3) The program runs as long as the (imaginary) ostrich stays within the circle.
 (4) To make the next step, the ostrich has to apply some force (make some effort). The force has direction Q, which depends on whether the ostrich wants to speed up, slow down, or just turn left or right, and it also has a magnitude F (big or small effort). You may change the value .2. This value represents the size and strength of your imaginary ostrich. A bigger value would describe a bigger and stronger ostrich that takes longer steps and moves faster.
 (5) and (6) The direction and magnitude of the force applied change the velocity of the ostrich. In simpler terms, the difference between two consecutive steps depends on Q and F. You may change the value .7.  It represents how smooth the running surface is. The value 1 represents a very smooth surface on which an ostrich can run fast. Values close to 0 represent something like tall grass or a rocky desert on which the ostrich cannot move very fast.
 (7) and (8) The end-point of the next step is computed and the line representing the step is drawn.
 (9) The end of the last step becomes the beginning of the next step. The number of steps is updated.
 (10) The random walk picture is displayed
 (11) After the ostrich runs out of the circle the movement stops. Press ENTER to stop the program. The total number of steps will be displayed.

Experiment with changing the size of the ostrich (.2) and the kind of surface (.7).

Here are some random walks with size = .2 and kind of surface =.7.  The number of steps is also shown.

 

 

 

 

 

 

 

 

 

 

                                                   

 

 

 

 

Here is a random with size = .5 and surface = -9. Notice how many fewer steps were taken:



                                                               


Webpage Maintained by Owen Ramsey
Lesson Index