Beispiel #1
0
        /// <summary>
        /// Return a deep copy
        /// </summary>
        public IRNG DeepClone()
        {
            RNG2002 newRNG = new RNG2002();

            newRNG.loadState(saveState());

            return(newRNG);
        }
Beispiel #2
0
        private void displayRNG(UInt64 start, UInt64 end)
        {
            IRNG displayRNG;

            if (cbPlatform.SelectedItem as string == "PS2")
            {
                displayRNG = new RNG1998();
            }
            else
            {
                displayRNG = new RNG2002();
            }
            //Clear datagridview
            dataGridView1.Rows.Clear();
            //Consume RNG seeds before our desired index
            //This can take obscene amounts of time.
            DateTime startt = DateTime.Now;

            for (UInt64 i = 0; i < start; i++)
            {
                displayRNG.genrand();
            }
            DateTime endtt = DateTime.Now;

            toolStripStatusLabelPercent.Text = (endtt - startt).Milliseconds.ToString();
            for (UInt64 i = start; i < end; i++)
            {
                //Start actually displaying
                UInt32 aVal = displayRNG.genrand();
                dataGridView1.Rows.Add();
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0].Value = i;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value = aVal;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[2].Value = randToHeal(aVal);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[3].Value = randToPercent(aVal);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[4].Value = (aVal < 0x1000000);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[5].Value = stealCompute(aVal, displayRNG, false);
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[6].Value = stealCompute(aVal, displayRNG, true);
            }
        }
Beispiel #3
0
        private void displayRNG(int start, int end)
        {
            IRNG displayRNG;

            if (cbPlatform.SelectedItem as string == "PS2")
            {
                displayRNG = new RNG1998();
            }
            else
            {
                displayRNG = new RNG2002();
            }
            //Clear datagridview
            dataGridView1.Rows.Clear();
            //Consume RNG seeds before our desired index
            //This can take obscene amounts of time.
            DateTime startt = DateTime.Now;

            for (int index = 0; index < start; index++)
            {
                displayRNG.genrand();
            }
            DateTime endtt = DateTime.Now;

            toolStripStatusLabelPercent.Text = (endtt - startt).Milliseconds.ToString();

            // Rare 1:
            double spawnMin1, spawnMax1;
            int    rareRNGPosition1;

            double.TryParse(tbMin1.Text, out spawnMin1);
            double.TryParse(tbMax1.Text, out spawnMax1);
            int.TryParse(tbRNG1.Text, out rareRNGPosition1);

            // Convert to fraction:
            spawnMin1 /= 100.0;
            spawnMax1 /= 100.0;

            // Rare 2:
            double spawnMin2, spawnMax2;
            int    rareRNGPosition2;

            double.TryParse(tbMin2.Text, out spawnMin2);
            double.TryParse(tbMax2.Text, out spawnMax2);
            int.TryParse(tbRNG2.Text, out rareRNGPosition2);

            // Convert to fraction:
            spawnMin2 /= 100.0;
            spawnMax2 /= 100.0;

            // Use these variables to check for first instance of chest and contents
            bool rareSpawn1    = false;
            int  rareFoundPos1 = 0;

            bool rareSpawn2    = false;
            int  rareFoundPos2 = 0;

            // Last rare 1 before rare 2 variable, for Ishteen
            int rareFoundPos3 = 0;

            // Use these variables to check for first punch combo
            bool comboFound = false;
            int  comboPos   = 0;

            UInt32 aVal1 = displayRNG.genrand();
            UInt32 aVal2 = displayRNG.genrand();

            // We want to preserve the character index, since this loop is just for display:
            int indexStatic = group.GetIndex();

            group.ResetIndex();

            //group.ResetIndex();
            for (int index = start; index < end; index++)
            {
                // Index starting at 0
                int index0 = index - start;

                // Get the heal value once:
                int healNow  = group.GetHealValue(aVal1);
                int healNext = group.PeekHealValue(aVal2);

                // Get chance to spawn rare game
                float spawnChance = (float)aVal1 / 4294967296;

                // Put the next expected heal in the text box
                if (index == start + healVals.Count - 1)
                {
                    tbLastHeal.Text = healNext.ToString();
                    //tbAppear1.Text = group.HealMin().ToString();
                    //tbItem1.Text = group.HealMax().ToString();
                }

                // Advance the RNG before starting the loop in case we want to skip an entry
                UInt32 aVal1_temp = aVal1;
                UInt32 aVal2_temp = aVal2;
                aVal1 = aVal2;
                aVal2 = displayRNG.genrand();

                // Skip the entry if it's too long ago
                if (index0 < healVals.Count - 5)
                {
                    continue;
                }

                //Start actually displaying
                dataGridView1.Rows.Add();

                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0].Value = index;
                //dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value = aVal1;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value = healNow;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[2].Value = spawnChance;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[3].Value = aVal1_temp.ToString("N0");

                // Check if the rares are in a position offset by a fixed amount

                if (rareCheck(spawnChance, spawnMin1, spawnMax1))
                {
                    int chestFirstChance = healVals.Count + rareRNGPosition1 - 1;

                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightBlue;
                    if (index0 >= chestFirstChance && !rareSpawn1)
                    {
                        rareFoundPos1 = index0 - healVals.Count - rareRNGPosition1 + 1;
                        rareSpawn1    = true;
                    }
                }
                if (rareCheck(spawnChance, spawnMin2, spawnMax2))
                {
                    int chestFirstChance = healVals.Count + rareRNGPosition2 - 1;

                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Crimson;
                    if (index0 >= chestFirstChance && !rareSpawn2)
                    {
                        rareFoundPos2 = index0 - healVals.Count - rareRNGPosition2 + 1;
                        rareSpawn2    = true;
                    }
                }
                if (rareCheck(spawnChance, spawnMin1, spawnMax1) && rareCheck(spawnChance, spawnMin2, spawnMax2))
                {
                    //int chestFirstChance = healVals.Count + Math.Max(rareRNGPosition1, rareRNGPosition2)+ 1;

                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.Orchid;
                }
                if (rareCheck(spawnChance, spawnMin1, spawnMax1))
                {
                    // Check if rare 2 has been found yet
                    if (!rareSpawn2)
                    {
                        rareFoundPos3 = index0 - healVals.Count - rareRNGPosition1 + 1;
                    }
                }

                // Color consumed RNG green
                if (index0 < healVals.Count)
                {
                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightGreen;
                }

                int comboCheck = index0 - healVals.Count - 5 + 1;
                if (comboCheck % 10 == 0 && comboCheck >= 0 && !comboFound &&
                    Combo.IsSucessful(aVal1_temp))
                {
                    comboFound = true;
                    comboPos   = comboCheck / 10;
                }
            }

            tbAppear1.Text = rareFoundPos1.ToString();

            tbAppear2.Text = rareFoundPos2.ToString();

            tbAppear12.Text = rareFoundPos3.ToString();

            tbCombo.Text = comboPos.ToString();

            tbLastHeal.Focus();
            tbLastHeal.SelectAll();

            group.SetIndex(indexStatic);
        }
