The Task

In Netlogo, upgrade the simple blocks program we did in class.

The Blocks Program

the program will:

  1. use a slider to determine the number of yellow blocks (patches. This can be from 0 to 100 blocks.
  2. use a slider to determine the number of red blocks (patches). This can be from 0 to 100 blocks.
  3. use a slider to determine the number of turtles. This can be from 0 to 10 turtles.
  4. create a button labeled Turtles that when pressed will create the indicated number of turtles. The turtles must be white, placed at a random location, and pointed in randomly in one of the 4 directions (N, S, E, W) and have a pen-size of 2. They start with their pen down. It does not clear the screen.
  5. create a button labeled Yellow that when pressed will create the number of yellow blocks in random places indicated by the slider. It is allowed to create 100 blocks but some blocks may accidentally overwrite other blocks.
  6. create a button labeled Red that when pressed will create the number of red blocks in random places indicated by the slider. It is allowed to create 100 blocks but some blocks may accidentally overwrite other blocks.
  7. There needs to be a button labeled Step that first moves the turtles one step forward and then:
    • If the turtle is on a yellow block, the turtle will turn right 90 degrees and turn the block green.
    • If the turtle is on a green block, it will turn left 90 degrees and turn the block yellow.
    • If the turtle is on a red block it will turn the turtle white. And turn the block to blue.
    • If the turtle is on a blue block it will turn the turtle yellow. And turn the block to red.
  8. There needs to be a button labeled Go that does Step forever.
  9. There needs to be a button labeled Setup that clears the screen of all blocks and turtles. But does not create any turtles.
It is important that on a single step only one of the block interactions occurs on a given step. For instance, if the turtle lands on a yellow block it does NOT turn right, turn the block gree and then turn left and turn the block back to yellow. That is, actions should not effect each other in the same step. We discussed this in class. (Hint: use ifelse statement)

Submission

Save your results as a .nlogo file and submit the file to "Assignment 5" in the BBLearn page for this class.