当前位置: 首页>>代码示例>>C#>>正文


C# FastRandom类代码示例

本文整理汇总了C#中FastRandom的典型用法代码示例。如果您正苦于以下问题:C# FastRandom类的具体用法?C# FastRandom怎么用?C# FastRandom使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FastRandom类属于命名空间,在下文中一共展示了FastRandom类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitBoxes

        private void InitBoxes(int Seed)
        {
            FastRandom rnd = new FastRandom(Seed);

            for (int i = 0; i < DataSize; i++)
            {
                //set random values in Box B (The output box)
                byte[] TempValues = new byte[BOX_SIZE];
                for (int x = 0; x < BOX_SIZE; x++)
                    TempValues[x] = (byte)x;
                ShuffleValues(TempValues, Seed);

                for (int j = 0; j < BOX_SIZE; j++)
                {
                    BOX_B[i, j] = TempValues[j];
                }

                //Set in Box A where the index of Box B
                for (int j = 0; j < BOX_SIZE; j++)
                {
                    for (int x = 0; x < BOX_SIZE; x++)
                    {
                        if (BOX_B[i, x] == j)
                        {
                            BOX_A[i, j] = (byte)x;
                            break;
                        }
                    }
                }
            }
        }
开发者ID:PavilionVI,项目名称:SecureSocketProtocol,代码行数:31,代码来源:DataConfuser.cs

示例2: RandomDecimalString

 public static String RandomDecimalString(FastRandom r)
 {
     int count = r.NextValue(20) + 1;
       StringBuilder sb = new StringBuilder();
       if (r.NextValue(2) == 0) sb.Append('-');
       for (int i = 0; i < count; i++) {
     if (i == 0)
       sb.Append((char)('1' + r.NextValue(9)));
     else
       sb.Append((char)('0' + r.NextValue(10)));
       }
       if (r.NextValue(2) == 0) {
     sb.Append('.');
     count = r.NextValue(20) + 1;
     for (int i = 0; i < count; i++) {
       sb.Append((char)('0' + r.NextValue(10)));
     }
       }
       if (r.NextValue(2) == 0) {
     sb.Append('E');
     count = r.NextValue(20);
     if (count != 0) {
       sb.Append(r.NextValue(2) == 0 ? '+' : '-');
     }
     sb.Append(Convert.ToString(
       (int)count, CultureInfo.InvariantCulture));
       }
       return sb.ToString();
 }
开发者ID:KSLcom,项目名称:CBOR,代码行数:29,代码来源:CBORTest.cs

示例3: GenerateInputOutput

    protected override Tuple<string[], string[]> GenerateInputOutput() {
      FastRandom rand = new FastRandom();
      List<List<int>> vectors = GetHardcodedTrainingSamples();
      var zeros = GetHardcodedZeros();
      var trainZeros = zeros.SampleRandomWithoutRepetition(rand, 30).ToList();
      var testZeros = zeros.Except<List<int>>(trainZeros, new EnumerableValueEqualityComparer<int>()).ToList();
      var help1 = GetDistinctPermutations(new int[4] { 0, 5, -8, 9 });
      var trainHelp1 = help1.SampleRandomWithoutRepetition(rand, 20).ToList();
      var testHelp1 = help1.Except<List<int>>(trainHelp1, new EnumerableValueEqualityComparer<int>()).ToList();
      var help2 = GetDistinctPermutations(new int[4] { 0, 0, -8, 9 });
      var trainHelp2 = help2.SampleRandomWithoutRepetition(rand, 10).ToList();
      var testHelp2 = help2.Except<List<int>>(trainHelp2, new EnumerableValueEqualityComparer<int>()).ToList();
      var help3 = GetDistinctPermutations(new int[4] { 0, 0, 0, 9 });

      vectors.AddRange(trainZeros);
      vectors.AddRange(trainHelp1);
      vectors.AddRange(trainHelp2);
      vectors.AddRange(help3);

      vectors.AddRange(GetRandomVectors(78, rand).ToList());

      vectors = vectors.Shuffle(rand).ToList();

      vectors.AddRange(testZeros);
      vectors.AddRange(testHelp1);
      vectors.AddRange(testHelp2);
      vectors.AddRange(GetRandomVectors(974, rand).ToList());

      var input = vectors.Select(x => String.Format("[{0}]", String.Join(", ", x))).ToArray();
      var output = vectors.Select(x => x.LastIndexOf(0).ToString()).ToArray();
      return new Tuple<string[], string[]>(input, output);
    }
开发者ID:t-h-e,项目名称:HeuristicLab.CFGGP,代码行数:32,代码来源:LastIndexOfZero.cs

示例4: NeuralColorQuantizer

        /// <summary>
        /// Initializes a new instance of the <see cref="NeuralColorQuantizer"/> class.
        /// </summary>
        public NeuralColorQuantizer()
        {
            Quality = DefaultQuality;

            random = new FastRandom(0);
            uniqueColors = new ConcurrentDictionary<Int32, Boolean>();
        }
开发者ID:RHY3756547,项目名称:FreeSO,代码行数:10,代码来源:NeuralColorQuantizer.cs

示例5: MsgKeepAlive

 public MsgKeepAlive()
     : base()
 {
     FastRandom fastRand = new FastRandom();
     this.Payload = new byte[fastRand.Next(32, 256)];
     fastRand.NextBytes(this.Payload);
 }
开发者ID:PavilionVI,项目名称:SecureSocketProtocol,代码行数:7,代码来源:MsgKeepAlive.cs

