Reputation: 449
I have a doubt/intrigued by a NetLogo situation. Also, I don't know if there is a solution and the exact reason for this to occur.
I made a small code to exemplify my question...
What happens is the following:
I would like to know why this happens? Will it be by the use of one-of?
And if there is any solution, because I need to see the turtle label in the interface to follow the model and check its operation.
If anyone has any ideas on how to resolve this and why this happens, I would appreciate it.
Thanks in advance :)
globals [ edge-size ValidHabs PatchSet ]
patches-own [ scale-patch ]
to setup
ca
random-seed 1
set ValidHabs [ [1] [2] [3] ]
set edge-size 60
set-patch-size 20
let list1 ( list 4 8 )
set PatchSet patches with [
( pxcor mod ( 2 + 1 ) = 0 ) and ( pycor mod ( 2 + 1 ) = 0 ) ]
(
foreach ValidHabs [
this-profile ->
ask one-of PatchSet [ sprout 1 ]
]
)
ask patches [
set scale-patch random 10
set pcolor scale-color green scale-patch -8 12
]
reset-ticks
end
to go
do-something
tick
end
to do-something
move-turtles
end
to move-turtles
ask turtles [
rt random-normal 0 90
fd 3
set color black
pen-down
set pen-size 2
]
end
;Interface button code (turtle labels)
;ask turtles [
; ifelse label = "" [
; set label ( who )
; set label-color white
; ]
; [
; set label ""
; ]
;]
Upvotes: 1
Views: 45
Reputation: 10291
Great job with the minimum reproducible example, that's really helpful! If I understand what you're asking, you're wondering why, despite setting random-seed
, there is a difference between your two runs? If that's the case, I think it's because you are doing an extra action (ask turtles [...
) that relies on randomness to operate. When you ask
turtles, the turtles act in a random order. So, if you need the turtles to move the same way each time, one quick way around that is to set the random number right before the action you're trying to replicate. For example, if I change your move-turtles
to:
to move-turtles
random-seed 123
ask turtles [
rt random-normal 0 90
fd 3
set color black
pen-down
set pen-size 2
]
end
And then run go 4 times, I get this movement pattern without labels:
And the same one if I setup
-> label
-> go
x 4:
Hopefully that gets you pointed in the right direction!
Upvotes: 2