Question: drunken sailor random walks

i want to write a program to simulate a walk of a drunken sailor who walks out of a bar at the centre of a city. the city has a regular pattern of 24\24 square blocks. the sailor doesnt know where he is going and how to exist teh city. the question is how many blocks will he have to walk to exit the city?

let him start at the centre of the city and assume that he exists the city when he reaches either north, east, south or western borders. it can happen that he wlks over pArts thta he already traversed. make a few plots  of the typical paths that he might follw to exit the city. how many blocks does he need to walk to exit the city?

how to repeat the random walk many time without making a plot and how to make a histogram, how to calculate the avarage number of steps to exit the city?

repeat the random walk now with the drunken sailor starting at a random position within the city.

assume that the sailor needs get to the harbour where his ship is waiting on the east side of the city. Let him start again at the centre of the of the city, and whether he gets to border on the east, his mates will help him get on board his ship. when he reaches the north, south or west border, he realise he has to turn around. simulate the walking around of the sailor with these new conditions. make a few plots to show typical paths that he might follow. also make a histogram of the total numberof steps taken to reach the harbour.

Please Wait...