A Dark Souls: Remastered Python API, enabling the development of real-time AI agents.
This repository provides an API for Dark Souls: Remastered, enabling the development of AI agents to interact with and play the game. The API handles game state detection, action execution, and provides a simple interface for training agents. Currently, the API exists to simulate boss fight scenarios.
- Ability to simulate various boss scenarios
- Real-time game screen capture for visual input
- Easy framework for training artificial intelligence agents
- Operating System: Windows only (due to
win32apidependency) - Python: 3.12 or higher
- Game: Dark Souls: Remastered must be installed already
Install from PyPI:
pip install darksoulsapiBefore using the API, configure Dark Souls: Remastered with these settings:
- Resolution: Set to 800x600, windowed mode
- Key Bindings: Update the following in Key Settings:
- "Right weapon action (attack)" →
t - "Right weapon action (Strong Attack)" →
Shift + t - "Left weapon action (block)" →
y - "Left weapon action (parry)" →
Shift + y
- "Right weapon action (attack)" →
Note: Custom key bindings help prevent mouse input issues.
The API requires two main paths:
-
Game Directory: Path to your Dark Souls: Remastered installation
Example: "C:/Program Files (x86)/Steam/steamapps/common/DARK SOULS REMASTERED/" -
Save Directory: Path to your Dark Souls save files
Example: "C:/Users/username/Documents/NBGI/Dark Souls Remastered/1638/"
import darksoulsapi
import random
import time
# Create game environment with your paths
env = darksoulsapi.create_game_state(
game_directory="C:/Program Files (x86)/Steam/steamapps/common/DARK SOULS REMASTERED/",
save_directory="C:/Users/username/Documents/NBGI/DARK SOULS REMASTERED/1638/"
)
# Reset the game state and obtain pixel input
pixel_input = env.reset()
# Main game loop
terminated = False
while not terminated:
# Choose a random action from the action space
action_key, action_value = random.choice(list(env.action_space.items()))
print("Performing", action_key)
# Execute action and get new state
pixel_input, terminated = env.step(action_value)
# Pause to allow action to be followed through
time.sleep(1.0)
print("Game Session Terminated")- Run the tests to make sure that the environment is set up correctly and working.
- Tests for game screen being obtained properly (run
show_visual_feed.py)
- Tests for game screen being obtained properly (run
