private Solution(Solution original, Cloner cloner) : base(original, cloner) { Tree = cloner.Clone(original.Tree); Path = (string)original.Path.Clone(); NrOfRounds = original.NrOfRounds; Enemies = cloner.Clone(original.Enemies); }
public BattleRunnerDialog(Solution solution) { InitializeComponent(); errorProvider.SetIconAlignment(robocodePathTextBox, ErrorIconAlignment.MiddleLeft); errorProvider.SetIconPadding(robocodePathTextBox, 2); nrOfRoundsNumericUpDown.Maximum = int.MaxValue; NrOfRounds = solution.NrOfRounds; Enemies = (EnemyCollection)solution.Enemies.Clone(new Cloner()); robocodePathTextBox.Text = Enemies.RobocodePath; }
public override void Analyze(ISymbolicExpressionTree[] trees, double[] qualities, ResultCollection results, IRandom random) { // find the tree with the best quality double maxQuality = double.NegativeInfinity; ISymbolicExpressionTree bestTree = null; for (int i = 0; i < qualities.Length; i++) { if (qualities[i] > maxQuality) { maxQuality = qualities[i]; bestTree = trees[i]; } } // create a solution instance var bestSolution = new Solution(bestTree, RobocodePath, NrOfRounds, Enemies); // also add the best solution as a result to the result collection // or alternatively update the existing result if (!results.ContainsKey("BestSolution")) { results.Add(new Result("BestSolution", "The best tank program", bestSolution)); } else { results["BestSolution"].Value = bestSolution; } }