I have a few variables which can be inherited to child agents by a variation of + 0.1 and -0.1 or without any changes, or random again, What I have done is like this: (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 child turtle is always within range by something like this:
if X > 1 [set X X - 0.2]
if X < 0 [set X X + 0.2]
What could be a better way to do it?
What if I have to use random-normal 0.5 0.1 , how can I limit that to values between 0 and 1 , I have done many repetitions of generating such random numbers I think the quality of random-normal is good and there is not that many times that I need to check if it's beyond the range.
for example :
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
OUTPUT is *67 times out of 100000000 Time* 67 is biggest one I got, I got 58 , 51 , ...