Skip to main content

No project description provided

Project description

SPaRC-Gym


Description

A custom Gymnasium environment for SPaRC. The Game and Dataset was develop by: https://sparc.gipplab.org/ . This project allows LLM agents and humans to interact/play the puzzles used in SPaRC. For how the puzzles work also look up https://sparc.gipplab.org/ .

Installation

📦 PyPI Package

Install the package from PyPI:

pip install SPaRC-Gym

Or install from source:

git clone https://github.com/tobiTKM/SPaRC-Gym.git
cd SPaRC-Gym
pip install -e .

Quick Start

To create the Gym Environment:

import gymnasium as gym
import SPaRC_Gym
env = gym.make("SPaRc-Gym", df_name='lkaesberg/SPaRC', df_split='all', df_set='test', render_mode='human', observation='new',traceback=True, max_steps=1000)

Options

The Options df_name='lkaesberg/SPaRC', df_split='all', df_set='test' define which Dataset and splits will be used, any Dataset of the Structure 'lkaesberg/SPaRC' is viable.

Option Default Options Description
render_mode None 'human', 'llm', or None Which Visualization to use
observation 'new' 'new' or 'SPaRC' Which Observation type to use
traceback False False or True Allow the agent to backtrack
max_steps 2000 any int Maximum steps per episode

Core Functions

env.reset(options{'puzzle_id': id}: 'String') -> Observation, Info: dict

Resets the Environment, moves to the next puzzle. Returns the Initial Observation and Info. Can pass the Option to load a specific Puzzle with puzzle_id.

env.step(action: int(0-3)) -> observation, reward: int, terminated: bool, truncated: bool, info: dict

Moves the Environment one Step based on the Action. Returns the new Observation, Info, Reward and if the puzzle is finished.

env.render()

Visualizes the Puzzle's current State

env.close()

Close the environment and cleanup any resources.

Environment Details

Action Space

  • Discrete(4): Represents the four possible moves:
    • 0: Right
    • 1: Up
    • 2: Left
    • 3: Down

Observation Space

if Observation = 'new':

  • Dict A Dictionary of:
    • base: Dict: A dictionary of 2D arrays representing the puzzle state:
      • "visited": Tracks visited cells.
      • "gaps": Represents gaps in the grid.
      • "agent_location": Current position of the agent.
      • "target_location": Goal position.
      • Additional keys for unique properties like "stars", "triangles", etc.
      • The 2D Arrays are of the shape of the puzzle and are One-hot Encoded
    • color: list: A 2D Array representing the colors of the properties.
      • 8 possible colors are represented with 1-8
      • 2D Array is of shape of the puzzle
    • additional_info: list A 2D Array with additional Info about the puzzle
      • 2D Array is of shape of the puzzle
      • Possible additional_info:
      • ID of the polyshape
      • Count of the Triangles

if Observation = 'SPaRC':

  • Json String Same Representation as in SPaRC https://github.com/lkaesberg/SPaRC . Json String Representation of a 2D array of the grid capturing all different properties as Symbols (Strings).

Reward System

  • Sparse Rewards:
    • +1: For solving the puzzle.
    • -1: For Failing.
    • +0.01: For staying on a solution path on each step.

Folder Structure

  • SPaRC-Gym/ # Custom environment implementation
    • SPaRC_Gym/ # Core environment logic
      • init.py # Environment initialization
      • SPaRC_Gym.py # Core environment logic
      • register_env.py # Environment registration
    • llm_testing/
      • llm_host.py # Example script for using the gym with a llm
      • parse_logs.py # Script to filter out the results of the created logfiles from llm_host.py
    • Final_Product.py # Main script for human interaction
    • human_play.py # Helper Function for human play
    • pyproject.toml
    • LICENCE
    • README.md

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues.

LICENSE

This project is licensed under the MIT License - see the LICENCE file for details.


Acknowlegdments

Special thanks to Lars Benedikt Kaesberg (l.kaesberg@uni-goettingen.de) and Jan Philip Wahle for giving me the opportunity to do this Project aswell as supervising the Project.

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

sparc_gym-0.2.7.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

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

sparc_gym-0.2.7-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file sparc_gym-0.2.7.tar.gz.

File metadata

  • Download URL: sparc_gym-0.2.7.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for sparc_gym-0.2.7.tar.gz
Algorithm Hash digest
SHA256 1846e7cd293a4ddd9039fc5e1460d831763495925ae5eda614128b02ca5d24ad
MD5 20f72e885ba17a9430cb9337bbb1ab71
BLAKE2b-256 fb270fde171238d0b903200dc7b182b068fcd198ca0dfab0ea4242d91ce33a07

See more details on using hashes here.

File details

Details for the file sparc_gym-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: sparc_gym-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for sparc_gym-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7003e92f837ce0450ff1ae2232c95d5bba02146273bee7115cac8de2bdab5cf6
MD5 885d25e30b405d182416003f2ab55afe
BLAKE2b-256 529f911365cbc1d38461f9eecb2e9e769d3f8fd0f67abd57b250ccee0ffa8c2e

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