Skip to main content

An OpenAI gym environment for the Flappy Bird game.

Project description

Flappy Bird for OpenAI Gym

Python versions PyPI License

This repository contains the implementation of two OpenAI Gym environments for the Flappy Bird game. The implementation of the game's logic and graphics was based on the FlapPyBird project, by @sourabhv.

The two environments differ only on the type of observations they yield for the agents. The "FlappyBird-rgb-v0" environment, yields RGB-arrays (images) representing the game's screen. The "FlappyBird-v0" environment, on the other hand, yields simple numerical information about the game's state as observations. The yielded attributes are the:

  • horizontal distance to the next pipe;
  • difference between the player's y position and the next hole's y position.

         

Installation

To install flappy-bird-gym, simply run the following command:

$ pip install flappy-bird-gym

Usage

Like with other gym environments, it's very easy to use flappy-bird-gym. Simply import the package and create the environment with the make function. Take a look at the sample code below:

import time
import flappy_bird_gym
env = flappy_bird_gym.make("FlappyBird-v0")

obs = env.reset()
while True:
    # Next action:
    # (feed the observation to your agent here)
    action = ...  # env.action_space.sample() for a random action

    # Processing:
    obs, reward, done, info = env.step(action)

    # Rendering the game:
    # (remove this two lines during training)
    env.render()
    time.sleep(1 / 30)  # FPS

    # Checking if the player is still alive
    if done:
        break

env.close()

Playing

To play the game (human mode), run the following command:

$ flappy_bird_gym

To see a random agent playing, add an argument to the command:

$ flappy_bird_gym --mode random

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

flappy-bird-gym-0.3.0.tar.gz (537.5 kB view details)

Uploaded Source

Built Distribution

flappy_bird_gym-0.3.0-py3-none-any.whl (558.1 kB view details)

Uploaded Python 3

File details

Details for the file flappy-bird-gym-0.3.0.tar.gz.

File metadata

  • Download URL: flappy-bird-gym-0.3.0.tar.gz
  • Upload date:
  • Size: 537.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.12

File hashes

Hashes for flappy-bird-gym-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a09d4c4b89659d853a17bf4742e1dc5c9c9be0efeda2e483ef30eb2771ef26e7
MD5 c6c7681190e1b20febfd07654d7ed10c
BLAKE2b-256 23d5b5194a68dcd18b651b17aadf9973f46b0a53481c17a4cfc01af3517e9e34

See more details on using hashes here.

File details

Details for the file flappy_bird_gym-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: flappy_bird_gym-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 558.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.12

File hashes

Hashes for flappy_bird_gym-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f40a7d3a22e77dcac9cb3843391190c6c91987b319b27af9bc7e27b0a7b31a4
MD5 b36569a76ca84616ad302d12246eeae4
BLAKE2b-256 00ea0fd4435fa2226f3d0d8d0a3840de586df030df7150408ca1e0769c077b1f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page