Currently I am building a route for a truck to drive inside my netlogo-land. When the truck is next to the shop-patch where it should deliver, the truck needs to change its actions.
However my if
or ifelse
statement does not seem to respond well and the answer depends on the output. With some tests:
*turtles> ifelse ((patch (first dirx) (first diry)) = one-of neighbors4) [write "11"] [write "22"]
"11"*
*turtles> ifelse ((patch (first dirx) (first diry)) = one-of neighbors4) [write "111"] [write "122"]
"122"*
*turtles> ifelse (patch (first dirx) (first diry)) = one-of neighbors4 [write "111"] [write "122"]
"122"*
*turtles> ifelse (patch (first dirx) (first diry)) = one-of neighbors4 [write "11"] [write "12"]
"12"*
*turtles> ifelse (patch (first dirx) (first diry)) = one-of neighbors4 [write "11"] [write "22"]
"11"*
Please note that during this time I do not move my truck, I use the command center to ask these questions (from turtle truck perspective).
I am very confused about this. As the only thing I change is the action (what to write). This should not impact the true/false statement itself.
Does anybody have any clue what is going on here and why the ifelse
responds strange?