Skip to main content

The collection of reinforcement learning environments developed for the Artificial Intelligence course at the Department of Computer Science and Engineering, Kangwon National University.

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 Mario must move left and right to avoid free-falling Blurps.
  • Bullet Bill: An environment where the Mario must jump around to avoid flying Bullet Bills.
  • Grid World: A classic grid-world environment where the agent navigates a maze to reach a goal.
  • Zelda's Adventure: A game where the Link must navigate a maze and fight against enemies to reach a goal.

Getting Started

Installation

pip -U 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/GridWorld-Crossing-26x26", # 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) 
        done = terminated or truncated
        # 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


agent = YourAgent.load(PATH_AGENT)

kym.evaluate(
    env_id='kymnasium/GridWorld-Crossing-26x26',
    agent=agent,
    render_mode='human',
    bgm=True
)

Manual Play

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

from kymnasium.grid_world import ManualPlayWrapper


agent = ManualPlayWrapper(
    env_id='kymnasium/GridWorld-Crossing-26x26',
    bgm=True,
    debug=True
)
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.2.3.tar.gz (5.5 MB view details)

Uploaded Source

Built Distribution

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

kymnasium-1.2.3-py3-none-any.whl (5.5 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kymnasium-1.2.3.tar.gz
  • Upload date:
  • Size: 5.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for kymnasium-1.2.3.tar.gz
Algorithm Hash digest
SHA256 d28679fdd77becbbb44719fe550eaf0e492d8b8ca087e1de237df50854a5f689
MD5 f4bb62201b3d42175faa1390eb38e770
BLAKE2b-256 6eeeea6d3624d1d5f84e8d73abb1636c7073b47009933c3fd734bc0954017e7f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kymnasium-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 5.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for kymnasium-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d4703ba2814d8c2c7e60cefa06517b671791804f5ddd04b55d898db4e3253c50
MD5 402251e774e6f7f60251c51b6ef4ef9b
BLAKE2b-256 3d829710cdba733865c966d8fbdc3a6ee2c1da66ceea283ba61e4f11972093cd

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