///<summary>Pass in a species and a number between 0 and 1 as mutation chance</summary> public DNABasedEvolutionManager(ISpecies <ADNA <T> > p_species, float p_mutation_chance_percentage, int p_size) { m_gene_pool = new FitnessList <ADNA <T> >(p_size); m_mutation_chance_percentage = p_mutation_chance_percentage; m_species = p_species; m_interval = new IntervalEventManager(); }
// Use this for initialization void Start() { m_rb = gameObject.GetComponent <Rigidbody2D>(); m_tm = new TimeoutEventManager(); m_actions = new PriorityList(); m_renderer = gameObject.GetComponent <SpriteRenderer>(); m_im = new IntervalEventManager(); m_im.addListener(HFlineFollowCONFIG.CreatureDecisionLatency, () => { m_actions.flush(); //Flush actions, set neew behaviours set_behaviour_samples++; setBehaviours(); }); // m_im.addListener(2f, () => // { // // Debug.Log("Fit: " + fit_samples + ", Beh: " + set_behaviour_samples); // fit_samples = 0; // set_behaviour_samples = 0; // }); m_im.addListener(1f, () => { m_health.add(-1f); }); m_im.addListener(HFlineFollowCONFIG.CreatureFitnessLatency, fitnessUpdate); }
void Start() { //Instantiate controller m_evolution = new DNABasedEvolutionManager <MindBodyDNDNA <ResourceFightDNCreature> >( new MindBodySpeciesDN <ResourceFightDNCreature>(0, new TraitGenesSpecies(0, new HashSet <string> { "SPEED", "HEALTH", "DAMAGE", "ENERGY", "ATTACKSPEED" }, 1, new Range <float>(2f, 2f), 0, new Range <float>(0f, 0f)), new DecisionNetSpecies <ResourceFightDNCreature>(0, ResourceFightDNCreature.getInputFactorys(), ResourceFightDNCreature.getOutputFactorys(), new Range <float>(0.8f, 1.2f)) ), 0.1f, 20, (float p_fitness) => { return(p_fitness * 0.95f); }, 1f ); //Fill with 20 random for (int i = 0; i < 10; i++) { m_evolution.addRandom(); } //Instantaite Interval and Listeners m_interval = new IntervalEventManager(); for (int i = 0; i < 5; i++) { spawnResource(); } for (int i = 0; i < 50; i++) { spawnCreature(); } // spawnCreature(); // spawnCreature(); m_interval.addListener(5f, () => { for (int i = 0; i < 5; i++) { spawnCreature(); } }); m_interval.addListener(10f, () => { for (int i = 0; i < 1; i++) { spawnResource(); } }); m_interval.addListener(30f, () => { GameObject[] obs = ObjectLogger.getByType("CREATURE"); foreach (GameObject ob in obs) { ob.GetComponent <ResourceFightDNCreature>().logFitness(); } }); }
public DNABasedEvolutionManager(ISpecies <ADNA <T> > p_species, float p_mutation_chance_percentage, int p_size, DFitnessMod p_dna_ageing, float p_interval) { m_gene_pool = new FitnessList <ADNA <T> >(p_size); m_mutation_chance_percentage = p_mutation_chance_percentage; m_species = p_species; m_interval = new IntervalEventManager(); m_interval.addListener(p_interval, () => { m_gene_pool.modifyFitness(p_dna_ageing); }); }
//Goal //---------------------------------------------------------- //Unity Callbacks // Use this for initialization void Start() { m_rb = gameObject.GetComponent <Rigidbody2D>(); m_renderer = gameObject.GetComponent <SpriteRenderer>(); m_tm = new TimeoutEventManager(); m_im = new IntervalEventManager(); m_actions = new PriorityList(); m_cooldowns = new CooldownLogger(); m_sense_angle = 30f; m_sense_proximity = 6f; m_brain_stop = false; m_cooldowns.activate("SENSE", 0); m_im.addListener(0.1f, () => { m_decision_time = true; }); }
void Start() { Time.fixedDeltaTime = 0.04f; trial = DataCollector.Trials; setUpAI(); setUpData(); Task t1 = Task.Factory.StartNew(() => { m_evolution = createManager(); for (int i = 0; i < m_evolution.Size; i++) { m_evolution.addRandom(); } }); m_interval = new IntervalEventManager(); m_interval.addListener(0.2f, () => { Task t2 = Task.Factory.StartNew(() => { m_goalLine.rotate(1f); }); }); t1.Wait(); m_interval.addListener(lineFollowCONFIG.ControllerSpawnLatency, () => { for (int i = 0; i < lineFollowCONFIG.ControllerCreatureSpawnAmount; i++) { spawn(); } }); }
void Start() { Time.fixedDeltaTime = 0.04f; trial = DataCollector.Trials; setUpAI(); setUpData(); Task t1 = Task.Factory.StartNew(() => { m_evolution = createManager(); for (int i = 0; i < m_evolution.Size; i++) { m_evolution.addRandom(); } }); m_interval = new IntervalEventManager(); t1.Wait(); for (int i = 0; i < 15; i++) { spawn(); } }