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


C# FastRandom.NextDouble方法代码示例

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


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

示例1: SetSpawnPosition

        public override void SetSpawnPosition (Vector3 playerSpawn, PhysicsComponent ownPhysics, object map, FastRandom rand)
        {
            Maze.Maze maze = map as Maze.Maze;
            if (maze != null)
            {
                bool gotit = false;

                while (!gotit)
                {
                    int pos = rand.Next (0, maze.graph.Nodes.Count);
                    Vector3 spawn_pos;
                    float distance;
                    for (int i = pos; i < maze.graph.Nodes.Count; i++)
                    {
                        spawn_pos = maze.graph.Nodes[i].Data.WorldPosition;
                        Vector3.Distance(ref playerSpawn, ref spawn_pos, out distance);
                        if (maze.graph.Nodes[i].Data.MazeCellType == MazeCellType.Ground && distance > 50 &&
                            !maze.graph.Nodes[i].Data.IsExit)
                        {
                            gotit = true;
                            ownPhysics.RigidBody.Position = new JVector (maze.graph.Nodes[i].Data.WorldPosition.X, height,
                                maze.graph.Nodes[i].Data.WorldPosition.Z);
                            break;
                        }
                    }
                }

                if (!gotit)
                {
                    Logger.Log.AddLogEntry (LogLevel.Severe, "GhostAI", "Failed to generate spawn position!");
                }

                fallback = JVector.Transform (JVector.Backward, JMatrix.CreateFromAxisAngle (JVector.Up,
                    (float) rand.NextDouble() * 2 * MathHelper.Pi));
                direction = fallback;

                Spawned = true;
            }
        }
开发者ID:AreonDev,项目名称:NoWayOut,代码行数:39,代码来源:FenFireAI.cs

示例2: GetRandomAuxArgs

 /// <summary>
 /// For activation functions that accept auxiliary arguments; generates random initial values for aux arguments for newly
 /// added nodes (from an 'add neuron' mutation).
 /// </summary>
 public double[] GetRandomAuxArgs(FastRandom rng, double connectionWeightRange)
 {
     double[] auxArgs = new double[2];
     auxArgs[0] = (rng.NextDouble()-0.5) * 2.0;
     auxArgs[1] = rng.NextDouble();
     return auxArgs;
 }
开发者ID:MrChocolateMoose,项目名称:DeepHyperNEAT,代码行数:11,代码来源:RbfGaussian.cs

示例3: TestExpressions

        private static void TestExpressions()
        {
            /* Wood
             double	s = pow ( SineWave ( RingSpacing*sqrt ( x*x+y*y ) + TurbScale * Turbulence ( p, 3 ) ), Squeeze );
         	 t.Color = ( 1 - s ) * LightWood + s * DarkWood;
            string wood = "unit-$pow<$saw<3*sqrt<x*x+y*y*>+1.8*$t<c,3>>,5>";
             */
            string wood = "(unit-($saw<3*$sqrt<x*x+y*y*>>+$t<c,3>))*lw + ( ($saw<3*$sqrt<x*x+y*y*>>+$t<c,3>)*dw)";
            string expression = wood;
            //@"unit*$sqrt<x*x+y*y>";
            float x = 0.5f;
            float y = 0.7f;
            var p = new Vector(x, y, 2 - x - y);
            var p0 = new Vector(x, y, 0);
            var u = new RgbSpectrum(1f);

            var rnd = new FastRandom();
            var c = new RgbSpectrum(NoiseProvider.Instance.Noise3D(p));
            var evaluator = new GenericExpressionEvaluator<RgbSpectrum>((i) =>
                {
                    if (i is float)
                    {
                        return new RgbSpectrum((float)i);
                    }
                    if (i is double)
                    {
                        return new RgbSpectrum((float)((double)i));
                    }
                    if (i is int)
                    {
                        return new RgbSpectrum((int)i);
                    }
                    if (i is Int64)
                    {
                        return new RgbSpectrum((int)i);
                    }
                    return (RgbSpectrum)i;
                }, RgbSpectrum.FromStringData);

            var func = evaluator.Compile(expression);
            var f = rnd.NextDouble();
            Console.WriteLine("Script version: {0}", func(new
                {
                    e = f,
                    c,
                    u,
                    unit = RgbSpectrum.UnitSpectrum(),
                    lw = new RgbSpectrum(0.5f, 0.2f, 0.3f),
                    dw = new RgbSpectrum(0.3f, 0.1f, 0.1f),
                    x,
                    y,
                    arr = new[] { 0.5, 0.6, 0.6 },
                    n = c * 0.5f,
                }));

            Console.WriteLine("C# version : {0}", c * Math.Sqrt(x * x + y * y));

            return;
        }
开发者ID:HungryBear,项目名称:rayden,代码行数:59,代码来源:Program.cs

示例4: Particle

 public Particle(FastRandom rnd)
 {
     Deviation0 = (float)rnd.NextDouble() * 2f - 1f;
     //Deviation1 = (float)rnd.NextDouble() * 2f - 1f;
     //TextureIndex = (ushort)rnd.Next(4);
 }
开发者ID:Hamsand,项目名称:Swf2XNA,代码行数:6,代码来源:Particle.cs


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