Results 1 to 16 of 16

Thread: Optimization?

  1. #1
    Join Date
    Jun 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Optimization?

    I'm by no means good at SCAR, I barely know anything. I've made something with my minimal knowledge of pascal/scar syntax, as long as with the help of this forum. It works pretty well, but is probably done horribly at best. this bot is supposed to be for Guitar-type-game. Using the best thing I could think of I made a separate script for each 'note'. On easy mode there are 3. So my bot would include 3 scripts, which means having to open 3 SCAR's. Which is quite annoying.

    Here's the scripts:

    Red:
    Code:
    program New;
    
    var colorvar : integer;
    
    begin
      wait(3000);
      repeat
      colorvar := GetColor(671, 460);
    if (SimilarColors(colorvar, 9345535, 50)) or (SimilarColors(colorvar, 15791091, 15)) then
        begin
        wait(5);
        KeyDown(52);
        KeyDown(13);
        repeat
          wait(45);
        until(not(SimilarColors(GetColor(671, 448), 7828735, 50)));
        KeyUp(13);
        KeyUp(52);
        wait(15);
        end;
      until 1=2;
    end.
    Yellow:
    Code:
    program New;
    
    var
      colorvar : integer;
    
    begin
      wait(3000);
      repeat
      colorvar := GetColor(550, 460);
    if (SimilarColors(colorvar, 8973055, 50)) or (SimilarColors(colorvar, 15791091, 15)) then
        begin
        wait(5);
        KeyDown(49);
        KeyDown(13);
        repeat
          wait(45);
        until(not(SimilarColors(GetColor(551, 446), 4521983, 50)));
        KeyUp(13);
        KeyUp(49);
        wait(15);
        end;
      until 1=2;
    end.
    Basically what it does is look for a certain color at an x,y if it's found then it presses the button, now it might be a long note, so it also looks for another color at a different x,y if found it continues to hold that button until it's gone. So it works really well. But as I said before, I'm just wondering if it could be made into one script. I have one more other script for another color, but I'm really just looking for ideas, or suggestions.

    It's a fast-paced game, so it needs to be really fast. Is this possible?

  2. #2
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Looks pretty good. You might want to change the repeat statements to repeat..until isFKeyDown(10); or whatever FKey you want to press, so that it's a bit easier to stop.

    Also, to increase readability (but only slightly. ) you may want to do

    SCAR Code:
    const
      Key_Tab = 13;
      Key_1 = 49;
    ...
    so it's more easily alterable in the future.

    But, yeah. Good job coding; the only two things I can find just make things a bit easier to read/do.

    Good luck with the game!
    ~Macro_FTW
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  3. #3
    Join Date
    Jun 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I was really asking if it would be plausible to make it into one script with the same performance.

  4. #4
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Check out using arrays!

    A TPointArray for the GetColors, an integer array for the colour found and an integer array for the keys!
    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

  5. #5
    Join Date
    May 2007
    Location
    UK
    Posts
    4,007
    Mentioned
    1 Post(s)
    Quoted
    12 Post(s)

    Default

    What game!?
    Sounds good

    T~M

  6. #6
    Join Date
    Jun 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I know about arrays. I'm actually fluent in several programming languages. Just not Pascal or SCAR. Either way, do you think it would be able to be fast enough while looping through an array to still hit all the notes?

  7. #7
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Al3x8730 View Post
    I know about arrays. I'm actually fluent in several programming languages. Just not Pascal or SCAR. Either way, do you think it would be able to be fast enough while looping through an array to still hit all the notes?
    Of course it would be. SCAR could do that [Scan for 5 notes to press and press the according keys] in under 30MS, I believe.
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  8. #8
    Join Date
    Jun 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Meh, I made this:

    Code:
    program New;
    const
    KEY_ENTER = 13;
    KEY_1 = 49;
    KEY_2 = 50;
    KEY_3 = 51;
    KEY_4 = 52;
    KEY_5 = 53;
    
    var colorvar, xfound, yfound : Integer;
    
    begin
      wait(5000);
      repeat
          colorvar := GetColor(671, 462);
          if (FindColorTolerance(xfound, yfound, 8978376, 655, 450, 689, 470, 70)) or (SimilarColors(colorvar, 15791091, 60)) then
          begin
            KeyDown(KEY_3);
            KeyDown(KEY_ENTER);
            wait(5);
            repeat
              wait(55);
            until(not(SimilarColors(GetColor(671, 446), 3866588, 50)));
            KeyUp(KEY_ENTER);
            KeyUp(KEY_3);
          end;
          colorvar := GetColor(590, 462);
          if (FindColorTolerance(xfound, yfound, 8973055, 571, 450, 604, 470, 70)) or (SimilarColors(colorvar, 15791091, 60)) then
          begin
            KeyDown(KEY_1);
            KeyDown(KEY_ENTER);
            wait(5);
            repeat
              wait(55);
            until(not(SimilarColors(GetColor(590, 447), 4521983, 50)));
            KeyUp(KEY_ENTER);
            KeyUp(KEY_1);
          end;
          colorvar := GetColor(631, 460);
          if (FindColorTolerance(xfound, yfound, 16750060, 614, 450, 648, 4701
          , 70)) or (SimilarColors(colorvar, 15791091, 60)) then
          begin
            KeyDown(KEY_2);
            KeyDown(KEY_ENTER);
            wait(5);
            repeat
              wait(55);
            until(not(SimilarColors(GetColor(631, 449), 16743679, 50)));
            KeyUp(KEY_ENTER);
            KeyUp(KEY_2);
          end;
      until 1=2;
    end.
    It only does 3 colors (easy mode).. But I'm not sure if it's fast enough..

  9. #9
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Al3x8730 View Post
    Meh, I made this:

    Code:
    program New;
    const
    KEY_ENTER = 13;
    KEY_1 = 49;
    KEY_2 = 50;
    KEY_3 = 51;
    KEY_4 = 52;
    KEY_5 = 53;
    
    var colorvar, xfound, yfound : Integer;
    
    begin
      wait(5000);
      repeat
          colorvar := GetColor(671, 462);
          if (FindColorTolerance(xfound, yfound, 8978376, 655, 450, 689, 470, 70)) or (SimilarColors(colorvar, 15791091, 60)) then
          begin
            KeyDown(KEY_3);
            KeyDown(KEY_ENTER);
            wait(5);
            repeat
              wait(55);
            until(not(SimilarColors(GetColor(671, 446), 3866588, 50)));
            KeyUp(KEY_ENTER);
            KeyUp(KEY_3);
          end;
          colorvar := GetColor(590, 462);
          if (FindColorTolerance(xfound, yfound, 8973055, 571, 450, 604, 470, 70)) or (SimilarColors(colorvar, 15791091, 60)) then
          begin
            KeyDown(KEY_1);
            KeyDown(KEY_ENTER);
            wait(5);
            repeat
              wait(55);
            until(not(SimilarColors(GetColor(590, 447), 4521983, 50)));
            KeyUp(KEY_ENTER);
            KeyUp(KEY_1);
          end;
          colorvar := GetColor(631, 460);
          if (FindColorTolerance(xfound, yfound, 16750060, 614, 450, 648, 4701
          , 70)) or (SimilarColors(colorvar, 15791091, 60)) then
          begin
            KeyDown(KEY_2);
            KeyDown(KEY_ENTER);
            wait(5);
            repeat
              wait(55);
            until(not(SimilarColors(GetColor(631, 449), 16743679, 50)));
            KeyUp(KEY_ENTER);
            KeyUp(KEY_2);
          end;
      until 1=2;
    end.
    It only does 3 colors (easy mode).. But I'm not sure if it's fast enough..
    Then try trimming the 55ms waits down to 10-15ms?
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  10. #10
    Join Date
    Jun 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Macro_FTW View Post
    Then try trimming the 55ms waits down to 10-15ms?
    I doubt that's it only because most of the time the if statement isn't even triggered. Idk it just seems to be a bit more off than before. And I need it working perfectly.

  11. #11
    Join Date
    May 2007
    Location
    UK
    Posts
    4,007
    Mentioned
    1 Post(s)
    Quoted
    12 Post(s)

    Default

    What game is it?
    Then I will see what i can do

    T~M

  12. #12
    Join Date
    Jun 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by The Man View Post
    What game is it?
    Then I will see what i can do

    T~M
    http://jamlegend.com Feel free to try mine out. You should see what I mean.

  13. #13
    Join Date
    Aug 2007
    Location
    in a random little world
    Posts
    5,778
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

  14. #14
    Join Date
    Jun 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Shuttleu View Post
    same here (and i want to play the game)

    ~shut
    I already posted it, http://jamlegend.com

  15. #15
    Join Date
    Sep 2008
    Posts
    241
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sucks for me.

    My brother ripped out the "3" key on my keyboard, and this game doesn't recognize the Number Pad.

    I don't like it too much anyways...
    PM me if you need any help with math.
    I can try to help you with anything!


  16. #16
    Join Date
    Jun 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by xXxBlender3DxXx View Post
    Sucks for me.

    My brother ripped out the "3" key on my keyboard, and this game doesn't recognize the Number Pad.

    I don't like it too much anyways...
    If you goto the options tab you can change the buttons you use to play.

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
  •