Skip to main content

Gymnasium extension for DarkSouls III

Project description

soulsgym_banner PEP8 Check Documentation Status

SoulsGym is an extension for Gymnasium, the successor of OpenAI's gym toolkit for reinforcement learning environments. It enables training and testing of reinforcement learning algorithms on boss fights from Dark Souls III, Elden Ring and other Souls games. SoulsGym uses the games as simulations that are modified at runtime by reading and writing into the game memory to create gym environments from the games' boss fights.

Requirements

You need to have the latest version of Dark Souls III installed since SoulsGym uses the game as engine for its environments. Dark Souls III, Elden Ring etc. are not available for free and have to be purchased (e.g. at the Steam store). SoulsGym requires the player to load into the game before any environments are created. In addition we require custom key bindings and graphic settings. It is also highly recommended to start the game in offline mode and delete your new save game after gym use to protect you from multiplayer bans.

Warning: Please follow the setup description in our official docs for the correct key settings, ban prevention, loss of game saves etc.

Installation

To install soulsgym, use pip install soulsgym. At this time, we only support Windows. SoulsGym requires a running instance of the game (see requirements) and relies on the win32api. It is therefore not available on other operating systems.

API

SoulsGym's environments follow the gymnasium API as closely as possible. Since our environments are based on the Souls games and Dark Souls III, Elden Ring etc. are nondeterministic, we are, however, not able to provide reproducible results by setting the RNG seeds.

Our internal API for interacting with the game and creating the boss fight environments is located in the core module.

A detailed API documentation of our environments and the core library can be found in the official docs.

Getting Started

You can use SoulsGym like any other gymnasium environment. Below is an example of a random agent fighting against Iudex Gundyr:

import gymnasium
import soulsgym

env = gymnasium.make("SoulsGymIudex-v0")
obs, info = env.reset()
terminated = False

while not terminated:
    action = env.action_space.sample()
    next_obs, reward, terminated, truncated, info = env.step(action)

env.close()

Note: Dark Souls III has to be running with the correct settings when executing the script. See requirements.

Roadmap

This roadmap describes the planned future expansions and possible avenues for contributions. The project is designed to offer an extensive collection of boss fights across Souls games as gymnasium environments. However, as of this moment, only Iudex Gundyr from Dark Souls III is implemented and has been solved with a 45% winrate.

Transitioning to image observations

Using ground truth information such as the exact player position, animation timings etc. drastically reduces the size of the observation space, which in general facilitates fast learning. For this reason, the first soulsgym environment, Iudex Gundyr from Dark Souls III, implements such an observation space. It verifies that it is indeed possible to train RL agents directly within the Souls games and learn a policy with meaningful winrates.

Nevertheless, human players do not have access to this information, but learn to play the game directly from images. In addition, agents that learn to act from rich visual input are more interesting from a research point of view, as they can be trained on much more general tasks. Furthermore, designing the obervation space with ground truth information can be tricky to implement as many boss fights in Dark Souls III, Elden Ring etc. include projectiles such as arrows or spells, ground effects or multiple entities that would need to be tracked. Images as a unified observation space would therefore drastically accelerate the development of new environments.

  • Add improved image capture module
  • Create Iudex Gundyr image observation space environment
  • Train an agent with > 10% winrate

Adding Elden Ring support

Initially, soulsgym was planned as a Dark Souls III RL extension only. However, much of the code such as game interfaces, player controls, window managers, speedhacks etc. are easily portable between the Souls games. In an effort to increase the number of available environments and the scope of the project, a major next step is the addition of an Elden Ring environment to the collection.

  • Refactor repository to support multiple Souls games
  • Add Elden Ring game interface
  • Implement 'Margit, The Fell Omen' as gymnasium environment

Increasing the number of environments

This one goes without saying. Having more bosses implemented is just better. There is not much focus on this though as long as we are transitioning to image observations, since the change of observation space also impacts how the environments have to be implemented.

Documentation

For details on the soulsgym package see our official docs.

Contributing

If you'd like to contribute, feel free to reach out to me. In addition, have a look at the roadmap, the documentation and try to understand how the gym works.

Implementing new bosses is probably the easiest way to contribute, and should be fairly self-contained. If you'd like to include other Souls games such as Dark Souls I or II, definitely reach out first so that we can coordinate our efforts.

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

soulsgym-1.1.0.tar.gz (161.9 kB view details)

Uploaded Source

Built Distribution

soulsgym-1.1.0-py3-none-any.whl (173.7 kB view details)

Uploaded Python 3

File details

Details for the file soulsgym-1.1.0.tar.gz.

File metadata

  • Download URL: soulsgym-1.1.0.tar.gz
  • Upload date:
  • Size: 161.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for soulsgym-1.1.0.tar.gz
Algorithm Hash digest
SHA256 15a1407158ed2d99cb8d79f6151d5003b492f430edb8ec4248c6ce893bd8defb
MD5 dc0ac8aeb046faef522aa749250e57dc
BLAKE2b-256 d88eaa3279554db8fa288325beefccd97f03c28020c41a939177a1fe3944a809

See more details on using hashes here.

File details

Details for the file soulsgym-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: soulsgym-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 173.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for soulsgym-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9737ce137ff991736523ef3c7a588a13f2f6236ff7eb5439a93135f637a3e525
MD5 aba88e6ad2d4d8335ba1dd06cc02ddcb
BLAKE2b-256 e0c5bfaaf4e12f1bdf7d52836059776d69e14d8bfb1bda6d90a46ae5f0b6a98a

See more details on using hashes here.

Supported by

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