I have no idea how to do the bold area. I had the idea of using a bool array and setting having it false for each unvisited edge but it seems too complicated for a variable size map/grid. Please help?
After leaving a pub, a drunk tries to walk home, as shown in following Figure. The streets
between the pub and the home form a rectangular grid. Each time the drunk reaches a corner, he
decides at random what direction to walk next. He never, however, wanders outside the grid.
Write a program to simulate this random walk. The number of rows and columns in the
grid should be variable. Your program should calculate, over many random walks on the
same grid, how long it takes the drunk to get home on average. Investigate how this
number depends on the shape and size of the grid.
Modify the original simulation so as to give the drunk some memory to help him, as
follows. Each time he arrives at a corner, if he has been there before on the current walk,
he remembers what streets he has already taken and tries a new one. If he has already
tried all the streets from the corner, he decides at random which to take now. How much
more quickly does he get home?