示例#1
0
func vpSpawn(size int, start int, mt int, parent VisualPredator, conditions ConditionParams, timestamp string) []VisualPredator {
	pop := []VisualPredator{}
	for i := 0; i < size; i++ {
		agent := parent
		agent.uuid = uuid()
		agent.description = AgentDescription{AgentType: "vp", AgentNum: start + i, ParentUUID: parent.uuid, CreatedMT: mt, CreatedAT: timestamp}
		agent.pos = parent.pos
		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 = parent.movS
		agent.movA = parent.movA
		agent.𝚯 = rand.Float64() * (2 * math.Pi)
		agent.dir = parent.dir
		agent.tr = parent.tr
		agent.vsr = parent.vsr
		agent.hunger = conditions.VpSexualRequirement + 1
		agent.fertility = 1
		agent.gravid = false
		agent.τ = colour.RandRGBClamped(parent.τ, 0.5) //	random offset (up to 50%) deviation from parent's target colour
		agent.ετ = conditions.VpVbε
		pop = append(pop, agent)
	}
	return pop
}
示例#2
0
// For now, mutation only affects colouration, but could be extended to affect any other parameter.
func (c *ColourPolymorphicPrey) mutation(Mf float64) {
	c.colouration = colour.RandRGBClamped(c.colouration, Mf)
}