// Check in an individual that has now acquired a fitness value public void CheckIn(SimpleAI2D NewDude) { // Make Individual newP.AddNewInd(NewDude); // Add to newP nextCIn++; // Count it Debug.Log("In CheckIn chr fit: " + NewDude.chrom + " " + NewDude.fitness); }
// Add a new Individual to the population in the next open spot public int AddNewInd(SimpleAI2D newDude) { int wherePut = -1; // -1 in case something breaks if (Full) Debug.Log ("Panic! Tried to add too many dudes"); else { wherePut = nDudes; dudes[wherePut] = newDude; nDudes++; // Increment for next time } return wherePut; // Return offset in array where it landed }
void Start() { if (Tilesize <= 0) { Tilesize = 1; } Pathfinder2D.Instance.Create2DMap(); //Get list of all villagers GameObject[] gos = GameObject.FindGameObjectsWithTag ("Villager"); SimpleAI2D[] villagers = new SimpleAI2D[gos.Length]; for (int i = 0; i < gos.Length; i++) { villagers [i] = gos [i].GetComponent<SimpleAI2D>(); } //Create new thresEvolve villagerList = new List<SimpleAI2D> (villagers); thres = new ThresEvolve (10, "Assets/villagerThres.txt", 0.9, 0.1, villagerList); int j = 0; while (! thres.AllCheckedOut()) { villagerList[j].chrom = thres.CheckOut(); j++; } }