The first change: Simultaneous Attraction and Repulsion. The interaction force between two types of particles should be both attractive and repulsive simultaneously for the same interaction, but at different distances. In your application we saw that the particles either repel or attract. So the interaction forces between particle types (particle colors) must have different ranges depending on the pair of interacting colors. This means that there must be matrix of interaction radii between all combinations of particle colours (particle types) taken two by two, one for attraction and one for repulsion. There must also be a matrix of the intensities of the interaction forces, one for attraction and one for repulsion. So, I would like to introduce 4 matrices, one for the intensity of the attractive forces, one for the intensity of the repulsive forces, one for the radii of action of the attractive forces and one for the radii of action of the repulsive forces. That would be the first change. For example: Red attracts Green at -7 for a distance of 12 and Red repulses Green at +9 for a distance of 4. This means that in the range between Red and Green of 0-4 they interact like this: -7+9=+2, i.e. Red repels Green with an intensity of +2, over a distance of 4. In the range 4-12, they interact like this: -7+0=-7, i.e. Red attracts Green with an intensity of -7, over a distance of 4 to 12. On ranges greater than 12 the two colours do not interact. In conclusion, Green will stay permanently at a distance from Red of 4, and will be trapped in Red's attractive force until another outside force greater than 7 pulls it away.
Second modification: The Probability of Interactions. Each type of interaction between two colours has a certain probability of occurring. Thus, we will have a probability matrix for each matrix of force strengths (both attractive and repulsive forces). The probability range will be (0%, +100%).
Third change: The Viscosity of the Interaction field. When two colours of particles interact, a force field is formed as described in the first modification. That force field will have a certain viscosity, which will brake or accelerate the interacting particles depending on the sign of the viscosity. The viscosity range will be (-100%, +100%). Negative viscosity will accelerate the particles, positive viscosity will slow them down.
Fourth change: The Asymmetric Probability of Reactions. Every reaction between a particle of colour X and a particle of colour Y has a certain probability of occurring, which is different from the probability of the reaction between a particle of colour Y and a particle of colour X. This is determined by a reaction probability matrix, which has values in the range (0%, 100%).
Fifth change: Asymmetric Reaction distances: Each type of particle has a certain reaction radius to a certain type of particle, within its reactivity range. For example, red reacts to yellow at a distance x1, but to yellow reacts to red at a distance x2.
Sixth change: Reactive Affinity: This concept assumes that the particle of a given type (color) has the possibility of transforming into any of the other types (color), but with a matrix probability for each type of particle that enters in his reaction range. So the particle will change its probability matrix according to the type of particle that stimulates its reactivity. For examnple, in a reactive affinity matrix, red has a 12% probability of remaining red when a red particle enters its reactivity range but has a 33% probability of remaining red when a yellow particle enters its reactivity range, and so on.
Seventh change: Sequentiality. The intensity, probability and viscosity of each type of interaction will have different values for each distance unit within the range of interaction forces. In your application we saw that the attractive or repulsive forces have constant intensity over the entire interaction distance. The seventh modification would be to introduce variable intensities, variable probability of interactions and variable viscosity of interactions over the interaction distances. In the example above, Red attracts Green with an intensity of -7 over the distance of 12. With this second modification, these would be the interactions between Red and Green over the distance of 12: (-7, -5, +4, -2, +10, +4, -7, 0, 0, +8, 0, -2) with probabilities of (75, 23, 18, 99, 86, 100, 85, 33, 10, 0, 5, 64) and viscosities of (20, 14, 52, 0, 0, 65, 74, 4, 18, 90, 41, 11). A linear matrix is formed with different intensities for each interaction type, and another linear matrix for probability of interactions and another linear matrix for viscosity of interactions. Thus, Red can attract Green on some segments, but repel it on others with different probabilities and different viscosities.
Eighth change: Evolutionary Parameters: All simulation parameters can change over time. Each parameter (intensity of each type of force, range of each type of force, probability of each type of interaction, viscosity of each type of interaction, etc.) has a certain probability to increase or decrease by a certain user-defined percentage at each time step. Even the functions defining the intensities of the interaction forces have a certain probability of evolving, in the sense that they may increase or decrease by a certain user-defined percentage. The user will define a maximum value for the increase and a minimum value for the decrease for each parameter so that it does not evolve to values that can cause chaos in the simulation.
Ninth change: Circular motion. When the attractive forces cancel with the repulsive forces, and the force resulting from their combination is of zero intensity, then all the kinetic energy of the particles is converted into circular motion along the curved line where the forces cancel. The motion is not necessarily in the shape of a circle, but follows the neutralization curve, which can be circle, oval, or some other shape, but is always closed. This leads to the formation of a bond between particles and the creation of a meta-particle, whose edge is the line described by the edge of the particles moving on the neutralization curve. The particles remain bound until an external force (another particle or group of particles) intervenes to hit or influence them and remove them from the bound. With this property one can create groups of particles that form stable structures with stable bonds, necessary for another application option, i.e., the metaparticle.
Tenth change: Particle mass. Each particle colour has a certain mass. For example: red has mass 5, green mass 2, yellow mass 0, blue mass 8, etc. So each coloured particle generates a gravitational field around it whose intensity decreases as the square of the distance and with an infinite range. Mass can have positive or negative values. If the mass is positive, the particle will be a matter particle. If the mass is negative, then the particle will be antimatter. When matter and antimatter meet, the particles annihilate each other, producing a shock wave (repulsive force) whose strength is a function of the sum of the masses of the two annihilating particles.
It is also very useful to be able to save all the parameters of a simulation and load them later to run the simulation again and have the option to randomise any simulation parameter. Please disable the Escape key press action as I may accidentally close the simulation without saving it. It would be useful to have the 2D simulation space on the surface of a sphere of a certain radius set by the user, and the 3D or 4D on the surface of a hypersphere. That way it's easier to visualize and control the simulation.