lundi 24 février 2020

How to create two different random color groups in NetLogo 6.1.1?

How to create two different random color groups in NetLogo 6.1.1?

I am trying to create two different groups from the group of 250 turtles. The starting situation is that all 250 turtles are gray and then they will turn to yellow and pink groups one by one.

This code of mine makes all turtles in the beginning to be gray and then they will all turn to pink. I do not want this but I want two randomly made groups where pink turtles is typically either larger or smaller group of turtles than the yellow group of turtles in the end of the code run.

I just started to code with NetLogo 6.1.1. Thank you for understanding and all help and have a nice day.

[
  time

  person
]


turtles-own [ x ]

to setup

  clear-all
  reset-ticks
  set time  0
  create-turtles 250 

  [
      setxy random-xcor random-ycor 

  ]  

  ask turtles

  [
    set shape "person"
    set size 1
    set color gray
  ]

  end


to go 

  ask turtles


 [

    show random 2 = x

    if x = 1 [set color yellow] 
    if x = 0 [set color pink]
  ]


end ```



Aucun commentaire:

Enregistrer un commentaire