Live data from Hacker News

Fireflies

ncase.me

41–50 of 93 posts

Re: Fireflies

#42
post #5

I 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?

No, partly because fireflies take a certain amount of time to "charge" so jumping mid cycle might not be plausible physically.

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

#43
If anyone is interested in this synchronization process or how it relates to synchronization in general, I highly recommend 'Sync' by Steven Strogatz. It's one of the best popular science/math books I've ever read, and Strogatz is a mathematician at the heart of the research, and a great writer as well, so you really get the story from someone who is a world expert, rather than an interested journalist.

Re: Fireflies

#44
ot, the patreon link comes up with an empty white page and pukes all kinds of js errors to the console for me

Re: Fireflies

#45

Nature 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…

Nudge the clock "forward", not increase speed. So the overall frequency will be a little higher, but it won't keep on increasing

Re: Fireflies

#50

Nature 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…

> If you see a neighbour nearby flash, when you are not flashing, nudge your clock forward by a bit.

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

Post reply on HN