Reputation: 35
please check this code. which part is wrong
to catch-lizards
let prey one-of lizards-here
ifelse prey = "lizard2"
[ show "WRONG" ask prey [die]
set lifetime = lifetime + hawks-life-gain ]
[ifelse droping-tail? = true
[ask prey [set shape "lizard2"
set lifetime lifetime + hawks-life-gain / 4 ] ]
[ask prey [die]
set lifetime lifetime + hawks-life-gain ]
]
]
end
problem is in place where (show "wrong") is written. that part doesn't execute. is syntax not correct?
Upvotes: 1
Views: 67
Reputation: 41686
In the ifelse prey = "lizard2"
part, you compare whether the prey
is the string lizard2
. But the prey is not a string, it is an object having some properties, like shape
or lifetime
.
So you need to ask whether the shape of the prey is lizard2
.
Update: Checking the shape of the prey probably looks like this:
ask prey [
ifelse shape = "lizard2" [
…
] [
…
]
]
Upvotes: 1