// First-time Initialization -- triggered through gameManager & GUI public void NewTrainingMode(Challenge.Type challengeType) { this.challengeType = challengeType; // Initialize int numPlayers = 1; switch (this.challengeType) { case Challenge.Type.Test: Debug.Log("Switch: Test"); numPlayers = 1; break; case Challenge.Type.Racing: Debug.Log("Switch: Racing"); numPlayers = 1; break; case Challenge.Type.Combat: Debug.Log("Switch: Combat"); numPlayers = 2; break; default: Debug.Log("Switch: Default"); break; } // environment is evolvable, 1 player: teamsConfig = new TeamsConfig(numPlayers, this.challengeType, 1, 1); playingCurGen = 0; evaluationManager = new EvaluationManager(); // Need to make sure all populations have their representatives set up before calling this: // Right now this is done through the teamsConfig Constructor evaluationManager.InitializeNewTraining(teamsConfig, challengeType); // should I just roll this into the Constructor? isTraining = true; //cameraEnabled = true; gameManager.uiManager.panelTraining.moduleViewUI.SetPendingGenomesFromData(this); }
public void NewTrainingMode() { // Initialize int numPlayers = 2; // environment is evolvable, 1 player: teamsConfig = new TeamsConfig(numPlayers, 1, 1); playingCurGen = 0; evaluationManager = new EvaluationManager(); // Need to make sure all populations have their representatives set up before calling this: // Right now this is done through the teamsConfig Constructor evaluationManager.InitializeNewTraining(teamsConfig); // should I just roll this into the Constructor? isTraining = true; //cameraEnabled = true; //gameManager.uiManager.panelTraining.moduleViewUI.SetPendingGenomesFromData(this); }
public void LoadTrainingMode() { Debug.Log("LoadTrainingMode(TeamsConfig teamsConfig)!"); //Debug.Log(teamsConfig.environmentPopulation.environmentGenomeList[0]..ToString()); Debug.Log(teamsConfig.challengeType.ToString()); // Initialize! teamsConfig.InitializeFromLoadedData(); // Sets up non-serialized data so it's ready for training playingCurGen = 0; // for now - eventually I can save this too, but it doesn't seem critically important evaluationManager = new EvaluationManager(); // Need to make sure all populations have their representatives set up before calling this: // Right now this is done through the teamsConfig Constructor evaluationManager.InitializeNewTraining(teamsConfig, challengeType); // should I just roll this into the Constructor? isTraining = true; //cameraEnabled = true; /* * Challenge.Type challengeType = teamsConfig.challengeType; * * // Initialize * * // Setup Teams, Environment, and Populations - held inside teamsConfig * switch (challengeType) { * case Challenge.Type.Test: * //print("test challenge"); * * // should be saved/built already: * //teamsConfig = new TeamsConfig(true, 1, Challenge.Type.Test); * * playingCurGen = 0; * //playingCurAgent = 0; * * // Set up eval pairs: * evaluationPairsList = new List<EvaluationPair>(); * agentFitnessList = new List<float>(); * environmentFitnessList = new List<float>(); * * int numAgentReps = 1; * int numEnvironmentReps = 4; * // Hardcoded for ONE PLAYER!!!! Agent evals: * for (int i = 0; i < teamsConfig.playersList[0].agentGenomeList.Count; i++) { * for (int j = 0; j < numEnvironmentReps; j++) { * int[] pairIndices = new int[2]; * pairIndices[0] = j; // Environment Representative * pairIndices[1] = i; // Agent Index * EvaluationPair evalPair = new EvaluationPair(pairIndices, 1); // 2 populations (including environment) * evaluationPairsList.Add(evalPair); // append pair to list * } * agentFitnessList.Add(0f); * } * // Environment evals: * for (int i = 0; i < teamsConfig.environmentGenomesList.Count; i++) { * for (int j = 0; j < numAgentReps; j++) { * int[] pairIndices = new int[2]; * pairIndices[0] = i; // Environment Index * pairIndices[1] = j; // Agent Representative * EvaluationPair evalPair = new EvaluationPair(pairIndices, 0); // 2 populations (including environment) * evaluationPairsList.Add(evalPair); // append pair to list * } * environmentFitnessList.Add(0f); * } * * // Set up evaluation Instance Managers: * Vector3 arenaBounds = Challenge.GetChallengeArenaBounds(challengeType); * evaluationInstancesList = new List<EvaluationInstance>(); * for (int x = 0; x < maxInstancesX; x++) { * for (int z = 0; z < maxInstancesZ; z++) { * GameObject evalInstanceGO = new GameObject("EvaluationInstance [" + x.ToString() + "," + z.ToString() + "]"); * EvaluationInstance evaluationInstance = evalInstanceGO.AddComponent<EvaluationInstance>(); * evaluationInstance.particleCurves = particleTrajectories; * evalInstanceGO.transform.position = new Vector3(x * (arenaBounds.x + instanceBufferX), 0f, z * (arenaBounds.z + instanceBufferZ)); * evaluationInstancesList.Add(evaluationInstance); * * if (x == 0 & z == 0) { * evaluationInstance.visible = true; * } * else { * evaluationInstance.visible = false; * } * } * } * * isTraining = true; * * break; * default: * print("default"); * break; * } */ }