• Visit Rebornbuddy
  • Where do I go to edit GoToFirstTab Coroutine?

    Discussion in 'Archives' started by Klacid, Jul 4, 2015.

    1. Klacid

      Klacid Member

      Joined:
      May 29, 2014
      Messages:
      173
      Likes Received:
      2
      Trophy Points:
      18
      It's the only thing keeping my bots from being completely autonomous, I need some help good sirs. :c

      I basically need more attempts and less time passed between each attempt.
       
    2. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      You can't, you have to make your own.
      That coroutine is not fully exposed, because the api needs to work for everyone, and not just you.

      Edit, How is it the only thing keeping your bot from being autonomous.. that does not make sense. The bot IS autonomous, of you are doing it correctly.
       
    3. Klacid

      Klacid Member

      Joined:
      May 29, 2014
      Messages:
      173
      Likes Received:
      2
      Trophy Points:
      18
      I get some lag every now and then and stashing isn't quite as responsive during those small intervals since it spams left arrow, I believe. Since the stash doesn't respond quickly it errors out and waits for another attempt, since I have up to 28 stash tabs in between depending on what was last stored it could land between stash tabs 2-29 and run out of attempts before it hits first stash tab, which means the bot stops itself completely afterwards.

      What I want to do is to edit the amount of attempts to say 10, so that it could fail once every 3 stash movements on average and still get to first tab before stopping on me and waiting for a resume. Likewise, 30 seconds is too long a wait for something that inevitably happens to my client and takes less than 2 seconds to resolve itself, so I could set it about there so that there isn't so much downtime between attempts. I have high latency, not low FPS so the only way to resolve it on my end without editing the bot is by getting faster internet.

      The bot is autonomous but needs babysitting on my end currently because when the GoToFirstTab.Coroutine runs out of attempts I have to manually restart it.
       
      Last edited: Jul 4, 2015
    4. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      I'm at work so I skimmed through this.
      What you want to do is,
      Things you are saving, add it to the end of the tabs, things you are processing add it to the beggining of your tabs.
      Inside BasicGrindBot, three's an option called Max Stash Tabs, set that to like whatever amount of tabs you are processing.
      There's really no reason to be checking all tabs, unless you are running my sorting plugin ( which isn't public ), or a custom one, where you need to either ask the maker to add blacklist tabs and somehow optimize this.
      If you are lagging, try a different gateway, if that cannot be resolved. The default coroutine handles lag and errors very, very efficiently.
      Since you say you lag, all the more reason not to do things faster, because you probability or getting errors due to lag greatly increases.
      The way the game works, is the info is loaded on each tab change. So, if you are lagging, you will need to wait for the information (memory) to be valid, which is what the delays in the coroutine does.
      I concur with your faster internet strategy, but sometimes that's not feasible.
      If you can pm me or link me the error log of when this happens, and/or the code you are working on, I'll be more then glad to help. As I've been through this problem, so have made a "faster" method, but still prefer the default coroutine, because it does all the necessary dirty work to make sure things don't error.
       
    5. Klacid

      Klacid Member

      Joined:
      May 29, 2014
      Messages:
      173
      Likes Received:
      2
      Trophy Points:
      18

      Thanks, I'll try the processing method though it might not work still since I process a bunch of tabs. I use AIF with lots of currency tabs and I leave about 5 stashes in between for Uniques and Quality Gems since I don't check it for days at a time; my job requires me to leave my home regularly, I just resume the bots remotely using Teamviewer but it's too awkward to actually sort my Uniques with.

      I'm not coding anything, just looking if I could edit the Coroutine itself, unfortunate that I can't.

      My lag isn't necessarily bad. In fact, I don't really lag in the traditional sense, just that when the Coroutine moves through the stash sometimes a tab will take a little more than half a second to load its contents which already errors out the Coroutine. Just increasing the wait limit between presses a little bit when moving through tabs would help.
       
    6. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      That's weird, with Pushedx's help, tony and I got rid of that issue by doing a

      Code:
      while (Stash.CurrentTabInventory == null || !Stash.CurrentTabInventory.IsValid)
                          await Coroutine.Sleep(20);
      Which does a wait, until we have valid memory, which means stash is loaded.
      This is in AIF so that's a weird issue. We had similar issues, but the above code fixed it. If you can get me a log I'll check it out.
      I'm using teamviewer too to access my 10 pcs at home while I'm at work lol, it's better then chrome remote desktop IMHO due to it's ability to choose which monitor.
       
    7. Klacid

      Klacid Member

      Joined:
      May 29, 2014
      Messages:
      173
      Likes Received:
      2
      Trophy Points:
      18

      Yeah, TeamViewer is great but I always wait to get home before I actually sort things :p.

      Actually just had the bot break on me by GoToFirstTab again so I got a log, but it looks like it didn't break the usual way of stopping while on the way to the first tab after stashing but rather while withdrawing.

      Apparently the file is too large to be uploaded so I'll just post the part where it breaks.

      You need to register and have one post to see spoilers!
       
    8. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      That's weird, What version of AIF are you running.

      Code:
      2015-07-04 18:57:03,080 [30] ERROR CustomLogger (null) - [RecipeWithdrawTask] WithdrawItemsCoroutine returned GoToFirstTabFailed.
      2015-07-04 18:57:03,081 [30] INFO  CustomLogger (null) - [Stop] Now requesting the BotThread to stop.
      Ok Do this,
      For AIF, find RecipeWithDrawTask.cs inside the Tasks Folder
      I'm running a fork of the release version so my lines are different.
      But Find something like this


      Edit, re-read the code, sec i'll post proper code.

      Ok find this code
      Code:
      var wierr = await Coroutines.WithdrawItemsCoroutine(ShouldWithdrawFromTab, ShouldWithdrawItem, ContinueWithdrawing);
                  if (wierr != Coroutines.WithdrawItemsCoroutineError.None)
                  {
                      Main.Log.ErrorFormat("[{0}] WithdrawItemsCoroutine returned {1}.", Name,wierr);
                      BotManager.Stop();
                  }
                  else
                  {
                      var stillNeed = _needs.FirstOrDefault(n => n.Value);
      
                      if (stillNeed.Key != null)
                      {
                          Main.Log.DebugFormat("[{0}] Seems like we had a problem withdrawing ({1} : {2})", Name, stillNeed.Key, stillNeed.Value);
                          return true;
                      }
      
                      Main.Log.InfoFormat("[{0}] Withdrawing has completed.", Name);
                      Reset();
                  }
      Change to
      Code:
                  int retryAttempts = 5;
                  for (int i = 0; i < retryAttempts; i++)
                  {
                      // Add clearcursor so we don't have any items on it before process
                      await GenericTasks.ClearCursorTask();
      
                      var wierr = await Coroutines.WithdrawItemsCoroutine(ShouldWithdrawFromTab, ShouldWithdrawItem, ContinueWithdrawing);
                      if (wierr != Coroutines.WithdrawItemsCoroutineError.None)
                      {
                          Main.Log.ErrorFormat("[{0}] WithdrawItemsCoroutine returned {1}., retry #{2}", Name, wierr, i);
                      }
                      else
                      {
                          var stillNeed = _needs.FirstOrDefault(n => n.Value);
      
                          if (stillNeed.Key != null)
                          {
                              Main.Log.DebugFormat("[{0}] Seems like we had a problem withdrawing ({1} : {2})", Name, stillNeed.Key, stillNeed.Value);
                              return true;
                          }
      
                          Main.Log.InfoFormat("[{0}] Withdrawing has completed.", Name);
                          Reset();
                          break;
                      }
      
                      if (i != retryAttempts) continue;
      
                      Main.Log.ErrorFormat("[{0}] WithdrawItemsCoroutine returned {1}., retry #{2}, Stop Bot", Name, wierr, i);
                      BotManager.Stop();
                      
                  }
      Where you can change retryAttempts= 5; to a retry amount of your choice.
       
      Last edited: Jul 4, 2015
    9. Klacid

      Klacid Member

      Joined:
      May 29, 2014
      Messages:
      173
      Likes Received:
      2
      Trophy Points:
      18
      Thanks! I changed the code and hopefully it won't bug out this way again.

      I'll post a log when my original problem happens again. Strangely enough it hasn't errored out in that way since I posted this thread. @_@
       
    10. pushedx

      pushedx Moderator Moderator Buddy Core Dev

      Joined:
      Sep 24, 2013
      Messages:
      4,252
      Likes Received:
      290
      Trophy Points:
      83
      In the upcoming version, the API should now be able to correctly detect when the stash page it's moving to is shown and fully loaded. This should help logic when it comes to the cases where there's higher latency issues, whether it's from your connection or the server. For example, during early testing since the Awakening release, I've seen cases where a stash tab took over 5 seconds to fully load. The API handled it correctly now, so hopefully the issue you described should be better handled in the future.

      If not, I can also make the logic you're referring to try again a few times before returning the error code.
       
    11. Klacid

      Klacid Member

      Joined:
      May 29, 2014
      Messages:
      173
      Likes Received:
      2
      Trophy Points:
      18
      Thanks! I'm really looking forward to it!
       
    12. darkbluefirefly

      darkbluefirefly Community Developer

      Joined:
      Nov 8, 2013
      Messages:
      1,927
      Likes Received:
      18
      Trophy Points:
      38
      Ya, pushedx has put in a lot of QoL into the bot, look forward to it, I've asked him to take his time, meaning take a year or so :p.
       
    13. Klacid

      Klacid Member

      Joined:
      May 29, 2014
      Messages:
      173
      Likes Received:
      2
      Trophy Points:
      18

      You would be the one losing out, Mr. 100/100. ;P
       
    14. toNyx

      toNyx Well-Known Member

      Joined:
      Oct 29, 2011
      Messages:
      3,770
      Likes Received:
      35
      Trophy Points:
      48
      He's losing account every week h3h3 this noob :troll:
      Well, tbh the game hasn't changed a lot itself, not a lot of "new" things.
      MALACHAI'S FIGHT IS STUPID, FUCK YOU GGG
       

    Share This Page