示例6: MarkovChainSampler

 public MarkovChainSampler()
 {
     this.sampleCache = new Stack<Sample>(100);
     rnd = new FastRandom();
     TotalSamples = 0L;
     samplesInPass = 0;
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:7,代码来源:MarkovChainSampler.cs

示例7: PreyCaptureWorld

 /// <summary>
 /// Constructs with the provided world parameter arguments.
 /// </summary>
 public PreyCaptureWorld(int gridSize, int preyInitMoves, double preySpeed, double sensorRange, int maxTimesteps)
 {
     _gridSize = gridSize;
     _preyInitMoves = preyInitMoves;
     _preySpeed = preySpeed;
     _sensorRange = sensorRange;
     _maxTimesteps = maxTimesteps;
     _rng = new FastRandom();
 }
开发者ID:MrChocolateMoose,项目名称:DeepHyperNEAT,代码行数:12,代码来源:PreyCaptureWorld.cs

示例8: InitNoise

 public void InitNoise() {
     var RNG = new FastRandom();
     NoiseTable = new float[NoiseDim + 1, NoiseDim + 1, NoiseDim + 1];
     int i, j, k;
     for (i = 0; i < NoiseDim; i++)
         for (j = 0; j < NoiseDim; j++)
             for (k = 0; k < NoiseDim; k++)
                 NoiseTable[i, j, k] = RNG.NextFloat();
 }
开发者ID:HungryBear,项目名称:rayden,代码行数:9,代码来源:NoiseProvider.cs

示例9: FastRandom

 /// <summary>
 /// Initializes a new instance from an existing one (copy constructor).
 /// </summary>
 /// <param name="original">The original <see cref="FastRandom"/> instance which is used to initialize the new instance.</param>
 /// <param name="cloner">A <see cref="Cloner"/> which is used to track all already cloned objects in order to avoid cycles.</param>
 private FastRandom(FastRandom original, Cloner cloner)
   : base(original, cloner) {
   x = original.x;
   y = original.y;
   z = original.z;
   w = original.w;
   bitBuffer = original.bitBuffer;
   bitMask = original.bitMask;
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:14,代码来源:FastRandom.cs

示例10: PathGenerator

 public PathGenerator(uint seed, GetHeight getHeight)
 {
     m_getHeight = getHeight;
     var fastRandom = new FastRandom(seed);
     m_cellNoise = new CellNoise2D(fastRandom.NextUInt());
     m_sources = new Dictionary<uint, PathGraphNode>();
     m_sinks = new Dictionary<uint, PathGraphNode>();
     m_general = new Dictionary<uint, PathGraphNode>();
     m_paths = new List<PathNodeList>();
 }
开发者ID:HaKDMoDz,项目名称:4DBlockEngine,代码行数:10,代码来源:PathGenerator.cs

示例11: MarkovChain

        public MarkovChain(MarkovChainNode[] nodes, int stepsPerActivation, FastRandom random)
        {
            _nodes = nodes;
            _stepsPerActivation = stepsPerActivation;
            _random = random;

            _rouletteWheels = new RouletteWheelLayout[nodes.Length];
            for (int i = 0; i < nodes.Length; i++)
                _rouletteWheels[i] = new RouletteWheelLayout(nodes[i].TransitionProbabilities);
        }
开发者ID:tansey,项目名称:password-evolution,代码行数:10,代码来源:MarkovChain.cs

示例12: GetRandomVectors

 private IEnumerable<List<int>> GetRandomVectors(int n, FastRandom rand) {
   for (int i = 0; i < n; i++) {
     int length = rand.Next(1, 50);
     List<int> cur = new List<int>(length) { 0 };
     for (int j = 0; j < length - 1; j++) {
       cur.Add(rand.Next(-50, 50));
     }
     yield return cur.Shuffle(rand).ToList();
   }
 }
开发者ID:t-h-e,项目名称:HeuristicLab.CFGGP,代码行数:10,代码来源:LastIndexOfZero.cs

示例13: FiniteAppertureCamera

        public FiniteAppertureCamera(Point eye, Vector dirt, Vector up, int width, int height, float fov)
        {
            rnd = new FastRandom();
            this.fieldOfView = fov;
            this.Height = height;
            this.Width = width;
            this.Position = eye;
            this.Target = dirt;
            this.Up = up;

            this.Update();
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:12,代码来源:FiniteAppertureCamera.cs

示例14: TestCBORObjectDecimal

 public void TestCBORObjectDecimal()
 {
     FastRandom rand = new FastRandom();
       for (int i = 0; i <= 28; i++) { // Try a random decimal with a given exponent
     for (int j = 0; j < 8; j++) {
       decimal d = RandomDecimal(rand, i);
       CBORObject obj = CBORObject.FromObject(d);
       TestCommon.AssertRoundTrip(obj);
       Assert.AreEqual(d, obj.AsDecimal());
     }
       }
 }
开发者ID:KSLcom,项目名称:CBOR,代码行数:12,代码来源:CBORExtraTest.cs

示例15: RandomBigIntString

 public static String RandomBigIntString(FastRandom r)
 {
     int count = r.NextValue(50) + 1;
       StringBuilder sb = new StringBuilder();
       if (r.NextValue(2) == 0) sb.Append('-');
       for (int i = 0; i < count; i++) {
     if (i == 0)
       sb.Append((char)('1' + r.NextValue(9)));
     else
       sb.Append((char)('0' + r.NextValue(10)));
       }
       return sb.ToString();
 }
开发者ID:KSLcom,项目名称:CBOR,代码行数:13,代码来源:CBORTest.cs


注:本文中的FastRandom类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。