Results 1 to 17 of 17

Thread: 2 equal Bitmaps

  1. #1
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default 2 equal Bitmaps

    Hi there,



    I need to use simba to create a script for a game which is not SRL.
    Hope you guys can help me, as I'm a begginer scripter. And I ask you not to get upset because of my english: I'm doing the absolute best I can.

    The situation is sometimes(randomly), from 5 to 19 bitmaps will appear on my client, being only one of them repeated (so 4 to 18 different bitmaps). When that happens, I have to double click both of the repeated bitmap, making them all disappear by doing so. Then go to back to beggining of the script, to do the same if the bitmaps come once more. There are 42 possible different bitmaps in total, being all of them rectangles with same sizes, but different contents.

    The structure I thought of was:
    -define the variables and the bitmapfromstrings for all the 42
    -search the client for each of the 42
    -if one of them is found, get it's coordinates, and search again, excluding the area this one was on, to find an equal bitmap (if CountBitmap was still working, it would be easier, cause I would have to find the bitmap the counted 2, and not 1)
    -if it finds 2 of the same bitmap, click both of them. if it doesn't find the second equal bitmap, continuing searching through the other 41 (and so on, until one is found(which will always happen if the first one was found)
    -loop

    For now I don't yet know how to do some parts of the script (like clicking the points of the 2 equal bitmaps, or continue looping if it doesn't find the second one or the first, or reset the loop if it successfully clicks both of the same bmps), but I do not want help with that, as I'll easily learn it by myself(at least that's what I suppose). What I want help is with the logical part. What to do.

    What I imagined to do after first finding a bitmap, and checking to see if there was a second one just the same, was to get the total area, and exclude the area of the first bmp found, what would leave me with 4 squares of area to search within. But then I realized that wouldn't work if part of the bmp to be found was on one area, and the other part on another.


    This is the core(the parts I don't yet know how to do are missing) of what I first thought, but now see wouldn't probably work:

    Code:
    program CHECKERS;
    var
    bmpp: TPointArray;
    n, w, h, x, y, a, b, c, d, e, f, g, i: integer;
    
    bmpp[1] := BitmapFromString (8, 11, blablabla)
    bmpp[2] := BitmapFromString (8, 11, blebleble)
    bmpp[3] := BitmapFromString (8, 11, blublublu)
    bmpp[4] := BitmapFromString (8, 11, bliblibli)
    .
    .
    .
    bmpp[42] := BitmapFromString (8, 11, whatever)
    
    begin
    GetClientDimensions(w, h);
    
    for n := 1 to 42
    If (FindBitmap (bmpp[n], x, y)) Then
    
    If FindBitmapIn(bmpp[n], a, b, 0, 0, x, h) Then
    
    If FindBitmapIn(bmpp[n], c, d, x + 8, 0, w, h) Then
    
    If FindBitmapIn(bmpp[n], e, f, x, y + 11, x + 8, h) Then
    
    If FindBitmapIn(bmpp[n], g, i, x, 0, x + 8, y) Then

    One more thing: When the bitmaps randomly appear on my screen, I have 8 minutes to click the 2 equal ones. So the script should have to work within this time limit, what I don't know would be possible using this logic I got to.

    Could you guys please help me?
    Thanks a lot.

  2. #2
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Could you tell us the game?
    I understand if its something private. I wouldn't go to all the trouble of getting each bitmap. Unless you know for a fact they're static.
    Is there a very distinct difference between the backdrop and the rectangles? are the rectangles all the same size? do they have specific outlines?
    I'd personally try to use TPA's cause that'd be the fastest and it'd be dynamic. So if they had a pool of 90,000,000,000,000 different bitmaps you could still use this method.

    If you show me the game or get me a picture i'd be more than willing to work with you on this. If you promise to attempt to understand what code i write

    love seeing and helping people learn here.
    good luck hope to see you around

  3. #3
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by footballjds View Post
    Could you tell us the game?
    I understand if its something private. I wouldn't go to all the trouble of getting each bitmap. Unless you know for a fact they're static.
    Is there a very distinct difference between the backdrop and the rectangles? are the rectangles all the same size? do they have specific outlines?
    I'd personally try to use TPA's cause that'd be the fastest and it'd be dynamic. So if they had a pool of 90,000,000,000,000 different bitmaps you could still use this method.

    If you show me the game or get me a picture i'd be more than willing to work with you on this. If you promise to attempt to understand what code i write

    love seeing and helping people learn here.
    good luck hope to see you around
    Actually the rectangles are each one a different a colour ( the content, I mean).
    That's why I mustn't use Tolerance.
    They have all the exact same size.
    And they never change.
    The 42 different colours most probably can be found on the background of them, but only small dots.

  4. #4
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    could you possible upload or pm me a link to an upload of a picture?

    if the colors are static then finding and identifying two equal rectangles would take about 3-100 ms max :P

  5. #5
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    A few guideline points:
    a bitmap is an integer -> bmpp should be a TIntegerArray or array of Integer.
    you have to set the length of an array -> SetLength(myArr, 4); means that myArr can now have 4 elements stored in it (ie, 3, 7, 0, 9 or 'how', 'you', 'doing', '?')
    array indices (the numbers between [ and ]) start from 0 in most programming languages, pascal and pascal script included (ie, myArr[0] is the first element, not myArr[1])
    when you want a loop (such as the for loop you use) or an if-then to run more than the first line afterwards, you have to put begin and end around the bit you want the loop or conditional to run (ie, for i := 1 to 10 do begin Writeln(i); end)
    if you want to check for duplicates, it will probably be easier to identify each bitmap on the screen and then set that bitmap to "appeared" and, if it has already appeared, then it's the duplicate (ie, make an array of booleans - they're true/false values - that's the same length as your bitmaps - 42 - and set them all to false to begin with; when you find a bitmap, say the third bitmap, then you set the third element in the array to true; if you find a bitmap and the element for it is already true, it's the duplicate)
    if you can come up with a mathematical formula for relating a and b to the on-screen areas of the bitmaps, you will make your life much easier, where a is what bitmap it is along and b is what bitmap it is down in (ie, bitmap a along and b down is in the square with the top left corner (25 + 50*a, 75 + 50*b) and the bottom right corner (45 + 50*a, 95 + 50*b) )
    you can make your algorithm more robust by looking in to how to make a bitmap from the client so that you don't have to save the bitmaps all yourself and instead you make a bitmap from the first position then compare it to the second - if it matches, you've found the duplicate; if it doesn't, then you make a bitmap from the second position and add it to your list; you then move on to the third position and check if it matches the first or the second and so on, repeating until you're done
    without seeing the game, you will have to do most of the work, even if someone else is kind enough to put my guidelines, or their own ideas, into practice for you, unless you link us to the game or give us screenshots or something visual to help us see what you need to do

    If some of this hard to translate yourself, I'd say that my grammar and spelling should be good enough that you can use a tool like google translate to help get the most from my post.

    I hope some of this helps you.
    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.

  6. #6
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah, as they are colours, it would be possible to do it by Getcolor or something, but I still don't know how to do it (cause it cannot get a spot which is not on one of the rectangles, and it has to differentiate the 2 equal ones)

  7. #7
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    My idea would be GetColors
    Then speed through the array of colors and split the tpa's(arrays of points) into the different rectangles(a sexy algorithm could easily do this )
    then you could get the matching one's instantly(virtually).

  8. #8
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by mixster View Post
    A few guideline points:
    a bitmap is an integer -> bmpp should be a TIntegerArray or array of Integer.
    you have to set the length of an array -> SetLength(myArr, 4); means that myArr can now have 4 elements stored in it (ie, 3, 7, 0, 9 or 'how', 'you', 'doing', '?')
    array indices (the numbers between [ and ]) start from 0 in most programming languages, pascal and pascal script included (ie, myArr[0] is the first element, not myArr[1])
    when you want a loop (such as the for loop you use) or an if-then to run more than the first line afterwards, you have to put begin and end around the bit you want the loop or conditional to run (ie, for i := 1 to 10 do begin Writeln(i); end)
    this is ok. thanks a lot

    Quote Originally Posted by mixster View Post
    A few guideline points:
    if you want to check for duplicates, it will probably be easier to identify each bitmap on the screen and then set that bitmap to "appeared" and, if it has already appeared, then it's the duplicate (ie, make an array of booleans - they're true/false values - that's the same length as your bitmaps - 42 - and set them all to false to begin with; when you find a bitmap, say the third bitmap, then you set the third element in the array to true; if you find a bitmap and the element for it is already true, it's the duplicate)
    this is what I'm looking for, and I understand what you said.
    the thing is:
    ok, I have found,let's say, the 15 bitmaps, and they are "appeared" (#true). let's say the bitmap number 3 has a duplicate.
    if I search for that bitmap once more, won't it find the same one? I mean, how can I exclude this one I set up as appeared, so it will find the OTHER one?
    this is the part I don't get.




    the rest of what you said is just logically incomprehensible for me :/
    but anyway I don't think I'll need it, tho I could be wrong.

    Let me make it clear: The number of rectangles is random, the position of them is random, and the position of them related to themselves is also random.

  9. #9
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by footballjds View Post
    My idea would be GetColors
    Then speed through the array of colors and split the tpa's(arrays of points) into the different rectangles(a sexy algorithm could easily do this )
    then you could get the matching one's instantly(virtually).
    no idea of what you mean, honestly.

  10. #10
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Don't know if this would work, but you could find one and move your mouse over it. Then, create a box around that rectangle and do a search outside of that one to find the other.
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  11. #11
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Camo Developer View Post
    Don't know if this would work, but you could find one and move your mouse over it. Then, create a box around that rectangle and do a search outside of that one to find the other.
    that's what I was trying if that first idea I came with, but that way I was taking wouldn't get me there.

  12. #12
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Where you setting up the box correctly? That's the simplest way of doing it.
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  13. #13
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Camo Developer View Post
    Where you setting up the box correctly? That's the simplest way of doing it.
    This is the only way I aknowledge to do this. This 4 different FindBitMapIn correspond to the 4 square areas I would get if I excluded the area of the found bitmap.

    If FindBitmapIn(bmpp[n], a, b, 0, 0, x, h) Then

    If FindBitmapIn(bmpp[n], c, d, x + 8, 0, w, h) Then

    If FindBitmapIn(bmpp[n], e, f, x, y + 11, x + 8, h) Then

    If FindBitmapIn(bmpp[n], g, i, x, 0, x + 8, y) Then

    If there's an easier way to:
    1st: set up a box
    2nd: search outside that box

    tell me it please, cause it's exactly what I need

  14. #14
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wizzup:

    Code:
    Program find;
    Var
    ppp: tpointarray;
    copp, w, h, X, Y:Integer;
    
    
    Begin
    GetClientDimensions(w, h);
    copp := BitmapFromString(7, 12, 'meJwlzxEUxDAMBmAdDqvFYTFaDAa' +
            'jxWCxWgwWq8Pi8HQ4LJ4Oh6eXe/fyveS9P5EEHUHHgskhQ6nS1Dm+' +
            'uk0pWvb3swBSVatXhjP58ern59F5+4jXe44cjxwHrv3o436i9hX5l' +
            '0jcE4zC7bzMSikjZAKJwMEXbWZlEQRjqxR8n7cJUgpBZagEafP7vE' +
            '29ZuWgHCoFoRhrM9zHP2zoPSXjiHNTu7FkS9k4EuukLeMWczVtPiB' +
            'lQbY3v6uUbuM=');
    
    If (FindBitmap(copp, ppp)) Then
    amountofbitmapsfound := length(ppp)
    Writeln('amountofbitmapsfound')
    Else
    Writeln('Could not findr');
    End.

    If (FindBitmap(copp, ppp)) Then is giving [Error] (17:26): Type mismatch
    why?

  15. #15
    Join Date
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    tried this also :
    Code:
    Program find;
    Var
    ppp: tpointarray;
    copp, w, h, X, Y: Integer;
    
    
    Begin
    GetClientDimensions(w, h);
    copp := BitmapFromString(7, 12, 'meJwlzxEUxDAMBmAdDqvFYTFaDAa' +
            'jxWCxWgwWq8Pi8HQ4LJ4Oh6eXe/fyveS9P5EEHUHHgskhQ6nS1Dm+' +
            'uk0pWvb3swBSVatXhjP58ern59F5+4jXe44cjxwHrv3o436i9hX5l' +
            '0jcE4zC7bzMSikjZAKJwMEXbWZlEQRjqxR8n7cJUgpBZagEafP7vE' +
            '29ZuWgHCoFoRhrM9zHP2zoPSXjiHNTu7FkS9k4EuukLeMWczVtPiB' +
            'lQbY3v6uUbuM=');
    ppp.x := MSX1;
    
    ppp.y := MSY1;
    
    If ((FindBitmapIn(copp, MSX1, MSY1, 0,0, w, h))) Then
    amountofbitmapsfound := length(ppp)
    Writeln('amountofbitmapsfound')
    Else
    Writeln('Could not findr');
    End.
    but "ppp.x := MSX1;" is returning "[Error] (16:5): Semicolon (';') expected at line 15
    Compiling failed."

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

    Default

    FindBitmapIn(b, x, y, sx, sy, ex, ey): Boolean

    If the bitmap stored in b is found, the position it is found at will be stored in x,y. It will look for the bitmap in the area starting at the position sx, sy and finish looking for it at the position ex, ey.

    ppp is a TPointArray - that means, it is a list of TPoints. A TPoint has an x and y variable - that is, if you have a TPoint named P then you can do P.x := 0; or P.y := 5;. You want to change ppp so that is it just a TPoint, not a TPointArray. You can then do FindBitmapIn(copp, ppp.x, ppp.y, 0, 0, w, h) - this will return true if the bitmap is somewhere on the screen.

    What I was suggesting is that you look at each bitmap on the screen one at a time and see which one it is. So, let's say there are five bitmaps on the screen: A B C D E. What you do is do FindBitmapIn(myBitmap1, x, y, sx, sy, ex, ey) where sx, sy is the top left corner of where the first bitmap will be and ex, ey is the bottom right corner of where the first bitmap will be. If you find myBitmap1 in that area, then you know that A is myBitmap1; if you don't find myBitmap1 in that area, then you can try with myBitmap2 and then myBitmap3 and so on until you find out what A is. You then move on to B and if it happens to be the same as A, then you found your duplicate. If it is different to A, then you see what C is and check if it's the same as A or if it's the same as B - if it is the same as either of them, then you have your duplicate. If C isn't the duplicate, you can then try again with seeing what bitmap D is and comparing it to A, then B, then C to see if D is you duplicate. Continue on to E if D isn't your duplicate and so on.
    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
    Dec 2011
    Posts
    20
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    working.
    thanks a lot for all of you guys.

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
  •