Summoning Calculator - Fully Working!!

All discussions of RuneScape gameplay: advice, guides, tips and so forth.

Summoning Calculator - Fully Working!!

Postby Lord Klotski » Wed Nov 19, 2008 7:20 pm

Hello, fellow EFU freaks (and others, I suppose, but they will lack appreciation for this)

I have finished writing a summoning calculator. This one is typical "Lord Klotski Style", so to speak. Unlike the (vastly inferior) RuneScript calculator, this calculator accomplishes the incredible feat of accounting for levels gained while you spend your charms.

NEW!!! >:D Summoning Optimizer Extreme - Included is the way to get the most XP

C++ Version: http://www.mediafire.com/?sharekey=0ec2 ... b9a8902bda


Algorithm Explanation

The original (base) algorithm was identical to the current one, and both run in the approximate same order of time (per se). However, it was simply too slow. The new algorithm is far superior. I'll try to explain the problem (and solutions) in the following paragraphs.

Firstly, unless you have very high expectations of the skills of the runescript writers, this algorithm will never be an "update" to the runescript calculator. For a computer to optimize something like this, it is FORCED to use recursive calls - that is, a function that calls itself - and in this case, it branches four times every iteration of recursion. Now, computers are certainly fast, but the original algorithm was running about 200-300 calculations (lol) each branch of the recursion, and each LEVEL gained was needing another recursive call. A good approximation of the running time, in seconds, is [(200) * 4^levels]/{1 billion}. Computers do 1 billion iterations per second, and the 4^ levels just means that for every level you multiply the recursive calls by 4.

Now this doesn't look too bad to start with (a billion is pretty big, and we can wait a few seconds for an answer, right?). Try 20 levels gained. 219902 seconds. Oops.

So I said "screw this" for a few days. Then I thought about it for a long time, and made 2 (large) improvements:

1) By hardcoding in XP lookup tables , I could significantly reduce the constant of 200 to about ... 20 ish.
2) By hardcoding in a "relevant level lookup table", I was able to reduce n to approximately n/2. What's a "relevant level?" Well, I only need to optimize my code to care about levels that matter to summoning - level 2, for instance, has no new familiars and can be ignored.

Another improvement is that, after level 71, golds should be used immediately, reducing the order after level 71 to 3^(n/2). After level 89, it's fairly easy to compute analytical solutions yourself anyways, and I doubt you'll be using the calculator.

Trying 20 levels again gives about .021 seconds. Pwnt @ world.


Anyways, what matters more to the rest of the world (i.e. the reader) is the actual code. Unfortunately for you, I'm lazy, and am currently writing the C++ .exe file. Until then, I have the java source code, if you care to run it yourself.

I'm fairly sure that it will work in every case (that is, given sufficient time, procure the correct method and xp). Don't try putting in 1 XP and 10,000 of each charm type if you want it to run in finite time though.

INPUT SPECIFICATION

