private void CheckF() { if (setF1 != setF2) { return; } ParetoPointGeneration gen = new ParetoPointGeneration(); for (int i = 0; i < F1.Length; i++) { gen.Points.Add(new MyPoint(F1[i], F2[i])); } // pareto uint[] indicies = ParetoFrontFinder.FindParetoFront(F1, F2); ParetoIncidies = indicies.Select(n => (int)n).ToArray(); ParetoFront.Clear(); for (int i = 0; i < indicies.Length; i++) { ParetoFront.Add(new Point(F1[indicies[i]], F2[indicies[i]])); } // calc colors Generations.Add(gen); if (Generations.Count > maxGen) { Generations.RemoveAt(0); } for (int i = 0; i < Generations.Count; i++) { byte c = (byte)(255 - ((double)i + 1) / Generations.Count * 255); Generations[i].Color = new SolidColorBrush(Color.FromArgb(255, c, c, c)); Generations[i].Size = i == Generations.Count - 1 ? 8 : 4; } RecalculateScale(); if (!Generations.Any()) { return; } if (!Generations.Last().Points.Any()) { return; } if (SelectedIndex >= Generations.Last().Points.Count) { return; } SelectedPoint = Generations.Last().Points[SelectedIndex]; }
public void UpdateNewIteration(int startCol, int endCol) { Cell[,] Previous = Generations.Last(); if (startCol == -1 || endCol == -1) { startCol = 0; endCol = GameCols - 1; } for (int i = 0; i < GameRows; i++) { for (int j = startCol; j <= endCol; j++) { int num = 0; int[] temp = Neightbourhood(Previous, i, j); for (int k = 0; k < temp.Length; k++) { if (temp[k] != -1) { if (temp[k] == 1) { num++; } } } if (Previous[i, j].State == 1) { if (num == 2 || num == 3) { Current[i, j].State = 1; } else { Current[i, j].State = 0; } } else { if (num == 3) { Current[i, j].State = 1; } else { Current[i, j].State = 0; } } } } }
/// <summary> /// Вернуть текущее поколение /// </summary> /// <returns></returns> public Generation GetGeneration() { return(Generations.Last()); }
/// <summary> /// Добавить пару state, action для поколения /// </summary> /// <param name="state"></param> /// <param name="action"></param> public void AddCondition(State state, Action action) { var last = Generations.Last(); last.Add(state, action); }
/// <summary> /// Получить score последнего поколения /// </summary> /// <returns></returns> public double GetScore() { return(Generations.Last().GetScore()); }
/// <summary> /// Обновить очки в текущей жизни /// </summary> /// <param name="score"></param> public void SetScore(double score) { Generations.Last().SetScore(score); }