Skip to main content

gym-csgo

Counter-Strike: Global Offensive environment for OpenAI Gym on Linux

:bangbang: Never use this connecting to official/online game servers! Never cheat! It might get you banned.

:bangbang: Consider creating a separate throwaway steam account for experimenting with this environment.

Prerequisites

To use the gym environment, steam for Linux with Counter-Strike: Global Offensive installed needs to be available.

As the native (Linux, using OpenGL) version of Counter-Strike: Global Offensive does not get hardware acceleration in virtual X servers like Xvfb or Xephyr, it is necessary to run the game in compatibility mode, to get reasonable performance (frames per second) in the gym environment: Using the steam client, in the Properties of Counter-Strike: Global Offensive navigate to Compatibility and check Force the use of a specific Steam Play compatibility tool and select Proton 5.13-6 (others might work but are not tested) from the drop-down menu below.

As of 1 October 2021 Proton 6.3-6 is longer available in the steam client. Using 6.3-7 the game keeps crashing just after startup, thus 5.13-6 seems to be the best option for now.

With the recent addition of experimental Vulkan support, it might actually be possible to run the native Linux version of Counter-Strike with sufficient performance. Please try this by adding -vulkan to your command line.

It should be possible to launch Counter-Strike: Global Offensive (App ID 730) from the terminal (this might take some time, especially the first start after updating or setting the compatibility):

steam -applaunch 730 -insecure -untrusted -novid -nojoy

Game State Integration

Counter-Strike: Global Offensive Game State Integration is necessary to communicate information about the current game state to the python interface. This needs to be set up in the game configurations: Copy the game state integration configuration file from the cfg directory of the repository into the cfg directory of the Counter-Strike: Global Offensive installation.

To find out more about the Counter-Strike: Global Offensive Game State Integration and its configuration look at the Valve Developer Community.

Virtual Display

The gym environment executes the game on a virtual X server display, either inside a window on the pre-existing X display (Xephyr) or invisible in the background (Xvfb). To install the required packages on Ubuntu:

sudo apt install xvfb xserver-xephyr

Installation

Note: This package is still in early stages of development, installing might miss dependencies or does not work at all.

pip install --upgrade gym-csgo

Basic Usage

Running a Deathmatch (game mode) environment with default configuration and random actions per step until it is done (the match is done after 10 minutes):

# gym_csgo registers the envs (to gym.make(...))
import gym_csgo
# Gym environments
import gym

# Open new environment context (automatically closes env at end of scope)
with gym.make('csgo_dm-v0') as env:
    # Reset the environment
    env.reset()
    # Env is not done yet
    done = False
    # Until the environment is done
    while not done:
        # Get random action from environment
        action = env.action_space.sample()
        # Execute the random action and collect observation
        obs, rew, done, info = env.step(action)

Demo Actors

Programs showing demo actors in the environment are provided in the gym_csgo.demo subpackage. There are random and noop actors which sample random actions from the environment's action space or do no action at all: These might be useful for testing the environment in general (esp. functionality, startup, graphics, etc.) or experiment with configuration options which can passed to the game. Start a random actor playing a deathmatch and show the frames per second to evaluate the performance:

python -m gym_csgo.demo.random csgo_dm-v0 de_dust2 +cl_showfps 1

A special case is the manual actor which allows to actually play the game through a pygame display interacting with the gym environment which itself wraps the game on the virtual display. This is merely a technical demonstration but might as well be suited as a starting point for collecting human demonstration data. Play a game of casual game mode on the map train (the pygame actor will be available once the match starts after the warmup period):

python -m gym_csgo.demo.manual csgo_casual-v0 de_train

Metadata

Release files for gym-csgo 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gym-csgo 0.0.4
File Size Uploaded Provenance Actions
gym-csgo-0.0.4.tar.gz 22.0 kB Without provenance Details for gym-csgo-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gym-csgo 0.0.4
File Interpreter ABI Platform Actions
gym_csgo-0.0.4-py3-none-any.whl Python 3 none any Details for gym_csgo-0.0.4-py3-none-any.whl

Total release size: 49.7 kB

Release files / gym-csgo-0.0.4.tar.gz

Download URL gym-csgo-0.0.4.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b862fe978d53f370b8401cf18183ec38e96c22f1d453e256c5c15e8c9c51cd7c
BLAKE2b-256 checksum
How to use checksums
62054c78a67591e314d465ac365abadf3dd66a9667f52a173d258cb4e441f832
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / gym_csgo-0.0.4-py3-none-any.whl

Download URL gym_csgo-0.0.4-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71d35b91b425f2ab6426217ac06fab9d7df483a0b43ad3550b7c081876ab787b
BLAKE2b-256 checksum
How to use checksums
ab0b0221c57c770eb543a2460fdbf6aca0643d8a19eb0c254436d9aa49543c14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Security for gym-csgo 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page