コード例 #1
0
        // private static probs[] probsST = new probs[20];

        public probs[] MainCalc(int totalSockets, int STR, int DEX, int _INT, int RED, int GREEN, int BLUE)
        {
            probs[] probsST = new probs[20];

            bool error = false;
            int  socks = totalSockets;
            int  str   = STR;
            int  dex   = DEX;
            int  _int  = _INT;
            int  red   = RED;
            int  green = GREEN;
            int  blue  = BLUE;

            if (socks <= 0 || socks > 6)
            {
                // recipeName,avgCost,chance,avgTries,recipeCost,stdDev,favg
                error = true;
                probsST[0].cratfType = "Invalid number of sockets.";
                return(probsST);
            }
            if (str < 0 || dex < 0 || _int < 0)
            {
                error = true;
                probsST[0].cratfType = "Invalid item stat requirements.";
                return(probsST);
            }
            if (str == 0 && dex == 0 && _int == 0)
            {
                error = true;
                probsST[0].cratfType = "Please fill in stat requirements.";
                return(probsST);
            }
            if (red < 0 || green < 0 || blue < 0 || red + blue + green == 0 || red > 6 || green > 6 || blue > 6 || red + blue + green > socks)
            {
                error = true;
                probsST[0].cratfType = "Invalid desired socket colors.";
                return(probsST);
            }

            // Do Calc.
            if (!error)
            {
                reqANDdesired[0] = new int[3] {
                    str, dex, _int
                };
                reqANDdesired[1] = new int[3] {
                    red, green, blue
                };
                probsST = getProbabilities(reqANDdesired[0], reqANDdesired[1], socks);
            }

            return(probsST);
        }
コード例 #2
0
        private probs[] getProbabilities(int[] requirements, int[] desired, int totalSockets)
        {
            probs[] probsST = new probs[20];

            double[] colorChances = getColorChances(requirements);

            // Not Necessory simulateLotsOfChromatics(colorChances[0], totalSockets);
            int nIndex = 0;

            while (nIndex < voriciRecipe.Length)
            {
                if (voriciRecipe[nIndex][0] <= desired[0] && voriciRecipe[nIndex][1] <= desired[1] && voriciRecipe[nIndex][2] <= desired[2])
                {
                    int[][] unvoricifiedDesires = new int[1][];
                    unvoricifiedDesires[0] = new int[3] {
                        desired[0] - voriciRecipe[nIndex][0],
                        desired[1] - voriciRecipe[nIndex][1],
                        desired[2] - voriciRecipe[nIndex][2]
                    };
                    var howManySocketsDoWeNotCareAbout = totalSockets - (desired[0] + desired[1] + desired[2]);
                    var chance = multinomial(colorChances, unvoricifiedDesires[0], howManySocketsDoWeNotCareAbout);
                    if (nIndex == 1)
                    {
                        double chanceForChromaticCollision = calcChromaticBonus(colorChances, unvoricifiedDesires[0], totalSockets);
                        chance = chance / (1 - chanceForChromaticCollision);
                    }

                    string strDescription = String.Empty;

                    #region [[[[[ Craft Description ]]]]]
                    switch (nIndex)
                    {
                    /*
                     * new int[] { 0, 0, 0, 1 },
                     * new int[] { 0, 0, 0, 1 },
                     * new int[] { 1, 0, 0, 4 },
                     * new int[] { 0, 1, 0, 4 },
                     * new int[] { 0, 0, 1, 4 },
                     * new int[] { 2, 0, 0, 25 },
                     * new int[] { 0, 2, 0, 25 },
                     * new int[] { 0, 0, 2, 25 },
                     * new int[] { 0, 1, 1, 15 },
                     * new int[] { 1, 0, 1, 15 },
                     * new int[] { 1, 1, 0, 15 },
                     * new int[] { 3, 0, 0, 120 },
                     * new int[] { 0, 3, 0, 120 },
                     * new int[] { 0, 0, 3, 120 },
                     * new int[] { 2, 1, 0, 100 },
                     * new int[] { 2, 0, 1, 100 },
                     * new int[] { 0, 2, 1, 100 },
                     * new int[] { 1, 2, 0, 100 },
                     * new int[] { 1, 0, 2, 100 },
                     * new int[] { 0, 1, 2, 100 }
                     */
                    case 0:
                        strDescription = "Drop Rate";
                        break;

                    case 1:
                        strDescription = "Chromatic Orb";
                        break;

                    case 2:
                        strDescription = "Craft 1R";
                        break;

                    case 3:
                        strDescription = "Craft 1G";
                        break;

                    case 4:
                        strDescription = "Craft 1B";
                        break;

                    case 5:
                        strDescription = "Craft 2R";
                        break;

                    case 6:
                        strDescription = "Craft 2G";
                        break;

                    case 7:
                        strDescription = "Craft 2B";
                        break;

                    case 8:
                        strDescription = "Craft 1G 1B";
                        break;

                    case 9:
                        strDescription = "Craft 1R 1B";
                        break;

                    case 10:
                        strDescription = "Craft 1R 1G";
                        break;

                    case 11:
                        strDescription = "Craft 3R";
                        break;

                    case 12:
                        strDescription = "Craft 3G";
                        break;

                    case 13:
                        strDescription = "Craft 3B";
                        break;

                    case 14:
                        strDescription = "Craft 2R 1G";
                        break;

                    case 15:
                        strDescription = "Craft 2R 1B";
                        break;

                    case 16:
                        strDescription = "Craft 2G 1B";
                        break;

                    case 17:
                        strDescription = "Craft 1R 2G";
                        break;

                    case 18:
                        strDescription = "Craft 1R 2B";
                        break;

                    case 19:
                        strDescription = "Craft 1G 2B";
                        break;

                    default:
                        break;
                    }
                    #endregion

                    probsST[nIndex].cratfType       = strDescription;
                    probsST[nIndex].averageCost     = Convert.ToDouble(voriciRecipe[nIndex][3] / chance).ToString("N1");
                    probsST[nIndex].successChance   = Convert.ToDouble(chance * 100).ToString("N5") + "%";
                    probsST[nIndex].averageAttempts = Convert.ToDouble(1 / chance).ToString("N1");
                    probsST[nIndex].costPerTry      = nIndex == 0 ? "-" : voriciRecipe[nIndex][3].ToString() == null
                                                                                                ? "null" : "" + voriciRecipe[nIndex][3].ToString();
                    nIndex = nIndex + 1;
                }
                else
                {
                    nIndex = nIndex + 1;
                }
            }

            return(probsST);
        }