Page 4 of 5 FirstFirst ... 2 3 4 5 LastLast
Results 31 to 40 of 42

Thread: anyone managed to use CreateHTTPRequest?

  1. #31
    Valve Developer
    Join Date
    Sep 2011
    Posts
    1,704
    We're totally cool with experiments with ML approaches, but for security reasons we only allow server-side bot scripting do be done with our lua interface. If we can maintain security, we're amenable to opening up the interface to better support ML back-ends.

  2. #32
    Basic Member
    Join Date
    Dec 2016
    Posts
    687
    Quote Originally Posted by ChrisC View Post
    We're totally cool with experiments with ML approaches, but for security reasons we only allow server-side bot scripting do be done with our lua interface. If we can maintain security, we're amenable to opening up the interface to better support ML back-ends.
    I think what you have is sufficient, b/c even if someone writes a good distributed RL algorithm and needs users at scale to help train it a webserver relay/proxy can be provided that that talks to the final server that aggregates all the test data and results. It is then on the people using that script if they want to partake and share their data with the group or not.

    I mean it wouldn't run straight out of the Workshop b/c it would require a separate setup of a webserver relay, but it's not hard (as I have shown) to create a python webserver which you could then do anything you want with. And the action of doing the step of setting up the webserver would suffice as consent I believe.

  3. #33
    Basic Member
    Join Date
    Dec 2016
    Posts
    687
    @ChrisC - thank you, confirming that CreateHTTPRequest() now properly uses the callback using the code I previously posted in this thread

    POST:
    Code:
    [VScript] {"data":{"MaxHealth": 640,"Health": 640}}
    REPLY:
    Code:
    [VScript] Request : table: 0x0022e168
    [VScript] Body : {"operation": "POST", "result": "success"}
    [VScript] StatusCode : 200

  4. #34
    Basic Member
    Join Date
    Dec 2016
    Posts
    687
    Also, I tested that I can specify a port of my choice (and not rely on the default port 80) and it works.

  5. #35
    Basic Member
    Join Date
    Dec 2016
    Posts
    687
    @ChrisC - thank you for including game/dkjson.lua

    I was dreading having to write my own JSON decoder for the replies from my webserver, low and behold you provided it.

    This is more of a PSA for other people that want to have JSON encoded bidirectional communication.

  6. #36
    Basic Member axetion's Avatar
    Join Date
    Jan 2017
    Posts
    38
    Quote Originally Posted by ChrisC View Post
    We're totally cool with experiments with ML approaches, but for security reasons we only allow server-side bot scripting do be done with our lua interface. If we can maintain security, we're amenable to opening up the interface to better support ML back-ends.
    It would be really nice if you could find a way to let us safely load Torch (and its NN framework). I'm currently nearing completion of a bot that uses it extensively, and it really sucks from both a technical and UX standpoint to have to use an HTTP server. Just for giggles I tried building it and linking it against libvscript which worked but obviously the sandbox doesn't let you then import it since it's a native library.

  7. #37
    Basic Member
    Join Date
    Dec 2016
    Posts
    687
    I have an issue with hitting the packet size now (no warnings are thrown...)

    - EDIT - Nevermind... the JSON was malformed as I was concatenating information of an enemy unit that walked out of LoS and I didn't check that it was not IsNull(). Failure to do so malformed my JSON structure
    Last edited by nostrademous; 06-13-2017 at 08:09 AM.

  8. #38
    Basic Member
    Join Date
    Dec 2016
    Posts
    687
    Hah, actually I'm back to strings larger than 8000 characters... hm....

    string.len(message) returns '8142' for the size... so I guess I need to be more terse, unless @ChrisC is willing to up the size

  9. #39
    Basic Member aveyo's Avatar
    Join Date
    Aug 2012
    Location
    EU West
    Posts
    2,762
    Back in the days of optimized programming, people used to "pack bits". I'm sure you're very familiar with that.
    Now we have these fuckin' json's and oversized google protobuffs in the backend.
    I'm willing to bet you would reduce your size ten times by not using raw strings. Hell, even a basic ascii encoding would help a lot.
    But why would you, when DOTA is already the most atrocious multiplayer game when it comes to bandwidth waste.. so 16K, here we come

  10. #40
    Basic Member
    Join Date
    Dec 2016
    Posts
    687
    Okay, I have decided to implement a much smarter HTTP transport system for my bot. One that doesn't just send full packet updates to the server every 0.5 seconds, but rather one that has 3 (for now) different packet types: 1) authentication packet, 2) world update packet, 3) player update packet. I am debating if eventually I will want to split the World and Player updates into "full data dumps" and "delta dumps" (meaning send full world state every 5 seconds, but then send only things that changed in between... we'll see if that is necessary as it will be a lot of tracking just to know what changes to report).

    Each packet type is processed by the server and provides it's own reply to that information which is processed on the Dota 2 backend properly (I track replies to each type separate as the socket connection is async and the replies might come back out of order in how they were sent). Ultimately if I move into a multi-threaded server (for AI purposes) I might additionally have to track unique sequence numbers of packets to know when replies from much more intensive analysis arrive which might be in reply to messages that have been sent a longer time ago (as in - a player update for Antimage is send; webserver does a quick analysis and replies with directives for the hero; at the same time the packet is also sent to the AI system which does much deeper analysis and could take a lot longer; another player update from Antimage is sent to webserver; webserver does a quick analysis and replies with directives for the hero; AI replies to the first message b/c it finally finished crunching - need a system to track this possible anomaly). This should be very easy to do if needed.

    For now I had to gut all the data that was in one large clump as I need to separate it into the different types of updates so all I send is the Type and Time. This part works. Just need to repopulate data dumps now and then write processors for the replies.

    Here is the barebones example:
    Code:
    [VScript] Connected Successfully to Backend Server
    [VScript] 43.46635 [npc_dota_hero_antimage]: Sending World Update: {"Type": "W", "Time": 1095.3802490234}
    [VScript] 43.46635 [npc_dota_hero_antimage]: Sending Player Update: {"Type": "P2", "Time": 1095.3806152344}
    
    [VScript] 43.46635 [npc_dota_hero_antimage]: Need to Process new World Update
    [VScript] 43.46635 [npc_dota_hero_antimage]: Packet RTT: 0.13659667970001
    
    [VScript] 43.46635 [npc_dota_hero_antimage]: Need to Process new Player Update
    [VScript] 43.46635 [npc_dota_hero_antimage]: Packet RTT: 0.13623046869998
    This is the code for the SendData function:
    Code:
    function webserver.SendData(hBot)
        -- if we have not verified the presence of a webserver yet, send authentication packet
        if not webserverFound and not webserverAuthTried then
            webserverAuthTried = true
            local jsonData = webserver.CreateAuthPacket()
            packet:CreatePacket(packet.TYPE_AUTH, jsonData)
            webserver.SendPacket(jsonData)
        end
        
        -- if we have a webserver
        if webserverFound then    
            -- check if we need to send a World Update Packet
            if packet.LastPacket[packet.TYPE_WORLD] == nil or packet.LastPacket[packet.TYPE_WORLD].processed
                or (GameTime() - webserver.lastWorldUpdate) > 0.5 then
                local jsonData = webserver.CreateWorldUpdate()
                packet:CreatePacket(packet.TYPE_WORLD, jsonData)
                webserver.lastWorldUpdate = GameTime()
                dbg.myPrint("Sending World Update: ", tostring(jsonData))
                webserver.SendPacket(jsonData)
            end
            
            -- check if we need to send a Player Update Packet
            local id = packet.TYPE_PLAYER .. tostring(hBot:GetPlayerID())
            if packet.LastPacket[id] == nil or packet.LastPacket[id].processed then
                local jsonData = webserver.CreatePlayerUpdate(hBot)
                packet:CreatePacket(id, jsonData)
                dbg.myPrint("Sending Player Update: ", tostring(jsonData))
                webserver.SendPacket(jsonData)
            end
        end
    end
    Last edited by nostrademous; 06-14-2017 at 07:06 AM.

Posting Permissions

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