Random Walker 2

This program models a “random walker” that starts at location 0,0, an intersection in the middle of a city laid out in square blocks. Each turn, the random walker moves one block to the north, east, west, or south, with the x-coordinate changing by 1 block or the y-coordinate changing by one block.

If the walker is moving around in an area that is 120 blocks wide (across the screen) and 30 blocks high (the screen height), we can graphically track the walker’s motion as she moves. Each time the walker moves to a new position, clear the screen, and use a pair of nested loops to print every location in the walker’s “world”:

At the bottom of the screen print the number of steps taken and the walker’s current position.