CodingTrain / CodingTrain/Suggestion-Box

Particle life

Open
#1,507 0 comments 5 reactions 0 assignees View on GitHub
Challenge
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

As Conway's game of life, particle life also takes place on 2d grid, but there are no cells. In this version, instead of cells being dead or alive, you have n amont of particles. They move freely in plane, but follow some rules.
1. There are multiple different types (like red, yellow...). These different types can attract or repell each other. Physics law of each reaction has an equal and opposite reaction does not apply. Red can attract blue to itself but blue can repell red away from itself.
2. Each type has a repelling force to all types no matter what if points are closer than 'point a'. Point a is chosen randomly, but works best if it is between the radius of a particle and 3 radiuses. From point a to point b (approx. 4 radiuses - 7 radiuses), there is a random force (rule 1), but it does not fade with distance.
3. Points have drag. Otherwise they could accelerate infinetly.

To recap random forces, as it may have been confusing.
At start of the program, a random number of types are generated (if less than 5, it isn't interesting, more than 12 gives you mess)
Then you create 2d array. In this case there will only be red and green type, so array is 2 by 2. Red has an index 0 and green has index 1. Loop through every slot. If index from main array == index from subarray, the program only chooses point a (distance for repelling force to prevent particle overlapping)at a random distance and point b with the same distance as point a. That means force in area b cannot be applied as it is either a or out of range for b. We want that, because a red can't add force to another red particle (remember: this is only for index from main array == index from subarray case) If index from main array! = index from subarray that means we are looking at two different colors. Array[0 (red) ] [1 (green) ] for instance means the program has to choose what force red particle will add to green particle, if it comes inside a certain radius. Again, distance a is randomly selected and distance b as well, this time not the same as distance a. For that object in that array[0][1] the program also randomly picks a force (lets say betwen - 5 and 5). That means red particle can either attract or repell green particle, and at different forces as well (it only changes once the game is restarted and new values are picked. Throughout the game, particle can add force to another particle, but it can recive comletly different force back from that particle or even no force, if other particle is inside this's b radius and this isn't inside other's b radius. At the end of the tick, they are slown down (drag)

This gives you even more alive forms than Conway's game of life.

If this wasn't clear, check out CodeParade's video about this: https://youtu.be/Z_zmZ23grXE

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.