hunar4321 / particle-life

A simple program to simulate artificial life using attraction/reuplsion forces between many particles
MIT License
2.98k stars 297 forks source link

More rulesets for the JS version? #1

Closed pachacamac closed 1 year ago

pachacamac commented 2 years ago

Awesome project! Could you give a few more examples for rule sets for the JavaScript version?

redblobgames commented 2 years ago

Adapted from the video, 7m44s:

    rule(red, red, 0.1);
    rule(yellow, red, 0.15);
    rule(green, green, -0.7);
    rule(green, red, -0.2);
    rule(red, green, -0.1);
    rule(yellow, yellow, 0.01);

I upped the yellow particle count to 1000 for this, and added the yellow-yellow rule.

hunar4321 commented 1 year ago

particle_life.html now have randomized settings. You can refresh until you find an interesting pattern. However, in my experience, the best way to find killer patterns is to have real-time GUI controls where you manually tweak the parameters and have a visual feedback of what happens. Without that I wouldn't have any of the interesting patterns shown in the video!

redblobgames commented 1 year ago

Here's a set I liked:

yellow = create(450, "yellow)
red = create(200, "red")
green = create(300, "green")
rule(yellow, yellow, 0.02)
rule(yellow, red, 0.10)
rule(yellow, green, -0.10)
rule(red, red, -0.15)
rule(red, yellow, 0.20)
rule(red, green, -0.30)
rule(green, yellow, -0.25)
rule(green, red, 0.15)
rule(green, green, 0.40)
hunar4321 commented 1 year ago

Guys the JavaScript version became more interesting with contributions. Check it out.

redblobgames commented 1 year ago

Guys the JavaScript version became more interesting with contributions. Check it out.

nice! btw if you go into the github project settings, you can enable Github Pages, and then it will host the js version at https://hunar4321.github.io/life_code/particle_life.html . That way people can try it out without having to make a copy somewhere.

hunar4321 commented 1 year ago

The JavaScript version now almost has a fully featured GUI with many facilities to generate & share interesting patterns.