2015-12-15

posted Dec 15, 2015, 4:46 AM by Samuel Konstantinovich   [ updated Nov 15, 2016, 6:52 AM ]
Goal:  ask agentset with [ x] [ command  ]    vs   ask agentset [  if x [ command ] ]

Do now:

On paper:
Write a setup function that:
turns the top quarter of patches red
turns the bottom quarter of patches green
turns a 3x3 block of patches in the middle white
turns the border of the screen (the last patch on the top/bottom/left/right) yellow


ask agentset with [ x] [ command  ]    vs   ask agentset [  if x [ command ] ]


LAB-N07
We want to make a pattern by spreading colors to uncolored neighbors.

to setup:
0. Clear all
1. Make a single patch   red + 3 .   
2. AFTER YOU TEST YOUR GO: modify this to make several patches random colors that end in 8

Let us define bright patches as having a color that ends in a number higher than 1. 

to go:  (forever button)
1. Ask the bright patches to spread their own color to the neighbors that are not bright
This will make a square pattern, OR a flowery random pattern depending on which method you use (explained later)

2. Modify this to spread a slightly darker color, so you get a fade effect.


[ PROPERTY ] of myself   is how you tell someone your property.
e.g.
[xcor] of myself    (this is a number)

You can use this in a command:
;patch context
ask turtles-here [set color [pcolor] of myself ] 




Note: The way you ask the bright patches matters. Make a 2nd go function that uses the OTHER command.

Go1:

ask patches with [ isBright ] 
    spreadColor
]

Go2:

ask patches [ 
    if isBright  
    [ spreadColor ] 
]

If you read the whole problem before writing it, you may now realize that making a funtion isBright could make your code cleaner

to-report isBright
   report   BOOLEAN EXPRESSION THAT TELLS YOU TRUE WHEN BRIGHT 
end

to spreadColor
    ;ask non-bright neighbors to become your color or a slightly darker color.
end

Comments