My ifelse statement's result depends on the actions for true/false?

Posted by Antal on Stack Overflow See other posts from Stack Overflow or by Antal
Published on 2010-06-03T06:29:22Z Indexed on 2010/06/03 6:34 UTC
Read the original article Hit count: 247

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about if

    Related posts about netlogo