I have several variables that can be inherited by child agents with a change of + 0.1 and -0.1, either without any changes or randomly. What I did is as follows: (The code is just an example)
to reproduce
ask turtle 1
[
let X-Of-Mother X
hatch 1
[
set X one-of (list (X-Of-Mother) (X-Of-Mother + 0.1) (X-Of-Mother - 0.1) (random-float 1))
]
]
end
Currently, I have to check if X of the baby turtle is always in range:
if X > 1 [set X X - 0.2]
if X < 0 [set X X + 0.2]
What could be the best way to do this?
What if I have to use random-normal 0.5 0.1, how can I limit it to values from 0 to 1, I have done many repetitions of generating such random numbers, I think that the quality of random normal is good, and there isn’t so many times that I need to check if it is out of range.
eg:
to test
Let c 0
let b 0
repeat 100000000
[Set b random-normal 0.5 0.1
if b > 1 [set C C + 1]
If b < 0 [set C C + 1]
]
print c
end
* 67 100000000 *
67 , , 58, 51,...