Jump to content

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

Recommended Posts


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){

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,


active infection.hip

Link to comment
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

active infection.hip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...