Ejemplo n.º 1
0
        public List <DreamRadarFrame> Generate(ulong seed, Profile profile)
        {
            var frames = new List <DreamRadarFrame>();
            // Build the PIDRNG
            uint initialFrame = Functions.initialPIDRNG(seed, profile);
            var  pidrng       = new BWRng(seed);

            pidrng.Advance(initialFrame);

            // Build the MTRNG
            // todo: use fast MTRNG when available
            var ivrng = new MersenneTwister((uint)(seed >> 32));

            // advance 8 frames for BW2
            for (uint i = 0; i < 10; ++i)
            {
                ivrng.Next();
            }

            // one single advancement for entering the menu
            pidrng.GetNext64BitNumber();

            var spins = new List <DreamRadarFrame.Spin>();

            // initial advances
            for (uint i = 0; i < initialFrame; ++i)
            {
                Advance(pidrng, ivrng, spins);
            }

            // slot advances
            // we're always doing the slot 1 advance here
            pidrng.GetNext64BitNumber();

            for (uint i = 1; i < TargetSlot; ++i)
            {
                SlotAdvances(pidrng, ivrng);
            }

            for (uint i = initialFrame; i <= MaxFrame; ++i)
            {
                DreamRadarFrame frame = GeneratePokemon(pidrng, ivrng);

                var arrSpins = new DreamRadarFrame.Spin[spins.Count];
                spins.CopyTo(arrSpins);
                frame.Spins = arrSpins;

                // add checks/comparisons on the frame here
                // nature/IVs
                frames.Add(frame);
                Advance(pidrng, ivrng, spins);
            }

            return(frames);
        }
Ejemplo n.º 2
0
        private DreamRadarFrame GeneratePokemon(BWRng pidrng2, MersenneTwister ivrng2)
        {
            var pidrng = new BWRng(pidrng2.Seed);
            var ivrng  = new MersenneTwister(ivrng2);
            var frame  = new DreamRadarFrame();

            frame.Pid = GeneratePID(pidrng);
            // two unknown advances
            pidrng.GetNext64BitNumber();
            pidrng.GetNext64BitNumber();
            frame.Nature = pidrng.GetNext32BitNumber(25);
            // IVs
            frame.Hp  = ivrng.Next() >> 27;
            frame.Atk = ivrng.Next() >> 27;
            frame.Def = ivrng.Next() >> 27;
            frame.Spa = ivrng.Next() >> 27;
            frame.Spd = ivrng.Next() >> 27;
            frame.Spe = ivrng.Next() >> 27;

            return(frame);
        }
Ejemplo n.º 3
0
        private DreamRadarFrame GeneratePokemon(BWRng pidrng2, MersenneTwister ivrng2)
        {
            var pidrng = new BWRng(pidrng2.Seed);
            var ivrng = new MersenneTwister(ivrng2);
            var frame = new DreamRadarFrame();

            frame.Pid = GeneratePID(pidrng);
            // two unknown advances
            pidrng.GetNext64BitNumber();
            pidrng.GetNext64BitNumber();
            frame.Nature = pidrng.GetNext32BitNumber(25);
            // IVs
            frame.Hp = ivrng.Next() >> 27;
            frame.Atk = ivrng.Next() >> 27;
            frame.Def = ivrng.Next() >> 27;
            frame.Spa = ivrng.Next() >> 27;
            frame.Spd = ivrng.Next() >> 27;
            frame.Spe = ivrng.Next() >> 27;

            return frame;
        }