Delays

Discussion in 'Programming & Hardware' started by Philosobyte, Dec 22, 2014.

  1. Philosobyte

    Joined:
    Dec 18, 2014
    Messages:
    398
    Likes Received:
    77
    When I script bot, I often use things like
    Code (Text):
    1.  
    2. if(Random.nextDouble() < 0.998)
    3. {
    4.     Execution.delay(Random.nextGaussian(someMin, someMax, someMean, someDeviation);
    5. }
    6. else Execution.delay(Random.nextGaussian(aLargeNumber, anotherLargeNumber, aLargeMean));
    7.  
    the point of which is to have realistic mouse delays, including rare instances of delays of 30 seconds or more. But should we be doing this? Or should we rely on whatever delays the client has personalized for the user?
     
  2. Cloud

    Cloud The Developer

    Joined:
    Jul 28, 2013
    Messages:
    2,304
    Likes Received:
    736
    Static sleeps are almost usually always a bad idea. Conditional sleeps are far better (Execution#delayWhile/delayUntil). Also, I highly suggest not usually all of those arguments in your random calls unless you really know what you're doing. Typically providing the min and max to nextGaussian is more than sufficient enough.
     
  3. Philosobyte

    Joined:
    Dec 18, 2014
    Messages:
    398
    Likes Received:
    77
    Hm, but the logic doesn't rely at all on the aforementioned sleeps. These sleeps are just anti-pattern measures. The question is whether they should be used as anti-pattern measures, or if the client takes care of all that for us.

    Okay. I'm not completely sure what I'm doing, but I do know that the standard deviation should be 1 (default) for a relatively wide bell curve and sqrt(0.2) for a steeper curve. I think in-between values result in weird things, so I'll limit myself to only using the default or sqrt(0.2).
     
  4. Cloud

    Cloud The Developer

    Joined:
    Jul 28, 2013
    Messages:
    2,304
    Likes Received:
    736
    I suggest you test generating some values with the random class and verifying your assumptions. Also, I don't think you should be using those sleeps because they will result in a pattern over a long enough period of time.
     
  5. Philosobyte

    Joined:
    Dec 18, 2014
    Messages:
    398
    Likes Received:
    77
    Thank you. I'll get rid of all my unnecessary sleeps and test any Gaussian functions if I use them again.
     
  6. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,044
    Likes Received:
    602
    As cloud stated, static sleeps are usually a bad idea. However, i think if you were to make a dynamic sleep and then follow it by the chance of having a randomly timed long sleep that shouldn't be too bad. For example if you are waiting for the player to not be moving this is the dynamic sleep you'd use:
    Code (Text):
    1. Execution.delayUntil(() -> !Players.getLocal().isMoving());
    Perhaps after that happens you could then have
    Code (Text):
    1. if (randValue > 0.99) {
    2.     Execution.delay(min, max);
    3. }
     
    Philosobyte likes this.
  7. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,430
    Likes Received:
    1,008
    As a general rule of thumb, anti-patterns can only cause benefits. That being said, implementing anti-patterns incorrectly is usually worse than not implementing them at all. I think the basic concept of what you're trying to do here is very good, so please don't be discouraged.
     
  8. Philosobyte

    Joined:
    Dec 18, 2014
    Messages:
    398
    Likes Received:
    77
    I'll reintroduce some static sleeps sparingly, make sure they make sense for a legit player, and combine them with shorter, dynamic sleeps, as per Aidden's excellent suggestion. Thanks for the additional input, guys.
     
    Aidden likes this.

Share This Page

Loading...