Page 1 of 3 123 LastLast
Results 1 to 25 of 59

Thread: Using SRL's SmartColors for object finding

  1. #1
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,459
    Mentioned
    2 Post(s)
    Quoted
    5 Post(s)

    Default Using SRL's SmartColors for object finding

    Smart Colors!


    Introduction
    I am extremely happy and proud to present the SmartColors.simba include. This is an Artificial Inteligence object finding method, but no need to be scared, as it is extremely simple to use. For basic use, you only need to worry about 2 functions:
    Simba Code:
    procedure MakeObj(MyName: string; MyColor, MyTol: integer; MyHue, MySat: extended; MyUpTexts, MyOptions: TStringArray);

    function SmartColors(FindWhat: string): boolean;

    All you need to do is call MakeObj once before calling SmartColors, (I'd suggest at the start of the script) and then you just call SmartColors whenever you want to find something.

    Here is how I used it:
    Simba Code:
    {$i SRL\Misc\SmartColors.simba}

    MakeObj('tree', 4689280, 9, 0.05, 0.74, ['n Tr', 'ree', 'hop', 'own'], ['hop down']);
    SmartColors('tree');
    NOTE: The name you give the object is the name you have to call.
    NOTE: SmartColors finds and clicks the tree.


    History
    Long story made short, a couple of years ago Tarajunky made a post about a new system he called SmartColors. It got me very interested and I learnt it straight from him and his ChickenKiller. I then developed a SmartColors function which never got into SRL, but still worked fairly well and I used it in the first version of RM Chopper. I then made a few threads about it and it caught EvilChicken's attention. EC then used his own version in his agility script. Since then, we've often enough attempted to develop a propper include for SRL with SmartColors. Here it finally is.


    The SmartColors 'Algorithm'
    SmartColors, as the name suggests, is smart and therefore learns and becomes better the more often it is called. The first time it is called, it will do a normal TPA finding and it will gather colors which are similar and close to the color you provided it with.
    It will then scan the MainScreen to see how unique these colors are. If they are rare enough, it will add them to an array of colors.
    Once added to this array of colors, it chooses the rarest of them to pass it on to a final array. You now have your SCArray ready (SmartColorsArray).

    Being done with picking all the best colors, you will now see the big difference between this system and previous ones. You will search for one color at a time from the SCArray with no tolerance. Usually, searching for even just the first color with 0 tol will be enough to find your object, making search times as low as 0 ms.

    If it does not find your object without tolerance, it will then go through all the colors again, this time with tolerance. This rarely happens.

    The speed is a big factor, but even more than that, SmartColors updates the SCArray as it runs; When it finds your object by a certain color, it will move that color up in the SCArray, meaning that next time it will search with this color sooner. What this means is that the best colors will eventually be the first ones to be searched for.

    And finally, when searching with tolerance and it finds the object, it analyses the new color, and if the color is unique enough and within tolerance range it will add it to the SCArray, meaning that SmartColors also learns about new colors to use.


    Advanced Use of SmartColors
    SmartColors if not setup will use the default SC_ constants values, however, you can set these up yourself if you wish.
    Simba Code:
    type
    {Type TSCDetails
       Description: Extra Object details; Can set them up or leave it to default values }

      TSCDetails = record
        IsSCSetup           : boolean; //do not touch, let SC know if you are using custom or default values
        UNIQUE_COLOR_MIN    : integer; //the mininum amount of color for it to join the SC array
        UNIQUE_COLOR_MAX    : integer; //same as above for maximum
        MAX_COLORS_IN_ARRAY : integer; //max length of SC Array
        HALF_BOX_SIZE       : integer; //half box size of object you are searching
        USE_TOL             : integer; //tolerance for your object
        TPA_DIST            : integer; //max distanc between points
        CLICK_STYLE         : integer; //how to click your object. Check consts
        RANDOM_RL_CHANCE    : integer; // x/100 to do R Click instead of L click
      end;

    It is extremely simple to set them up as all you have to do is call one single function:
    Simba Code:
    procedure SetupSmartColorsDetails(Name: string; ColorMin, ColorMax, MaxColors, BoxSize, Tol, Dist, ClickStyle, R_RL_Chance: integer);

    And here are the default values:
    Simba Code:
    SC_UNIQUE_COLOR_MIN      =  5;
    SC_UNIQUE_COLOR_MAX      = 20;
    SC_MAX_COLORS_IN_ARRAY   =  7;
    SC_HALF_BOX_SIZE         = 25;
    SC_USE_TOL               =  5;
    SC_TPA_DIST              =  5;
    SC_CLICK_STYLE           = 3;
    SC_RANDOM_RL_CHANCE      = 20; // x / 100 for R click

    So finally, for an advanced use of SmartColors here is your code:
    Simba Code:
    MakeObj('clay', 5215677, 17, 0.01, 1.01, ['ine', 'ock'], ['ine']);
    SetupSmartColorsDetails('clay', 3, 15, 7, 15, 5, 5, 3, 15);
    SmartColors('clay');


    And so, I hope to see people using this new system as it is extremely fast, accurate and very easy to use.

    Lots o' Love,
    The Dev Team
    Last edited by Coh3n; 03-25-2012 at 08:47 AM.

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  2. #2
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    14,997
    Mentioned
    84 Post(s)
    Quoted
    540 Post(s)

    Default

    Wow, when I read the include, I didn't think it would be that easy to use. Very nice!

  3. #3
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

  4. #4
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    5,988
    Mentioned
    30 Post(s)
    Quoted
    10 Post(s)

    Default

    Very nice RM.

    I may mess with this once I update my 99 mage script
    ~
    SRL6| Git |SRL5
    ~



  5. #5
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,434
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Simply Beautiful. Lovely code.

    Good job RM

  6. #6
    Join Date
    Oct 2006
    Location
    Ontario
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  7. #7
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,455
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Sounds nice, but disappointed at string identifiers. Constant integers would've been nicer imo and made it easier for scripters as the slight differences in string names may cause problems (haven't read through, but I assume at the least it will give a runtime writeln saying that it doesn't exist or at worst cause a crash of some kind).
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  8. #8
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,459
    Mentioned
    2 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    Sounds nice, but disappointed at string identifiers. Constant integers would've been nicer imo and made it easier for scripters as the slight differences in string names may cause problems (haven't read through, but I assume at the least it will give a runtime writeln saying that it doesn't exist or at worst cause a crash of some kind).
    I recon it would crash. Constant identifiers weren't really the best option in my opinion, as I was aiming for ease of use Also, there was very little point in constants, as there are no actually pre-made records, the scripter has to construct them themselves.

    edit: Added failsafe, no longer crashes, sends an SRL_warning and exits smart colors

    ~RM
    Last edited by Sir R. M8gic1an; 11-21-2009 at 05:50 PM.

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  9. #9
    Join Date
    Feb 2009
    Location
    Alberta, Canada
    Posts
    1,449
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  10. #10
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,455
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    It just means that the scripter has to remember which string he is using or setup a const for it, which means that an integer one would have been just as easy.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  11. #11
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,459
    Mentioned
    2 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    It just means that the scripter has to remember which string he is using or setup a const for it, which means that an integer one would have been just as easy.
    easier to remember 'mithril' rather than 10 I recon. Also, 'mithril' is more reader-friendly than 10.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  12. #12
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,023
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    easier to remember 'mithril' rather than 10 I recon. Also, 'mithril' is more reader-friendly than 10.

    ~RM
    Don't we use player[].integers[] as numbers? I honestly don't think that it would be that user unfriendly...

    Nice job.

  13. #13
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,455
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    const mithril = 10;

    or, even better, sc_mithril = 10; sc_coal = 11; sc_ *ctrl+space* => all the smart colours defined.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  14. #14
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,925
    Mentioned
    7 Post(s)
    Quoted
    133 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    const mithril = 10;

    or, even better, sc_mithril = 10; sc_coal = 11; sc_ *ctrl+space* => all the smart colours defined.
    Well, you can do constant strings too, if you're dead set on using constants.

  15. #15
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,685
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You're too sexy.
    Just watching this makes me wanna go create a script :I
    Rep++ for this, awesome.

    (I don't go like this everyday, so you better be proud >;I )

  16. #16
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,455
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    you could do constant strings, but then the whole point of using strings to be user friendly kind of goes down the drain.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  17. #17
    Join Date
    Jan 2007
    Location
    Stavanger, Norway
    Posts
    8,660
    Mentioned
    107 Post(s)
    Quoted
    255 Post(s)

    Default

    Amazing piece of art right there! Great job RM!
    I love how it works, I'll test it asap
    (I ran scar on my friends computer today and stupid avarst antivirus deleted scar.exe... <_<)

  18. #18
    Join Date
    Oct 2006
    Location
    Ontario
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  19. #19
    Join Date
    Mar 2007
    Location
    WhereDoILive:='New Hampshire'
    Posts
    3,118
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    VERY sexy
    I would have done:
    SCAR Code:
    I:=MakeObj(4689280, 9, 0.05, 0.74, ['n Tr', 'ree', 'hop', 'own'], ['hop down']);
    But what ever

  20. #20
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,459
    Mentioned
    2 Post(s)
    Quoted
    5 Post(s)

    Default

    Ok guys, I have added an advanced setup to the include and explained it in the tutorial This should be the finalized version of Smartcolors

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  21. #21
    Join Date
    Jan 2007
    Location
    Stavanger, Norway
    Posts
    8,660
    Mentioned
    107 Post(s)
    Quoted
    255 Post(s)

    Default

    Quote Originally Posted by Rasta Magician View Post
    Ok guys, I have added an advanced setup to the include and explained it in the tutorial This should be the finalized version of Smartcolors

    ~RM
    Good job
    Nicely explained and it seems extremely easy to use :O <3 your work RM

  22. #22
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    4 Post(s)
    Quoted
    0 Post(s)

    Default

    Very nice, always good to see some innovation in SRL!
    Verrekte Koekwous

  23. #23
    Join Date
    Mar 2006
    Posts
    3,052
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Tremendous work. I'm proud of designing the strategy, but you've really made it shine.


  24. #24
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,810
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Perhaps it should just return an x, y and not click..
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  25. #25
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,455
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Isn't one of the great things about SRL that it is open sauce? Go in and alter it to return a point
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •