After trying all somewhat applicable solutions here to no avail, I still would like to see if someone can help me with this.
I have a type of turtle (sexworkers) divided along a boolean variable [trust?] and want to make a certain percentage/certain number (not so important) of one of the two types exit the model [die] every 10 number of ticks.
I tried and failed with the following:
tried to make half exit, BUT: kills all or most, not half. :
ask n-of (count sexworkers / 2) sexworkers [ die ]
this one works but kills too many. If there are more than 2 sexworkers on any given patch, all but one will die. Can I set this to percentage?
ask patches with [count sexworkers-here >= 2]
[ ask one-of sexworkers-here [ ask other sexworkers-here[die]]
]
this also kills all on each 10 ticks so too many for me
ask sexworkers with [trust?][ if ticks - birth-tick > 10 [die] ]
;all trusting sexworkers die when they are older than 10 ticks
should kill a certain percentage but the reporter variable is missing because of the boolean property instead of a number-based one
ask min-n-of (0.5 * count sexworkers with [trust?]) sexworkers with [trust?] [XXXXXXREPORTERXXXX]
[die]
Your first code is correct. Try this in a new model to see:
to testme
clear-all
create-turtles 150 [set color red setxy random-xcor random-ycor]
print count turtles
ask n-of (count turtles / 2) turtles [ die ]
print count turtles
end
You describe the problem as the code killing too many. I suspect you called it multiple times. For example, try this version:
turtles-own [trust?]
to testme
clear-all
create-turtles 150
[ set color red
setxy random-xcor random-ycor
set trust? random-float 1 < 0.1
]
print count turtles
print count turtles with [trust?]
ask turtles with [trust?]
[ ask n-of (count turtles / 2) turtles [ die ]
print count turtles
]
end
It assigns 10% of the turtles as having TRUE trust? and then asks each of those turtles to kill half the turtles still alive. Did you do something like that?