Jump to content
sasbom

"active" infection based growing solver doesn't cook well

Recommended Posts

Hey!

I was going through some tutorials on growth solvers, and I noticed that a lot of them are driven by the
"food" group looking to get "infected" if you know what I mean. I wanted to try and make a growth solver that workes differently, 
looking instead at the points that are already infected and infecting more from their perspective.

A very simple summation of what I'm trying to achieve:

1. List the points around me

2. If they are food, they are candidates

3. Infect only 1 of the found candidates

rinse and repeat

I've put the code underneath in a point wrangle in a solver, but it doesn't work well.
I tried running the command on the seperate food and infected groups but that doesn't seem to improve either.

What happens when it doesn't go well:

1. nothing

2. Almost every point gets put into the infected group in 1 framespan and then the solver doesn't do anything anymore.

//initialiation of radius to search for, and random seed;

float radius = 0.2;
float seed = 8008135;

//stalking prey (finding a list of points to infect);

int neighbours[] = nearpoints(0,@P,radius,5);

//hopefully grabbing a random one out of the stack of many;

float array_length= len(neighbours);
//random number between 0 and the length of the list of neighbours;
int targetp = rint( rand(seed) * array_length);
//looking up point ID in list of neighbours;
int point_to_infect = neighbours[targetp];

//actually infect the point, if it is food;

if (point(0,"infection",point_to_infect) == 0){
    setpointattrib(0,"infection",point_to_infect,1);
    };

I haven't any clue what's going on, I got no errors other than a little green line under the local variable "targetp" when it gets created.

I've attached my .hip! It might be something else I'm doing wrong.

I hope you can help me, thanks in advance,

Sasbom

active infection.hip

Share this post


Link to post
Share on other sites

you were missing 
1) condition to only run on infected points
2) I cannot infect the point that infected me, which you can get around by changing the target seed by time
though there is prob a smarter way by removing infected points @ptnum from the candidate array

also to iterate correctly in a solver sop you want to fetch the results from last frame and run over that


infect.gif.c965bb9b48ed0cfc1fd0583debab3178.gif
active infection.hip

Share this post


Link to post
Share on other sites

Thank you so very much. This is a great help!

Have a nice day/night/whatever!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×