Saturday, November 28, 2015

Gen Landscape

The Processing code above is based on the logic implemented in this code I posted before. I just added some random attractors, timing for agents continous initialization and a function to render the field properly. What you get with this code is (a sort of) simulation of percolation. What's interesting I guess is that you can watch the landscape continously changing over time.
The code is written for Processing 2.0 and You will need Toxiclibs and ControlP5.
 N : turn on/off agent preview
 T : turn on/off agent tail preview
 D : turn on/off landscape preview

You can have a look at the code on my Git.

Below some screen captures of the code running:

Thursday, November 19, 2015

GitHub Repo

As I anticipated in my last post, in order to enhance better sharing and collaboration, I just opened a GitHub account where I uploaded the already shared sketches and all the codes and ongoing experiments yet to come. You can have a look here:

For any of you not familiar with source control and GitHub or simply interested in beginning to use it properly, I strongly suggest this tutorial . and the LearnGit course on codeAcademy.

May the fork be with you!

Monday, November 9, 2015

Field pathfinding

At the time this piece of code was written, I was investigating possible alternatives for pathfinding algorithms. This code came from an idea grown in my mind after working a bit with the fibrous system02 code I posted before. Fibrous system is based on proximity calculation: each agents checks distance to all other agents tail points. This is obviously computationally expensive especially when playing with big populations. The Fibrous system code was then optimized a bit introducing tree data structure, simply using Toxiclibs pointOcTree class, although you can notice improvements in the framerate only while playing with big populations. You can have a look at the code on openProcessing
At that time I was one of the backers of (the always great) Daniel Shiffman's "nature of code" project on Kickstarter and got fascinated by the chapters about Fields and Agents. The flowField class in the sketch linked below is a modification of the field class from Shiffman's book. I just added some functions for visualization and some agents behaviors. Each agent in the sketch reads data ( direction vectors) from the correspondent field's cell and overrides the previous cell with its current direction. The field becomes a substrate for agents communication (for a sort of pathfinding) and proximity calculation is completely avoided. You can try to run the sketch with 1 Million agents if you want, you will kill the framerate, but the sketch will run (consider that the rendering functions are completely unoptimized, just using VBO the code would run much faster). 

You can download the code here.
This the code I used to record this (crappy) video.

After running the sketch and let the system self organize a bit, you can press "c" to destabilize the field..the effects you will get are quite mesmerizing in my personal opinion and resemble a bit some natural behavior like slime mold diffusion .

I'm planning to upload these codes on Github too and I will start to do so from next week post on.
I have been thinking that maybe it would be generally more useful to make this publishing initiative more participatory, instead of being just me posting

If you have any question, critique or suggestion please drop a comment!

If you like the code and you would like to extend it in any way, we could work on it and post it again, so please drop a comment! 

If you have any idea on how to use this code for a project and want to collaborate, please drop a comment!

So well yes...drop a comment!:)

below some images of the sketch running: