Home/ Logo/ Projects/ Drunkard's Walk

Drunkard's Walk Project

Screen Shots | Rate the Project | Bottom of Page
Next Section Next Section

Background

This project implements another version of the 'drunkard's walk'. In the version most people are familiar with a drunk is standing next to a lamp post and begins walking making turns at random. What does his path look like and where will he wind up?

In this version a drunk is asked to leave the establishment he was imbibing in. Once on the sidewalk the door closes behind him and he can walk either towards the street or back towards the door, randomly choosing a direction before he takes each step. If he bumps into the door he turns around, if he reaches the curb he falls into the street ending his walk.

Will he ever reach the street? How long will it take? What will his path look like?

In his book Full House Stephen Jay Gould uses this example to illustrate his argument that lifes seeming directed movement torwards higher and higher complexty can be explained entirely as random motion.

Implementation

The basic project is fairly simple; place a turtle at one side of the screen, and have it turn randomly left or right and move so many steps. If we reach the left boundary turn right and start again. If we reach the right boundary the walk is over. Add a few buttons to control things, a slider to set the size of each 'step', a text area to record the number of times we 'stepped' and we're done.

Once the basic project was written I wanted a way to plot the turtles movement, to draw a graph of its movements. How can we do this? The traditional way is to create a data structure, an array most likely, with each element of the array corresponding to one spot on the path. We record the number of times the turtle lands at a particular spot in the arrray. Once the walk is finished we can take this data and plot the turtles movements. One drawback to this approach is that the data structure can get hard to handle and in MicroWorlds there is no 'array' data type so we would have to implement our own out of lists. Possible but not easy.

Another approach is to use MicroWorlds multi-turtle capabilites.

Plotting with Turtles

How can we use turtles to draw the data? We hatch a turtle for each spot on the path that the 'drunk' turtle can stop. Then each time that turtle takes a step the corresponding 'plotting' turtle moves forward one turtle step.

This project uses the multiple turtle routines I introduced in the Circles project.

Rate this project.

Rate this project.

Previous Top Previous

Home | Top of Page | Logo | Screen Shots | Projects