Beispiel #1
0
// GenerateCpPreyPopulation will create `size` number of Colour Polymorphic Prey agents
func GenerateCpPreyPopulation(size int, start int, mt int, conditions ConditionParams, timestamp string) []ColourPolymorphicPrey {
	pop := []ColourPolymorphicPrey{}
	for i := 0; i < size; i++ {
		agent := ColourPolymorphicPrey{}
		agent.uuid = uuid()
		agent.description = AgentDescription{AgentType: "CP Prey", AgentNum: start + i, ParentUUID: "", CreatedMT: mt, CreatedAT: timestamp}
		agent.pos = geometry.RandVector(conditions.Bounds)
		if conditions.CpPreyAgeing {
			if conditions.RandomAges {
				agent.lifespan = calc.RandIntIn(int(float64(conditions.CpPreyLifespan)*0.7), int(float64(conditions.CpPreyLifespan)*1.3))
			} else {
				agent.lifespan = conditions.CpPreyLifespan
			}
		} else {
			agent.lifespan = 99999
		}
		agent.movS = conditions.CpPreyS
		agent.movA = conditions.CpPreyA
		agent.𝚯 = rand.Float64() * (2 * math.Pi)
		agent.dir = geometry.UnitVector(agent.𝚯)
		agent.tr = conditions.CpPreyTurn
		agent.sr = conditions.CpPreySr
		agent.hunger = 0
		agent.fertility = 1
		agent.gravid = false
		agent.colouration = colour.RandRGB()
		pop = append(pop, agent)
	}
	return pop
}
// GenerateVPredatorPopulation will create `size` number of Visual Predator agents
func GenerateVPredatorPopulation(size int, start int, mt int, conditions ConditionParams, timestamp string) []VisualPredator {
	pop := []VisualPredator{}
	for i := 0; i < size; i++ {
		agent := VisualPredator{}
		agent.uuid = uuid()
		agent.description = AgentDescription{AgentType: "vp", AgentNum: start + i, ParentUUID: "", CreatedMT: mt, CreatedAT: timestamp}
		agent.pos = geometry.RandVector(conditions.Bounds)
		if conditions.VpAgeing {
			if conditions.RandomAges {
				agent.lifespan = calc.RandIntIn(int(float64(conditions.VpLifespan)*0.7), int(float64(conditions.VpLifespan)*1.3))
			} else {
				agent.lifespan = conditions.VpLifespan
			}
		} else {
			agent.lifespan = 99999
		}
		agent.movS = conditions.VpMovS
		agent.movA = conditions.VpMovA
		agent.𝚯 = rand.Float64() * (2 * math.Pi)
		agent.dir = geometry.UnitVector(agent.𝚯)
		agent.tr = conditions.VpTurn
		agent.vsr = conditions.VpVsr
		agent.𝛄 = conditions.VpVb𝛄 //	baseline search tolerance level
		agent.hunger = conditions.VpSexualRequirement + 1
		agent.fertility = 1
		agent.gravid = false
		agent.τ = colour.RandRGB()
		agent.ετ = conditions.VpVbε
		pop = append(pop, agent)
	}
	return pop
}