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

Updating state is not really done "correctly" #18

Open pstray opened 1 year ago

pstray commented 1 year ago

As all the rules modify state, later rules are influenced by the effects of earlier rules... if this should be a "correct" simulation, all forces had to be calculated first, then applied to to the state. But the simulation is much more interesting with this bug ;)

hunar4321 commented 1 year ago

The modified Javascript file fixes that. I may modify the C++too but this might change the parameter settings to different numbers in order to reproduce similar patterns. For now, I'll leave it like that.

pstray commented 1 year ago

Yes, not even sure you can get the same results if you make the simulation "correct"

dangarfield commented 1 year ago

One other point to note is that the fx fy values are also iteratively updated, which means that if you were going to fully GPU parallelise the fx fy calculations, it wouldn't be possible in the current method as the earlier atom x, y positions are updated. If you fully calculate the fx fy values in parallel before applying any values to any given atom x y, it just doesn't look very good. I experimented with this using gpu.js and whilst it works (using matrices rather than objects), nothing looks anything as interesting as when the updates are applied progressively.

You can, of course, apply parallelism to each individual atom, but there is no real performance benefit, in fact it is worse than using the basic matrices.

IRobot1 commented 1 year ago

Great minds thing alike.
A 3D version was also implemented here.
The VR experience really makes a difference

hunar4321 commented 1 year ago

Great minds thing alike. A 3D version was also implemented here. The VR experience really makes a difference

I don't have VR but I imagine interacting with the particles with attraction/repulsion gestures can be so fun