// Use this for initialization
    void Start()
    {
        gameMap = GetComponent<GameMap>();

        if(Options.populationName == null){

            Type genome = Type.GetType(Options.genomeType == null? "Explorer1Genome": Options.genomeType);//FiveLongFeelerGenome//Explorer1Genome
            populationSize = 50;

            population = new Genome[populationSize];

            for (int currGenome = 0; currGenome < populationSize; ++currGenome) {

                population[currGenome] = Genome.createGenome(genome);
            }

            generation = 0;
        }
        else  {

            string fileName = Options.GADirectory +"/" +Options.populationName+".txt";

            Debug.Log ("Loading Population from file "+fileName +".");

            loadPopulationFromString(File.ReadAllText(fileName));
        }

        prevPopulation = null;

        testSubjects = new TrainingAgent[populationSize];

        for(int currIndividual = 0; currIndividual < populationSize; ++currIndividual) {

            //Vector3 location = gameMap.map.cellIndexToWorld(gameMap.map.HumanSpawnPoints[currTarget]);
            //Quaternion rotation = Quaternion.LookRotation(transform.forward, Vector3.zero - location);
            Quaternion rotation = gameMap.map.getSpawnAngle(currTarget);
            gameMap.spawnHumanImmediate(gameMap.map.HumanSpawnPoints[currTarget], Options.mapName.Equals("TrainingMap")?gameMap.Human.transform.rotation: rotation, population[currIndividual]);

            testSubjects[currIndividual] = gameMap.HumansOnMap[currIndividual].GetComponent<TrainingAgent>();
        }

        initialize();
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        gameMap = GetComponent<GameMap>();

        SpawnPoints = new List<Vector2>(gameMap.map.HumanSpawnPoints);
        //
        //		//gameMap.spawnHumanImmediate(gameMap.map.getRandomHumanSpawn(), gameMap.Human.transform.rotation);
        //		gameMap.spawnHumanImmediate(gameMap.map.HumanSpawnPoints[currTarget], gameMap.Human.transform.rotation);
        //
        //		testSubject = gameMap.HumansOnMap[0].GetComponent<TestableAgent>();

        if(Options.populationName == null){

            Type genome = typeof(FiveLongFeelerGenome);
            populationSize = 50;

            population = new Genome[populationSize];

            for (int currGenome = 0; currGenome < populationSize; ++currGenome) {

                population[currGenome] = Genome.createGenome(genome);
            }

            generation = 0;
        }
        else  {

            string fileName = Options.GADirectory +"/" +Options.populationName+".txt";

            Debug.Log ("Loading Population from file "+fileName +".");

            loadPopulationFromString(File.ReadAllText(fileName));
        }

        //gameMap.spawnHumanImmediate(gameMap.map.getRandomHumanSpawn(), gameMap.Human.transform.rotation);
        gameMap.spawnHumanImmediate(gameMap.map.HumanSpawnPoints[currTarget], gameMap.Human.transform.rotation, population[0]);

        testSubject = gameMap.HumansOnMap[0].GetComponent<TrainingAgent>();

        initialize();
    }