6
« on: April 27, 2017, 02:45:46 AM »
Couldn't you limit it with a counter variable set for each initial projectile fired, that only lets its descendants replicate for like three generations? You'd have to be careful, so that it doesn't reset the counter every time it calls itself, maybe with a boolean that is a necessary variable to call it, and if the boolean is set to 'true' (which it is only on the firing from the launcher) it initialises the counter, and if it's set to 'false' (which is how you have it call itself), it merely increments it, until it reaches the preset limit, and doesn't call itself anymore? It'd be more complex than that to do true generation tracking, of course, but if you didn't want to do generation tracking, you could have it for a total limit of self-replication which is equal to three full generations, so that if there's only ever one survivor from a generation it can go for quite some time.
If you did want to do generation tracking... you'd have to do it on a per-drone level, where each drone 'knows' how many drones its 'line' goes, so it'd pretty much have to be an array or a matrix, and every time you call the drone function, you pass it what generation drone is spawning it? If each drone splits into five, and you only want at most three generations, you'd only need an array of size sixteen (one for the initial drone), and each time you replicate you store which generation the drone is. Any time a drone attempts to self-replicate and is at the generation limit, nothing happens, because of your if statement that only allows you to get to the replication call when under the generation limit.
Would that work? I haven't done a programming course in about four years, even though it's my major - personal issues put Uni on hold - so it might need some tweaking.