Metadata-Version: 2.1
Name: flappy-bird-gym
Version: 0.1.2
Summary: An OpenAI gym environment for the Flappy Bird game.
Home-page: https://github.com/Talendar/flappy-bird-gym
Author: Gabriel Guedes Nogueira (Talendar)
Author-email: gabriel.gnogueira@gmail.com
License: MIT License
Download-URL: https://github.com/Talendar/flappy-bird-gym/releases
Keywords: Flappy-BirdGame Gym OpenAI-Gym Reinforcement-Learning Reinforcement-Learning-Environment
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: gym (~=0.18.0)
Requires-Dist: numpy (~=1.19.5)
Requires-Dist: pygame (~=2.0.1)

## Flappy Bird for OpenAI Gym

![Python versions](https://img.shields.io/pypi/pyversions/flappy-bird-gym)
[![PyPI](https://img.shields.io/pypi/v/flappy-bird-gym)](https://pypi.org/project/flappy-bird-gym/)
[![License](https://img.shields.io/github/license/Talendar/flappy-bird-gym)](https://github.com/Talendar/flappy-bird-gym/blob/master/LICENSE)

This repository contains an implementation of an OpenAI Gym environment for the Flappy Bird
game. It's based on [FlapPyBird](https://github.com/sourabhv/FlapPyBird), by
[@sourabhv](https://github.com/sourabhv). Currently, the environment provides the following
observation parameters to the agents: 

* The bird's *y* position;
* The bird's vertical velocity;
* Horizontal distance to the next pipe;
* The next pipe's *y* position.

In the future, I also intend to implement a version of the environment that provides an
image representing the game's screen as observation.

<p align="center">
  <img align="center" 
       src="https://github.com/Talendar/flappy-bird-gym/blob/main/imgs/yellow_bird_playing.gif?raw=true" 
       width="200"/>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <img align="center" 
       src="https://github.com/Talendar/flappy-bird-gym/blob/main/imgs/red_bird_start_screen.gif?raw=true" 
       width="200"/>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <img align="center" 
       src="https://github.com/Talendar/flappy-bird-gym/blob/main/imgs/blue_bird_playing.gif?raw=true" 
       width="200"/>
</p>

## 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