Beispiel #4
0
        private void displayRNG(int start, int end)
        {
            IRNG displayRNG;

            if (cbPlatform.SelectedItem as string == "PS2")
            {
                displayRNG = new RNG1998();
            }
            else
            {
                displayRNG = new RNG2002();
            }
            //Clear datagridview
            dataGridView1.Rows.Clear();
            //Consume RNG seeds before our desired index
            //This can take obscene amounts of time.
            DateTime startTime = DateTime.Now;

            for (int i = 0; i < start; i++)
            {
                displayRNG.genrand();
            }
            DateTime endTime = DateTime.Now;

            toolStripStatusLabelPercent.Text = (endTime - startTime).Milliseconds.ToString();

            Steal steal      = new Steal();
            Steal stealCuffs = new Steal();

            int rarePosition      = 0;
            int rarePositionCuffs = 0;

            bool rareSteal      = false;
            bool rareStealCuffs = false;

            // Use these variables to check for first punch combo
            bool comboFound = false;
            int  comboPos   = 0;

            uint aVal1 = displayRNG.genrand();
            uint aVal2 = displayRNG.genrand();
            uint aVal3 = displayRNG.genrand();

            // We want to preserve the character index, since this loop is just for display:
            int indexStatic = group.GetIndex();

            group.ResetIndex();

            //group.ResetIndex();
            for (int index = start; index < end; index++)
            {
                // Index starting at 0
                int loopIndex = index - start;

                // Get the heal value once:
                int currentHeal = group.GetHealValue(aVal1);
                int nextHeal    = group.PeekHealValue(aVal2);

                // Put the next expected heal in the text box
                if (index == start + healVals.Count - 1)
                {
                    tbLastHeal.Text = nextHeal.ToString();
                }

                // Advance the RNG before starting the loop in case we want to skip an entry
                uint aVal1_temp = aVal1;
                uint aVal2_temp = aVal2;
                uint aVal3_temp = aVal3;
                aVal1 = aVal2;
                aVal2 = aVal3;
                aVal3 = displayRNG.genrand();

                // Skip the entry if it's too long ago
                if (loopIndex < healVals.Count - 5)
                {
                    continue;
                }

                //Start actually displaying
                dataGridView1.Rows.Add();

                // Color consumed RNG green
                if (index < start + healVals.Count)
                {
                    dataGridView1.Rows[dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightGreen;
                }

                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0].Value = index;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value = currentHeal;
                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[2].Value = randToPercent(aVal1_temp);

                handleSteal(steal, aVal1_temp, aVal2_temp, aVal3_temp, 3);
                handleStealCuffs(stealCuffs, aVal1_temp, aVal2_temp, aVal3_temp, 4);

                dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[5].Value = (aVal1_temp < 0x1000000);

                // Check if the chests are in a position offset by a fixed amount
                if ((aVal1_temp % 100) < 3 && !rareSteal && loopIndex >= healVals.Count)
                {
                    rareSteal    = true;
                    rarePosition = loopIndex - healVals.Count;
                }

                if ((aVal1_temp % 100) < 6 && !rareStealCuffs && loopIndex >= healVals.Count)
                {
                    rareStealCuffs    = true;
                    rarePositionCuffs = loopIndex - healVals.Count;
                }

                // Check for combo during string of punches
                int comboCheck = loopIndex - healVals.Count - 5 + 1;
                if (comboCheck % 10 == 0 && comboCheck >= 0 && !comboFound &&
                    Combo.IsSucessful(aVal1_temp))
                {
                    comboFound = true;
                    comboPos   = comboCheck / 10;
                }
            }

            tbRare.Text      = rarePosition.ToString();
            tbRareCuffs.Text = rarePositionCuffs.ToString();

            tbCombo.Text = comboPos.ToString();

            tbLastHeal.Focus();
            tbLastHeal.SelectAll();

            group.SetIndex(indexStatic);
        }