コード例 #1
0
ファイル: NodeGrid.cs プロジェクト: tp-nscan/NodePad
        public NodeGrid(Sz2 <int> strides, IEnumerable <P1V <int, float> > tuples, int generation, int seed)
        {
            Strides = strides;
            Values  = new float[Strides.Count()];
            foreach (var tup in tuples)
            {
                Values[tup.X] = tup.V;
            }

            Generation = generation;

            Seed = seed;
            var randy = GenV.Twist(Seed);

            Noise    = GenS.NormalSF32(randy, 0.0f, 1.0f).Take(Strides.Count()).ToArray();
            NextSeed = randy.Next();

            var Offhi = new P2 <int>(0, -1);
            var Offlo = new P2 <int>(0, 1);
            var Offlf = new P2 <int>(-1, 0);
            var Offrt = new P2 <int>(1, 0);

            Top    = GridUtil.OffsetIndexes(Strides, Offhi);
            Bottom = GridUtil.OffsetIndexes(Strides, Offlo);
            Left   = GridUtil.OffsetIndexes(Strides, Offlf);
            Right  = GridUtil.OffsetIndexes(Strides, Offrt);
        }
コード例 #2
0
ファイル: Star4Grid.cs プロジェクト: tp-nscan/NodePad
 public Star4Grid(float[,] initVals, float[,] fixedVals, int seed)
 {
     Seed       = seed;
     Noise      = GenS.NormalSF32(GenV.Twist(seed), 0.0f, 1.0f);
     Stars      = Star4Procs.MakeStarGrid(initVals, fixedVals);
     Rows       = Stars.GetLength(1);
     Columns    = Stars.GetLength(0);
     Generation = 0;
 }
コード例 #3
0
 public StarGrid(float[,] initVals, int noiseSeed)
 {
     NoiseSeed  = noiseSeed;
     Noise      = GenS.NormalSF32(GenV.Twist(NoiseSeed), 0.0f, 1.0f);
     Stars      = StarProcs.MakeStarGrid(initVals);
     Rows       = Stars.GetLength(1);
     Columns    = Stars.GetLength(0);
     Generation = 0;
 }
コード例 #4
0
ファイル: NodeProcs.cs プロジェクト: tp-nscan/NodePad
        public static NodeGrid RandNodeGrid(Sz2 <int> bounds, int initSeed, int updateSeed)
        {
            var nodeVals = GenS.SeqOfRandUF32(GenV.Twist(initSeed)).Take(bounds.Count()).ToArray();
            var tuples   = Enumerable.Range(0, bounds.Count()).Select(i => new P1V <int, float>(i, nodeVals[i]));

            return(new NodeGrid(
                       strides: bounds,
                       tuples: tuples,
                       generation: 0,
                       seed: updateSeed
                       ));
        }