sprout

 

sprout is a patch-only primitive that allows us to ask patches to create new turtles. It must be used within an ask patches [...] context. For example, if we wanted to create a model in which each patch sprouted a flower once it was watered enough, we would write the following code:

ask patches [
    if water-level > 10 [
        sprout 1 [
            set shape "flower"
            set color yellow
            set size 0.1
        ]
    ]
]

Things to keep in mind when using sprout:

In the model example below, we have an empty garden and a farmer. Our farmer moves around randomly and fertilizes each patch. When a patch is fertilized, its pcolor turns into a lighter brown. Once a patch reaches a certain level of fertilization, it sprouts a new plant. If the farmer fertilizes a patch that already has a plant there, the fertilizer helps the plant grow.

 

Try it Yourself