Normalize() 공개 메소드

public Normalize ( double d, int i ) : int
d double
i int
리턴 int
        public void Render()
        {
            NEATGenome genome = (NEATGenome)this.pop.BestGenome;
            Substrate substrate = SubstrateFactory.factorSandwichSubstrate(resolution, resolution);
            HyperNEATCODEC codec = new HyperNEATCODEC();
            NEATNetwork phenotype = (NEATNetwork)codec.Decode(this.pop, substrate, genome);

            TrialEvaluation trial = new TrialEvaluation(phenotype, this.testCase);
            IntPair actualPos = trial.Query(resolution);

            // clear what was there before
            GridCanvas.Children.Clear();

            //
            double boxWidth = GridCanvas.ActualWidth / resolution;
            double boxHeight = GridCanvas.ActualHeight / resolution;
            double delta = 2.0 / resolution;
            int index = 0;

            for (int row = 0; row < resolution; row++)
            {
                double y = -1 + (row * delta);
                double boxY = row * boxHeight;
                for (int col = 0; col < resolution; col++)
                {
                    double x = -1 + (col * delta);
                    double boxX = col * boxWidth;

                    Rectangle r = new Rectangle();
                    r.SetValue(Canvas.LeftProperty, boxX);
                    r.SetValue(Canvas.TopProperty, boxY);
                    r.Width = boxWidth;
                    r.Height = boxHeight;

                    if (this.testCase.GetPixel(x, y) > 0)
                    {
                        r.Fill = Brushes.Blue;
                    }
                    else
                    {
                        double d = trial.Output[index];
                        int c = trial.Normalize(d, 255);
                        SolidColorBrush b = new SolidColorBrush(Color.FromRgb(255, (byte)c, 255));
                        r.Fill = b;
                        r.Stroke = Brushes.Black;
                    }

                    GridCanvas.Children.Add(r);
                    index++;
                }
            }

            Rectangle target = new Rectangle();
            target.SetValue(Canvas.LeftProperty, actualPos.X * boxWidth);
            target.SetValue(Canvas.TopProperty, actualPos.Y * boxHeight);
            target.Width = boxWidth;
            target.Height = boxHeight;
            target.Fill = Brushes.Red;
            GridCanvas.Children.Add(target);
        }
        public void Render()
        {
            NEATGenome     genome    = (NEATGenome)this.pop.BestGenome;
            Substrate      substrate = SubstrateFactory.factorSandwichSubstrate(resolution, resolution);
            HyperNEATCODEC codec     = new HyperNEATCODEC();
            NEATNetwork    phenotype = (NEATNetwork)codec.Decode(this.pop, substrate, genome);

            TrialEvaluation trial     = new TrialEvaluation(phenotype, this.testCase);
            IntPair         actualPos = trial.Query(resolution);

            // clear what was there before
            GridCanvas.Children.Clear();

            //
            double boxWidth  = GridCanvas.ActualWidth / resolution;
            double boxHeight = GridCanvas.ActualHeight / resolution;
            double delta     = 2.0 / resolution;
            int    index     = 0;

            for (int row = 0; row < resolution; row++)
            {
                double y    = -1 + (row * delta);
                double boxY = row * boxHeight;
                for (int col = 0; col < resolution; col++)
                {
                    double x    = -1 + (col * delta);
                    double boxX = col * boxWidth;

                    Rectangle r = new Rectangle();
                    r.SetValue(Canvas.LeftProperty, boxX);
                    r.SetValue(Canvas.TopProperty, boxY);
                    r.Width  = boxWidth;
                    r.Height = boxHeight;

                    if (this.testCase.GetPixel(x, y) > 0)
                    {
                        r.Fill = Brushes.Blue;
                    }
                    else
                    {
                        double          d = trial.Output[index];
                        int             c = trial.Normalize(d, 255);
                        SolidColorBrush b = new SolidColorBrush(Color.FromRgb(255, (byte)c, 255));
                        r.Fill   = b;
                        r.Stroke = Brushes.Black;
                    }

                    GridCanvas.Children.Add(r);
                    index++;
                }
            }

            Rectangle target = new Rectangle();

            target.SetValue(Canvas.LeftProperty, actualPos.X * boxWidth);
            target.SetValue(Canvas.TopProperty, actualPos.Y * boxHeight);
            target.Width  = boxWidth;
            target.Height = boxHeight;
            target.Fill   = Brushes.Red;
            GridCanvas.Children.Add(target);
        }