Fireflies
41–50 of 93 posts
Re: Fireflies
#42I think the example works more quickly than it should due to the line "if(ff.clock>1) ff.clock=1;" Every time the clock goes over 1, wouldn't you mod the clock value, not set it to 1 exactly?
So what this line does (which is in the section of code where a flash alters the fireflies around it) is that after advancing the other fireflies clocks, if any are over 1 then it puts them in the right state to flash on the next time they're evaluated. If you mod it, then you would have the logic:
"if I'm a firefly and see my neighbour flash while just about to flashing myself, don't flash but reset my clock to part way through the cycle"
rather than
"if I'm a firefly and see my neighbour flash while just about to flashing myself, flash as well"
Edit - setting it to one ensures that each neighbour can't keep adding to the clock, advancing it to a random point in the cycle.
Re: Fireflies
#43Re: Fireflies
#44Re: Fireflies
#45Nature has the best algorithms, don't it folks? I have a question about a detail. The rule is: 1. When you see a nearby neighbour flash, nudge your own clock forward. 2. That's it. My question is -- when the fireflies are firing at the same time, they see each other flash, so they all nudge their clocks forward, correct? Assuming they don't nudge their clocks forward at the same amount, they would fall out of sync, c…
Re: Fireflies
#46Re: Fireflies
#47http://www.sciencedirect.com/science/article/pii/S0378437116...
Re: Fireflies
#48Re: Fireflies
#49Re: Fireflies
#50Nature has the best algorithms, don't it folks? I have a question about a detail. The rule is: 1. When you see a nearby neighbour flash, nudge your own clock forward. 2. That's it. My question is -- when the fireflies are firing at the same time, they see each other flash, so they all nudge their clocks forward, correct? Assuming they don't nudge their clocks forward at the same amount, they would fall out of sync, c…
I think this is it. There could be some missing detail (e.g. a firefly is unable to "see" when it flashes) which keeps them from nudging their clocks once already in sync