// Use this for initialization void Start() { UniversalGravitationManager ug = UGPrefab.GetComponent <UniversalGravitationManager>(); Vector3 size = ug.boxSize; nextGenerations = new Gene[unitNum]; float x = 0; float y = 0; for (int i = 0; i < unitNum; i++) { x = (i % numX) * size.x; y = (i / numX) * size.x; ug = CreateUGManager(new Vector3(x, y, 0)); // 初期化 ug.rocket.gene.RandomParam(defaultGeneParamRange[0].x, defaultGeneParamRange[0].y, defaultGeneParamRange[1].x, defaultGeneParamRange[1].y); ugManagerList.Add(ug); nextGenerations[i] = new Gene(); } for (int i = 0; i < unitNum; i++) { ugManagerList[i].Restart(); } }
UniversalGravitationManager CreateUGManager(Vector3 position) { GameObject go = Instantiate(UGPrefab, position, Quaternion.identity); UniversalGravitationManager ug = go.GetComponent <UniversalGravitationManager>(); ug.Initialize(); return(ug); }
int compareGene(UniversalGravitationManager a, UniversalGravitationManager b) { return((int)Mathf.Sign(a.goalDistanceMin - b.goalDistanceMin)); }