Giter Club home page Giter Club logo

Comments (19)

TimZaman avatar TimZaman commented on September 24, 2024

Yeah reset is in the order of seconds. 50 seconds would be a lot. By 'pause' I am assuming you preload games, and no you cannot do that because only one host can run one dota game at a time. So you need to run in VM's which is exactly what dotaservice does: you put it in a docker container.

from dotaservice.

lenLRX avatar lenLRX commented on September 24, 2024

Yeah reset is in the order of seconds. 50 seconds would be a lot. By 'pause' I am assuming you preload games, and no you cannot do that because only one host can run one dota game at a time. So you need to run in VM's which is exactly what dotaservice does: you put it in a docker container.

of cause cache with dota2 in docker containers

from dotaservice.

TimZaman avatar TimZaman commented on September 24, 2024

dotaservice bonanza at my place, these are all containers running dota:

screenshot 2018-12-14 at 00 54 49

from dotaservice.

lenLRX avatar lenLRX commented on September 24, 2024

that is not exactly what i need.
when the container is created, dota2 is not started until we call reset().
once we call the reset() we have to consume the events asap otherwise the game goes to the end.

my scenario is that: i have N core on a host, and 1 container each core.
I want to prepare N inited dota game, so that i can start next batch in 1 sec.

from dotaservice.

TimZaman avatar TimZaman commented on September 24, 2024

OK! Yes that sounds like a fair optimisation. The only way to do that must be calling reset into dota's stdin (its console) and somehow restart the game with all the settings exactly. I think that's going to be tricky and error-prone, and will probably hard to get stable.

from dotaservice.

lenLRX avatar lenLRX commented on September 24, 2024

found dota_pause for console cmd

] dota_pause CDOTAGamerules:Pause = true PlayerId=0 fUnpauseDelay=3.00 fPauseDelay=0.00 --- CSODOTALobby.game_state: DOTA_GAMERULES_STATE_PRE_GAME +++ CSODOTALobby.game_state: DOTA_GAMERULES_STATE_GAME_IN_PROGRESS ] dota_pause CDOTAGamerules:Pause = false PlayerId=0 fUnpauseDelay=0.00 fPauseDelay=3.00

from dotaservice.

lenLRX avatar lenLRX commented on September 24, 2024

dota_pause twice for unpause

from dotaservice.

lenLRX avatar lenLRX commented on September 24, 2024

@TimZaman I found that the increment of world_state.dota_time is constant.
If i reset the game and sleep for long time, it seems that the dota_time is unchanged, so the dota seems synchronize with dotaservice. if thats true, we dont need pause at all.
Is that ture? how dotaservice sync with dota game?

from dotaservice.

TimZaman avatar TimZaman commented on September 24, 2024

from dotaservice.

Nostrademous avatar Nostrademous commented on September 24, 2024

There is a lua function that gives pause.
DebugPause() <-- that's it. no need to use console to do it necessarily.

from dotaservice.

TimZaman avatar TimZaman commented on September 24, 2024

from dotaservice.

Nostrademous avatar Nostrademous commented on September 24, 2024

There exist a bunch of functions that are not mentioned in any API. DebugPause() was introduced early in API development by Chris C. per my request when there were ways to crash the game via bot commands and we needed better ways to debug the situation when invalid targets and dangling unit handles existed.

I believe it is the equivalent of pressing F9 in game.

from dotaservice.

TimZaman avatar TimZaman commented on September 24, 2024

from dotaservice.

Nostrademous avatar Nostrademous commented on September 24, 2024

No arguments.

It doesn't wait within lua. It does return. The protobufs continue to come every X frames and the main LUA thread that controls the bots keeps iterating every frame but never enters the individual bot's Think() function. The dotaTime and the gameTime stay the same, realTime continues to increment.

This is all based from my recollection of about 2 years ago, best to just test it.

from dotaservice.

Nostrademous avatar Nostrademous commented on September 24, 2024

Here is when it was added:
https://dev.dota2.com/showthread.php?t=277988&highlight=DebugPause

from dotaservice.

lenLRX avatar lenLRX commented on September 24, 2024

The increment isn't contant. See my notes in NOTES.md. Dotaserivce indeed syncs with the dota game of "pauses" if you want to call it that ('blocked' is the better term). See code.

On Sat, Dec 15, 2018 at 11:11 AM 李睿昕 @.***> wrote: @TimZaman https://github.com/TimZaman I found that the increment of world_state.dota_time is constant. If i reset the game and sleep for long time, it seems that the dota_time is unchanged, so the dota seems synchronize with dotaservice. if thats true, we dont need pause at all. Is that ture? how dotaservice sync with dota game? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#13 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRHvVO9Zb95abpL9aDDt3_lgtyjTgks5u5Ul4gaJpZM4ZUp1y .

but consider the following code , why the increment is constant 1/3 sec?

import asyncio
import time
from grpclib.client import Channel

