Skip to main content

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

Metadata

Release files for flappy-bird-gymS 0.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 flappy-bird-gymS 0.3.0
File Size Uploaded
flappy-bird-gymS-0.3.0.tar.gz 544.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flappy-bird-gymS 0.3.0
File Interpreter ABI Platform
flappy_bird_gymS-0.3.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 1.1 MB

Release files / flappy-bird-gymS-0.3.0.tar.gz

Download URL flappy-bird-gymS-0.3.0.tar.gz
Size 544.5 kB
Tags Source
SHA-256 checksum
How to use checksums
048528e141afebbd014d683f82eb363082f1b38aa5b3a9dd1266fbba7ffcfbbd
BLAKE2b-256 checksum
How to use checksums
53f2c26f19c2865cd5bd35b83ffae033d379eafa0c53cd725291145f0cee5275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.11

Release files / flappy_bird_gymS-0.3.0-py2.py3-none-any.whl

Download URL flappy_bird_gymS-0.3.0-py2.py3-none-any.whl
Size 558.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
afca1c2099fde28a306782ec8e359964bff304e2fc137b3afbaabca5f22f622a
BLAKE2b-256 checksum
How to use checksums
653139decbc0b5ed10480cd79b077f985bb5d8b79dee3fdaa8ab5caa3911e94f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.11

Release history Release notifications | RSS feed

This release

0.3.0 This release

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