Reputation: 896
I am trying to have a turtle check the color of the patch ahead and make a decision on where to move. If the patch ahead isn't white then the turtle to rotate left or right and moves. I am getting an error in my If decision construct that says "Expected a TRUE?FALSE here, rather than a list of block". Any idea what might be causing it? I used the same logic for my while loops which seem to work fine. Below is my code and the error occurs in the first line of the code "ifelse [[pcolor] of patch-ahead 1 != white]".
ifelse [[pcolor] of patch-ahead 1 != white][
ifelse(tempx < xcor)[
set heading 270
jump 1
]
[
set heading 90
jump 1
]
]
Thanks in advance!
Upvotes: 3
Views: 4698
Reputation: 9142
You have a syntax error. The conditional in an ifelse should not be in a block.
Fix it as such:
ifelse [pcolor] of patch-ahead 1 != white [
....
Upvotes: 7