Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Communication between lua and outside - Proof of concept

  1. #1
    Basic Member
    Join Date
    Dec 2016
    Posts
    29

    Question Communication between lua and outside - Proof of concept

    Hi,

    Soo, I've built a proof of concept for communication(just string messages atm) between the lua scripting part, and pretty much any outside program.

    It consist of a simple lua module, and a C++ program (a dll actually, which can be included in most languages).
    The c++ part communicates to lua by reading and writing into it's memory. While it sounds kinda shady, it's actually pretty straightforward once you consider that lua is open source and it's memory layout is very simple.
    The lua module itself can't do anything, so it's safe to distribute. However, when running on a local server, the c++ part can be attached and enables the good stuff.
    The memory reading/writing is done for the lua part of the dota memory only. And even there just on the tables created by the module.

    Some examples of what should be possible:
    • Have an interactive lua shell in the bots context (great for learning the api)
    • Commanding bots to do things (testing the bots)
    • Exchange data for machine learning or debugging (I didn't measure the data rates yet though)
    • Let AM tweet "Magic shall not prevail" every 5 minutes (I didn't even start writing a bot by now, you guys should be able to find some more actual use cases)

    While I think it's really cool, it's still messing with dota's memory, and Valve might not like this. So I'm not sure what to do:
    1. Upload it to github, so everyone can use it
    2. Keep it, since Valve might hunt me down and take my rares.


    merry christmas

  2. #2
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,017
    Hello, thanks for this!
    I recommend sending it to ChrisC

    ATM he's on holiday so it might take a while for him to answer.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  3. #3
    Basic Member
    Join Date
    Dec 2016
    Posts
    76
    http://dev.dota2.com/showthread.php?t=274148

    why this guy failed and you successed?
    if C++ binding really works,that will be a great news
    https://github.com/lenLRX/Dota2_DPPO_bots ----My ML bot work in progress

  4. #4
    Basic Member
    Join Date
    Dec 2016
    Posts
    29
    You can't import c++ lua modules, since they killed the methods necessary for it.
    My module is plain lua und just sets up a simple table, while an outside c++ program is doing the heavy lifting.

  5. #5
    Basic Member
    Join Date
    Dec 2016
    Posts
    76
    Quote Originally Posted by Justus Mea View Post
    You can't import c++ lua modules, since they killed the methods necessary for it.
    My module is plain lua und just sets up a simple table, while an outside c++ program is doing the heavy lifting.
    oh i want to have a look at "hello world" of you module,I am new to lua
    https://github.com/lenLRX/Dota2_DPPO_bots ----My ML bot work in progress

  6. #6
    Basic Member
    Join Date
    Dec 2016
    Posts
    29
    Bump.
    Would be great to get a official answer on this.

  7. #7
    Basic Member
    Join Date
    Dec 2016
    Posts
    731
    It would be great to get a Valve response officially on this. It isn't hard for me to create a large table in LUA in any of the available API functions, seed it with a magic key that I can than comb using another application for in system memory, and directly manipulate it from an external source. HOWEVER, if such an implementation is frowned upon or violates any Terms of Use I am not going to waste time implementing it as it will never get approved for Workshop distribution or use in any bot tournaments.

    If Valve doesn't mind doing this then they would most likely create an official API for IPC of some form.

  8. #8
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,017
    Let's assume that by some weird conjecture Valve agrees...

    My only concern is portability. Using a dll on Linux or Mac OS is not something that can work (outside Mono which is not the case here). Same as dynlibs and so files.
    If we are using Ansi C, then it means there needs to be a way to either detect the OS to only download the necessary library for that OS or... it might only download the sources which leaves it up to the user to compile which I think is not OK.

    In the end, I think it's a great POC, but not sure it can be properly implemented without a plugin system.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  9. #9
    Basic Member
    Join Date
    Dec 2016
    Posts
    29
    What I wrote is not supposed to be a part of the bot, but to help with the development of the bot.

    To use the dll, there has to be a process outside of dota. That process is either platform dependent itself, or can at least choose the right .dll/.so/.osx-thingy. Distributing these via the workshop is out of the question anyway.
    (Custom bot tournaments could in theory use it. Platform stuff would be up to their rules.)

    Also, the dll makes heavy use of winapi, and wouldn't work on other OS'es at all (Rewriting it for *nix shouln't be to hard though, dont know about Mac OS).

  10. #10
    Basic Member
    Join Date
    Dec 2016
    Posts
    76
    Quote Originally Posted by Justus Mea View Post
    What I wrote is not supposed to be a part of the bot, but to help with the development of the bot.

    To use the dll, there has to be a process outside of dota. That process is either platform dependent itself, or can at least choose the right .dll/.so/.osx-thingy. Distributing these via the workshop is out of the question anyway.
    (Custom bot tournaments could in theory use it. Platform stuff would be up to their rules.)

    Also, the dll makes heavy use of winapi, and wouldn't work on other OS'es at all (Rewriting it for *nix shouln't be to hard though, dont know about Mac OS).
    cross platform is not so hard if the code does not involve system api.
    C/C++ standard itself is cross platform.
    i don't think computational codes need system api.
    we may need some BLAS lib and they are cross platform as well.

    so i think we just have to compile the same code three times for Win/Linux/OS X
    https://github.com/lenLRX/Dota2_DPPO_bots ----My ML bot work in progress

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •