Skip to content

🎲 Woodoku-based reinforcement learning environment using Gymnasium

License

Notifications You must be signed in to change notification settings

helpingstar/gym-woodoku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to gym-woodoku!

rl-video-episode-21.mp4

Installation

git clone https://github.com/helpingstar/gym-woodoku.git
cd gym-woodoku
pip install -e .

Usage

import gym_woodoku
import gymnasium as gym

env = gym.make('gym_woodoku/Woodoku-v0', game_mode='woodoku', render_mode='human')
# env = gym.wrappers.RecordVideo(env, video_folder='./video_folder')

observation, info = env.reset()
for i in range(100000):
    action = env.action_space.sample()
    obs, reward, terminated, _, info = env.step(action)
    if terminated:
        env.reset()
env.close()

Observation

Dict({
  "board": Box(low=0, high=1, shape=(9, 9), dtype=np.int8),
  "block_1": Box(low=0, high=1, shape=(5, 5), dtype=np.int8),
  "block_2": Box(low=0, high=1, shape=(5, 5), dtype=np.int8),
  "block_3": Box(low=0, high=1, shape=(5, 5), dtype=np.int8),
})

Location of Blocks in Array :

Wrap the block in a rectangle.

  • If side length is odd : len(side) // 2
  • If side length is even : len(side) // 2 - 1

Each point is placed at the index (2,2) of the size array (5,5). (zero based)

example)

action

action_space : Discrete(243)

  • 0~80 : use block_1
    • Place block_1 at ((action-0) // 9, (action-0) % 9)
  • 81~161 : use block_2
    • Place block_2 at ((action-81) // 9, (action-81) % 9)
  • 162~242 : use block_3
    • Place block_3 at ((action-162) // 9, (action-162) % 9)

example

  1. action == 0
    • Take block_1 and place it at position (0, 0) based on the center of the block.

  1. action == 212
    • Take block_3 and place it at position (5, 5) based on the center of the block.

Arguments

import gym_woodoku
import gymnasium as gym

env = gym.make('gym_woodoku/Woodoku-v0', 
                game_mode: str = 'woodoku',
                render_mode: str = None,
                crash33: bool = True)
  • game_mode : Gets the type of block to use in the game.
    • woodoku
  • crash33 : If true, when a 3x3 cell is filled, that portion will be broken.
  • render_modes : Determines gym rendering method.
    • ansi : The game screen appears on the console.
    • human : continuously rendered in the current display
    • rgb_array : return a single frame representing the current state of the environment. Use with RecordVideo Wrapper if you want to save episodes.

About

🎲 Woodoku-based reinforcement learning environment using Gymnasium

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages