2017-10-24 LAB!

posted Oct 24, 2017, 6:13 AM by Konstantinovich Samuel   [ updated Oct 24, 2017, 6:20 AM ]
Goal: LAB-N02 (2 day lab)

Read all directions.
Read all the directions AGAIN.
Post any questions about the specifications on the mailing list.

Pre-Lab:

Big idea 1: Buttons should be observer context, and setup/go should be observer context.
We often want both turtles and patches to do things in your model. This is why 
An observer can :
ask turtles [  <turtle context command block> ]
ask patches [ <patch context command block> ]

This is useful when you want to write a 'go' function. It will free us to tell turtles, patches and other sets of things in our program to do things using one forever button.

Big Idea 2:
In this lab, turtles in different quadrants will behave in different ways. Because of this, we would like our wiggle to act differently for individual turtles. We need to use parameters in this case, instead of linking it directly to a slider.
Use your wiggle function, it should have two parameters like this:
to wiggle [ howFar  angle]
  ;code here
end

TERMINOLOGY: A 'frame' is one execution of the go command. Every time you run go, netlogo will draw the screen once. We call this a frame, just like in animation.


Lab specifications: 

-On a new sheet of paper: date your notes, and record ALL of your paper work for this lab on this paper.
-Answer the questions Q1,Q2, etc. in your lab notes, as well as in the lab as a comment. (They should be at the top)

Note: On a lab/test I will never tell you to run a command, I will always describe what your goal is, and you make it happen.


1. You should have a setup button and a go button.
-Setup : call the setup procedure
-Go : call the go procedure, this should be a forever button.

We generally want our go procedure to look like this:
to go
  every 1 / 60 [
    ;<code here>
  ]
end

Q1: How do you make your program go faster/slower with the every command? 

2. Sliders

a - Turtles regular speed that is determined by a slider turtle-speed 
This ranges from 0.01 to 1.0 with an increment of .01

b - Turtles have a maximum wiggle angle that is determined by max-turn-angle 
This ranges from 1 to 180 degrees with an increment of 1.

c - The number of turtles spawned in the setup is based on the slider num-turtles 
This ranges from 1 to 100 inclusive, in increments of 1.

d - Turtles can grow in this model, they are limited by the slider max-turtle-size 
This ranges from 1 to 5 with an increment of 0.5.

4. Setup:
a - Reset the world completely
b - Spawn a number of turtles based on the num-turtles slider. 
c - Set the x and y positions of the turtles randomly based on your world size. They should be distributed evenly throughout the entire world.

5. Go:
Q2 - Explain what it means when I tell you "You can make the random turn in wiggle equal probability or biased"

a - Turtles move in a wiggle-like manner using the speed and angle sliders. 



b - The world has 4 quadrants and the turtles behave differently depending on which quadrant they are in. 
- You should use an if statement to make the turtle choose one of 4 different behaviors, you should write each behavior in a separate function to make your code cleaner! These functions are:
quadrant1
quadrant2
quadrant3
quadrant4
Do not worry about which quadrant behavior turtles that spawn with an xcor or ycor equal to 0. (Effectively it doesn't matter if you compare with > or >= )

Here is what each turtle must do in every frame:

Quadrant 1 Turtles  run a quadrant1 command that:
-wiggle aturtle-speed but do not turn. 
-color: change to red.
-size: decreases by 0.1 per frame every frame but cannot shrink below size 1.
You should write a helper function that the turtle can run to reduce their size! This will put the logic in a separate place and make your code more readable. A reporter would be VERY clean here. e.g.
set size decrease-by-one-tenth-no-lower-than-1 size
or
set size decrease-no-lower-than-1 size 0.1 

Note that: 
-Some helper functions would breusable!

Quadrant 2 turtles run a quadrant2 command that: 
-Wiggle at double turtle-speed, turning up to max-turn-angle
-color: increases by 0.1 , such that the ones digit never passes a 9 (ones digit should stay at 9 if it passes 9,  19 stays 19, 39 stays 39.)
-size: decreases by 0.2 but cannot shrink below size 1.
You should write helper functions that the turtle can run to reduce their size and another to increase their color! This will put the logic in a separate place and make your code more readable. Again, a reporter would be nice.


Q3 - How do we get the one's digit of a variable? The rest of the digits? (Look up in the math portion of the dictionary)

Quadrant 3 turtles  run a quadrant3 command that:
-Wiggle at half turtle-speed, turning up to double max-turn-angle
color: no change! Don't write anything about color here.
size: increases by 0.1 every frame up to a maximum size of max-turtle-size
You should write a helper function to help here!

Quadrant 4 turtles run a quadrant4 command that:
move: forward at turtle-speed
turn: randomly up to max-turn-angle
colors: set to a random multiple of 10 + 5 like 15 25 35 etc.range is 5 to 135.
size: decreases by 0.1 every frame but cannot shrink below size 1.
You should write a helper function to help here!

(I will post submission guidelines tomorrow)
Comments