fixthissite Posted January 13, 2015 Share Posted January 13, 2015 Each call to myPlayer performs some kind of wrap. Why is this wrap needed each call? Could I store the player somewhere to prevent multiple myPlayer calls, or would doing that result in the player not getting updated for some reason? I don't have an account, so I can't really test this out, so if someone could let me know I'd appreciate it Link to comment Share on other sites More sharing options...
Botre Posted January 13, 2015 Share Posted January 13, 2015 Each call to myPlayer performs some kind of wrap. Why is this wrap needed each call? Could I store the player somewhere to prevent multiple myPlayer calls, or would doing that result in the player not getting updated for some reason? I don't have an account, so I can't really test this out, so if someone could let me know I'd appreciate it Why exactly would you want to prevent myPlayer calls? Link to comment Share on other sites More sharing options...
fixthissite Posted January 13, 2015 Author Share Posted January 13, 2015 (edited) Why exactly would you want to prevent myPlayer calls? I'm not trying to prevent it, I just don't want to use it myself. I would expect myPlayer to reference the instance immediately, but instead it wraps it for some reason, which I didn't want to struggle finding out why. I was hoping someone could either give me an explination of why the wrapping occurs, or confirm that it's safe to store the instance in my own variable and use my variable to reference it (to prevent performing the wrap each time, if it's not needed). I guess you can call it premature optimization, but I'm very curious as to why myPlayer requires a wrap rather than immediately reference the player instance Edited January 13, 2015 by fixthissite Link to comment Share on other sites More sharing options...
Alek Posted January 13, 2015 Share Posted January 13, 2015 It checks to see if the adapter already has a wrapper. If it does then it returns the wrapper; if it doesn't it sets it for future reference. Link to comment Share on other sites More sharing options...
fixthissite Posted January 13, 2015 Author Share Posted January 13, 2015 (edited) It checks to see if the adapter already has a wrapper. If it does then it returns the wrapper; if it doesn't it sets it for future reference. It's pretty efficient. I had a feeling it was to lazily initialize something (not completely sure the purpose of a wrapper, but I have no doubts that it's essential), but is there at any point the adapter won't have a wrapper after setting it? Or is it just to prevent creating the wrapper before the user is called for? I understand it's not a HUGE difference, but I actually plan on using quite a bit of resources (CPU time wise in this case), and seeing how myPlayer isn't subject for inlining (on some JVMs), I was wondering if I could safely reference the object using my own variable. Thanks for the confirmation, by the way! EDIT: I understand HotSpot may inline the method if it hasn't been overriden yet, but I'm asking for a general case Edited January 13, 2015 by fixthissite Link to comment Share on other sites More sharing options...
Alek Posted January 13, 2015 Share Posted January 13, 2015 You're assumption is correct regarding creating the wrapper before the user is called for. I didn't write it but from what it looks like, that's what it is. I closed out of IntelliJ but from what quickly skimmed though, you won't be able to safely reference the object. Edit: Good guesses by the way. What will you be doing that would require that kind of optimization? 1 Link to comment Share on other sites More sharing options...
fixthissite Posted January 14, 2015 Author Share Posted January 14, 2015 (edited) You're assumption is correct regarding creating the wrapper before the user is called for. I didn't write it but from what it looks like, that's what it is. I closed out of IntelliJ but from what quickly skimmed though, you won't be able to safely reference the object. Edit: Good guesses by the way. What will you be doing that would require that kind of optimization? A few AI tactics that I think might evolve bots to be more human-like, such as increasing the amount of possible paths taken, multi-tasking and an artificial conscience that lets the bot decide (with guidance from the user) when it should switch to a new skill, quest or market event. I also wanted to attempt a pretty crazy task, which would be logging bot information, sending it to a database to be analyzed by an artificial neural network that I've been thinking of the past week. Within time, I was hoping it would contribute to finding out how Jagex scouts for bots. I just want to make sure the foundation I'm building this on is as optimized as possible (I'm talking micro-optimization), since I know how these subjects can be pretty resource greedy at times, not to mention overhead from the synchronization required to bring all this together together. I'm not even sure if I could fit this all into your client, seeing how I haven't had the chance to profile an average bot, but it's worth a shot. I'm pretty keen when it comes to optimization, so hopefully I could make something of this Although I'm not building on the actual API (rather than a mock I've slowly been attempting to write; not planning on releasing it once it's finished or anything, the implementation is probably far from true anyways), I want to account for certain aspects one would need to using the real API And just a heads up, I might have quite a few more questions in the future that I'm not sure the community will be able to properly answer. Would you rather me post a topic or message you? Edited January 14, 2015 by fixthissite Link to comment Share on other sites More sharing options...
Swizzbeat Posted January 14, 2015 Share Posted January 14, 2015 The wrapper just wraps the accessor which is used to call the injected methods. This provides the abstraction needed for the average script developer. I'd suggest learning about how OSBot works before attempting any sort of projects :p 1 Link to comment Share on other sites More sharing options...
fixthissite Posted January 14, 2015 Author Share Posted January 14, 2015 The wrapper just wraps the accessor which is used to call the injected methods. This provides the abstraction needed for the average script developer. I'd suggest learning about how OSBot works before attempting any sort of projects That's what I'm doing right now. Not sure what inject methods are in the context of bot scripting, but I'm sure I'll come to realize it in the future when I stumble across them Link to comment Share on other sites More sharing options...
Swizzbeat Posted January 14, 2015 Share Posted January 14, 2015 That's what I'm doing right now. Not sure what inject methods are in the context of bot scripting, but I'm sure I'll come to realize it in the future when I stumble across them Feel free to PM me if you want some resources, I can't share them here or I'll get banned. Link to comment Share on other sites More sharing options...