Skip to main content

DotaService is a service to play Dota 2 through gRPC

Project description

DotaService

dotaservice icon

NOTE: The project that uses the dotaservice in a k8s environment is the DotaClient repo.

DotaService is a service to play Dota 2 through gRPC. There are first class python bindings and examples, so you can play dota as you would use the OpenAI gym API.

It's fully functional and super lightweight. Starting Dota obs = env.reset() takes 5 seconds, and each obs = env.step(action) in the environment takes between 10 and 30 ms.

You can even set the config of render=True and you can watch the game play live. Each game will have a uuid and folder associated where there's a Dota demo (replay) and console logs.

demo

Run DotaService Locally

Run the DotaService so you can connect your client to it later. Only one client per server is supported, and only one DotaService per VM (eg local or one per docker container).

python3 -m dotaservice
>>> Serving on 127.0.0.1:13337

Run DotaService Distributed

See docker/README.md.

To run two dockerservice instances, one on port 13337 and one on 13338, f.e. run:

docker run -dp 13337:13337 ds
docker run -dp 13338:13337 ds

You can run as many as you want, until you run out of ports or ip addresses. If you are wearing your fancy pants, use Kubernetes to deploy gazillions.

Client Code

from grpclib.client import Channel
from protobuf.DotaService_grpc import DotaServiceStub
from protobuf.DotaService_pb2 import Action
from protobuf.DotaService_pb2 import Config

# Connect to the DotaService.
env = DotaServiceStub(Channel('127.0.0.1', 13337))

# Get the initial observation.
observation = await env.reset(Config())
for i in range(8):
    # Sample an action from the action protobuf
    action = Action.MoveToLocation(x=.., y=.., z=..)
    # Take an action, returning the resulting observation.
    observation = await env.step(action)

This is very useful to provide an environment for reinforcement learning, and service aspect of it makes it especially useful for distributed training. I am planning to provide a client python module for this (PyDota) that mimics typical OpenAI gym APIs. Maybe I won't even make PyDota and the gRPC client is enough.

dotaservice connections

Requirements

  • Python 3.7
  • Unix: MacOS, Ubuntu. A dockerfile is also provided see: docker/README.md.

Installation

Installing from pypi:

pip3 install dotaservice

For development; installing from source:

pip3 install -e .

(Optional) Compile the protos for Python (run from repository root):

python3 -m grpc_tools.protoc -I. --python_out=. --python_grpc_out=. --grpc_python_out=. dotaservice/protos/*.proto

Notes

My dev notes: NOTES.md.


Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dotaservice-0.3.9.tar.gz (71.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dotaservice-0.3.9-py3-none-any.whl (75.5 kB view details)

Uploaded Python 3

File details

Details for the file dotaservice-0.3.9.tar.gz.

File metadata

  • Download URL: dotaservice-0.3.9.tar.gz
  • Upload date:
  • Size: 71.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for dotaservice-0.3.9.tar.gz
Algorithm Hash digest
SHA256 aef9c17ca9d069dcdba9f33f83abb6fe76cbabc91604071e9c8a7b3f81243c32
MD5 b3cb03d24bf342ac318ad0eff0b6f265
BLAKE2b-256 8e696de5b245aef4dcbdfd69541d07fec6283985ab3723c9c5a03bc13c2d7203

See more details on using hashes here.

File details

Details for the file dotaservice-0.3.9-py3-none-any.whl.

File metadata

  • Download URL: dotaservice-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 75.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.2

File hashes

Hashes for dotaservice-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2c44794ee11e00f5e4e48d4e9b7d5791eb7811fdbc68c5cb23e72ddea9cd5a5b
MD5 8e74465732e8ea782e46db24ecd9aba6
BLAKE2b-256 791923ddb41bf9457766d52729374993dc6cadf4bb055a3d4fce35bd9007ba56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page