from dotaservice.protos.DotaService_grpc import DotaServiceStub
from dotaservice.protos.dota_gcmessages_common_bot_script_pb2 import CMsgBotWorldState
from dotaservice.protos.DotaService_pb2 import Action
from dotaservice.protos.DotaService_pb2 import Empty
from dotaservice.protos.DotaService_pb2 import Config
from dotaservice.protos.DotaService_pb2 import HostMode
from dotaservice.protos.dota_gcmessages_common_bot_script_pb2 import CMsgBotWorldState

async def main():
remote_host = '127.0.0.1'
config = Config(
ticks_per_observation=10,
host_timescale=10,
host_mode=HostMode.Value('DEDICATED'),
)
loop = asyncio.get_event_loop()
channel = Channel(remote_host, 13337, loop=loop)
env = DotaServiceStub(channel)
state = await asyncio.wait_for(env.reset(config), timeout=60)
time.sleep(10)
action_pb = CMsgBotWorldState.Action()
action_pb.actionType = CMsgBotWorldState.Action.Type.Value(
'DOTA_UNIT_ORDER_NONE')

for i in range(5):
    await asyncio.sleep(i)
    state = await asyncio.wait_for(env.step(Action(action=action_pb)), timeout=60)
    world_state = state.world_state
    print(world_state.dota_time, world_state.game_time)
channel.close()

asyncio.run(main())

the output is
-89.5666732788086 31.5665283203125
-89.23334503173828 31.899856567382812
-88.90001678466797 32.233184814453125
-88.56668853759766 32.56651306152344
-88.23336029052734 32.89984130859375

from dotaservice.

TimZaman avatar TimZaman commented on September 24, 2024

from dotaservice.

lenLRX avatar lenLRX commented on September 24, 2024

Floating point math isnt constant so the reported game time isnt perfect.

On Sat, Dec 15, 2018, 21:40 李睿昕 @.*** wrote: The increment isn't contant. See my notes in NOTES.md. Dotaserivce indeed syncs with the dota game of "pauses" if you want to call it that ('blocked' is the better term). See code. … <#m_-8209969957807654932_> On Sat, Dec 15, 2018 at 11:11 AM 李睿昕 @.***> wrote: @TimZaman https://github.com/TimZaman https://github.com/TimZaman I found that the increment of world_state.dota_time is constant. If i reset the game and sleep for long time, it seems that the dota_time is unchanged, so the dota seems synchronize with dotaservice. if thats true, we dont need pause at all. Is that ture? how dotaservice sync with dota game? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#13 (comment) <#13 (comment)>>, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRHvVO9Zb95abpL9aDDt3_lgtyjTgks5u5Ul4gaJpZM4ZUp1y . but consider the following code , why the increment is constant 1/3 sec? import asyncio import time from grpclib.client import Channel from dotaservice.protos.DotaService_grpc import DotaServiceStub from dotaservice.protos.dota_gcmessages_common_bot_script_pb2 import CMsgBotWorldState from dotaservice.protos.DotaService_pb2 import Action from dotaservice.protos.DotaService_pb2 import Empty from dotaservice.protos.DotaService_pb2 import Config from dotaservice.protos.DotaService_pb2 import HostMode from dotaservice.protos.dota_gcmessages_common_bot_script_pb2 import CMsgBotWorldState async def main(): remote_host = '127.0.0.1' config = Config( ticks_per_observation=10, host_timescale=10, host_mode=HostMode.Value('DEDICATED'), ) loop = asyncio.get_event_loop() channel = Channel(remote_host, 13337, loop=loop) env = DotaServiceStub(channel) state = await asyncio.wait_for(env.reset(config), timeout=60) time.sleep(10) action_pb = CMsgBotWorldState.Action() action_pb.actionType = CMsgBotWorldState.Action.Type.Value( 'DOTA_UNIT_ORDER_NONE') for i in range(5): await asyncio.sleep(i) state = await asyncio.wait_for(env.step(Action(action=action_pb)), timeout=60) world_state = state.world_state print(world_state.dota_time, world_state.game_time) channel.close() asyncio.run(main()) the output is -89.5666732788086 31.5665283203125 -89.23334503173828 31.899856567382812 -88.90001678466797 32.233184814453125 -88.56668853759766 32.56651306152344 -88.23336029052734 32.89984130859375 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#13 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AHXSRNTaYMfJ_9tMHujjXxqycieiax5Uks5u5dy8gaJpZM4ZUp1y .

I am not focus on if it is perfectly constant.
I found that no mater how much time i sleep before calling first step().
the dota time is always -89.5666732788086.
so i don't need a 'pause' at all?

from dotaservice.

lenLRX avatar lenLRX commented on September 24, 2024

it is hard to pause the game. but i think my problem solved. now the start time is about 9s.
i found that i must call DotaServiceStub.clear before reset.

from dotaservice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.