hunar4321 / particle-life

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

[Feature Request] A) Import/Export Weights/Params - and B) Time-dependent functions as a parameter #83

Open letshin opened 1 year ago

letshin commented 1 year ago

Hi, I have two requests,

1: Is it possible to import/export the weights as a CSV file or something similar so we can share parameters 2: Is it possible to include an input function for a time-dependent perturbation as a parameter. Maybe just a simple function which defaults to y(t) = x. but allows us to add in our own perturbations eg y(t) = sin(t) to perturb the potential as a function of time? Where t is whatever time unit is used for each 'step' of course.

ker2x commented 1 year ago

the C++ version already have an import/export, I assume you're talking about the js version ?

KhadrasWellun commented 1 year ago

2: Is it possible to include an input function for a time-dependent perturbation as a parameter. Maybe just a simple function which defaults to y(t) = x. but allows us to add in our own perturbations eg y(t) = sin(t) to perturb the potential as a function of time? Where t is whatever time unit is used for each 'step' of course.

What exactly do you mean by that? Please be more explicit.

letshin commented 1 year ago

@ker2x Yes, should be. I have been using https://hunar4321.github.io/particle-life/particle_life.html#91651088029.

@KhadrasWellun I would assume that each particle, n has a attraction/repulsion term for each other particle in the simulation let's call these terms n_x (x = 1, 2, 3... n).

For each time step, the position of each particle relative to its nearest neighbours change according to the magnitudes of n_x.

So, there add in a new integer variable, t_angle, which will be defined as the number of time steps for a single revolution (ie 2pi).

Then, add in another variable which is the equation input that is a function of t_angle, lets call this eq_in(t_angle).

Create a lookup table for eq_lookup = [t_angle, eq_in] for all values of t_angle.

Now let n_x * eq_loopup[n], n = 1, 2, 3... t_angle(max) and loop back to n =1 when n = t_angle(max).

This way, the attractive and repulsive forces can be multiplied by a time-dependent variable, e.g. a sine wave term or other more complex wavefunctions. The equation can be input through the GUI.