Darwinbots Forum

Code center => Bugs and fixes => Topic started by: Sprotiel on June 23, 2005, 11:50:52 AM

Title: Veggie pop control
Post by: Sprotiel on June 23, 2005, 11:50:52 AM
The way I understand population control, it only allows vegetables to reproduce when there's less of them than the threshold, in which case all of them trying to repro are allowed to do so, which means that veggie pop can reach up to twice the threshold. The trouble is that right now, I have a sim with pop max = 1000 and 2192 vegetables!
Title: Veggie pop control
Post by: Numsgil on June 23, 2005, 12:17:32 PM
I've included something in the new version no one has yet, I've forgot to mention it.

As the number of veggies drops below the max, vegs are allowed to reproduce.  As the new population climbs above the max, vegs have a one in (how many over we are) chance of reproing.

It's not perfect...
Title: Veggie pop control
Post by: PurpleYouko on June 23, 2005, 12:39:29 PM
I originally tried to set it up such that each veg could only repro if the current population was less than the limit.
The trouble is that the veg population is calculated independently of the repro loop so it didn't work out right.

I could have fixed this by incrementing the population as a new veg was born but this would have meant that only veggies with low robot numbers would be able to repro as they would be get to go first each time.

I like Num's idea better.
Title: Veggie pop control
Post by: Numsgil on June 23, 2005, 12:49:44 PM
It still favors bots with low numbers, but at least it addresses the problem.
Title: Veggie pop control
Post by: Greven on June 24, 2005, 09:01:45 AM
The problem is, if you have a maxpop at 75, and you have a veggie pop 75 >, the veggies just accumulate energy, and a lot of them get up to 32000, even at 5 nrg/cycle/veggie. When the pop goes under 75, 74 for example, all the vegs reproduce (at the extreme) and we get 2 * 74 = 148, which completely schrews up the sim (or so I think), although the energy level is the same, it is just easier for the bots to find possible food....

This problem need to be adressed as soon as possible! I know Num & PY is busy on other things, but it shouldnt be too hard...?
Title: Veggie pop control
Post by: PurpleYouko on June 24, 2005, 09:21:38 AM
The trouble is in the hierarchy of the program.

The way reproduction works is that when a robot activates a repro gene, it is added to an array of "robots that will reproduce on this cycle" and then the program moves on to the next robot.
Later after all the main routines have been processed (including the one that counts the veggies), it moves onto the repro array and goes through them all one by one, form low robot number to high.

Who gets to repro and who doesn't?

If we set it to cut off when the cap is reached then all the lower number bots will reproduce while the higher ones won't.
Random access to the list will take too long to process.
Nums new feature only allows each one to repro if it meets a certain criteria based on a random number (1 in 100) a bit like mutations. It shuld be a good compromise, particularly if the repro chance can be set in the control panel.
Title: Veggie pop control
Post by: Greven on June 24, 2005, 09:29:43 AM
Okay sounds better to me :)
Title: Veggie pop control
Post by: Numsgil on June 24, 2005, 10:25:43 AM
Just thought I'd post the code for you to look at:

Code: [Select]
If rob(n).Veg = True And totvegs > SimOpts.MaxPopulation Then
    t = Random(0, totvegs - SimOpts.MaxPopulation)
    totvegs = totvegs + 1
    If t > 0 Then Exit Sub 'attempt to stop veg overpopulation but will it work?
  ElseIf rob(n).Veg = True Then
    totvegs = totvegs + 1
  End If
Title: Veggie pop control
Post by: PurpleYouko on June 24, 2005, 11:39:48 AM
Why not just set it up so that veggies always have to pass a random check before reproducing. We can set the chance of them reproducing in the options.
As they exceed the maxpop the chance can just get progressively smaller.

Could be a useful way to control explosive populations of veggies.