Ejemplo n.º 1
0
func cpPreySpawn(size int, parent ColourPolymorphicPrey, conditions ConditionParams, timestamp string) []ColourPolymorphicPrey {
	pop := []ColourPolymorphicPrey{}
	for i := 0; i < size; i++ {
		agent := parent
		agent.uuid = uuid()
		agent.pos = parent.pos
		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 //	i.e. Undead!
		}
		agent.movS = parent.movS
		agent.movA = parent.movA
		agent.𝚯 = rand.Float64() * (2 * math.Pi)
		agent.dir = geometry.UnitVector(agent.𝚯)
		agent.tr = parent.tr
		agent.sr = parent.sr
		agent.hunger = 0
		agent.fertility = 1
		agent.gravid = false
		agent.colouration = parent.colouration
		pop = append(pop, agent)
	}
	return pop
}
Ejemplo n.º 2
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
}
Ejemplo n.º 3
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
}
Ejemplo n.º 4
0
// 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
}