Skip to main content

A Dark Souls: Remastered API for AI research

Project description

Dark Souls: Remastered API

A Dark Souls: Remastered Python API, enabling the development of real-time AI agents.

About

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.

Features

  • Ability to simulate various boss scenarios
  • Real-time game screen capture for visual input
  • Easy framework for training artificial intelligence agents

Requirements

  • Operating System: Windows only (due to win32api dependency)
  • Python: 3.12 or higher
  • Game: Dark Souls: Remastered must be installed already

Installation

Install from PyPI:

pip install darksoulsapi

Usage

1. Configure Game Settings

Before 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

Note: Custom key bindings help prevent mouse input issues.

2. Obtain Game Paths

The API requires two main paths:

  1. Game Directory: Path to your Dark Souls: Remastered installation

    Example: "C:/Program Files (x86)/Steam/steamapps/common/DARK SOULS REMASTERED/"
    
  2. Save Directory: Path to your Dark Souls save files

    Example: "C:/Users/username/Documents/NBGI/Dark Souls Remastered/1638/"
    

3. Basic usage (more examples in /examples folder)

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")

Testing

  • 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)

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

darksoulsapi-0.0.1.tar.gz (47.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

darksoulsapi-0.0.1-py3-none-any.whl (48.1 MB view details)

Uploaded Python 3

File details

Details for the file darksoulsapi-0.0.1.tar.gz.

File metadata

  • Download URL: darksoulsapi-0.0.1.tar.gz
  • Upload date:
  • Size: 47.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for darksoulsapi-0.0.1.tar.gz
Algorithm Hash digest
SHA256 77fb715e34980ff3da5e5e797c692c6e736a72c6fd103f1e43a94d80daf03474
MD5 cadffd0c4b350b1996cc0c3675101a93
BLAKE2b-256 022f2a91786d25c1fade2995174ff1ca7b13771923312a4839d12d7acef86db1

See more details on using hashes here.

File details

Details for the file darksoulsapi-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: darksoulsapi-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 48.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for darksoulsapi-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e3290eb39644b6921fb0ecea78cc4cb7355aeeffcc60533b0a3fe7a1622d9f52
MD5 1010b795d6f49619e7c95aa2e7e4dfa9
BLAKE2b-256 ca265b6bff28d6c6489768b96cddfabf7eb18f6c28198fbf9b5828a6210fa52e

See more details on using hashes here.

Supported by

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