Current Summoning XP (haven't implemented anything with double precision yet, so just enter an integer).
Whether you'd prefer to use "normal pouches" or "every pouch". Talon beasts, for instance, are used in "every pouch", so it's not recommended.
Gold Charms
Green Charms
Crimson Charms
Blue Charms

OUTPUT SPECIFICATION

Your current level

Path to get the most XP.

Format: CharmType PouchLevel Quantity

XP Gained, if you spent all your charms optimally.
Your level, if you spent all your charms optimally.

CodeZ:


Code: Select all

import java.util.* ;

/******************************************************
*   This code was written by Lord Klotski.           *
*   Although I have no qualms about breaking         *
*   copyright, I'll kill you if you pirate this.     *
******************************************************/
class haxx0r
{
    public double XP ;
    public String s ;
   
    public haxx0r()
    {
        XP = 0 ;
        s = "" ;
    }
}


public class CharmTradeIn {
   
    static double pouchArray[][][] ;
    static int relevantLevels[];
    static int nextRelevantLevel[] ;
    static int prevRelevantLevel[] ;
    static double xpTable[] ;
   
   
   
    public static haxx0r Optimize(int gold, int green, int crimson, int blue, double currXP)
    {
        if (gold + green + crimson + blue == 0)
        {
            return new haxx0r() ;
        }
        int currentLev = currentLevel(currXP) ;
        double goldXP = pouchXP(currentLev,0) ;
        double greenXP = pouchXP(currentLev,1) ;
        double crimsonXP = pouchXP(currentLev,2) ;
        double blueXP = pouchXP(currentLev,3) ;
       
       
       
        double XP2Lvl = xpToLevel(currXP, currentLev) ;
       
        double goldQuantity = Math.min(gold, Math.ceil(XP2Lvl/goldXP)) ;
        double greenQuantity = Math.min(green, Math.ceil(XP2Lvl/greenXP)) ;
        double crimsonQuantity = Math.min(crimson, Math.ceil(XP2Lvl/crimsonXP)) ;
        double blueQuantity = Math.min(blue, Math.ceil(XP2Lvl/blueXP)) ;
       
        double totalGoldXP = goldQuantity * goldXP ;
        double totalGreenXP = greenQuantity * greenXP ;
        double totalCrimsonXP = crimsonQuantity * crimsonXP ;
        double totalBlueXP = blueQuantity * blueXP ;
       
        haxx0r hax1 = new haxx0r() ;
        haxx0r hax2 = new haxx0r() ;
        haxx0r hax3 = new haxx0r() ;
        haxx0r hax4 = new haxx0r() ;
       
        boolean pwn = false ;
        //if (gold > 0 && currentLev > 71)
        //{
        //    pwn = true ;
        //}
       
        if (gold > 0 )
        {
            hax1 = Optimize((int)(gold - goldQuantity),green,crimson,blue,currXP + totalGoldXP)  ;
            hax1.XP += totalGoldXP ;
            hax1.s = "" + goldXP + "," + 0 + "," + goldQuantity + " " + hax1.s ;
        }
        if (green > 0)
        {
            hax2 = Optimize(gold,(int)(green-greenQuantity),crimson,blue,currXP + totalGreenXP) ;
            hax2.XP += totalGreenXP ;
            hax2.s = "" + greenXP + "," + 1 + "," + greenQuantity + " " +hax2.s ;
        }
        if (crimson > 0 )
        {
            hax3 = Optimize(gold,green,(int)(crimson-crimsonQuantity),blue,currXP + totalCrimsonXP)  ;
            hax3.XP += totalCrimsonXP ;
            hax3.s = "" + crimsonXP + "," + 2 + "," + crimsonQuantity + " " + hax3.s ;
        }
        if (blue > 0)
        {
            hax4 = Optimize(gold,green,crimson,(int)(blue-blueQuantity),currXP + totalBlueXP)  ;
            hax4.XP += totalBlueXP ;
            hax4.s = "" + blueXP + "," + 3 + "," + blueQuantity + " " + hax4.s ;
        }
        //if (pwn)
        //{
        //    hax1 = Optimize(0,green,crimson,blue, currXP + gold*goldXP)  ;
        //    hax1.XP = gold * goldXP ;
        //    hax1.s = "" + goldXP + "," + 0 + "," + gold + " " + hax1.s ;
        //}
       
        double hax5 = Math.max(hax1.XP, hax2.XP) ;
        double hax6 = Math.max(hax3.XP, hax4.XP) ;
        double finalHax = Math.max(hax5, hax6) ;
        //System.out.println(gold + " " + green + " " + crimson + " " + blue);
        //System.out.println(hax1.XP + " " + hax2.XP + " " + hax3.XP + " " + hax4.XP + " " + hax5 + " " + hax6 + " " + finalHax);
        //System.out.println(totalGoldXP + " " + totalGreenXP + " " + totalCrimsonXP + " " + totalBlueXP);
       
        //System.out.println(currentLev + "   " + XP2Lvl + "  " + currXP + " " + xpTable[nextRelevantLevel[currentLev]]);
       
        haxx0r theNewHax = new haxx0r() ;
       
        if (finalHax == hax1.XP)
        {
            theNewHax = hax1 ;
        }
        else if (finalHax == hax2.XP)
        {
            theNewHax = hax2 ;
        }
        else if (finalHax == hax3.XP)
        {
            theNewHax = hax3 ;
        }
        else if (finalHax == hax4.XP)
        {
            theNewHax = hax4 ;
        }
       
         
       
        return theNewHax ;
    }
   
    public static void initializePouchArray()
    {
        for (int I = 0 ; I < 4 ; I ++)
            {
                for (int K = 1 ; K < 100 ; K ++)
                {
                    pouchArray[I][K][0] = 1;
                    double XP = 0 ;
                    int Lvl = 0 ;
                    int moarHAX = 0 ;
                    int shards = 0 ;
                    switch (I)
                    {
                        case 0:
                            switch (K)
                            {
                                case 1: XP = 4.8; Lvl = 1 ; shards = 7; break ;
                                case 4: XP = 9.3; Lvl = 4 ;shards = 8; break ;
                                case 10: XP = 12.6;Lvl = 10 ;shards = 8; break ;
                                case 13: XP = 12.6;Lvl = 13 ;shards = 9; break ;
                                case 16: XP = 21.6;Lvl = 16 ;shards = 7; break ;
                                case 17: XP = 46.5;Lvl = 17 ;shards = 1; break ;
                                case 40: XP = 52.8;Lvl = 40 ; shards = 11;break ;
                                case 52: XP = 68.4;Lvl = 52 ; shards = 12;break ;
                                case 66: XP = 87;Lvl = 66 ; shards = 11;break ;
                                case 67: XP = 58.6;Lvl = 67 ; shards = 1;break ;
                                case 71: XP = 93.2;Lvl = 71 ; shards = 14;break ;
                                default: XP = 0 ; Lvl = 200 ; shards = 9999; moarHAX = 1 ; break;
                               
                            } break ;
                        case 1:
                        switch (K)
                            {
                                case 18: XP = 31.2; Lvl = 18 ; shards = 45; break ;
                                case 28: XP = 49.8; Lvl = 28 ;shards = 47; break ;
                                case 33: XP = 57.6;Lvl = 33 ;shards = 72; break ;
                                case 34: XP = 59.6;Lvl = 34 ;shards = 74; break ;
                                case 41: XP = 72.4;Lvl = 41 ;shards = 78; break ;
                                case 43: XP = 75.2;Lvl = 43 ;shards = 88; break ;
                                case 47: XP = 83.2;Lvl = 47 ; shards = 88;break ;
                                case 54: XP = 94.8;Lvl = 54 ; shards = 106;break ;
                                case 56: XP = 98.8;Lvl = 56 ; shards = 109;break ;
                                case 62: XP = 109.6;Lvl = 62 ; shards = 119;break ;
                                case 68: XP = 119.2;Lvl = 68 ; shards = 110;break ;
                                case 69: XP = 121.2;Lvl = 69 ; shards = 130;break ;
                                case 76: XP = 134;Lvl = 76 ; shards = 141;break ;
                                case 78: XP = 136.8;Lvl = 78 ; shards = 124;break ;
                                case 80: XP = 140.8;Lvl = 80 ; shards = 128;break ;
                                case 88: XP = 158.8;Lvl = 88 ; shards = 140;break ;
                                case 93: XP = 163.2;Lvl = 93 ; shards = 113;break ;
                                default: XP = 0 ; Lvl = 200 ; shards = 9999;moarHAX = 1; break;
                               
                               
                            } break ;
                        case 2:
                        switch (K)
                            {
                                case 19: XP = 83.2; Lvl = 19 ; shards = 57; break ;
                                case 22: XP = 96.8; Lvl = 22 ;shards = 64; break ;
                                case 31: XP = 136;Lvl = 31 ;shards = 81; break ;
                                case 32: XP = 140.8;Lvl = 32 ;shards = 84; break ;
                                case 42: XP = 184.8;Lvl = 42 ;shards = 104; break ;
                                case 46: XP = 202.4;Lvl = 46 ;shards = 111; break ;
                                case 49: XP = 215.2;Lvl = 49 ; shards = 117;break ;
                                case 61: XP = 268;Lvl = 61 ; shards = 141;break ;
                                case 63: XP = 276.8;Lvl = 63 ; shards = 116;break ;
                                case 64: XP = 281.6;Lvl = 64 ; shards = 128;break ;
                                case 70: XP = 132;Lvl = 70 ; shards = 79;break ;
                                case 74: XP = 325.6;Lvl = 74 ; shards = 166;break ;
                                case 75: XP = 329.6;Lvl = 75 ; shards = 168;break ;
                                case 77: XP = 1015.2;Lvl = 77 ; shards = 174;break ;
                                case 83: XP = 364.8;Lvl = 83 ; shards = 1;break ;
                                case 85: XP = 373.6;Lvl = 85 ; shards = 150;break ;
                                case 92: XP = 404.8;Lvl = 92 ; shards = 203;break ;
                                case 95: XP = 417.6;Lvl = 95 ; shards = 198;break ;
                                case 96: XP = 422.4;Lvl = 96 ; shards = 211;break ;
                                case 99: XP = 435.2;Lvl = 99 ; shards = 178;break ;
                                default: XP = 0 ; Lvl = 200 ; shards = 9999; moarHAX = 1; break;
                               
                               
                            } break ;
                        case 3:
                        switch (K)
                            {
                                case 23: XP = 202.4; Lvl = 23 ; shards = 75; break ;
                                case 25: XP = 220; Lvl = 25 ;shards = 51; break ;
                                case 29: XP = 255.2;Lvl = 29 ;shards = 84; break ;
                                case 34: XP = 59.6;Lvl = 34 ;shards = 74; break ;
                                case 36: XP = 316.8;Lvl = 36 ; shards = 102;break ;
                                case 46: XP = 404.8;Lvl = 46 ; shards = 125;break ;
                                case 55: XP = 484;Lvl = 55 ; shards = 151;break ;
                                case 56: XP = 492.8;Lvl = 56 ; shards = 141;break ;
                                case 57: XP = 501.6;Lvl = 57 ; shards = 153;break ;
                                case 58: XP = 510.4;Lvl = 58 ; shards = 144;break ;
                                case 66: XP = 580.8;Lvl = 66 ; shards = 152;break ;
                                case 73: XP = 642.46;Lvl = 73 ; shards = 195;break ;
                                case 76: XP = 668.8;Lvl = 76 ; shards = 144;break ;
                                case 79: XP = 695.2;Lvl = 79 ; shards = 198;break ;
                                case 83: XP = 730.4;Lvl = 83 ; shards = 219;break ;
                                case 86: XP = 756.8;Lvl = 86 ; shards = 1;break ;
                                case 89: XP = 783.2;Lvl = 89 ; shards = 222;break ;
                                default: XP = 0 ; Lvl = 200 ; shards = 9999; moarHAX = 1 ;break;
                               
                               
                            } break ;   
                    }
                    pouchArray[I][K][1] = XP;
                    pouchArray[I][K][2] = Lvl;
                    pouchArray[I][K][3] = shards ;
                    if (moarHAX == 1)
                    {
                        moarHAX = 0 ;
                        pouchArray[I][K][0] = 0 ;
                    }
                }
            }
    }
   
    public static double pouchXP(int level, int charmType)
    {
        int i = level ;
        while ( i > 0 )
        {

            if (relevantLevels[i] == 0)
            {
                i = prevRelevantLevel[i] ;
            }
            if (pouchArray[charmType][i][0] != 0)
            {
                // Got a working pouch!
                return pouchArray[charmType][i][1] ;
               
            }
            else
            {
                i = prevRelevantLevel[i] ;
            }
           
        }
        return 0 ;
    }
   
    public static double xpToLevel(double XP,int currentLevel)
    {
        double sum = 0;
       
        int nextRelLevel = nextRelevantLevel[currentLevel] ;
        double xpThatIsNeeded = xpTable[nextRelLevel - 1] ;
       
        return xpThatIsNeeded - XP ;
    }
   
    public static int currentLevel(double XP)
    {
       
        // This method uses binary search to find out the current level,
        // it will run in log (n) in almost every case (99.99% of the time)
       
       
       
        int left = 0 ;
        int right = 99 ;
        int c = 50 ;
        while (left <= right)
        {
            c = (right + left)/2 ;
            if (XP == xpTable[c])
            {
                return c ;
            }
            if (XP > xpTable[c])
            {
                left = c + 1 ;
            }
            else
            {
                right = c - 1 ;
            }
        }
       
       
       
        return left  ;
       
    }
    public static void initializePrevRelevantLevel()
    {
        prevRelevantLevel[0] = 0 ;
        prevRelevantLevel[1] = 0 ;
        prevRelevantLevel[2] = 1 ;
        prevRelevantLevel[3] = 1 ;
        prevRelevantLevel[4] = 1 ;
        prevRelevantLevel[5] = 4 ;
        prevRelevantLevel[6] = 4 ;
        prevRelevantLevel[7] = 4 ;
        prevRelevantLevel[8] = 7 ;
        prevRelevantLevel[9] = 7 ;
        prevRelevantLevel[10] = 7 ;
        prevRelevantLevel[11] = 10 ;
        prevRelevantLevel[12] = 10 ;
        prevRelevantLevel[13] = 10 ;
        prevRelevantLevel[14] = 13 ;
        prevRelevantLevel[15] = 13 ;
        prevRelevantLevel[16] = 13 ;
        prevRelevantLevel[17] = 16 ;
        prevRelevantLevel[18] = 16 ;
        prevRelevantLevel[19] = 18 ;
        prevRelevantLevel[20] = 19 ;
        prevRelevantLevel[21] = 19 ;
        prevRelevantLevel[22] = 19 ;
        prevRelevantLevel[23] = 22 ;
        prevRelevantLevel[24] = 23 ;
        prevRelevantLevel[25] = 23 ;
        prevRelevantLevel[26] = 25 ;
        prevRelevantLevel[27] = 25 ;
        prevRelevantLevel[28] = 25 ;
        prevRelevantLevel[29] = 28 ;
        prevRelevantLevel[30] = 29 ;
        prevRelevantLevel[31] = 29 ;
        prevRelevantLevel[32] = 31 ;
        prevRelevantLevel[33] = 32 ;
        prevRelevantLevel[34] = 33 ;
        prevRelevantLevel[35] = 33 ;
        prevRelevantLevel[36] = 33 ;
        prevRelevantLevel[37] = 36 ;
        prevRelevantLevel[38] = 36 ;
        prevRelevantLevel[39] = 36 ;
        prevRelevantLevel[40] = 36 ;
        prevRelevantLevel[41] = 40 ;
        prevRelevantLevel[42] = 41 ;
        prevRelevantLevel[43] = 41 ;
        prevRelevantLevel[44] = 43 ;
        prevRelevantLevel[45] = 43 ;
        prevRelevantLevel[46] = 43 ;
        prevRelevantLevel[47] = 46 ;
        prevRelevantLevel[48] = 47 ;
        prevRelevantLevel[49] = 47 ;
        prevRelevantLevel[50] = 49 ;
        prevRelevantLevel[51] = 49 ;
        prevRelevantLevel[52] = 49 ;
        prevRelevantLevel[53] = 52 ;
        prevRelevantLevel[54] = 52 ;
        prevRelevantLevel[55] = 52 ;
        prevRelevantLevel[56] = 55 ;
        prevRelevantLevel[57] = 56 ;
        prevRelevantLevel[58] = 57 ;
        prevRelevantLevel[59] = 58 ;
        prevRelevantLevel[60] = 58 ;
        prevRelevantLevel[61] = 58 ;
        prevRelevantLevel[62] = 61 ;
        prevRelevantLevel[63] = 61 ;
        prevRelevantLevel[64] = 61 ;
        prevRelevantLevel[65] = 64 ;
        prevRelevantLevel[66] = 64 ;
        prevRelevantLevel[67] = 66 ;
        prevRelevantLevel[68] = 66 ;
        prevRelevantLevel[69] = 68 ;
        prevRelevantLevel[70] = 69 ;
        prevRelevantLevel[71] = 69 ;
        prevRelevantLevel[72] = 69 ;
        prevRelevantLevel[73] = 69 ;
        prevRelevantLevel[74] = 69 ;
        prevRelevantLevel[75] = 74 ;
        prevRelevantLevel[76] = 74 ;
        prevRelevantLevel[77] = 76 ;
        prevRelevantLevel[78] = 76 ;
        prevRelevantLevel[79] = 78 ;
        prevRelevantLevel[80] = 79 ;
        prevRelevantLevel[81] = 80 ;
        prevRelevantLevel[82] = 80 ;
        prevRelevantLevel[83] = 80 ;
        prevRelevantLevel[84] = 83 ;
        prevRelevantLevel[85] = 84 ;
        prevRelevantLevel[86] = 85 ;
        prevRelevantLevel[87] = 85 ;
        prevRelevantLevel[88] = 85 ;
        prevRelevantLevel[89] = 88 ;
        prevRelevantLevel[90] = 89 ;
        prevRelevantLevel[91] = 89 ;
        prevRelevantLevel[92] = 89 ;
        prevRelevantLevel[93] = 89 ;
        prevRelevantLevel[94] = 93 ;
        prevRelevantLevel[95] = 93 ;
        prevRelevantLevel[96] = 95 ;
        prevRelevantLevel[97] = 96 ;
        prevRelevantLevel[98] = 96 ;
        prevRelevantLevel[99] = 96 ;
       
       
        return ;
    }
    public static void initializeNextRelevantLevel()
    {
        nextRelevantLevel[0] = 1 ;
        nextRelevantLevel[1] = 4 ;
        nextRelevantLevel[2] = 4 ;
        nextRelevantLevel[3] = 4 ;
        nextRelevantLevel[4] = 7 ;
        nextRelevantLevel[5] = 7 ;
        nextRelevantLevel[6] = 7 ;
        nextRelevantLevel[7] = 10 ;
        nextRelevantLevel[8] = 10 ;
        nextRelevantLevel[9] = 10 ;
        nextRelevantLevel[10] = 13 ;
        nextRelevantLevel[11] = 13 ;
        nextRelevantLevel[12] = 13 ;
        nextRelevantLevel[13] = 16 ;
        nextRelevantLevel[14] = 16 ;
        nextRelevantLevel[15] = 16 ;
        nextRelevantLevel[16] = 18 ;
        nextRelevantLevel[17] = 18 ;
        nextRelevantLevel[18] = 19 ;
        nextRelevantLevel[19] = 22 ;
        nextRelevantLevel[20] = 22 ;
        nextRelevantLevel[21] = 22 ;
        nextRelevantLevel[22] = 23 ;
        nextRelevantLevel[23] = 25 ;
        nextRelevantLevel[24] = 25 ;
        nextRelevantLevel[25] = 28 ;
        nextRelevantLevel[26] = 28 ;
        nextRelevantLevel[27] = 28 ;
        nextRelevantLevel[28] = 29 ;
        nextRelevantLevel[29] = 31 ;
        nextRelevantLevel[30] = 31 ;
        nextRelevantLevel[31] = 32 ;
        nextRelevantLevel[32] = 33 ;
        nextRelevantLevel[33] = 36 ;
        nextRelevantLevel[34] = 36 ;
        nextRelevantLevel[35] = 36 ;
        nextRelevantLevel[36] = 40 ;
        nextRelevantLevel[37] = 40 ;
        nextRelevantLevel[38] = 40 ;
        nextRelevantLevel[39] = 40 ;
        nextRelevantLevel[40] = 41 ;
        nextRelevantLevel[41] = 43 ;
        nextRelevantLevel[42] = 43 ;
        nextRelevantLevel[43] = 46 ;
        nextRelevantLevel[44] = 46 ;
        nextRelevantLevel[45] = 46 ;
        nextRelevantLevel[46] = 47 ;
        nextRelevantLevel[47] = 49 ;
        nextRelevantLevel[48] = 49 ;
        nextRelevantLevel[49] = 52 ;
        nextRelevantLevel[50] = 52 ;
        nextRelevantLevel[51] = 52 ;
        nextRelevantLevel[52] = 55 ;
        nextRelevantLevel[53] = 55 ;
        nextRelevantLevel[54] = 55 ;
        nextRelevantLevel[55] = 56 ;
        nextRelevantLevel[56] = 57 ;
        nextRelevantLevel[57] = 58 ;
        nextRelevantLevel[58] = 61 ;
        nextRelevantLevel[59] = 61 ;
        nextRelevantLevel[60] = 61 ;
        nextRelevantLevel[61] = 64 ;
        nextRelevantLevel[62] = 64 ;
        nextRelevantLevel[63] = 64 ;
        nextRelevantLevel[64] = 66 ;
        nextRelevantLevel[65] = 66 ;
        nextRelevantLevel[66] = 68 ;
        nextRelevantLevel[67] = 69 ;
        nextRelevantLevel[68] = 74 ;
        nextRelevantLevel[69] = 74 ;
        nextRelevantLevel[70] = 74 ;
        nextRelevantLevel[71] = 74 ;
        nextRelevantLevel[72] = 74 ;
        nextRelevantLevel[73] = 74 ;
        nextRelevantLevel[74] = 76 ;
        nextRelevantLevel[75] = 76 ;
        nextRelevantLevel[76] = 78 ;
        nextRelevantLevel[77] = 78 ;
        nextRelevantLevel[78] = 79 ;
        nextRelevantLevel[79] = 80 ;
        nextRelevantLevel[80] = 83 ;
        nextRelevantLevel[81] = 83 ;
        nextRelevantLevel[82] = 83 ;
        nextRelevantLevel[83] = 85 ;
        nextRelevantLevel[84] = 85 ;
        nextRelevantLevel[85] = 88 ;
        nextRelevantLevel[86] = 88 ;
        nextRelevantLevel[87] = 88 ;
        nextRelevantLevel[88] = 89 ;
        nextRelevantLevel[89] = 93 ;
        nextRelevantLevel[90] = 93 ;
        nextRelevantLevel[91] = 93 ;
        nextRelevantLevel[92] = 93 ;
        nextRelevantLevel[93] = 95 ;
        nextRelevantLevel[94] = 95 ;
        nextRelevantLevel[95] = 96 ;
        nextRelevantLevel[96] = 99 ;
        nextRelevantLevel[97] = 99 ;
        nextRelevantLevel[98] = 99 ;
        nextRelevantLevel[99] = 99 ;
       
       
       
       
       
       
        return ;
    }
   
    public static void initializeRelevantLevels()
    {
        relevantLevels[0] = 0 ;
        relevantLevels[1] = 1 ;
        relevantLevels[2] = 0 ;
        relevantLevels[3] = 0 ;
        relevantLevels[4] = 1 ;
        relevantLevels[5] = 0 ;
        relevantLevels[6] = 0 ;
        relevantLevels[7] = 1 ;
        relevantLevels[8] = 0 ;
        relevantLevels[9] = 0 ;
        relevantLevels[10] = 1 ;
        relevantLevels[11] = 0 ;
        relevantLevels[12] = 0 ;
        relevantLevels[13] = 1 ;
        relevantLevels[14] = 0 ;
        relevantLevels[15] = 0 ;
        relevantLevels[16] = 1 ;
        relevantLevels[17] = 0 ; // MOSQUITO - EXCLUDED
        relevantLevels[18] = 1 ;
        relevantLevels[19] = 1 ;
        relevantLevels[20] = 0 ;
        relevantLevels[21] = 0 ;
        relevantLevels[22] = 1 ;
        relevantLevels[23] = 1 ;
        relevantLevels[24] = 0 ;
        relevantLevels[25] = 1 ;
        relevantLevels[26] = 0 ;
        relevantLevels[27] = 0 ;
        relevantLevels[28] = 1 ;
        relevantLevels[29] = 1 ;
        relevantLevels[30] = 0 ;
        relevantLevels[31] = 1 ;
        relevantLevels[32] = 1 ;
        relevantLevels[33] = 1 ;
        relevantLevels[34] = 0 ; // VOID STUFF - EXCLUDED
        relevantLevels[35] = 0 ;
        relevantLevels[36] = 1 ;
        relevantLevels[37] = 0 ;
        relevantLevels[38] = 0 ;
        relevantLevels[39] = 0 ;
        relevantLevels[40] = 1 ;
        relevantLevels[41] = 1 ;
        relevantLevels[42] = 0 ; // EVIL TURNIP - EXCLUDED
        relevantLevels[43] = 1 ;
        relevantLevels[44] = 0 ;
        relevantLevels[45] = 0 ;
        relevantLevels[46] = 1 ;
        relevantLevels[47] = 1 ;
        relevantLevels[48] = 0 ;
        relevantLevels[49] = 1 ;
        relevantLevels[50] = 0 ;
        relevantLevels[51] = 0 ;
        relevantLevels[52] = 1 ;
        relevantLevels[53] = 0 ;
        relevantLevels[54] = 0 ; // ABYSSAL PARASITE - EXCLUDED
        relevantLevels[55] = 1 ;
        relevantLevels[56] = 1 ;
        relevantLevels[57] = 1 ;
        relevantLevels[58] = 1 ;
        relevantLevels[59] = 0 ;
        relevantLevels[60] = 0 ;
        relevantLevels[61] = 1 ;
        relevantLevels[62] = 0 ; // ABYSSAL LURKER
        relevantLevels[63] = 0 ; // SPIRIT COBRA - EXCLUDED
        relevantLevels[64] = 1 ;
        relevantLevels[65] = 0 ;
        relevantLevels[66] = 1 ;
        relevantLevels[67] = 0 ; // WAR TORTOISE - EXCLUDED
        relevantLevels[68] = 1 ;
        relevantLevels[69] = 1 ;
        relevantLevels[70] = 0 ; // RAVENOUS LOCUST - EXCLUDED
        relevantLevels[71] = 0 ; // ARCTIC BEAR - EXCLUDED
        relevantLevels[72] = 0 ;
        relevantLevels[73] = 0 ;
        relevantLevels[74] = 1 ;
        relevantLevels[75] = 0 ; // PRAYING MANTIS - EXCLUDED
        relevantLevels[76] = 1 ;
        relevantLevels[77] = 0 ; // TALON BEAST - EXCLUDED
        relevantLevels[78] = 1 ;
        relevantLevels[79] = 1 ;
        relevantLevels[80] = 1 ;
        relevantLevels[81] = 0 ;
        relevantLevels[82] = 0 ;
        relevantLevels[83] = 1 ;
        relevantLevels[84] = 0 ;
        relevantLevels[85] = 1 ;
        relevantLevels[86] = 0 ; // RUNE MINOTAUR - EXCLUDED
        relevantLevels[87] = 0 ;
        relevantLevels[88] = 1 ;
        relevantLevels[89] = 1 ;
        relevantLevels[90] = 0 ;
        relevantLevels[91] = 0 ;
        relevantLevels[92] = 0 ; // WOLPERTINGER - EXCLUDED
        relevantLevels[93] = 1 ;
        relevantLevels[94] = 0 ;
        relevantLevels[95] = 1 ;
        relevantLevels[96] = 1 ;
        relevantLevels[97] = 0 ;
        relevantLevels[98] = 0 ;
        relevantLevels[99] = 1 ;
        relevantLevels[100] = 0 ;
       
        return ;
    }
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in) ;
       
        System.out.println("Enter current XP:") ;
        System.out.println();
        int x = input.nextInt() ;
       
        //System.out.println(xpToLevel(x));
        int haxsum = 0 ;
        double chex = 0 ;
       
        xpTable = new double[100] ;
       
        for (int i = 1 ; i < 100 ; i ++)
        {
            haxsum += (i + 300*Math.pow(2, (double)i/7))  ;
            chex = Math.floor(Math.floor(haxsum) / 4) ;
            xpTable[i] = ((int) chex) ;
        }
       
        System.out.println(currentLevel(x));
       
       
        // Initialize the pouch array.
        System.out.println("Please enter type of analysis:");
        System.out.println("1) Lord Klotski's recommended pouches");
        System.out.println("2) All pouches - ***Highly not recommended***");
           
        pouchArray = new double[4][100][4] ;
           
        initializePouchArray() ;
        relevantLevels = new int[101] ;
        prevRelevantLevel = new int[101] ;
        nextRelevantLevel = new int[101] ;
        initializeRelevantLevels() ;
        initializePrevRelevantLevel() ;
        initializeNextRelevantLevel() ;
       
       
       
        int y = input.nextInt() ;
           
        if (y == 1)
        {
            pouchArray[0][17][0] = 0 ; // Mosquito (Expensive 2nd)
            pouchArray[0][71][0] = 0 ; // Arctic Bear
           
            pouchArray[1][34][0] = 0 ; // Void ravager(Impossible 2nd)
            pouchArray[1][54][0] = 0 ; // Abyssal Parasite(Impossible 2nd)
            pouchArray[1][62][0] = 0 ; // Abyssal Lurker(Impossible 2nd)
            //Note that because of it's complete superiority, the abyssal titan is left in :D
               
            pouchArray[2][75][0] = 0 ; // Praying Mantis
            pouchArray[2][77][0] = 0 ; // Talon Beast (Impossible 2nd)
            pouchArray[2][83][0] = 0 ; // Sprit Dagannoth (Expensive 2nd)
            pouchArray[2][92][0] = 0 ; // Wolpertinger(~40 GP/XP)
           
            pouchArray[3][86][0] = 0 ; // Rune Minotaur (Expensive 2nd)
               
        }
        System.out.println("Enter Gold Charms:");
        int gold = input.nextInt() ;
        System.out.println("Enter Green Charms:");
        int green = input.nextInt() ;
        System.out.println("Enter Crimson Charms:");
        int crimson = input.nextInt() ;
        System.out.println("Enter Blue Charms:");
        int blue = input.nextInt() ;
           
        haxx0r Lol = Optimize(gold,green,crimson,blue,(double)x) ;
           
        System.out.println("");
        System.out.println("");
       
        Double summage = 0.0 ;
       
        while (Lol.s.length() > 0)
        {
            String v ;
            try
            {
                v = Lol.s.substring (0,Lol.s.indexOf(' ')) ;
                System.out.println(v);
                Lol.s = Lol.s.substring(Lol.s.indexOf(' ') + 1) ;
                String haxFTW = v.substring(0,v.indexOf(',')) ;
                v = v.substring(v.indexOf(',') + 1 ) ;
                v = v.substring(v.indexOf(',') + 1 ) ;
                Double hacky = Double.parseDouble(haxFTW) ;
                Double hackymore = Double.parseDouble(v) ;
                summage += hacky * hackymore ;
            }
            catch (Exception e)
            {
                v = Lol.s ;
                Lol.s = "" ;
            }
        }
        int lolol = (int) Math.floor(summage) ;
       
        System.out.println(lolol);
        System.out.println(currentLevel(summage + x)) ;
       
    }
}




