GetRandomNumber() публичный статический Метод

public static GetRandomNumber ( int min, int max ) : int
min int
max int
Результат int
Пример #1
0
 public void Init(Tools tool)
 {
     this.tool = tool;
     // pick a colour from the image.
     Pixel pix = colours[tool.GetRandomNumber(0, colours.Length - 1)];
     Red = pix.R;
     Green = pix.G;
     Blue = pix.B;
     Alpha = tool.GetRandomNumber(Settings.ActiveAlphaRangeMin, Settings.ActiveAlphaRangeMax);
 }
Пример #2
0
        public double GetNextErrorLevel()
        {
            int tailIndex = 0;

            while (true)
            {
                var results = new List <DnaPartitionResult>();

                foreach (ClusteredWorker worker in workers)
                {
                    DnaPartitionResult partitionResult = worker.GetNextResult();
                    results.Add(partitionResult);
                }

                double newErrorLevel = 0;
                foreach (DnaPartitionResult partitionResult in results)
                {
                    newErrorLevel += partitionResult.ErrorLevel;
                }

                if (newErrorLevel <= currentErrorLevel)
                {
                    currentErrorLevel = newErrorLevel;
                    int newSeed = Tools.GetRandomNumber(int.MinValue, int.MaxValue);
                    foreach (ClusteredWorker worker in workers)
                    {
                        worker.AcceptGoodDrawing(tailIndex, newSeed);
                    }
                    break;
                }

                tailIndex++;
                //  Thread.Sleep(10);
            }


            return(currentErrorLevel);
        }
Пример #3
0
 public void Init(Tools tool)
 {
     this.tool = tool;
     X = tool.GetRandomNumber(0, Tools.MaxWidth);
     Y = tool.GetRandomNumber(0, Tools.MaxHeight);
 }