Coder Social home page Coder Social logo

breakout-env's Introduction

Breakout-env

A gym like Breakout environment but with more configurable options.

Configurable Options

Option Description Type Range Default Value
max_step Max step per episode. int 0 ~ Inf 10000
lifes Lifes per episode. int 0 ~ 9 5
ball_pos Ball's initial position. [y, x] [int, int] -Inf ~ Inf [100, 40]
ball_speed Ball's initial velocity. [y, x] [int, int] -Inf ~ Inf [4, 2]
ball_color Ball's color. (gray scale) int 0 ~ 255 143
ball_size Ball's size. [h, w] [int, int] 1 ~ Inf [5, 2]
paddle_width Paddle's width. int 1 ~ 100 15
paddle_color Paddle's color. (gray scale) int 0 ~ 255 143
paddle_speed Paddle's moving speed. int 1 ~ Inf 3
bricks_rows Number of bricks row. int 0 ~ Inf 6
bricks_color Row color of bricks.* list of int 0 ~ 255 [200, 180, 160, 140, 120, 100]
bricks_reward The reward of bricks.* list of int -Inf ~ Inf [6, 5, 4, 3, 2, 1]

* len(bricks_color) and len(bricks_color) should equal to bricks_rows.

Installation

Install from PyPI:

$ pip install breakout_env

Install from master branch

$ pip install git+https://github.com/SSARCandy/breakout-env.git@master

Example

Interact with environment

from breakout_env import Breakout

# Create Breakout environment with some options.
env = Breakout({
    'lifes': 7,
    'paddle_width': 30,
    'paddle_speed': 5
  })

for ep in range(2):
  obs = env.reset()
  while True:
    # Select random action
    action = random.randint(0, env.actions - 1)
    obs, reward, done, _ = env.step(action)
    print('Episode: {}, Reward: {}, Done: {}'.format(ep, reward, done))
    if done:
      break

Visualize the game

The observation retuned by env is a numpy 2D array, it can be easily visualize using some library like OpenCV or matplotlib.

import cv2
from breakout_env import Breakout

env = Breakout()
env.reset()

while True:
  # Select random action
  action = random.randint(0, env.actions - 1)
  obs, _, _, _ = env.step(action)
  # Show the observation using OpenCV
  cv2.imshow('obs', obs)
  cv2.waitKey(1)
  if done:
    break

Develop Requirement

  • python3
  • numpy

Reference

breakout-env's People

Contributors

marcofavorito avatar ssarcandy avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.