예제 #1
0
    static void Init()
    {
        //set up seed
        uint seed = TMath.Seed();

        //overide
        //seed = 809171303;

        System.Console.WriteLine(seed.ToString());

        var gen = new XorShift128Generator(seed);

        for (int i = 0; i < 3; i++) // Becuase of bug in RNG, make sure we are completely pseudo-random
        {
            gen.Next();
        }
        GoRogue.Random.SingletonRandom.DefaultRNG = gen;

        MapGen generator = new MapGen(BuildBlob9());

        ArrayMap <Cell> map = generator.GenerateMap(9);

        var console = new Console(map.Width, map.Height, map);

        SadConsole.Global.CurrentScreen = console;
    }
예제 #2
0
 public GameContext(uint?seed = null)
 {
     if (seed == null)
     {
         RNG = new XorShift128Generator();
     }
     else
     {
         RNG = new XorShift128Generator(seed.Value);
     }
 }
예제 #3
0
        private static IGenerator GetDefaultGenerator()
        {
            var gen = new XorShift128Generator();

            for (int i = 0; i < 3; i++)             // Becuase of bug in RNG, make sure we are completely pseudo-random
            {
                gen.Next();
            }

            return(gen);
        }
예제 #4
0
        public void TestDungeonGenNonDefaultRNG()
        {
            var map = new ArrayMap <bool>(100, 100);
            // Assert no exceptions are thrown
            var gen = new XorShift128Generator();

            for (int i = 0; i < 3; i++)             // Due to Troscheutz.Random bug
            {
                gen.Next();
            }

            QuickGenerators.GenerateDungeonMazeMap(map, gen, 10, 30, 4, 9);
        }
예제 #5
0
        public void Serializing_XorShift128Generator_keeps_sequence()
        {
            var r1 = new XorShift128Generator();

            for (var i = 0; i < 10; i++)
            {
                int toss = r1.Next();
            }

            byte[] ser_r1 = ObjectToByteArray(r1);
            string b64_r1 = Convert.ToBase64String(ser_r1);

            byte[] ser_r2 = Convert.FromBase64String(b64_r1);
            var    r2     = (XorShift128Generator)ByteArrayToObject(ser_r2);

            for (var j = 0; j < 100; j++)
            {
                int r1_out = r1.Next();
                int r2_out = r2.Next();

                Assert.That(r1_out, Is.EqualTo(r2_out));
            }
        }