Reputation: 65
I'm trying to create a simulation where there are zombies and human turtles that move around the world. I'm using 2 sliders to create different numbers of zombies and humans. I want to set the color of zombies to green and humans to red. Here is my code so far:
to setup
cro Zombies
cro Humans
ask turtles [set shape "person"]
end
I'm not sure how I would be able to set the color of zombies and humans since they are only interpreted as numbers and I can't use:
ask Zombies [set color green]
Any ideas are appreciated thanks!
Upvotes: 0
Views: 33
Reputation: 10301
Is there any reason you don't want to use breed
s? It would probably make your life a lot easier in the long run. For example, this basic setup has two sliders like yours, but note that they are called "n-Zombies" and "n-Humans":
breed [ zombies zombie ]
breed [ humans human ]
to setup
ca
set-default-shape turtles "person"
; create a number of zombies set by the "n-Zombies" slider
create-zombies n-Zombies [
set color green
setxy random-xcor random-ycor
]
; create a number of humans set by the "n-Humans" slider
create-humans n-Humans [
set color red
setxy random-xcor random-ycor
]
reset-ticks
end
Gives you something like:
Upvotes: 2