Skip to main content

No project description provided

Project description

KNU Gymnasium, or Kymnasium for Reinforcement Learning Environments

Welcome to Kymnasium! This project is a collection of reinforcement learning environments developed for the Artificial Intelligence course at the Department of Computer Science and Engineering, Kangwon National University.

About the Project

Kymnasium provides a simple and effective platform for students to learn, implement, and test reinforcement learning algorithms. The environments are designed to be straightforward, allowing you to focus on the core concepts of RL. This project is inspired by Gymnasium.

Environments

  • Alkkagi: A Korean traditional game where the objective is to flick your stones to knock the opponent's stones off the board.
  • Avoid Blurp: An environment where the agent must learn to avoid free-fall enemies.
  • Grid Adventure: A classic grid-world environment where the agent navigates a maze to reach a goal.
  • Grid Survivor: A grid-world environment where the agent must survive for as long as possible.

Getting Started

Installation

pip install kymnasium

Implement Your Agent

To train your own agent, you need to override 'kymnasium.Agent' and implement three methods as below:

import kymnasium as kym

# Your agent logic goes here
class YourAgent(kym.Agent): 
    def act(self, observation: any, info: dict):
        # Replace this with your agent's action selection logic return env.action_space.sample()
        pass
    
    @classmethod
    def load(cls, path: str) -> 'kym.Agent':
        # Load a pre-trained agent
        pass
    
    def save(self, path: str):
        # Save the trained agent
        pass

Basic Training loop

import gymnasium as gym


# Train the agent for 100 episodes
EPISODES = 100

# Path for saving your agent
PATH_AGENT = './agent.pkl'
agent = YourAgent()

# Create the environment
env = gym.make(
    id="kymnasium/GridAdventure-FullMaze-26x26-v0", # Environment ID
    render_mode='rgb_array', # or 'human',
    obs_type='custom', # or 'image'
    bgm=False # or True for playing background music
)
for _ in range(EPISODES):
    observation, info = env.reset()
    done = False
    while not done: 
        action = agent.act(observation, info) 
        observation, reward, terminated, truncated, info = env.step(action) 
        if terminated or truncated: 
            done = True
        # Here writes any training logic

# Close the environment        
env.close()

# Save your agent
agent.save(PATH_AGENT)

Live Evaluation of Your Agent

import kymnasium as kym


evaluator = kym.LocalEvaluator(
    env_id="kymnasium/GridAdventure-FullMaze-26x26-v0", # Environment ID
    agent=YourAgent.load(PATH_AGENT), # Your trained agent
    render_mode='human', # 'render_mode' should be 'human' for live evaluation
    obs_type='custom', # or 'image'
    bgm=True #  'bgm' should be 'True' for live evaluation
)

evaluator.evaluate()

Manual Play

If you want to manually play the environment, see below:

from kymnasium.grid_adventure import ManualPlayWrapper


agent = ManualPlayWrapper(
    env_id='kymnasium/GridAdventure-FullMaze-26x26-v0',
    render_mode='human', #'render_mode' should be 'human' for manual play
)
agent.play()

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

kymnasium-1.0.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

kymnasium-1.0.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file kymnasium-1.0.0.tar.gz.

File metadata

  • Download URL: kymnasium-1.0.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for kymnasium-1.0.0.tar.gz
Algorithm Hash digest
SHA256 676e4b9222da81e11dd3f9e6289c1882199a8f6e4e9bf0e3e93bc9dc6beb67b3
MD5 ed242370114eb023692ae5fb1593324e
BLAKE2b-256 b24109b500f3cc8f207ee22daa97c2bf597bd0412d48ab0c43206286d489e35e

See more details on using hashes here.

File details

Details for the file kymnasium-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kymnasium-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for kymnasium-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f0dc3d4960c0a1c7646a3063fcbafef0e10369c19a77ab2355134c1d4f46815
MD5 a1e9405b08c9a3bde376dca4d9747e27
BLAKE2b-256 5998639295ce889a12720fce5c9adfea8fdd267ac0a7e5cb56b7552e83d3d342

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