Package: gym-csgo
gym-csgoCounter-Strike: Global Offensive environment for OpenAI Gym on Linux:bangbang:Never use this connecting to official/online game servers! Never cheat! Itmightget you banned.:bangbang:Consider creating a separate throwaway steam account for experimenting with this environment.PrerequisitesTo 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 likeXvfborXephyr,
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 thePropertiesof Counter-Strike: Global Offensive navigate toCompatibilityand checkForce the use of a specific Steam Play
compatibility tooland selectProton 5.13-6(others might work but are not
tested) from the drop-down menu below.As of 1 October 2021Proton 6.3-6is longer available in the steam
client. Using6.3-7the game keeps crashing just after startup, thus5.13-6seems to be the best option for now.With the recent addition ofexperimental Vulkan
support, it might
actually be possible to run the native Linux version of Counter-Strike with
sufficient performance. Please try this by adding-vulkanto 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 -nojoyGame State IntegrationCounter-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
integrationconfiguration filefrom
thecfgdirectory of the repository into thecfgdirectory 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 theValve Developer
Community.Virtual DisplayThe 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 onUbuntu:sudo apt install xvfb xserver-xephyrInstallationNote: This package is still in early stages of development, installing might
miss dependencies or does not work at all.pip install --upgrade gym-csgoBasic UsageRunning aDeathmatch(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(...))importgym_csgo# Gym environmentsimportgym# Open new environment context (automatically closes env at end of scope)withgym.make('csgo_dm-v0')asenv:# Reset the environmentenv.reset()# Env is not done yetdone=False# Until the environment is donewhilenotdone:# Get random action from environmentaction=env.action_space.sample()# Execute the random action and collect observationobs,rew,done,info=env.step(action)Demo ActorsPrograms showing demo actors in the environment are provided in thegym_csgo.demosubpackage. There arerandomandnoopactors 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 1A special case is themanualactor 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