Skip to main content

No project description provided

Project description

Gym Environment for SpaRC


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 Gym-Env-SPaRC

Or install from source:

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

Quick Start

To create the Gym Environment:

import gymnasium as gym
import gymnasium_env_for_SPaRC
env = gym.make("env-SPaRC-v1", puzzles=df, render_mode='human', observation='new',traceback=True, max_steps=1000)

Options

Option Default Options Description
puzzles required pd.Dataframe Pandas DataFrame of SPaRC puzzles
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() -> Observation, Info: dict

Resets the Environment, moves to the next puzzle. Returns the Initial Observation and Info.

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

  • Gym-Environment_for_SPaRC/ # Custom environment implementation
    • gymnasium_env_for_SPaRC/ # Core environment logic
      • init.py # Environment initialization
      • gym_env_for_SPaRC.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

gym_env_sparc-0.1.14.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

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

gym_env_sparc-0.1.14-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file gym_env_sparc-0.1.14.tar.gz.

File metadata

  • Download URL: gym_env_sparc-0.1.14.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for gym_env_sparc-0.1.14.tar.gz
Algorithm Hash digest
SHA256 c4a355b682bb9f51b496cb8b0925ca6e59c245e74f738570232013645e4c7b65
MD5 ebfb7f56a6a0e42db521a5ed214f26a5
BLAKE2b-256 018dd11d874754c85e924c3af52a0c2b47f517bbc7ef818a163c474e1171bc8e

See more details on using hashes here.

File details

Details for the file gym_env_sparc-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: gym_env_sparc-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for gym_env_sparc-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 60cbaa84d4d200e042d697de3fef9130b03f591fead50ba2a69b94565e6d3b99
MD5 be697ee3c1490655ec9337ffaf874a4a
BLAKE2b-256 c0f508cd4a036e237227e6a662a7814643dd1faeef75a8a8260b44c04c5c38d3

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