X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=src%2FuccProgComp.py;h=e3080bbb964f3a4127c2ea0cb31926ccfdd06b78;hb=580f670dd7bea442c8f478ef2f2efa4c9974c47f;hp=9f256fd9752fae6f8d1a4554dfedc3d791fd2908;hpb=bde6a9634c116c190cb631e962ccda551503a5c5;p=progcomp10.git diff --git a/src/uccProgComp.py b/src/uccProgComp.py index 9f256fd..e3080bb 100644 --- a/src/uccProgComp.py +++ b/src/uccProgComp.py @@ -153,12 +153,13 @@ class Supervisor: @Debug def SpawnAgent (self, agent): - child = agent.__class__ () - self.population.append (child) - agent.Reproduced () - stat = self.agentStats [str(agent.__class__)] - stat [0] += 1 - stat [1] += 1 + if MAX_TOTAL_AGENTS > 0 and len(self.population) - len(self.pendingDeaths) < MAX_TOTAL_AGENTS: + child = agent.__class__ () + self.population.append (child) + agent.Reproduced () + stat = self.agentStats [str(agent.__class__)] + stat [0] += 1 + stat [1] += 1 def Select (self): # This approach causes agents to keep fighting until they've either died or reproduced.