コード例 #1
0
 void eliminateLVPToolStripMenuItem_Click(object sender, EventArgs e)
 {
     lock (State.ImprovementLock) {
         ShapeEvaluation[] polys = PolygonValueEvaluator.SortShapes(State);
         int    i    = 0;
         Random rand = new Random();
         ClearOutlines();
         while (polys[polys.Length - 1 - i].Divergence <= DivergenceEliminationThreshold)
         {
             State.BestMatch.DivideShape(rand,
                                         Array.IndexOf(State.BestMatch.Shapes, polys[i + 1].Shape),
                                         Array.IndexOf(State.BestMatch.Shapes, polys[polys.Length - 1 - i].Shape));
             i++;
         }
         picBestMatch.Invalidate();
         State.SetEvaluator(State.Evaluator);
         UpdateTick();
         MessageBox.Show("Redistributed " + i + " shapes.", "Least Valuable Polygon elimination");
     }
 }
コード例 #2
0
 void evaluatePolygonValueToolStripMenuItem_Click(object sender, EventArgs e)
 {
     lock (State.ImprovementLock) {
         ShapeEvaluation[] polys = PolygonValueEvaluator.SortShapes(State);
         int polysToShow         = polys.Count(shape => shape.Divergence <= DivergenceEliminationThreshold);
         var sb = new StringBuilder();
         ClearOutlines();
         foreach (var kvp in polys.Skip(1).Take(polysToShow))
         {
             sb.AppendLine("MVP: " + kvp.Divergence);
             State.BestMatch.Shapes[kvp.Ordinal].OutlineColor = Color.Green;
         }
         sb.AppendLine();
         foreach (var kvp in polys.Reverse().Take(polysToShow))
         {
             sb.AppendLine("LVP: " + kvp.Divergence);
             State.BestMatch.Shapes[kvp.Ordinal].OutlineColor = Color.Red;
         }
         picBestMatch.Invalidate();
         MessageBox.Show(sb.ToString(), "Polygon evaluation");
     }
 }