[INFO] Compilation of Math for your bot menu

Shout-Out

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Musah's Avatar Corporal
    Reputation
    3
    Join Date
    Sep 2011
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [INFO] Compilation of Math for your bot

    (I appoligize for not citing my sources-- I will edit this post in the morning when I'm not on my iOS)

    Unless otherwise noted, I am not the owner of the algorithms/concepts. I am simply trying to compile a helpful and yet non-spoon-fed manuscript (or list rather) for those embracing the "next step".
    As noted by streppel, If you don't understand math, hold off on making a bot for now and come back when you've learned something in math class.

    I'm going to dump more later, but let's start with the easy stuff.

    Target nearest NPC using Euclidian Distance
    (Euclidean distance - Wikipedia, the free encyclopedia)

    Your going to need the Non-dynamic (static?) X,Y,Z addresses for the player. I would dump mine, but I'm not using windows and such addresses differ.

    From that point, compute the difference between X,Y,Z of the target object and the X,Y,Z of the player.
    The result that you should compare Amongst other objects is sqrt(xdif*xdif + ydif*ydif + zdif*zdif)

    Now compare all results for every target object, and get the result that holds the lowest value.
    Personally I do the brute force method which is about n^2 processor speed (being the worst and longest)
    Plug the GUID low and GUID high into the non-dynamic (static?) last target address spaces.
    Use the macro "/targetlasttarget" or the hotkey for target las target, and presto-- the nearest target is targeted!

    If you really want the Objective-C dumped (a Mac lang. and not windows), then here they are.

    How I handle getting the closest Object's position
    Code:
    - (DSObject*)closestDSObjectFromList:(NSArray*)theObjectList DSObjectType:(NSString*)aObjectType{
        NSMutableArray* distanceFromArray = [[NSMutableArray alloc] init];
        float distanceFrom = INFINITY;
    
        float selfX = [DSMemory readFloat:0x11F8FF4 withSize:sizeof(float)];
        float selfY = [DSMemory readFloat:0x11F8FF8 withSize:sizeof(float)];
        float selfZ = [DSMemory readFloat:0x11F8FFC withSize:sizeof(float)];
    
        for (DSObject* targetObject in theObjectList)
        {
            float xDif = [[targetObject objectXPos] floatValue]-selfX;
            float yDif = [[targetObject objectYPos] floatValue]-selfY;
            float zDif = [[targetObject objectZPos] floatValue]-selfZ;
    
            distanceFrom = sqrt(xDif*xDif + yDif*yDif + zDif*zDif);
    
            if (distanceFrom == 0) {distanceFrom = INFINITY;}
            [distanceFromArray addObject:[NSNumber numberWithFloat:distanceFrom]];
        }
        NSLog(@"Distance Array (UNSORTED): %@",distanceFromArray);
        if (aObjectType != nil)
        {
            NSUInteger possibleValueIndex = [distanceFromArray indexOfObject:[distanceFromArray valueForKeyPath:@"@min.floatValue"]];
            int i = 0;
            while (![aObjectType isEqualToString:[[theObjectList objectAtIndex:possibleValueIndex] objectType]])
            {
                NSLog(@"Trying Index: %lu which holds Object: %@",possibleValueIndex,[distanceFromArray valueForKeyPath:@"@min.floatValue"]);
                 NSLog(@"Trying object # %d/%lu",i,[distanceFromArray count]-1);
                [distanceFromArray removeObjectAtIndex:possibleValueIndex];
                possibleValueIndex = [distanceFromArray indexOfObject:[distanceFromArray valueForKeyPath:@"@min.floatValue"]];
                i++;
            }
    
            return [theObjectList objectAtIndex:possibleValueIndex];
        }
        else
        {
            return [theObjectList objectAtIndex:[distanceFromArray indexOfObject:[distanceFromArray valueForKeyPath:@"@min.floatValue"]]];
        }
    }


    How Tarnias4 handles distance and then getting the closest node (He has a function for each separate game object whereas I can just enter my own criteria)
    (Thanks to Tarnais4 for his source obviously!)

    Code:
    - (float)distanceToPosition: (Position*)position {    float distance = INFINITY;
        if(position && ([self xPosition] != INFINITY && [self yPosition] != INFINITY && [self zPosition] != INFINITY)) {
            float xDiff = [position xPosition] - [self xPosition];
            float yDiff = [position yPosition] - [self yPosition];
            float zDiff = [position zPosition] - [self zPosition];
            distance = sqrt(xDiff*xDiff + yDiff*yDiff + zDiff*zDiff);
        }
        return distance;
    }
    
    
    - (Node*)closestNode:(UInt32)entryID {
        Position *playerPosition = [(PlayerDataController*)playerData position];
        Node *closestNode = nil;
        float closestDistance = INFINITY;
        float distance = 0.0f;
        // add gas clouds
        NSMutableArray *nodes = [NSMutableArray arrayWithArray:_objectList];
        [nodes addObjectsFromArray:[self allGasClouds]];
        for(Node* node in nodes) {
            distance = [playerPosition distanceToPosition: [node position]];
            if( [node isValid] && [node entryID]==entryID && (distance <= closestDistance) ) {
                closestDistance = distance;
                closestNode = node;            
            }
        }
        return closestNode;
    }






    Get a position on the screen for an in-game position
    (Thanks to Tarnais4!)
    Coming soon..
    Last edited by Musah; 09-28-2011 at 02:27 PM. Reason: Cleanup teim

    [INFO] Compilation of Math for your bot
  2. #2
    streppel's Avatar Active Member
    Reputation
    78
    Join Date
    Mar 2007
    Posts
    196
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good idea to make a thread like this in general, BUT i think if people are not smart enough to get things like this running(c'mon,i had almost all the requires math in school except the A* algorithm which i did learn myself)
    and you should possibly give the name of the methods/algorithms
    Euclidean distance - Wikipedia, the free encyclopedia like the Euclidian distance (sqrt(x²+y²+z²))

  3. #3
    adaephon's Avatar Active Member
    Reputation
    76
    Join Date
    May 2009
    Posts
    167
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Musah View Post
    From that point, compute the difference between X,Y,Z of the target object and the X,Y,Z of the player.
    The result that you should compare Amongst other objects is sqrt(xdif*xdif + ydif*ydif + zdif*zdif)

    Now compare all results for every target object, and get the result that holds the lowest value.
    Personally I do the brute force method which is about n^2 speed (being the worst and longest)
    Firstly if you're only trying to find whichever object is closest, but not what the actual distance is, you don't need to take the square root. Secondly, how is this algorithm n^2 in any case (worst or longest...which are the same thing)? You should only be calculating the distance between yourself and every other object, which would require 1 calculation for n objects, meaning time complexity of O(n). O(n^2) would imply you were making n calculations for n objects (for instance calculating the distances between every object).

  4. #4
    Musah's Avatar Corporal
    Reputation
    3
    Join Date
    Sep 2011
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by adaephon View Post
    Firstly if you're only trying to find whichever object is closest, but not what the actual distance is, you don't need to take the square root. Secondly, how is this algorithm n^2 in any case (worst or longest...which are the same thing)? You should only be calculating the distance between yourself and every other object, which would require 1 calculation for n objects, meaning time complexity of O(n). O(n^2) would imply you were making n calculations for n objects (for instance calculating the distances between every object).
    I'm just using the square root to keep things simple. I really don't want huge numbers being held by my array. (More of personal preference and not "good math skills")
    The algorithm isn't n^2 speed, it's how I'm comparing the distances as I stated in OP.
    You misunderstand the "n^2 speed" reference. Take it in terms of processor speed and not You misunderstand the "n^2 speed" reference. Take it in terms of processor speed and not what I'm actually doing. See the seventh paragraph starting with "Two radically": (High Performance Computing for Mac OS X)
    In any case, I am calculating the distance between every object, throwing it in an array, checking to see if it's the minim number (Obj-C KVC Makes this fast) and if it is and doesn't match the criteria I enter (an NPC type for example) then it sets that number as math.h's INFINITY. (I could just set it to an empty string). I don't want to remove an object from the array because I need the index of which it is at for the object (the x array needs to have the same number of objects as the array that holds all of my objects).

    Really messy, I know, and that's why I'm dubbing it n^2 speed.

    ---------- Post added at 10:03 AM ---------- Previous post was at 10:02 AM ----------

    Originally Posted by streppel View Post
    Good idea to make a thread like this in general, BUT i think if people are not smart enough to get things like this running(c'mon,i had almost all the requires math in school except the A* algorithm which i did learn myself)
    and you should possibly give the name of the methods/algorithms
    Euclidean distance - Wikipedia, the free encyclopedia like the Euclidian distance (sqrt(x²+y²+z²))
    Thanks! I'll add this

  5. #5
    adaephon's Avatar Active Member
    Reputation
    76
    Join Date
    May 2009
    Posts
    167
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Musah View Post
    I'm just using the square root to keep things simple. I really don't want huge numbers being held by my array. (More of personal preference and not "good math skills")
    The algorithm isn't n^2 speed, it's how I'm comparing the distances as I stated in OP.
    You misunderstand the "n^2 speed" reference. Take it in terms of processor speed and not You misunderstand the "n^2 speed" reference. Take it in terms of processor speed and not what I'm actually doing. See the seventh paragraph starting with "Two radically": (High Performance Computing for Mac OS X)
    In any case, I am calculating the distance between every object, throwing it in an array, checking to see if it's the minim number (Obj-C KVC Makes this fast) and if it is and doesn't match the criteria I enter (an NPC type for example) then it sets that number as math.h's INFINITY. (I could just set it to an empty string). I don't want to remove an object from the array because I need the index of which it is at for the object (the x array needs to have the same number of objects as the array that holds all of my objects).
    Ow my head. The problem is *you* misunderstand what you're talking about. The article you linked has nothing to do with what you're talking about. They are talking about the algorithmic complexity of two different mathematical solvers for tracking motion of a set of bodies moving under the influence of gravity. I would LOVE to hear you explain WTF that has to do with you finding the closest relevant NPC to your character. Big O notation describes the relationship between the size of input data, and how your algorithm's time or space complexity grows. It has nothing to do with processor speed. And that article certainly doesn't imply in any way that it does. As you've described your algorithm, you're first iterating through all items to calculate the distance, and then iterating through your array to find the smallest distance. Thus you iterate through n objects twice. Your algorithm's complexity is still growing linearly in relation to the input size n, and this is drastically different to O(n^2). I.e., at a simplistic level, if you had 10 targets, you would execute 20 operations; 50 targets, 100 operations. O(n^2) would imply 10 targets, 100 operations; 20 targets, 400 operations; 50 targets, 2500 operations.

  6. #6
    Musah's Avatar Corporal
    Reputation
    3
    Join Date
    Sep 2011
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by adaephon View Post
    Ow my head. The problem is *you* misunderstand what you're talking about. The article you linked has nothing to do with what you're talking about. They are talking about the algorithmic complexity of two different mathematical solvers for tracking motion of a set of bodies moving under the influence of gravity. I would LOVE to hear you explain WTF that has to do with you finding the closest relevant NPC to your character. Big O notation describes the relationship between the size of input data, and how your algorithm's time or space complexity grows. It has nothing to do with processor speed. And that article certainly doesn't imply in any way that it does. As you've described your algorithm, you're first iterating through all items to calculate the distance, and then iterating through your array to find the smallest distance. Thus you iterate through n objects twice. Your algorithm's complexity is still growing linearly in relation to the input size n, and this is drastically different to O(n^2). I.e., at a simplistic level, if you had 10 targets, you would execute 20 operations; 50 targets, 100 operations. O(n^2) would imply 10 targets, 100 operations; 20 targets, 400 operations; 50 targets, 2500 operations.
    Again, I'm using the article's paragraph as a reference. I really don't want to start a flame war, I'm saying that in terms of NON-OBJECTIVE HYPOTHETICAL PSEUDO processor speed, the way I am handling the objects is not the fastest.
    Thus, I am saying that in terms of NON-OBJECTIVE HYPOTHETICAL PSEUDO processor speed I am using the WORST which is n^2 on a SCALE of n to n^2.

    Again, NON-OBJECTIVE HYPOTHETICAL PSEUDO PROCESSOR SPEED verses WTF IS ACTUALLY HAPPENING IN THE PROCESSOR

    But fine, if you really want to be exact and objective, then I'm wrong.

    Using caps to better express the main points because I have run on sentences and easily confuse myself re-reading them.

  7. #7
    SKU's Avatar Contributor
    Reputation
    306
    Join Date
    May 2007
    Posts
    565
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    < quick, look over there! >
    Last edited by SKU; 08-16-2013 at 08:21 AM.

  8. #8
    Musah's Avatar Corporal
    Reputation
    3
    Join Date
    Sep 2011
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by SKU View Post
    Thanks for the new sig bro, keep us entertained.
    Surely, anything for the community.

  9. #9
    !@^^@!'s Avatar Active Member
    Reputation
    23
    Join Date
    Feb 2007
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Musah View Post
    I'm just using the square root to keep things simple. I really don't want huge numbers being held by my array. (More of personal preference and not "good math skills")
    extra math operations just makes it more complicated imo, also a float is a float and doesn't magically increase its size because the number is bigger :confused:

    Originally Posted by Musah View Post
    The algorithm isn't n^2 speed, it's how I'm comparing the distances as I stated in OP.
    You misunderstand the "n^2 speed" reference. Take it in terms of processor speed and not You misunderstand the "n^2 speed" reference. Take it in terms of processor speed and not what I'm actually doing. See the seventh paragraph starting with "Two radically": (High Performance Computing for Mac OS X)
    In any case, I am calculating the distance between every object, throwing it in an array, checking to see if it's the minim number (Obj-C KVC Makes this fast) and if it is and doesn't match the criteria I enter (an NPC type for example) then it sets that number as math.h's INFINITY. (I could just set it to an empty string). I don't want to remove an object from the array because I need the index of which it is at for the object (the x array needs to have the same number of objects as the array that holds all of my objects).

    Really messy, I know, and that's why I'm dubbing it n^2 speed.
    No offense but that's just ugly and plain stupid you're writing object oriented code, stop pretending it's C! I assume you're keeping an array of all the objects (anything npc, dynamic stuff, etc) with inheritance like described here: http://www.ownedcore.com/forums/worl...e-objects.html ([Guide-kind of] How I handle objects.) ?
    Why not just make a method in WowObject that calculates the distance and takes a WowObject as parameter? and then in your object manager class you make a method that loops over every object of the specified type(s) calling the distance method and only writes the WowObject to the return value if it's closer than the previous WowObject?
    “Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.” - Rich Cook

  10. #10
    streppel's Avatar Active Member
    Reputation
    78
    Join Date
    Mar 2007
    Posts
    196
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    !@^^@ exactly how I'd be doing it. Keeping distances associated with the objects they belong to is one of the key ideas of oop, not?Ps: mobile view of ownedcore is baaaaaad

  11. #11
    Musah's Avatar Corporal
    Reputation
    3
    Join Date
    Sep 2011
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by !@^^@! View Post
    extra math operations just makes it more complicated imo, also a float is a float and doesn't magically increase its size because the number is bigger :confused:



    No offense but that's just ugly and plain stupid you're writing object oriented code, stop pretending it's C! I assume you're keeping an array of all the objects (anything npc, dynamic stuff, etc) with inheritance like described here: http://www.ownedcore.com/forums/worl...e-objects.html ([Guide-kind of] How I handle objects.) ?
    Why not just make a method in WowObject that calculates the distance and takes a WowObject as parameter? and then in your object manager class you make a method that loops over every object of the specified type(s) calling the distance method and only writes the WowObject to the return value if it's closer than the previous WowObject?
    Yeah, in regards to the square root issue, it makes absolutely no sense for me to use the square root (since it will will thwart my speed and not improve it?).
    Yeah, but my objects are only refreshing when a button is pressed so I can display new ones (so far) I will implement distance calculated every time I'm calling my object list when I progress further enough.

    Originally Posted by !@^^@! View Post
    WowObject as parameter
    This is what I love about Objective langs.
    Last edited by Musah; 09-28-2011 at 02:26 PM.

  12. #12
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Musah View Post
    Yeah, in regards to the square root issue, it makes absolutely no sense for me to use the square root (since it will will thwart my speed and not improve it?).
    How would one extra math operation (sqrt isn't the fastest I think) ever improve your speed? I don't know how it precisely compiles down to asm, but you seem to not even have the slightest clue about processor arithmetics.
    Originally Posted by Musah View Post
    This is what I love about Objective langs.
    Yeah... Objective C is obviously my favorite one.

    I really appreciate that you share some bread and butter logic in a non-C&P form (at least I would rather adapt it) for new people in this section... But please be sure that you know what you are talking about.

    Originally Posted by streppel View Post
    !@^^@ exactly how I'd be doing it. Keeping distances associated with the objects they belong to is one of the key ideas of oop, not?Ps: mobile view of ownedcore is baaaaaad
    Yeah... you can't even go to the second page of a post oO
    Last edited by Bananenbrot; 09-28-2011 at 02:56 PM.

  13. #13
    Musah's Avatar Corporal
    Reputation
    3
    Join Date
    Sep 2011
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, no, no. You misunderstand. Google search of "thwart" thwart - Google Search
    As in not improve my speed.

  14. #14
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah ok sorry english skills...

  15. #15
    Musah's Avatar Corporal
    Reputation
    3
    Join Date
    Sep 2011
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    How would one extra math operation (sqrt isn't the fastest I think) ever improve your speed? I don't know how it precisely compiles down to asm, but you seem to not even have the slightest clue about processor arithmetics.

    Yeah... Objective C is obviously my favorite one.

    I really appreciate that you share some bread and butter logic in a non-C&P form (at least I would rather adapt it) for new people in this section... But please be sure that you know what you are talking about.
    I'm not pretending to know anything about the processor, but even a puny one as me knows that the more tasks you give to the processor the slower it runs and thus I dubbed the way I handle targeting the closest object n^2 speed on a scale from n to n^2.

    ---------- Post added at 04:00 PM ---------- Previous post was at 03:59 PM ----------

    Sorry, functionality is horrible on iOS I planned to delete the other post but you replied to it

Page 1 of 2 12 LastLast

Similar Threads

  1. [Selling] Dedicated Server for your bots (WOW,AA...)
    By dinya24 in forum ArcheAge Buy Sell Trade
    Replies: 2
    Last Post: 09-10-2015, 04:02 PM
  2. [Selling] Dedicated Server for your bots (WOW,AA...)
    By dinya24 in forum World of Warcraft Buy Sell Trade
    Replies: 0
    Last Post: 10-18-2014, 11:25 AM
  3. [Selling] Dedicated Server for your bots (WOW,AA...)
    By dinya24 in forum World of Warcraft Buy Sell Trade
    Replies: 1
    Last Post: 09-25-2014, 11:27 AM
  4. Replies: 18
    Last Post: 10-19-2012, 03:46 PM
  5. do you use VPN for your bot?
    By triel559 in forum WoW Bots Questions & Requests
    Replies: 1
    Last Post: 08-07-2012, 03:36 PM
All times are GMT -5. The time now is 04:22 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search