CSC107 - Exam 2

Assigned Mar 12th 9am
Due Mar 12th, 9:50am


Read all questions before beginning. You will have 50 minutes from when you begin this exam until you must finish working. You may have one 3"x5" notecard. You are not allowed to use the internet in general for this exam, only what is linked from this page. You may use the computer to execute your model. You are bound by the Honor Code for this exam, which you need to sign. Write your answers and any procedures you write on a separate sheet of paper. Show your work on all problems for full credit.

Reference

Question 1

Download the Turtle Painters model by right-clicking on the link and saving it to the desktop. Open this model and click "Setup", you should see a number of people show up on the screen.

In this model, you are an artist interested in creating collaborative abstract art. You have hired the turtles to paint their world and make paintings for you. Set up the world so that there are four colors of turtles, red, green, yellow, and blue in equal distribution, so that each color is 1/4 of the population. This code should go where the procedures say:

; SPECIFY TURTLE COLOR HERE

For half credit, set up the world with three colors, red, green and blue, so that each color is 1/3 of the population.

Question 2

You must next add code to have the turtles paint the world. The turtles start by following a simple rule: if they see an empty (black) patch, color it with their own color, then wiggle. You need to complete the color-patch prodecure, where it says

; CODE FOR PAINTING PATCHES GOES HERE

Run the model 10 times, and report the average number of ticks it takes for the world to be completely colored (the model should be set up to stop at this point).

Question 3

You hire another set of turtles, but they are not entirely reliable with their color. If they see a black patch, they color it with their color, but if they see a patch that is already colored but is not their own color, they change into that color and start painting with this new color. For example, a red turtle encounters a blue patch, causing it to become a blue turtle, and this turtle is now painting black patches blue.

Replace your earlier code with this code in your model. Record again the average until all patches are colored over 10 runs. Discuss any differences between the paintings from the turtles in Question 2 and Question 3.

Question 4

You hire a third set of turtles, which follow a slightly different set of rules. If they encounter a black patch, they paint it their color, but if they encounter a colored patch that is not their own, they change into that color and color this patch black. For example, a red turtle encounters a blue patch, causing it to become a blue turtle and paint the blue patch black, and this turtle is now painting black patches blue.

Replace your earlier code with this code in your model. Record again the average until all patches are colored over 10 runs. (Note that this model might not end in a reasonable amount of time. If it has not finished after 10,000 time steps, stop the simulation and start again. Discuss any differences between this model and the models in Questions 2 and Questions 3. Why do you think this model behaves the way it does?

Question 5

If we observe in this model that every tick 15% of the patches are painted, and start with 20,000 patches, how many patches do we expect to be painted after 50 ticks?

You Must Turn In