Skip to main content

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.envs.grid_world import ManualPlayWrapper

agent = ManualPlayWrapper(
    env_id='kymnasium/GridWorld-Crossing-26x26',
    bgm=True,
    debug=True
)
agent.play()

Metadata

Release files for kymnasium 1.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kymnasium 1.2.7
File Size Uploaded
kymnasium-1.2.7.tar.gz 5.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for kymnasium 1.2.7
File Interpreter ABI Platform
kymnasium-1.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 11.0 MB

Release files / kymnasium-1.2.7.tar.gz

Download URL kymnasium-1.2.7.tar.gz
Size 5.5 MB
Tags Source
SHA-256 checksum
How to use checksums
f95b10981f3a07d2237ccc8b040f2c29dda36176d4e7f3cc460bc32a63f64e60
BLAKE2b-256 checksum
How to use checksums
aeadae315d325c9899388f1648e7332e98bfeacb0f874897abd821574f84a470
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / kymnasium-1.2.7-py3-none-any.whl

Download URL kymnasium-1.2.7-py3-none-any.whl
Size 5.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c376ee392d8678cd57bdb0fb836be96b28204569f0aacf41cf999ce9fec1eda8
BLAKE2b-256 checksum
How to use checksums
3dd0f3924d6b7655cf46c480e8850bc3b1c5ecb3913ea8572b7091f8ae9de44f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

1.2.7 This release

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

1 release file

1.1.0

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page