PSO Intelligence

Discussion about PSO Intelligence
GH source file is being updated here!

I am doing an experiment about PSO basic rules, for the moment I am stuck in the part of creating a container in which boids will bounce and reverse direction; problem is boids are jumping out of the container due to the irregular trajectory they draw in 3d space which is not matching the steps of time…I guess,
if anyone is interested in this experiment please give me a hand …

For the rebound effect (reverse speed when out of the box) to work well, you also need to adjust the position. For example (in C#), for all coordinates:
if (pt.x < Bounds.x0) {
vel.x *= -1;
pt.x = Bounds.x0;
}else if(pt.x > Bounds.x1){
vel.x *= -1;
pt.x = Bounds.x1;

Keep in mind that in particle system, collisions are a process apart from that of the forces, and in your case a good place to apply it is after integrating the position, that is, you update the particle and then run the collisions.

1 Like

I was trying to push the position after collided , and I had been somehow succeeded, before I read your comment and got illuminated, so now I know the theory behind it , I appreciate your help!

Accordingly the updated script will be the following:

for i in range(3):

if pt[i] < 0 :
    vel[i] *= -1
    pt[i] = 0

if pt[i] > 100:
    vel[i] *= -1
    pt[i] = 100

a = v
point = pt