patches-own

 

patches-own is a special NetLogo keyword that allows us to define characteristics that belong exclusively to the patches in a model. These characteristics are variables that have a unique value for each individual patch. patches-own is helpful in modeling environmental variables. For example, if we wanted to create a model of pollution where a factory would pollute the patches immediately near them:

patches-own [pollution]
create-turtles 1 [
    set shape "factory"
    ask patches in-radius 3 [
        set pollution 100
    ]
]

Things to keep in mind when using patches-own:

In the model example below, we are modeling a garden with flowers. We define a nutrients characteristic for our patches and assign each patch a random number of nutrients between 0 and 10. We also change each patch's pcolor according to its nutrient level so that a darker patch indicates higher nutrient levels. Finally, we sprout a flower on each patch. Initially, each flower has the same size but when the go button is clicked, each flower grows according to the nutrition level of their patch.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the patches-own primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the patches-own primitive:
 
 
Similar primitives:
turtles-own

Declare a variable that belongs to turtles.

Read more
set

Changes the value of a variable (global, local, or agent-owned).

Read more
of

Reports the value of an agent-owned variable.

Read more
with

Reports a subset of the original agentset that only contains the agents with specified characteristics.

Read more
 
Learn another primitive: