Mothz

Exploring attraction and repulsion: Stage

"Like a Moth to a Flame"

“Thus hath the candle singed the moth. O, these deliberate fools! When they do choose, They have the wisdom by their wit to lose.”

chaos theory

If you look at our source code, you'll notice that our original metaphor for this attraction/repulsion simulation was the 'gnat.' However, to be more cultured, we adopted the 'moth' metaphor because it:

  • gave us a connection to Shakespeare
  • provided a way-cooler app name (Mothz)
  • was closer in nature to a butterfly than a gnat and therefore utilized the butterfly's literary connection to Chaos Theory via the short story The Sound of Thunder. The process we simulate certainly has a 'chaotic' feel to it! You can even watch or listen to Ray Bradbury's classic story for perspective!
Shedding some light :  Usage Tips
candle
Light Features:
  • You can drag it anywhere in the canvas in real time; moth activity will adjust
  • It's hue can be adjusted for a 'custom' look
  • It's size and intensity can be adjusted with the respective sliders
  • The light can be toggled on/off with the 'L.Off' button
  • The light can be hidden from view using the 'H/S L' button

Our 'flame' (or 'light' as it's mentioned in code) initially appears as a yellow circle in the center of the canvas.

It provides the initial 'pull' on the moths; when/if you include attractive or repulsive forces between moths, those are overlaid on the system, and you can even hit the 'L.Off' button to turn off the light!

If the light's turned off without other influences, the moths stop moving.

Moth Features:
  • Choose the number of moths in the system. The canvas will automatically reset
  • The initial moth speeds can be set with values in [0, 3]. Move the speed slider all the way to the right to get randomized speeds in [-2, 2]
  • Zero-attracted moths are a tint of green based on their mass/size (which are randomly assigned)
  • Moth attraction/repulsion is controlled by the 'Moth Attraction' slider; Attracted moths are a shade of red; Repulsion moths are a shade of blue. Color intensities increase with the strength of the force
  • The path of each moth can be reduced to a point by clicking the 'T Ph' (Toggle Path) button
swarm
Global usage:

The overall action speed can be influenced by the 'Frame Rate' slider.

The app may be resized and everything scales accordingly. The 'T Bg' button ('Toggle Background') will hide/show the paths of the moths. The canvas color may be selected with the color picker, and reset by clicking the 'Canvas' label.

The 'Reset' button takes the app back to 'factory settings.'

If you're thinking that this app is a cheezy way of introducing the concepts of force, acceleration, velocity, position and gravitation...you'd be correct! Daniel Shiffman's Nature of Code was a valuable resource in putting this app together!

Can you provoke a 'slingshot effect'?


...loading...