Skip to main content

Kymnasium

Kymnasium은 강원대학교 컴퓨터공학과 인공지능 수업에서 강화학습 에이전트를 구현하고 평가하기 위한 Gymnasium 환경 모음입니다. 아래 문서는 같은 환경의 난이도, 스테이지, 조작 방식 차이를 한곳에서 설명합니다.

환경 안내

환경 문서 목표 기본 행동 공간
알까기 흑과 백이 번갈아 돌을 튕겨 상대 돌을 모두 판 밖으로 밀어냅니다. 차례·돌 번호·세기·각도의 Dict
AvoidBlurp 수직 낙하 또는 포물선으로 날아오는 물고기를 피해 생존합니다. Discrete(6) 또는 연속 2축
BulletBill 발판, 밟기, 무적 별을 이용해 탄환을 피해 생존합니다. Discrete(6) 또는 연속 2축
Frogger 죽으면 출발점에서 재도전해 목표 수만큼 개구리를 서로 다른 연잎에 보냅니다. 기본 목표는 세 마리입니다. Discrete(5)
GridWorld 격자에서 열쇠와 문을 다루고 위험을 피해 목표 칸에 도달합니다. Discrete(7)
ProceduralMario 생성된 횡스크롤 코스를 통과해 깃대에 도달합니다. Discrete(6) 또는 연속 2축
QWOP 4관절 또는 8관절 선수를 조작해 평지나 허들 코스를 완주합니다. MultiBinary(4/8) 또는 키별 연속 강도
ZeldaAdventure 검을 사용하고 물과 불을 피해 출구 계단에 도달합니다. Discrete(7)

설치

Python 3.12 이상에서 이 저장소의 환경과 데모를 사용하려면 저장소 최상위 폴더에서 실행합니다.

python -m pip install -e .

PyPI 배포판 설치 명령은 python -m pip install --upgrade kymnasium입니다. 이 문서에 나오는 등록 ID와 설정은 현재 저장소 기준입니다.

에피소드 실행

import kymnasium을 하면 환경이 Gymnasium에 등록됩니다. 다음 예시는 GridWorld에서 임의 행동을 선택하고 종료 시 목표까지 남은 거리를 출력합니다. 학습할 때는 env.action_space.sample()을 정책의 출력으로 교체하면 됩니다.

import gymnasium as gym
import kymnasium

with gym.make("kymnasium/GridWorld-Crossing-26x26", render_mode="none") as env:
    env.action_space.seed(42)
    obs, info = env.reset(seed=42)
    while True:
        action = env.action_space.sample()
        obs, reward, terminated, truncated, info = env.step(action)
        if terminated or truncated:
            print(info["steps"], info["distance"])
            break
  • obs_type="default"는 환경별 수치 관측, obs_type="image"는 상태 표시를 제외한 RGB 관측입니다. 알까기의 이미지 관측은 이미지와 차례를 담은 딕셔너리입니다.
  • render_mode="none"은 창 없이 실행합니다. "human"은 플레이 화면을 표시하고, "rgb_array"에서 env.render()는 진행 상태가 표시된 전체 화면을 반환합니다. 이미지 관측은 "none"에서도 사용할 수 있습니다.
  • Frogger와 ProceduralMario는 진행도와 종료 결과에 따라 보상을 줍니다. 다른 여섯 환경의 기본 보상은 항상 0입니다. 성공 판정과 평가 지표는 각 문서의 종료 조건과 info 항목을 참고하세요.
  • 설치한 버전의 ID 목록은 import kymnasium 후 sorted(i for i in gym.registry if i.startswith("kymnasium/"))로 확인할 수 있습니다.

직접 플레이와 에이전트 평가

저장소 최상위에서 원하는 데모를 실행하세요.

환경 실행 명령 조작
알까기 python demo/alkkagi.py 자기 돌을 잡아 발사 방향의 반대로 드래그한 뒤 놓기
AvoidBlurp python demo/avoid_blurp.py 좌우 방향키로 이동, Space로 점프
BulletBill python demo/bullet_bill.py 좌우 방향키로 이동, Space로 점프
Frogger python demo/frogger.py 방향키로 한 칸 이동, Space로 한 스텝 대기
GridWorld python demo/grid_adventure.py 또는 python demo/grid_crossing.py 좌우로 회전, 위로 전진
ProceduralMario python demo/procedural_mario.py 좌우 방향키로 이동, Space로 점프
QWOP python demo/qwop.py 관절 수와 코스를 선택한 뒤 QWOP로 다리, 8관절형은 ASKL로 팔 조작
ZeldaAdventure python demo/zelda_adventure.py 좌우로 회전, 위로 전진, Q로 공격

Esc 또는 창 닫기로 종료합니다. 각 환경 패키지의 ManualPlayWrapper에 등록 ID를 전달하면 다른 난이도나 스테이지로 플레이할 수 있습니다.

from kymnasium.envs.procedural_mario import ManualPlayWrapper

player = ManualPlayWrapper("kymnasium/ProceduralMario-Normal-Discrete-v0")
player.play(max_play=1, seed=42)

에이전트를 파일로 저장하고 다시 평가하려면 kymnasium.Agent를 상속해 act(observation, info), save(path), 클래스 메서드 load(path)를 구현합니다. kymnasium.evaluate(env_id, agent, seed=42)는 플레이 창에서 해당 정책으로 한 에피소드를 실행합니다. 에이전트 인터페이스 · 평가 함수

Metadata

Release files for kymnasium 1.3.0

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.3.0
File Size Uploaded Provenance Actions
kymnasium-1.3.0.tar.gz 10.9 MB Without provenance Details for kymnasium-1.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 21.8 MB

Release files / kymnasium-1.3.0.tar.gz

Download URL kymnasium-1.3.0.tar.gz
Size 10.9 MB
Tags Source
SHA-256 checksum
How to use checksums
6913a393c41e89031e56dbf010b4337f661973a560a53de821963455ba79ade4
BLAKE2b-256 checksum
How to use checksums
3cb7a604942f966e69dcb2e6db2f2a2a04e311148c73ed6d52a36c21897f0106
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.10

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

Download URL kymnasium-1.3.0-py3-none-any.whl
Size 10.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7364c4df6aec29949273dbb974caf0d247e717c5814058834cba98288f390ab9
BLAKE2b-256 checksum
How to use checksums
a8ad9b015076c5ed18a67f79977e6a06fe2d38158fba1f9452e564d4b64bdccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.10

Security for kymnasium 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files No provenance

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