1 pointby cscmsg2 hours ago1 comment
  • cscmsg2 hours ago
    I was at my desk when a large and very loud fly started circling my head and tapping the screen. I swatted it but missed every time, so I casually asked my AI assistant why. That kicked off an interesting thread.

    I was surprised to learn that a fly does not curve. It flies a straight run, turns 90 degrees in 0.05s, then flies straight again (Wagner 1986 for houseflies; Tammero and Dickinson 2002 for fruit flies).

    I also learned that each straight section has random duration (obstacles excepted). The pattern is exponential, which makes it very hard to predict. Watching it for longer really doesn't help.

    Human reaction time is 0.15s at the fast end, so even if you guess correctly, it may still be gone. However, you still have a chance, which is why we keep coming back, in the game and in real life.

    The resting fly research is Card and Dickinson (2008). It shifts position to jump away from the swatter and is off the wall in 0.2s, before your arm has moved. So standard advice is to aim a little ahead of where it faces.

    The parameters are printed on the page. Depth is not modeled and the page says so.

    20 swats, then you see your percentage score. I'm getting better, but still top out at about 25%.

    It's plain JavaScript with no framework and no dependencies. Tests are node --test with nothing to install. No cookies... because they attract flies :)