finjou
finjou

Reputation: 21

Netlogo : spawning a turtle on a certain patch with a certain pcolor

I'm working on a Simulation of a Stadion. I have created several rows with pcolor = 35. Now I need my number of turtles to spawn on the patches with pcolor = 35, but nowhere else. They also need to spawn randomly on those patches. My code for this problem looks like this:

to seat-people

set color green

setxy int random-xcor int random-ycor

if (pcolor = 35) [seat-people]

if any? other turtles-here [seat-people]

end

The turtles are green, spawn randomly and there is only one turtle per patch; but they won't spawn on patches with pcolor = 35 but everywhere! How do I do that?

I've seen a code with if (pcolor > 35) [seat-people], but I already have many other pcolors < and > than 35.

Upvotes: 1

Views: 3029

Answers (2)

King-Ink
King-Ink

Reputation: 2096

I think you are looking for the 'not equal' operator !=

 Ask n-of 20 patches with [pcolor != 35][sprout 1]

Upvotes: 2

drstein
drstein

Reputation: 1113

try with this. where N is the number of turtle you want to sprout and sprout 1 is the procedure to sprout 1 turtle which you can modify as you want.

ask n-of N patches with [pcolor = 35 and not any? other turtles-here][sprout 1]

Upvotes: 2

Related Questions