Write a main program as follows:
program Lab12 implicit None integer*4 duration /100/, maxExp /10000/ real*8 distance(10000), angle(10000) call simulate(duration, maxExp, distance, angle) call showDistribution(maxExp, distance, angle) endThe robot starts at the origin and then moves one unit toward the right, left, up, or down, in one second. The choice of direction is uniformaly-distributed. We will allow the robot to move about for 100 seconds and record the polar coordinates of its final position in the two arrays distance (away from origin) and angle (of the final radial with the x-axis). We will take the angle in radians between -pi/2 and +pi/2. The above experiment will be repeated maxExp times (100,000 in the above main).
Main invokes simulate which populates the arrays. Note that it should work for any duration (not just 100) and any maxExp (not just 100,000). It does the simulation by invoking the sub
subroutine step(x,y) implicit None integer*4 x, ywhich takes the starting point coordinates (x,y) and return the new ones, also in x,y. The show sub simply tabulates the two arrays on a disk file so that each record would have three numbers: the experiment number, the distance, and the angle
Run the program and (using Excel) generate a chart with the experiment# on the x-axis and the distance as well as the angle as two series on the y-axis.
Modify the step subroutine so that the robot chooses to go EAST 40% of the times and chooses the other 3 directions with probability 20% each. Run the modified program and generate a chart using the new data. Prepare for checking: