Reputation: 11
I have a microorganism that is eating 160 lettuce molecules. I want the microorganism to only eat one of the lettuce molecules every 60 ticks. How do I write that code in? Below is the code for the microorganism eating the lettuce molecules. Thanks in advance!
to go
ask microorganisms [
move
let food one-of lettuces-here
if food != nobody [
ask food [ die ]
]
]
tick
end
to move
set lettuce_index 1
loop [
ifelse lettuce lettuce_index != nobody [
face lettuce lettuce_index
fd 1
stop
]
[
set lettuce_index lettuce_index + 1
]
]
end
Upvotes: 1
Views: 83
Reputation: 17678
I can't work out what your move procedure is supposed to do. However, I don't think that's important to solve the 'only do this every 60 ticks' problem. The easiest way is to use the mod
primitive. So put your entire eating of food inside an if
condition with if ticks mod 60 = 0 [ ]
Upvotes: 1