Hi I am trying to write a code to simulate a dorm buildings behavior and I am trying to model the movements of students within by creating multiple probabilities of which room they will move/ stay in for different times of the day. I have tried multiple methods using if and ifelse statments but the "decisions" the turtles to go to each room build off of the previous command when I want it to decide between 5 types of rooms at the same time. Here is one attempt I had:
if ticks <= 400
[ifelse random-float 1 < dr-stay-before-400
[setxy -4 random-ycor]
[if (random-float 1 <= dr-leave-before-400)
[setxy -8 random-ycor]
if (random-float 1 > dr-leave-before-400) and (random-float 1 <= dr-br-before-400)
[setxy 0 random-ycor]
if (random-float 1 > dr-br-before-400) and (random-float 1 <= dr-cr-before-400)
[setxy 4 random-ycor]
if (random-float 1 > dr-cr-before-400) and (random-float 1 <= dr-lr-before-400)
[setxy 8 random-ycor]
Did you get any replies to your question? Did you like any of them :)
I'm not sure what you want to do. Do you want to ask each turtle during
each tick to choose only one room, go there, then do it again the next
tick, up through tick 400? Do you have different kinds of turtles
represented by colors and each color has a different set of choices?
One thing about your first method is that you were sampling random-float
multiple times. That results in your actual distribution being somewhat
different from the uniform distribution you get from random-float. That
matters in that you may be skewing the outcome in ways you weren't
The thing about your second method (below) is that, while you're
computing the probability of a move based on the number of turtles of a
certain color, you're not picking turtles of that color. Your moving n
turtles out of the total number of turtles. Furthermore, you're sampling
n turtles with replacements, meaning that you will move some turtles
multiple times, and some turtles not at all.
At any rate, there are simpler ways to do what you want to do, but I
would need to understand your problem a bit better to recommend something.
On 07/12/2017 02:50 PM, shayla19 [hidden email] [netlogo-users] wrote:
Thanks for your inquiry.
The turtles themselves do not have their own colors. There are different color patches for each of the xcor and I want the turtles to move to these different colored patches or stay on their color patch based on a probability for each.
Let's say the probability of changing rooms is dr-leave-before-400 (and
the probability of staying is 1 - dr-leave-before-400). Furthermore,
let's say that the probability of going to a specific room is the same
for all rooms (that is, for five rooms, the probability of going to any
one of them is 0.2). This can be done with