本文整理汇总了C#中Population.InitializeMasterAgentArray方法的典型用法代码示例。如果您正苦于以下问题:C# Population.InitializeMasterAgentArray方法的具体用法?C# Population.InitializeMasterAgentArray怎么用?C# Population.InitializeMasterAgentArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population
的用法示例。
在下文中一共展示了Population.InitializeMasterAgentArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyPopulationSettings
public Population CopyPopulationSettings()
{
// returns a copy of the current Population instance calling the function i.e. Population newPop = new Population(); newPop = sourcePop.CopyPopulation();
Population populationCopy = new Population();
populationCopy.SetMaxPopulationSize(populationMaxSize);
populationCopy.brainType = brainType;
populationCopy.templateBrain = templateBrain;
populationCopy.numInputNodes = numInputNodes;
populationCopy.numOutputNodes = numOutputNodes;
populationCopy.numAgents = numAgents;
populationCopy.InitializeMasterAgentArray();
//populationCopy = this;
return populationCopy;
}
示例2: ClickCreateNewPopulation
public void ClickCreateNewPopulation() {
DebugBot.DebugFunctionCall("TNewPopUI; ClickCreateNewPopulation(); ", debugFunctionCalls);
Trainer trainer = trainerModuleScript.gameController.masterTrainer; // ?? why only set up reference here???
if(trainer.PlayerList != null) { // if there is a valid PlayerList
int curPlayer = trainer.CurPlayer;
if(trainer.PlayerList[curPlayer-1] != null) { // If Current Player exists
populationRef = trainer.PlayerList[curPlayer-1].masterPopulation; // grab current player's population -- this might not be needed
populationRef.SetMaxPopulationSize(pendingPopulationSize);
if (toggleZeroedWeights.isOn) {
populationRef.initRandom = false;
}
else {
populationRef.initRandom = true;
}
populationRef.initNumHiddenNodes = pendingNumHiddenNodes;
populationRef.initConnectedness = pendingConnectedness;
// CREATE AGENT ARRAY!!!!!!! :
CritterGenome genomeToLoad = ES2.Load<CritterGenome>(pendingBodyTemplateFilename);
CrossoverManager.nextNodeInnov = genomeToLoad.savedNextNodeInno;
CrossoverManager.nextAddonInnov = genomeToLoad.savedNextAddonInno;
populationRef.InitializeMasterAgentArray(genomeToLoad, trainer.PlayerList[curPlayer - 1].masterCupid.useSpeciation);
trainer.PlayerList[curPlayer-1].hasValidPopulation = true;
}
else {
DebugBot.DebugFunctionCall("TNewPopUI; ClickCreateNewPopulation(); Null Player Ref!", debugFunctionCalls);
}
}
trainerModuleScript.ClickPopulation(); // switches to Population Panel -- might not be necessary?
trainer.PlayerList[trainer.CurPlayer-1].graphKing.BuildTexturesCurAgentPerAgent(trainer.PlayerList[trainer.CurPlayer-1], 0);
trainerModuleScript.SetAllPanelsFromTrainerData();
}
示例3: SplitPopulation
public Population[] SplitPopulation(int numFactions)
{
if(numFactions > masterAgentArray.Length) { // safety
numFactions = masterAgentArray.Length;
}
Population[] populationArray = new Population[numFactions];
float factionSize = (float)masterAgentArray.Length / (float)numFactions;
float incrementSize = factionSize; // start at ideal length
float currentSplitPosition = 0f;
int curAgentIndex = 0;
for(int i = 0; i < numFactions; i++) { // 4/3:
currentSplitPosition += incrementSize; // 1.333, 3.0, 3.67
int blockSize = Mathf.RoundToInt(incrementSize); // 1, 2, 1
incrementSize += (factionSize - (float)blockSize); // 1.67, -0.67,
//Debug.Log ("Faction #" + (i+1).ToString () + ": " + blockSize.ToString() + " Agents, IncrementSize= " + incrementSize.ToString() + ", CurPos: " + currentSplitPosition.ToString());
// Create new Population:
Population factionPop = new Population();
factionPop.populationMaxSize = blockSize;
factionPop.brainType = brainType;
factionPop.templateBrain = templateBrain;
factionPop.numInputNodes = numInputNodes;
factionPop.numOutputNodes = numOutputNodes;
factionPop.InitializeMasterAgentArray();
for(int j = 0; j < blockSize; j++) { // copy over Agents from source Pop.
factionPop.masterAgentArray[j] = masterAgentArray[curAgentIndex];
curAgentIndex++;
}
populationArray[i] = factionPop;
}
return populationArray;
}
示例4: ClickCreateNewPopulation
public void ClickCreateNewPopulation()
{
DebugBot.DebugFunctionCall("TNewPopUI; ClickCreateNewPopulation(); ", debugFunctionCalls);
if(populationRef.brainType != Population.BrainType.None) { // BrainType needs to BE something
Trainer trainer = trainerModuleScript.gameController.masterTrainer;
if(trainer.PlayerList != null) { // if there is a valid PlayerList
int curPlayer = trainer.CurPlayer;
if(trainer.PlayerList[curPlayer-1] != null) { // If Current Player exists
populationRef = trainer.PlayerList[curPlayer-1].masterPopulation; // grab current player's population -- this might not be needed
populationRef.SetMaxPopulationSize(pendingPopulationSize);
populationRef.numInputNodes = pendingNumInputs;
populationRef.numOutputNodes = pendingNumOutputs;
// !!!!!!! Transfer over specific Brain-Type Options!
// Or Do I simply change these values in real-time as they are selected by UI?
//===================================================
// CREATE AGENT ARRAY!!!!!!! :
populationRef.InitializeMasterAgentArray();
trainer.PlayerList[curPlayer-1].hasValidPopulation = true;
}
else {
DebugBot.DebugFunctionCall("TNewPopUI; ClickCreateNewPopulation(); Null Player Ref!", debugFunctionCalls);
}
}
trainerModuleScript.ClickPopulation(); // switches to Population Panel -- might not be necessary?
trainer.PlayerList[trainer.CurPlayer-1].graphKing.BuildTexturesCurAgentPerAgent(trainer.PlayerList[trainer.CurPlayer-1], 0);
trainerModuleScript.SetAllPanelsFromTrainerData();
}
}