private SimulationInfo createSimulation(int sim_i, Rect location, int indexIndRed, int indexIndBlue) { D31NeuralControler bluePlayerScript = null; D31NeuralControler redPlayerScript = null; GameObject sim = Instantiate(simulationPrefab, transform.position + new Vector3(0, (sim_i * 250), 0), Quaternion.identity); sim.GetComponentInChildren <Camera>().rect = location; if (sim.transform.Find("D31-red") != null) { redPlayerScript = sim.transform.Find("D31-red").gameObject.transform.Find("Body").gameObject.GetComponent <D31NeuralControler>(); } if (sim.transform.Find("D31-blue") != null) { bluePlayerScript = sim.transform.Find("D31-blue").gameObject.transform.Find("Body").gameObject.GetComponent <D31NeuralControler>(); } sim.transform.Find("Scoring System").gameObject.GetComponent <ScoreKeeper>().setIds("" + indexIndBlue, "" + indexIndRed); if (redPlayerScript != null && redPlayerScript.enabled) { redPlayerScript.neuralController = metaengine.PopulationRed[indexIndRed].getIndividualController(); } if (bluePlayerScript != null && bluePlayerScript.enabled) { bluePlayerScript.neuralController = metaengine.PopulationBlue[indexIndBlue].getIndividualController(); } return(new SimulationInfo(sim, redPlayerScript, bluePlayerScript, indexIndRed, indexIndBlue)); }
private SimulationInfo createSimulation(int sim_i, Rect location) { D31NeuralControler bluePlayerScript = null; D31NeuralControler redPlayerScript = null; GameObject sim = Instantiate(simulationPrefab, transform.position + new Vector3(0, (sim_i * 250), 0), Quaternion.identity); sim.GetComponentInChildren <Camera>().rect = location; if (sim.transform.Find("D31-red") != null) { redPlayerScript = sim.transform.Find("D31-red").gameObject.transform.Find("Body").gameObject.GetComponent <D31NeuralControler>(); } if (sim.transform.Find("D31-blue") != null) { bluePlayerScript = sim.transform.Find("D31-blue").gameObject.transform.Find("Body").gameObject.GetComponent <D31NeuralControler>(); } sim.GetComponentInChildren <Camera> ().rect = location; sim.transform.Find("Scoring System").gameObject.GetComponent <ScoreKeeper>().setIds(PathBluePlayer, PathRedPlayer); if (bluePlayerScript != null && bluePlayerScript.enabled) {// BluePlayer Controller bluePlayerScript.neuralController = BlueController; bluePlayerScript.maxSimulTime = this.MatchTimeInSecs; bluePlayerScript.running = true; } if (redPlayerScript != null && redPlayerScript.enabled || PathRedPlayer.Length != 0) {// RedController Controller redPlayerScript.enabled = true; redPlayerScript.neuralController = RedController; redPlayerScript.maxSimulTime = this.MatchTimeInSecs; redPlayerScript.running = true; } return(new SimulationInfo(sim, redPlayerScript, bluePlayerScript, 0, 0)); }
public SimulationInfo(GameObject sim, D31NeuralControler playerRed, D31NeuralControler playerBlue, int individualIndexRed, int individualIndexBlue) { this.sim = sim; this.playerRed = playerRed; this.playerBlue = playerBlue; this.individualIndexRed = individualIndexRed; this.individualIndexBlue = individualIndexBlue; }