soulsgym


Namesoulsgym JSON
Version 1.1.0 PyPI version JSON
download
home_page
SummaryGymnasium extension for DarkSouls III
upload_time2023-12-06 11:02:48
maintainer
docs_urlNone
author
requires_python>=3.11.2
licenseCopyright 2022 Martin Schuck Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords gym reinforcement learning dark souls
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![soulsgym_banner](https://raw.githubusercontent.com/amacati/SoulsGym/master/docs/img/soulsgym_banner.png)
[![PEP8 Check](https://github.com/amacati/SoulsGym/actions/workflows/github-actions.yaml/badge.svg)](https://github.com/amacati/SoulsGym/actions/workflows/github-actions.yaml)   [![Documentation Status](https://readthedocs.org/projects/soulsgym/badge/?version=latest)](https://soulsgym.readthedocs.io/en/latest/?badge=latest)

SoulsGym is an extension for [Gymnasium](https://github.com/Farama-Foundation/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](#requirements)
- [Installation](#installation)
- [API](#api)
- [Getting Started](#getting-started)
- [Roadmap](#roadmap)
- [Documentation](#documentation)
- [Contributing](#contributing)

## 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](https://store.steampowered.com/)). 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](https://soulsgym.readthedocs.io/en/latest/index.html) 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](#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`](soulsgym/core/) module. 

A detailed API documentation of our environments and the core library can be found in the [official docs](https://soulsgym.readthedocs.io/en/latest/index.html).

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

```python
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](#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.

- [x] Add improved image capture module
- [x] 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.

- [x] Refactor repository to support multiple Souls games
- [x] 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](https://soulsgym.readthedocs.io/en/latest/index.html).

## 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.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "soulsgym",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11.2",
    "maintainer_email": "",
    "keywords": "gym,reinforcement learning,dark souls",
    "author": "",
    "author_email": "Martin Schuck <real.amacati@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d8/8e/aa3279554db8fa288325beefccd97f03c28020c41a939177a1fe3944a809/soulsgym-1.1.0.tar.gz",
    "platform": null,
    "description": "![soulsgym_banner](https://raw.githubusercontent.com/amacati/SoulsGym/master/docs/img/soulsgym_banner.png)\r\n[![PEP8 Check](https://github.com/amacati/SoulsGym/actions/workflows/github-actions.yaml/badge.svg)](https://github.com/amacati/SoulsGym/actions/workflows/github-actions.yaml)   [![Documentation Status](https://readthedocs.org/projects/soulsgym/badge/?version=latest)](https://soulsgym.readthedocs.io/en/latest/?badge=latest)\r\n\r\nSoulsGym is an extension for [Gymnasium](https://github.com/Farama-Foundation/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.\r\nSoulsGym 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.\r\n\r\n- [Requirements](#requirements)\r\n- [Installation](#installation)\r\n- [API](#api)\r\n- [Getting Started](#getting-started)\r\n- [Roadmap](#roadmap)\r\n- [Documentation](#documentation)\r\n- [Contributing](#contributing)\r\n\r\n## Requirements\r\nYou 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](https://store.steampowered.com/)). 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.\r\n\r\n> **Warning:** Please follow the setup description in our [official docs](https://soulsgym.readthedocs.io/en/latest/index.html) for the correct key settings, ban prevention, loss of game saves etc.\r\n\r\n## Installation\r\nTo install soulsgym, use `pip install soulsgym`. At this time, we only support Windows. SoulsGym requires a running instance of the game (see [requirements](#requirements)) and relies on the win32api. It is therefore not available on other operating systems.\r\n\r\n## API\r\nSoulsGym'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.\r\n\r\nOur internal API for interacting with the game and creating the boss fight environments is located in the [`core`](soulsgym/core/) module. \r\n\r\nA detailed API documentation of our environments and the core library can be found in the [official docs](https://soulsgym.readthedocs.io/en/latest/index.html).\r\n\r\n## Getting Started\r\nYou can use SoulsGym like any other `gymnasium` environment. Below is an example of a random agent fighting against Iudex Gundyr:\r\n\r\n```python\r\nimport gymnasium\r\nimport soulsgym\r\n\r\nenv = gymnasium.make(\"SoulsGymIudex-v0\")\r\nobs, info = env.reset()\r\nterminated = False\r\n\r\nwhile not terminated:\r\n    action = env.action_space.sample()\r\n    next_obs, reward, terminated, truncated, info = env.step(action)\r\n\r\nenv.close()\r\n```\r\n> **Note:** Dark Souls III has to be running with the correct settings when executing the script. See [requirements](#requirements).\r\n\r\n## Roadmap\r\nThis 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.\r\n\r\n### Transitioning to image observations\r\nUsing 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.\r\n\r\nNevertheless, 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.\r\n\r\n- [x] Add improved image capture module\r\n- [x] Create Iudex Gundyr image observation space environment\r\n- [ ] Train an agent with > 10% winrate\r\n\r\n### Adding Elden Ring support\r\nInitially, `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.\r\n\r\n- [x] Refactor repository to support multiple Souls games\r\n- [x] Add Elden Ring game interface\r\n- [ ] Implement 'Margit, The Fell Omen' as gymnasium environment\r\n\r\n### Increasing the number of environments\r\nThis 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.\r\n\r\n## Documentation\r\nFor details on the `soulsgym` package see our [official docs](https://soulsgym.readthedocs.io/en/latest/index.html).\r\n\r\n## Contributing\r\nIf 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.  \r\n\r\nImplementing 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.\r\n",
    "bugtrack_url": null,
    "license": "Copyright 2022 Martin Schuck  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "Gymnasium extension for DarkSouls III",
    "version": "1.1.0",
    "project_urls": {
        "Documentation": "https://soulsgym.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/amacati/SoulsGym",
        "Repository": "https://github.com/amacati/SoulsGym"
    },
    "split_keywords": [
        "gym",
        "reinforcement learning",
        "dark souls"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e0c5bfaaf4e12f1bdf7d52836059776d69e14d8bfb1bda6d90a46ae5f0b6a98a",
                "md5": "aba88e6ad2d4d8335ba1dd06cc02ddcb",
                "sha256": "9737ce137ff991736523ef3c7a588a13f2f6236ff7eb5439a93135f637a3e525"
            },
            "downloads": -1,
            "filename": "soulsgym-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aba88e6ad2d4d8335ba1dd06cc02ddcb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11.2",
            "size": 173742,
            "upload_time": "2023-12-06T11:02:45",
            "upload_time_iso_8601": "2023-12-06T11:02:45.537207Z",
            "url": "https://files.pythonhosted.org/packages/e0/c5/bfaaf4e12f1bdf7d52836059776d69e14d8bfb1bda6d90a46ae5f0b6a98a/soulsgym-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d88eaa3279554db8fa288325beefccd97f03c28020c41a939177a1fe3944a809",
                "md5": "dc0ac8aeb046faef522aa749250e57dc",
                "sha256": "15a1407158ed2d99cb8d79f6151d5003b492f430edb8ec4248c6ce893bd8defb"
            },
            "downloads": -1,
            "filename": "soulsgym-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "dc0ac8aeb046faef522aa749250e57dc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11.2",
            "size": 161857,
            "upload_time": "2023-12-06T11:02:48",
            "upload_time_iso_8601": "2023-12-06T11:02:48.596382Z",
            "url": "https://files.pythonhosted.org/packages/d8/8e/aa3279554db8fa288325beefccd97f03c28020c41a939177a1fe3944a809/soulsgym-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-06 11:02:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "amacati",
    "github_project": "SoulsGym",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "soulsgym"
}
        
Elapsed time: 0.18046s