public void Simulate(OrganismSetup[] parents) { currentGenerationData = new GenerationData(ammount); for (int i = 0; i < ammount; i++) { OrganismSetup setup; if (parents == null) { setup = randomizer.Randomize(originalSetup); } else { setup = randomizer.Randomize(parents[Random.Range(0, parents.Length)]); } currentGenerationData.organisms [i] = setup; SpawnOrganism(transform.position, setup, i); } if (onRestartSimulation != null) { onRestartSimulation(); } Invoke("EndGeneration", simulationTime); }
public BarcodeViewModel(BarcodeViewModel barcodeViewModel) { Title = barcodeViewModel.Title; Description = barcodeViewModel.Description; Barcode = barcodeViewModel.Barcode.Clone(); GenerationData = new GenerationData(barcodeViewModel.GenerationData); }
public void GenerateWorld(GenerationSettings settings, BackgroundWorker worker = null) { GenerationData genData = generator.Generate(settings, worker); worldData = new WorldData(genData); worldData.SetName(settings.name); }
public override void Execute(GenerationData data, Random rng, BackgroundWorker worker = null) { int width = data.width; int height = data.height; int x, y; float dX, dY, t, d; float halfHeight = height * 0.5f; NoiseWrapper generator = new NoiseWrapper( FastNoise.NoiseType.SimplexFractal, FastNoise.FractalType.FBM, 9.5f, 0.9f, 8, rng.Next() ); for (int i = 0; i < data.pointData.Length; i++) { x = i % width; y = i / width; dX = x / (float)width; dY = y / (float)height; t = generator.GetValue(dX, dY, 0, true); d = 1 - Math.Abs(y / halfHeight - 1); t = (3 * d + t) / 4.0f; data.pointData[i].temperature = t; } }
internal void Init(AreaMapComponent inAreaMapComponent, GenerationData inGenData) { genData = inGenData; areaMapComponent = inAreaMapComponent; FillList(); }
/// <summary> /// Use BFS flood fill to identify the main island, and fill in any inaccessible land /// </summary> /// <param name="data">An object wrapper for information about each tile</param> void FillIslands(GenerationData data) { PointData[] climateData = data.pointData; int width = data.width; int height = data.height; int halfIndex = (height / 2 * width) + (width / 2); int nIndex; PointData c; if (climateData[halfIndex].land) { Queue <PointData> q = new Queue <PointData>(climateData.Length); climateData[halfIndex].mainland = true; q.Enqueue(climateData[halfIndex]); while (q.Count > 0) { c = q.Dequeue(); nIndex = ((c.y + 0) * width) + (c.x + 1); if (nIndex >= 0 && nIndex < climateData.Length && climateData[nIndex].land && !climateData[nIndex].mainland) { climateData[nIndex].mainland = true; q.Enqueue(climateData[nIndex]); } nIndex = ((c.y + 0) * width) + (c.x - 1); if (nIndex >= 0 && nIndex < climateData.Length && climateData[nIndex].land && !climateData[nIndex].mainland) { climateData[nIndex].mainland = true; q.Enqueue(climateData[nIndex]); } nIndex = ((c.y + 1) * width) + (c.x + 0); if (nIndex >= 0 && nIndex < climateData.Length && climateData[nIndex].land && !climateData[nIndex].mainland) { climateData[nIndex].mainland = true; q.Enqueue(climateData[nIndex]); } nIndex = ((c.y - 1) * width) + (c.x + 0); if (nIndex >= 0 && nIndex < climateData.Length && climateData[nIndex].land && !climateData[nIndex].mainland) { climateData[nIndex].mainland = true; q.Enqueue(climateData[nIndex]); } } for (int i = 0; i < climateData.Length; i++) { climateData[i].land = climateData[i].mainland; climateData[i].mainland = false; } } else { Debug.WriteLine("Assumed the center would be land, and it wasn't."); } }
/** * Generates GUI elements given a type of generator. * The GenData it points to should not be shared by multiple UI elements. */ private void GeneratorGUI(Type generatorType, string buttonName, GenerationData data) { SpriteGeneratorBuilder builder = ObjectController.GetContext(). AddComponent <SpriteGeneratorBuilder>().CreateBuilder(generatorType); GUILayout.BeginHorizontal(); // A dropdown list which displays all the PNG files that can be used as spites // See AssetController for IList <string> spriteList = AssetFetcher.GetSprites(); spriteList.Insert(0, "Default Sprite"); string[] sprites = spriteList.ToArray <string>(); GUILayout.Label("Sprite:"); data.idx = EditorGUILayout.Popup(data.idx, sprites); GUILayout.EndHorizontal(); if (GUILayout.Button(new GUIContent(buttonName))) { // We use the Builder pattern so that the GUI logic can get updated easily builder = builder.ByCoord(0.0f, 0.0f); if (data.idx != 0) { builder = builder.ByPath(sprites [data.idx]); } if (data.width != "") { builder = builder.ByWidth(int.Parse(data.width)); } if (data.height != "") { builder = builder.ByHeight(int.Parse(data.height)); } if (lightsUI.addLight) { builder = builder.ByLightData(lightsUI.lightData); } // We append the file name of the sprite at the end so the type of // the object is easily identifiable string finalName = "object-" + sprites[data.idx].Replace(" ", "-") + fileIncrement++; // The Builder is the component that should persist as a Script Component // together with the object. All the fields of the Builder *must* be serializable // to persist with the saved scene. The Builder can encasulate all behaviour // of the generators. GameObject gameObject = builder.Build().GenerateObject(finalName); gameObject.AddComponent <SpriteGeneratorBuilder>().ByBuilder(builder); } UnityEngine.Object.DestroyImmediate(builder); }
public string GenerateCode(string licenseKey, GenerationData generationData) { var hw = Hardware.GetId(); var body = GenerateRequestBody(licenseKey, hw, generationData); var task = RequestHelper.PostAsync(_apiUrl, body); task.Wait(); return(GetResultFromResponse(task.Result)); }
public void Test() { var key = "ta"; var data = new GenerationData { Namespace = "test" }; var code = _client.GenerateCode(key, data); Assert.IsNull(code); }
public IEnumerable <TemplateLicense> GetAllLicences(GenerationData generationData) { BuildContextProvider(generationData); var userSelection = generationData.ToUserSelection(); var licences = GenComposer.GetAllLicences(userSelection); return(licences); }
private string GenerateRequestBody(string licenseKey, string hw, GenerationData generationData) { var message = new RequestMessage { Key = licenseKey, Hardware = hw, GenerationData = generationData }; return(Cryptographer.Encrypt(message)); }
public void Test_FileStoring() { var documentManager = new WordDocumentManager(); var simpleFile = new GenerationData(); var filePath = "C:\\temp\\WordGeneration"; var fileName = $"{Guid.NewGuid().ToString()}.docx"; documentManager.SaveDocument(simpleFile, filePath, fileName); }
private static GenerationData ReadFile(string path, bool embeddedPdb) { try { var generation = new GenerationData(); var stream = File.OpenRead(path); if (IsPE(stream)) { var peReader = new PEReader(stream); generation.PEReaderOpt = peReader; if (embeddedPdb) { var embeddedEntries = peReader.ReadDebugDirectory().Where(entry => entry.Type == DebugDirectoryEntryType.EmbeddedPortablePdb).ToArray(); if (embeddedEntries.Length == 0) { throw new InvalidDataException("No embedded pdb found"); } if (embeddedEntries.Length > 1) { throw new InvalidDataException("Multiple entries in Debug Directory Table of type EmbeddedPortablePdb"); } var provider = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedEntries[0]); generation.MetadataReader = provider.GetMetadataReader(); generation.MemoryOwner = provider; } else { generation.MetadataReader = peReader.GetMetadataReader(); generation.MemoryOwner = peReader; } } else if (IsManagedMetadata(stream)) { var mdProvider = MetadataReaderProvider.FromMetadataStream(stream); generation.MetadataReader = mdProvider.GetMetadataReader(); generation.MemoryOwner = mdProvider; } else { throw new NotSupportedException("File format not supported"); } return(generation); } catch (Exception e) { Console.WriteLine($"Error reading '{path}': {e.Message}"); return(null); } }
public static GenerationSettings ToSettings(this GenerationData @this) { return(new GenerationSettings { Width = @this.Width, DefaultSize = @this.DefaultSize, Height = @this.Height, Type = @this.Type, ValidateCodeText = @this.ValidateCodeText, }); }
private static string GetDay(int?amountOfDays, GenerationData data) { if (amountOfDays.HasValue) { return(amountOfDays > 1 ? DocumentMetadataTexts.GetText(MetadataTexts.CV_DAYS, data.Language) : DocumentMetadataTexts.GetText(MetadataTexts.CV_DAY, data.Language)); } else { return(string.Empty); } }
/// <summary> /// Use BFS flood fill to identify the main ocean, and fill in any inaccessible water /// </summary> /// <param name="data">An object wrapper for information about each tile</param> void FillLakes(GenerationData data) { PointData[] climateData = data.pointData; int width = data.width; int height = data.height; int nIndex; PointData c; if (!climateData[0].land) { Queue <PointData> q = new Queue <PointData>(climateData.Length); climateData[0].mainland = true; q.Enqueue(climateData[0]); while (q.Count > 0) { c = q.Dequeue(); nIndex = ((c.y + 0) * width) + (c.x + 1); if (nIndex >= 0 && nIndex < climateData.Length && !climateData[nIndex].land && !climateData[nIndex].mainland) { climateData[nIndex].mainland = true; q.Enqueue(climateData[nIndex]); } nIndex = ((c.y + 0) * width) + (c.x - 1); if (nIndex >= 0 && nIndex < climateData.Length && !climateData[nIndex].land && !climateData[nIndex].mainland) { climateData[nIndex].mainland = true; q.Enqueue(climateData[nIndex]); } nIndex = ((c.y + 1) * width) + (c.x + 0); if (nIndex >= 0 && nIndex < climateData.Length && !climateData[nIndex].land && !climateData[nIndex].mainland) { climateData[nIndex].mainland = true; q.Enqueue(climateData[nIndex]); } nIndex = ((c.y - 1) * width) + (c.x + 0); if (nIndex >= 0 && nIndex < climateData.Length && !climateData[nIndex].land && !climateData[nIndex].mainland) { climateData[nIndex].mainland = true; q.Enqueue(climateData[nIndex]); } } for (int i = 0; i < climateData.Length; i++) { climateData[i].land = !climateData[i].mainland; climateData[i].mainland = false; } } }
public static StorageBarcode ToStorageBarcode(this GenerationData @this) { return(new StorageBarcode { Width = @this.Width, Data = @this.Data, DefaultSize = @this.DefaultSize, Height = @this.Height, Type = @this.Type, Title = null }); }
private Generator() { roomList = new List <Room>(); monsterGenerator = new MonsterGenList(); GenerationData data = GenerationData.getInstance(); availableSquares = data.gridSquares; weightedMin = 4; weightedMax = availableSquares / 2; }
public override void Execute(GenerationData data, Random rng, BackgroundWorker worker = null) { int x, y; float dX, dY; float ddX, ddY; float e1, e2, d; float halfHeight = data.height >> 1; NoiseWrapper shapeGenerator1 = new NoiseWrapper( FastNoise.NoiseType.SimplexFractal, FastNoise.FractalType.Billow, 12f, 0.525f, 8, rng.Next() // 22.5f, 0.575f, 8 ); NoiseWrapper shapeGenerator2 = new NoiseWrapper( FastNoise.NoiseType.SimplexFractal, FastNoise.FractalType.FBM, 20.0f, .45f, 8, rng.Next() // 25.0f, 0.4f, 8, ); for (int i = 0; i < data.pointData.Length; i++) { x = i % data.width; y = i / data.width; dX = x / (float)data.width; dY = y / (float)data.height; data.pointData[i].x = x; data.pointData[i].y = y; // Calculate Shape e1 = 1 - Math.Abs(shapeGenerator1.GetValue(dX, dY, 0, true)); e1 *= 0.1f; e1 = (e1 * 2) - 1; ddX = dX + e1; ddY = dY + e1; e1 = shapeGenerator2.GetValue(ddX, ddY, 0, true); d = MathEx.EuclideanDistanceCenter(x, y, data.width, data.height); e2 = e1 + sA - sB * (float)Math.Pow(d, sC); data.pointData[i].land = e2 > oceanThreshold; data.pointData[i].elevation = e2; //Report Progress back to Main thread if (worker != null) { worker.ReportProgress((int)((i / (float)data.pointData.Length) * 100)); } } FillIslands(data); FillLakes(data); }
public string GenerateElements(string path, string elementsNamespace = "") { var docs = Loader.Load(path); Validator.CheckDocuments(docs); LocatorRenderer.Run(docs); var docsString = docs.Values.Select(x => x.Save()); var data = new GenerationData { Namespace = elementsNamespace, XmlDocuments = docsString }; return(_apiClient.GenerateCode(_licenseKey, data)); }
private void GenerateMonsters() { GenerationData data = GenerationData.getInstance(); int monsterCount = 0, monsterLikelyness = 0; monsterGenerator = new MonsterGenList(); // Determine what monster mode we are using and set the variables to act as such switch (data.monsterMode) { case MonsterMode.None: monsterCount = monsterLikelyness = 0; break; case MonsterMode.Few: monsterCount = 5; monsterLikelyness = 21; break; case MonsterMode.Moderate: monsterCount = 10; monsterLikelyness = 31; break; case MonsterMode.Many: monsterCount = 20; monsterLikelyness = 61; break; } //check & set level monsterGenerator.SetMonsterStats(data.level, data.level + 5); for (int i = 0; i < roomList.Count; i++) { // Needs randomized x coord? monsterGenerator.SetMonsterRoomDimensions(roomList[i].posX, roomList[i].posY, roomList[i].width, roomList[i].height); //set monsters //everything is minions for now for (int j = 0; j < monsterCount; j++) { int currRand = rndTwo.Next(1, 101); if (currRand < monsterLikelyness) { roomList[i].addToMonsList(monsterGenerator.GenerateMinion()); } } } }
private void BuildContextProvider(GenerationData generationData) { var safeProjectName = generationData.ProjectName.MakeSafeProjectName(); var combinedPath = Path.Combine(generationData.GenPath, safeProjectName, safeProjectName); ContextProvider provider = new ContextProvider() { ProjectName = generationData.ProjectName, GenerationOutputPath = combinedPath, DestinationPath = combinedPath, }; GenContext.Current = provider; }
/// <summary> /// Applies the calculated alphamap to the Terrain. /// </summary> public void ApplyAlphamap() { GenerationData gen = TerraConfig.Instance.Generator; int res = gen.SplatmapResolution - 1; int maxResPerFrame = TerraConfig.Instance.Generator.CoroutineRes; int splatCount = Alphamap.GetLength(2); _terrain.terrainData.alphamapResolution = res; // if (gen.UseCoroutines && Application.isPlaying && res > maxResPerFrame) { // _tile.StartCoroutine(ApplyAlphamapCoroutine(res, maxResPerFrame, splatCount)); // } else { _terrain.terrainData.SetAlphamaps(0, 0, Alphamap); // } }
public void SaveLastGeneration() { if (currentGeneration < 1) { Debug.LogError("Cannot save last generation while on Generation 0."); return; } BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/savedGeneration.gen", FileMode.OpenOrCreate); GenerationData genData = new GenerationData(carData, currentGeneration - 1, bestCar); bf.Serialize(file, genData); file.Close(); Debug.Log("Successfully saved last generation."); }
// Generation Button, does the magic private void generateButton_Click(object sender, EventArgs e) { // Get the data instance GenerationData data = GenerationData.getInstance(); // Pass in the data data.setupData(levelBox.SelectedIndex + 1, roomsBox.SelectedIndex + 1, (TrapMode)trapBox.SelectedIndex, (MonsterMode)monstersBox.SelectedIndex, (DifficultyLevel)difficultyBox.SelectedIndex, (TreasureMode)treasureBox.SelectedIndex); // TODO: Run the Generation Generator generator = Generator.getInstance(); generator.GenerateRooms(); LevelData.getInstance().setupLevelWithData(generator.roomList); }
public WorldData(GenerationData genData) { int chunkWidth = (genData.width / Config.CHUNK_SIZE); int chunkHeight = (genData.height / Config.CHUNK_SIZE); chunks = new Chunk[chunkWidth * chunkHeight]; loadedChunks = new Dictionary <int, Chunk>(); header.width = genData.width; header.height = genData.height; header.spawnArea = genData.spawnArea; for (int i = 0; i < (chunkWidth * chunkHeight); i++) { chunks[i] = new Chunk(genData, i % chunkWidth, i / chunkWidth, header.width); } }
public void GenerateRooms() { roomList.Clear(); GenerationData data = GenerationData.getInstance(); availableSquares = data.gridSquares; //check # rooms //go through each and make a new room while (roomList.Count < data.numberOfRooms) { GenerateRoom(); } // Add the Monsters to the Room GenerateMonsters(); }
private bool LoadGenerationFromFile(out GenerationData loadData) { if (File.Exists(Application.persistentDataPath + "/savedGeneration.gen")) { // Load file BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/savedGeneration.gen", FileMode.Open); loadData = (GenerationData)bf.Deserialize(file); return(true); } else { loadData = null; return(false); } }
private void InitializeGenerationData() { _generationData = _generationDataService.Get(); OrganizerPdfTextBox.Text = _generationData.Organizer?.FieldName; OrganizerExcelTextBox.Text = _generationData.Organizer?.Cell; EventPdfTextBox.Text = _generationData.Event?.FieldName; EventExcelTextBox.Text = _generationData.Event?.Cell; PlacePdfTextBox.Text = _generationData.Place?.FieldName; PlaceExcelTextBox.Text = _generationData.Place?.Cell; DatePdfTextBox.Text = _generationData.Date?.FieldName; DateExcelTextBox.Text = _generationData.Date?.Cell; TimePdfTextBox.Text = _generationData.Time?.FieldName; TimeExcelTextBox.Text = _generationData.Time?.Cell; PapsPdfTextBox.Text = _generationData.Paps?.FieldName; TeamNumberPdfTextBox.Text = _generationData.TeamNumber?.FieldName; LocalPdfTextBox.Text = _generationData.Local?.FieldName; MealPdfTextBox.Text = _generationData.Meal?.FieldName; }
public static string Generate(GenerationData data) { data.Namespace = string.IsNullOrWhiteSpace(data.Namespace) ? "ZennoFramework.Generated" : data.Namespace; var result = Header.Create().NewLine(); result += "namespace " + data.Namespace.NewLine(); result += "{".NewLine(); foreach (var xml in data.XmlDocuments) { var document = XDocument.Parse(xml.Trim('\uFEFF', '\u200B')); var root = document.ToGenerationElements(); result = result.NewLineSafe(); result += WriteElements(root, " "); } return(result + "}".NewLine()); }
// public void InitializeNewGenerationDataArrays(int generationIndex) { if (recordScoresTrialDataArray == null) { // if first time: // USE THIS STUFF TO STORE GLOBAL RECORD SCORES PER-FITNESSCOMPONENT!!! // This will then be used to help score each generation in the future // I'm just re-using the data classes here but this might need a more custom solution later. // as with the rest of this system, it can't handle drastic changes to number/type of Trials, or adding/deleting fitness components. // Eventually I'll have to build a very flexible system that can handle gen0 being totally different from currentGen.... recordScoresTrialDataArray = new List<TrialData>(); int numActiveTrials = 0; for (int i = 0; i < playerRef.masterTrialsList.Count; i++) { // First loop needed just to Count if (playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) { // if active trial numActiveTrials++; } } // Loop through all Trials: for (int trialIndex = 0; trialIndex < numActiveTrials; trialIndex++) { // Get numFitnessComponents: int numFitnessComponents = playerRef.masterTrialsList[trialIndex].fitnessManager.masterFitnessCompList.Count; TrialData newTrialData = new TrialData(numFitnessComponents); for (int fitCompIndex = 0; fitCompIndex < numFitnessComponents; fitCompIndex++) { FitnessComponentData newFitnessComponentData = new FitnessComponentData(); newTrialData.fitnessComponentDataArray[fitCompIndex] = newFitnessComponentData; } recordScoresTrialDataArray.Add(newTrialData); } } // For This Player: if(generationIndex >= generationDataList.Count) { // if new generation needs to be created // !!!!!!!@!@!#$!@$#!$!@@@@@@@@@@@@@@@@@@@@@@@!@$#!#############!!!!!!!!!!!!!!!!!!!!!!^^^^^^^^^^^^^$%&###############%***********************$$$$$$$$########## // Calculate total TrialWeights and totalFitnessComponentWeights per Trial for later use somewhere in this function!!!! int numAgents = playerRef.masterPopulation.populationMaxSize; // Get number of Trials: int numActiveTrials = 0; for(int i = 0; i < playerRef.masterTrialsList.Count; i++) { // First loop needed just to Count if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) { // if active trial numActiveTrials++; } } GenerationData newGenerationData = new GenerationData(numActiveTrials); // Loop through all Trials: for(int trialIndex = 0; trialIndex < numActiveTrials; trialIndex++) { // Get numFitnessComponents: int numFitnessComponents = playerRef.masterTrialsList[trialIndex].fitnessManager.masterFitnessCompList.Count; TrialData newTrialData = new TrialData(numFitnessComponents); for(int fitCompIndex = 0; fitCompIndex < numFitnessComponents; fitCompIndex++) { FitnessComponentData newFitnessComponentData = new FitnessComponentData(numAgents); for(int a = 0; a < numAgents; a++) { AgentData newAgentData = new AgentData(); newFitnessComponentData.agentDataArray[a] = newAgentData; } newTrialData.totalSumOfWeights += playerRef.masterTrialsList[trialIndex].fitnessManager.masterFitnessCompList[fitCompIndex].weight; newTrialData.fitnessComponentDataArray[fitCompIndex] = newFitnessComponentData; } newGenerationData.totalSumOfWeights += playerRef.masterTrialsList[trialIndex].weight; newGenerationData.trialDataArray[trialIndex] = newTrialData; // actually assign the new AgentData instance to generationData newGenerationData.totalNumFitnessComponents = numFitnessComponents; } // AvgGenome: // Calculate Generation average genome: // BROKEN BECAUSE USING NEW GENOMES!!! /*Genome avgGenome = new Genome(); avgGenome.genomeBiases = new float[playerRef.masterPopulation.masterAgentArray[0].genome.genomeBiases.Length]; avgGenome.genomeWeights = new float[playerRef.masterPopulation.masterAgentArray[0].genome.genomeWeights.Length]; avgGenome.ZeroGenome(); // set all values to 0f; for (int i = 0; i < numAgents; i++) { // iterate through Bias Arrays and add each agent's bias value to the avg for (int b = 0; b < avgGenome.genomeBiases.Length; b++) { avgGenome.genomeBiases[b] += playerRef.masterPopulation.masterAgentArray[i].genome.genomeBiases[b] / (float)numAgents; } // iterate through Weight Arrays and add each agent's weight value to the avg for (int w = 0; w < avgGenome.genomeWeights.Length; w++) { avgGenome.genomeWeights[w] += playerRef.masterPopulation.masterAgentArray[i].genome.genomeWeights[w] / (float)numAgents; } } // Save the genome values to this generation Data: newGenerationData.genAvgGenome = avgGenome;*/ //newGenerationData.genAvgGenome.genomeBiases = avgGenome.genomeBiases; //newGenerationData.genAvgGenome.genomeWeights = avgGenome.genomeWeights; generationDataList.Add(newGenerationData); // Add the newly created generation data to the master list // OLD BELOW v v v v v v v v v v v v // Loop over all agents /*int numAgents = playerRef.masterPopulation.populationMaxSize; for (int j = 0; j < numAgents; j++) { AgentData newAgentData = new AgentData(numActiveTrials); // Fill the AgentData's TrialsList: int curTrialIndex = 0; int totalNumComponents = 0; for(int i = 0; i < playerRef.masterTrialsList.Count; i++) { if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) { // if active trial // For each Trial, Get number of FitnessComponents & GameRounds int numGameRounds = playerRef.masterTrialsList[i].numberOfPlays; int totalFitnessComponents = playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count + playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; int numActiveFitnessComponents = 0; // Brain Components: for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) { if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) { numActiveFitnessComponents++; totalNumComponents++; } } // Game Components: for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) { if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) { numActiveFitnessComponents++; totalNumComponents++; } } int curFitnessComponentIndex = 0; TrialData newTrialData = new TrialData(numActiveFitnessComponents); for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) { if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) { newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds); curFitnessComponentIndex++; } } for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) { if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) { newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds); curFitnessComponentIndex++; } } newAgentData.trialDataArray[curTrialIndex] = newTrialData; // Set AgentData for this agent. //Debug.Log ("curTrialIndex= " + curTrialIndex.ToString() + ", numGameRounds= " + numGameRounds.ToString() + ", numFitnessComponents= " + totalFitnessComponents.ToString() + ", numActiveFitnessComponents= " + numActiveFitnessComponents.ToString()); curTrialIndex++; // before or after? } } newGenerationData.agentDataArray[j] = newAgentData; // actually assign the new AgentData instance to generationData newGenerationData.totalNumFitnessComponents = totalNumComponents; } // generationDataList.Add (newGenerationData); // Add the newly created generation data to the master list */ } }
// public void InitializeNewGenerationDataArrays(int generationIndex) { // For This Player: if(generationIndex >= generationDataList.Count) { // if new generation needs to be created //Debug.Log ("InitializeNewGenerationDataArrays" + generationIndex.ToString()); int numAgents = playerRef.masterPopulation.populationMaxSize; GenerationData newGenerationData = new GenerationData(numAgents); // Now I have a generationData wrapper and an array of AgentData's // Get number of Trials int numActiveTrials = 0; for(int i = 0; i < playerRef.masterTrialsList.Count; i++) { // First loop needed just to Count if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) { // if active trial numActiveTrials++; } } //Debug.Log ("NumActiveTrials= " + numActiveTrials.ToString() + ", NumAgents= " + numAgents.ToString()); // Loop over all agents? for(int j = 0; j < numAgents; j++) { AgentData newAgentData = new AgentData(numActiveTrials); // Fill the AgentData's TrialsList: int curTrialIndex = 0; int totalNumComponents = 0; for(int i = 0; i < playerRef.masterTrialsList.Count; i++) { if(playerRef.masterTrialsList[i].miniGameManager.gameType != MiniGameManager.MiniGameType.None) { // if active trial // For each Trial, Get number of FitnessComponents & GameRounds int numGameRounds = playerRef.masterTrialsList[i].numberOfPlays; int totalFitnessComponents = playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count + playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; int numActiveFitnessComponents = 0; // Brain Components: for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) { if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) { numActiveFitnessComponents++; totalNumComponents++; } } // Game Components: for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) { if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) { numActiveFitnessComponents++; totalNumComponents++; } } int curFitnessComponentIndex = 0; TrialData newTrialData = new TrialData(numActiveFitnessComponents); for(int b = 0; b < playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList.Count; b++) { if(playerRef.masterTrialsList[i].fitnessManager.brainFitnessComponentList[b].on) { newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds); curFitnessComponentIndex++; } } for(int g = 0; g < playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList.Count; g++) { if(playerRef.masterTrialsList[i].fitnessManager.gameFitnessComponentList[g].on) { newTrialData.fitnessComponentDataArray[curFitnessComponentIndex] = new FitnessComponentData(numGameRounds); curFitnessComponentIndex++; } } newAgentData.trialDataArray[curTrialIndex] = newTrialData; // Set AgentData for this agent. //Debug.Log ("curTrialIndex= " + curTrialIndex.ToString() + ", numGameRounds= " + numGameRounds.ToString() + ", numFitnessComponents= " + totalFitnessComponents.ToString() + ", numActiveFitnessComponents= " + numActiveFitnessComponents.ToString()); curTrialIndex++; // before or after? } } newGenerationData.agentDataArray[j] = newAgentData; // actually assign the new AgentData instance to generationData newGenerationData.totalNumFitnessComponents = totalNumComponents; } // generationDataList.Add (newGenerationData); // Add the newly created generation data to the master list } }