Again, I really haven't tested it thoroughly, so I'd appreciate *some* leeway. Think of it as Jagex code, k? It should run (most of the time), give the correct answer (some of the time), etc. :D
Last edited by Lord Klotski on Fri Nov 21, 2008 11:27 pm, edited 6 times in total.
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby Doomedrusher » Wed Nov 19, 2008 7:24 pm

Hmm... I might add calculators to my index.

Anyways, your code fails. It actually labels variables for what they are and has COMMENTS to help people plagiarize your code XD

(My code is undecipherable; I just go through 26 vars in alphabetical order. It's an artifact from programming huge BASIC projects on the TI-84)
User avatar
Doomedrusher
 
Posts: 3437
Joined: Fri Jan 18, 2008 7:01 pm

Summoning Calculator (Super BETA)

Postby Da_Dragon555 » Wed Nov 19, 2008 7:33 pm

I'll do a touch of Testing...

BBL
Staple guns: Because duct tape can't make that 'kaCHUNK' noise.
Image
Thank You to Fuzzy for this Wonderful Gift!!
Image
Image

Image
Image
!~NOTICE:I will be adding people frome Truthscape to my Friends List if I see that you are on.
Image

Deaconis wrote:Amen Brother! Runescape = Pixel Crack!
ikraz55 wrote:
satan dragon wrote:I haven't noticed any lag. I presume its because my IP address is a prime number.
:lol: I'd siggy that, but my sig hasn't changed in years.

I am a(n): ESAK
Breakdown: Achiever: 33.33%; Explorer: 86.67%; Killer: 26.67%; Socializer: 53.33%
Last updated: Sept. 29, 2009

Friends:
ImageImage
ImageImage
ImageImage
R.I.P. Josh Jacobson D: 03/07/2008
User avatar
Da_Dragon555
 
Posts: 2510
Joined: Sat Dec 01, 2007 4:23 am
Location: Isle of Crandor, Gielinor

Summoning Calculator (Super BETA)

Postby Lord Klotski » Wed Nov 19, 2008 7:38 pm

Doomedrusher wrote:Hmm... I might add calculators to my index.

Anyways, your code fails. It actually labels variables for what they are and has COMMENTS to help people plagiarize your code XD

(My code is undecipherable; I just go through 26 vars in alphabetical order. It's an artifact from programming huge BASIC projects on the TI-84)


double hax1 = 0 ;
double hax2 = 0 ;
double hax3 = 0 ;
double hax4 = 0 ;

boolean pwn = false ;

double hax5 = Math.max(hax1, hax2) ;
double hax6 = Math.max(hax3, hax4) ;
double finalHax = Math.max(hax5, hax6) ;

int moarHAX = 0 ;

int haxsum = 0 ;

double Lol = Optimize(gold,green,crimson,blue,(double)x) ;


Yep, those'd be descriptive variable names. :D

I ran out of room once with a TI-83 + game I wrote. LOL...
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby dandonio » Wed Nov 19, 2008 7:56 pm

Nice piece of coding (I especially like the binary search method)

*Beware: nitpicking ahead*
But you've wasted your time by importing a java.math class you don't use, by initializing a variable counter and value which you never use and by adding 'return;' at the end of void methods. (and I can't help but think there was a more efficient way to initialize those lvls in the static methods)

You might find a NTE invitation in your mailbox any time now lol... :lol:
wearing a pink coat, feeling the breeze, smelling the green grass and walking towards the ever elusive horizon.
Image

Do not stand at my grave and weep,
I am not there, I do not sleep.
I am in a thousand winds that blow,
I am the softly falling snow.
I am the fields of ripening grain,
I am the gentle autumn rain.
I am in the morning hush,
I am in the graceful rush
Of beautiful birds in circling flight,
I am the starshine of the night.
I am in the flowers that bloom,
I am in a quiet room.
I am in the birds that sing,
I am in each lovely thing.
Do not stand at my grave and cry,
I am not there. I do not die.

________________________________________________________________
"Anyone who tells a lie has not a pure heart, and cannot make a good soup. "
________________________________________________________________
User avatar
dandonio
 
Posts: 2979
Joined: Tue Jan 15, 2008 3:12 pm
Location: Your dreams...(you know it's true)

Summoning Calculator (Super BETA)

Postby Lord Klotski » Wed Nov 19, 2008 8:08 pm

I use the math class! I use it for Math.max, in the Optimize method. I prefer to maximise my summon XP. >:D

Return is necessary, I think, for void methods (in java, anyways). As for variables that I don't use....I got lots of those lol! You should see my code in programming contests - looks like this except more HAX variables and FAR more counters that I end up never using :D

And hard coding the hash tables was most likely unnecessary - in fact, I wrote myself loops to produce the code >:D. It's a common programming technique (in contests, anyways...) - simply write yourself code that does something slow (like calculating prime numbers from 1 to a billion), and have it print you out code. Hard code in the primes from 1 to a billion, and you are on the way to success :D.

The problem was that I got sick of using binary search when I knew that I could get O(1) access time if I set it up right (and I need to be fast lol). This was the first solution that came to mind. I used it. Generally, that's about as efficient as it gets.

P.S. I'm working on finishing up the C++ now, I should be able to upload a working version before my class starts.
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby Lord Klotski » Wed Nov 19, 2008 8:37 pm

Note: If you feel like coming up with test Cases for me, that would be cool too.

Give me XP, amount of charms, and your calculated current level/max XP possible to achieve, and I'll see whether the program works :D

(Note that you will need to come up with the analytical solution that is best. This is not necessarily trivial...)
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby ferrariman12 » Wed Nov 19, 2008 8:43 pm

Wow, I can't believe you did it :shock:

Didn't think you could :P
I panned through the code and read and tried to understand parts of it, but not being the coder you are I didn't quite understand all of it. Loved the Hax, Doublehax, Lol code names though.

Quick question, why skip wolpertingers? (You do have 40 gp/xp at the bottom) Then again I'm 4 levels away from that so it doesn't concern me quite yet.

Otherwise, looking forward to the .exe file :)
"What I look forward to is continued immaturity followed by death."
--Dave Barry
ferrariman12
 
Posts: 1173
Joined: Fri Aug 24, 2007 11:53 pm
Location: New Jersey

Summoning Calculator (Super BETA)

Postby dandonio » Wed Nov 19, 2008 8:45 pm

Just for your interest:

All classes in the java.lang package are imported by default. That includes the .math class which is actually java.lang.Math.
(You can compare the .Math class to the .System class which is also a part of java.lang. You never need to import a class in order to use 'System.out.println();' , right. :)
You never really have to use the return statement in void methods. It doesn't do any harm but doesn't really serve a purpose either way.


Anyway, I'm busy learning myself actionscript, javascript and along the way css and html (creating a big ass website along the way) and I long for a strong-typed programming language lol. scripts are so...messy...brrrr. Really, the more I learn the more I realize how messed up everything is...people making websites with a structure of html tables...people so addicted to css they use divs instead of tables to create...well tables...the gigantic flaws in modern browsers (and the lack of a standard),... it's saddening.
If they would just make everthing a bit more strong-typed, we wouldn't have to see so many hideous websites on the interwebz.
And there wouldn't be so many messed up programmers...(I fear for the programmers who start programming in script languages and then hop to a *real* programming language lol)

Anyway, I guess I could think out some test cases, altough I don't know if I'll be fast enough lol. Right now it's 1.48 am, I can't be bothered to think now :D and tomorrow I have a test-exam, so yeah, but I'll see what I can do (so far it seems pretty good though, altough some exception handling would've been nice (overflow, wrong input,...just so the program doesn't crash after one misclick :P )
wearing a pink coat, feeling the breeze, smelling the green grass and walking towards the ever elusive horizon.
Image

Do not stand at my grave and weep,
I am not there, I do not sleep.
I am in a thousand winds that blow,
I am the softly falling snow.
I am the fields of ripening grain,
I am the gentle autumn rain.
I am in the morning hush,
I am in the graceful rush
Of beautiful birds in circling flight,
I am the starshine of the night.
I am in the flowers that bloom,
I am in a quiet room.
I am in the birds that sing,
I am in each lovely thing.
Do not stand at my grave and cry,
I am not there. I do not die.

________________________________________________________________
"Anyone who tells a lie has not a pure heart, and cannot make a good soup. "
________________________________________________________________
User avatar
dandonio
 
Posts: 2979
Joined: Tue Jan 15, 2008 3:12 pm
Location: Your dreams...(you know it's true)

Summoning Calculator (Super BETA)

Postby Lord Klotski » Wed Nov 19, 2008 8:52 pm

@ Ferrari: I skipped wolpertingers because they looked really expensive for the exp that they were providing.

The .exe won't be out for a while (I lied lol); I fail at coding C++.

@Dan: LOL! You are right on the return statement. Never knew that :P. As for Math being imported by default...yeah, didn't know that either. Useless programming teachers, told me to import it... :P



I was thinking of compiling a long list of familiars that should and shouldn't be used, but I figured that people would be eager enough to tell me that my code had "flaws" that there really wasn't a whole lot of need. :D
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby Doomedrusher » Wed Nov 19, 2008 8:55 pm

Lord Klotski wrote:@ Ferrari: I skipped wolpertingers because they looked really expensive for the exp that they were providing.

The .exe won't be out for a while (I lied lol); I fail at coding C++.

@Dan: LOL! You are right on the return statement. Never knew that :P. As for Math being imported by default...yeah, didn't know that either. Useless programming teachers, told me to import it... :P



I was thinking of compiling a long list of familiars that should and shouldn't be used, but I figured that people would be eager enough to tell me that my code had "flaws" that there really wasn't a whole lot of need. :D


Why not just compile java console? It produces a .bat file.
User avatar
Doomedrusher
 
Posts: 3437
Joined: Fri Jan 18, 2008 7:01 pm

Summoning Calculator (Super BETA)

Postby Lord Klotski » Thu Nov 20, 2008 2:30 am

http://www.mediafire.com/?sharekey=0ec2 ... b9a8902bda

Link updated - this is now the new version.

ITS HERE!!!

This is the C++ executable. Results are not guaranteed. I'm too lazy to check it atm, I'll do some rigorous testing tomorrow and likely fix any bugs that arise.

Please do your part and report any incorrect output, as you see fit. If the number that the program outputs seems too high, check your math and make sure the program isn't just smarter than you :D.
Last edited by Lord Klotski on Fri Nov 21, 2008 3:15 pm, edited 1 time in total.
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby ferrariman12 » Thu Nov 20, 2008 3:21 am

Nvm can't read :lol:
"What I look forward to is continued immaturity followed by death."
--Dave Barry
ferrariman12
 
Posts: 1173
Joined: Fri Aug 24, 2007 11:53 pm
Location: New Jersey

Summoning Calculator (Super BETA)

Postby Lord Klotski » Thu Nov 20, 2008 3:54 am

I would like to re-iterate that the calculator only provides the maximum possible summoning XP, and *not the steps to get there*.

I might add in this functionality...if I can figure out a way to add it in :D
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby Da_Dragon555 » Thu Nov 20, 2008 4:03 am

Ok,
so I entered in my Exp (272,501)
and then put in the Charms I have.
Gold: 281
Green:9
Crimson: 7
Blue: 1

On option 1. Output was:
Code: Select all
22126.4
60


Am I correct in assuming that the first output is the Exp Gain, and the second is Probable Level?

Also, when you get a chance, (I realize this may be a long way off), if you could have it tell the Number and Type of Pouches theoretically made?
Good piece of code, as far as I can tell, runs smoothly. Great Job! :D
Staple guns: Because duct tape can't make that 'kaCHUNK' noise.
Image
Thank You to Fuzzy for this Wonderful Gift!!
Image
Image

Image
Image
!~NOTICE:I will be adding people frome Truthscape to my Friends List if I see that you are on.
Image

Deaconis wrote:Amen Brother! Runescape = Pixel Crack!
ikraz55 wrote:
satan dragon wrote:I haven't noticed any lag. I presume its because my IP address is a prime number.
:lol: I'd siggy that, but my sig hasn't changed in years.

I am a(n): ESAK
Breakdown: Achiever: 33.33%; Explorer: 86.67%; Killer: 26.67%; Socializer: 53.33%
Last updated: Sept. 29, 2009

Friends:
ImageImage
ImageImage
ImageImage
R.I.P. Josh Jacobson D: 03/07/2008
User avatar
Da_Dragon555
 
Posts: 2510
Joined: Sat Dec 01, 2007 4:23 am
Location: Isle of Crandor, Gielinor

Summoning Calculator (Super BETA)

Postby Lord Klotski » Thu Nov 20, 2008 4:16 am

See the post above yours :P. It's actually really non trivial to come up with the pouch order - I'll have to discuss this with a fellow member of my programming team - he may have some ideas...

Anyways, you have fairly few charms, so there isn't even any optimization.

281 Golds at 68.4 XP = 19220.4
9 Greens at 98.8 XP = 889.2
7 Crims at 215.2 XP = 1506.4
1 Blue at 510.4 = 510.4

Total = 22126.4. YAY!

My program has passed a (trivial) test case. Bring 'em on.
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby Whiteanundil » Thu Nov 20, 2008 6:13 am

New test:
starting xp: 1031062
option: klotski's recommended pouches
gold: 774
green: 808
crimson: 583
blue: 163

xp gain: 464107
end level: 77

seems reasonable...
Image
User avatar
Whiteanundil
 
Posts: 672
Joined: Sun Jan 27, 2008 6:49 am

Summoning Calculator (Super BETA)

Postby Blade Sabre » Thu Nov 20, 2008 6:26 am

I think you could make it tell us how it did it, by changing the return of Optimize, from double, to a custom object containing a double and a list of what pouches it made. Then you'd have to compare and select the retured objects according to their contained xp value.

It's unfortunate that the standard console doesn't exist when using double-clickable jar files. Writing your programs in Java and in C++ seems rather NTE. If you could figure out the answer in a reusable fashion, this could save you some time later. Here's the question in someone else's words.

By the way, you've used java.lang.Math a few times, but I'd agree with the first statement that java.math.* is unused in the program.
User avatar
Blade Sabre
 
Posts: 614
Joined: Sun Dec 16, 2007 12:17 pm
Location: UK

Summoning Calculator (Super BETA)

Postby Lord Klotski » Thu Nov 20, 2008 1:12 pm

Whiteanundil wrote:New test:
starting xp: 1031062
option: klotski's recommended pouches
gold: 774
green: 808
crimson: 583
blue: 163

xp gain: 464107
end level: 77

seems reasonable...


Well, let's figure out the analytical solution.

Ideally, we start with golds. This program does not consider arctic bears, only barker toads, so that's 67338 XP. That puts us at level 74, so now we should use up all the crimsons. We will only consider granite lobsters, so we have 325.6 * 583 = 189824.8 XP. We are now at level 75, with 48218.2 XP to gain before level 76 (forge regents). However, at level 76 there are also adamant minotaurs! We need to analytically optimize...

It should be clear that some quantity (not the entire set) of either charm would be enough to get us to level 76, so we assign a "bonus" to green charms and blue charms. The previous green charm pouch was the fruit bat (121.2 XP instead of 134), and the previous blue pouch was the mithril minotaur (Obsidian golem not considered due to difficulty in getting the second), so that's 580.8 XP instead of 668.8.

We have a green bonus of green * xp bonus = 808 * (134-121.2) = 10342.4 XP extra if level 76 XP were attained with other charms.
We have a blue bonus of blue * XP bonus = 163 * (668.8 - 580.8) = 14344 XP extra.

It therefore makes sense to get level 76 with green charms.

So we go back to our 48212.2 XP needed. Divide that by 121.2 (fruit bats), and we make 398 fruit bats. 398 * 121.2 = 48237. Then we make forge regents and addy minotaurs. Forge regents : (808-398)*134 = 54940 XP. Addy minotaurs = 163 * 668.8 XP = 109014.4.

Add them all together:

Barker Toads:67338 XP
Granite Lobs:189824.8 XP
Fruit Bats: 48237 XP
Forge Regents: 54940 XP
Addy minotaurs: 109014.4 XP

Adding these together gives 469354.2 XP. FAIL.

I think I know what the problem is...it's not optimizing the other half of the fruit bats (not making them forge regents). It knows that it has to do greens before blues, but isn't taking advantage of the greens at 76...
Image
With max hit 'm', accuracy 'a', and monster HP 'x', this gives the expected number of hits to kill the monster :)

Submit combat data to Lord Klotski's Calculator V 1.337 ! viewtopic.php?f=7&t=5744&p=133065#p133065
User avatar
Lord Klotski
 
Posts: 1291
Joined: Wed Apr 16, 2008 7:12 pm

Summoning Calculator (Super BETA)

Postby sk3l3t0r711 » Thu Nov 20, 2008 1:32 pm

I am going to do to you what my business users like to do to me in the real world...

cough...what if you don't use charms to level? (Like transforming pouches, casting scrolls (to keep it simple)... Reviews SRS...dang it, we forgot that in the analysis and requirements but it is still considered in scope for the deliverables. crap, time to book a meeting with the dev team and pm, re-estimate the work effort and put in for a change request on the project to get more money or push out the timeline.

Efficeint or not people still do it for various reasons ;)
Image Image Image Image Image Image Image Image Image Image Image
User avatar
sk3l3t0r711
 
Posts: 2845
Joined: Thu Jan 03, 2008 12:37 pm
Location: GTA, Ontario, Canada

Next

Return to RuneScape Gameplay

Who is online

Users browsing this forum: No registered users and 2 guests