Announcement

Collapse

Forum Rules

  • No flaming or derogatory remarks, directly or through insinuation.
  • No discussion, sharing or referencing illegal software such as hacks, keygen, cracks and pirated software.
  • No offensive contents, including but not limited to, racism, gore or pornography.
  • No excessive spam/meme, i.e. copious one liners in a short period of time, typing with all caps or posting meme responses (text/image).
  • No trolling, including but not limited to, flame incitation, user provocation or false information distribution.
  • No link spamming or signature advertisements for content not specific to Dota 2.
  • No Dota 2 key requests, sell, trade etc.
  • You may not create multiple accounts for any purpose, including ban evasion, unless expressly permitted by a moderator.

  • Please search before posting. One thread per issue. Do not create another thread if there is an existing one already.
  • Before posting anything, make sure you check out all sticky threads (e.g., this). Do not create new threads about closed ones.
  • It is extremely important that you post in correct forum section.

  • Balance discussion only in Misc.
  • All art related (such as hero model) feedbacks go to Art Feedback Forum.
  • All matchmaking feedback should go here: Matchmaking Feedback
  • All report/low priority issues should go here: Commend/Report/Ban Feedback
  • No specific workshop item feedback. These should go to workshop page of that item.
  • When posting in non-bugs section (such as this), use [Bugs], [Discussion] or [Suggestion] prefix in your thread name.



In case you object some action by a moderator, please contact him directly through PM and explain your concerns politely. If you are still unable to resolve the issue, contact an administrator. Do not drag these issues in public.



All rules are meant to augment common sense, please use them when not conflicted with aforementioned policies.
See more
See less

Communication between lua and outside - Proof of concept

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            Bump.
            Would be great to get a official answer on this.

            Comment


            • #7
              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.

              Comment


              • #8
                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

                Comment


                • #9
                  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).

                  Comment


                  • #10
                    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

                    Comment


                    • #11
                      I doubt that Valve will allow you to run arbitrary not-sandboxed code linked to your bots. A library can do virtually everything in your OS with obvious security problems.

                      Comment


                      • #12
                        I doubt they will too. Too much risk of exploitation.

                        Hence why I think they should allow for an IPC method of their design, but this won't happen for a while.

                        Comment


                        • #13
                          Agreed that it probably shouldn't and won't.

                          On the personal side, I would be very suspicious and non-trusting if I was playing a script that wanted to connect to an outside source.
                          Last edited by Cornbane; 01-11-2017, 09:26 AM.

                          Comment


                          • #14
                            I didn't really get an answer and the code is not that big of deal. But mostly because the anwers aren't related to what I asked anymore, I decided to just put it on github.
                            Valve: just tell me if I should put it down.
                            Everyone who is interested: Would be great to hear you opinions.
                            Link: https://github.com/Keithenneu/dota2comm

                            Comment

                            Working...
                            X