Continuation of flocking example

I have continued with the arraylist example called flocking.
I add health, age of boid, and a pecking order. Then, i can add predators. To amuse myself during a plague, i have been adding lifelike avoidance and hunting behaviors.
Like others have done, i have started a square wave oscillator, and tied it to the fraction of the prey species that are currently avoiding a predator.

Now, i am trying to go 3d. I had to give up on the nice directional arrow shape, and start with spheres. My spherical boids now have billiard ball collisions with others. They do not wrap but act like a boid gas confined in a clear box.

My new idea is to tune up the way that the spheres bounce off of one another to speed up the animation of the separation behavior, while leaving it very lifelike.

For now, i quickly sum all of the locations of the prey, to find the center of mass, and also find the average velocity of every sphere. Then i apply those cohesion and alighnment changes to the velocity in a single function.

Again, i am skipping the complicated check for collision risks, in favor of a simpler elastic collision with any sphere that is under 2 radii away.

I may be dreaming, but i am hoping that i can learn how to fly in the 3d sim. Vr is the obvious venue . I do not know how to link to code yet, but would be proud to share the simple code for the 2d and 3d sims.

I would even welcome help or participation in the project.

1 Like

Hi @alfrandell
Welcome to the forum.
Maybe you could place a link to the code?
Also, there is no coding question and you could consider renaming the category to Galery or something else.

Haha, normally, i am decent at using a website with forms, but this forum defeated me handily. Using an android tablet, my post appears in the gallery category. I was unable to change categories, unable to find any place to post code, and almost unable to post at all.

Probably have to give up , since the reply points out these faults without helping with changing the category or locating a place to post code. It has always been like this for me. I understand code , but not other people.

Moved this to “Development”.

For that, you might want to look at Processing for Android – since that is one of the easiest ways to do VR projects with processing, especially if you plan to use your mobile phone with a Cardboard headset.

For projects with many files, easiest way is to create a free GitHub account and upload the code there, then post a link to it here. Would love to see it.

If you have small code in one file, you can paste the code into a forum post, then put ``` above and below it to format it.

Or highlight it and press the forum editor </> button.

I did manage to upload the 2d version to

It requires the sound library, and runs on computer and on the android version of processing called adpe…i think that i need to add back button function so that it is easy to quit full screen mode.

1 Like

Thanks.

I started a git hub account and uploaded a zip file of the directory in my sketchbook.

Great! One further recommendation – upload the files, not a zip. Github works much better with the files, so that people can browse, comment, test, suggest changes, etc.

1 Like

I am accessing github using an android tablet.
I have not succeeded in creating a directory structure at github.
The zip file contains 3 .pde files and a data directory with files.

Perhaps someone will download the zip and run it.