## Flappy Bird for OpenAI Gym

[](https://pypi.org/project/flappy-bird-gym/)
[](https://github.com/Talendar/flappy-bird-gym/blob/master/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](https://github.com/sourabhv/FlapPyBird) project, by
[@sourabhv](https://github.com/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.
<br>
<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"/>
<img align="center"
src="https://github.com/Talendar/flappy-bird-gym/blob/main/imgs/red_bird_start_screen.gif?raw=true"
width="200"/>
<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
Raw data
{
"_id": null,
"home_page": "https://github.com/Talendar/flappy-bird-gym",
"name": "flappy-bird-gymS",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "Flappy-BirdGame Gym OpenAI-Gym Reinforcement-Learning Reinforcement-Learning-Environment",
"author": "Gabriel Guedes Nogueira (Talendar)",
"author_email": "gabriel.gnogueira@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/53/f2/c26f19c2865cd5bd35b83ffae033d379eafa0c53cd725291145f0cee5275/flappy-bird-gymS-0.3.0.tar.gz",
"platform": null,
"description": "## Flappy Bird for OpenAI Gym\n\n\n[](https://pypi.org/project/flappy-bird-gym/)\n[](https://github.com/Talendar/flappy-bird-gym/blob/master/LICENSE)\n\nThis repository contains the implementation of two OpenAI Gym environments for\nthe Flappy Bird game. The implementation of the game's logic and graphics was\nbased on the [FlapPyBird](https://github.com/sourabhv/FlapPyBird) project, by\n[@sourabhv](https://github.com/sourabhv). \n\nThe two environments differ only on the type of observations they yield for the\nagents. The \"FlappyBird-rgb-v0\" environment, yields RGB-arrays (images)\nrepresenting the game's screen. The \"FlappyBird-v0\" environment, on the other\nhand, yields simple numerical information about the game's state as\nobservations. The yielded attributes are the:\n\n* horizontal distance to the next pipe;\n* difference between the player's y position and the next hole's y position.\n\n<br>\n\n<p align=\"center\">\n <img align=\"center\" \n src=\"https://github.com/Talendar/flappy-bird-gym/blob/main/imgs/yellow_bird_playing.gif?raw=true\" \n width=\"200\"/>\n \n <img align=\"center\" \n src=\"https://github.com/Talendar/flappy-bird-gym/blob/main/imgs/red_bird_start_screen.gif?raw=true\" \n width=\"200\"/>\n \n <img align=\"center\" \n src=\"https://github.com/Talendar/flappy-bird-gym/blob/main/imgs/blue_bird_playing.gif?raw=true\" \n width=\"200\"/>\n</p>\n\n## Installation\n\nTo install `flappy-bird-gym`, simply run the following command:\n\n $ pip install flappy-bird-gym\n \n## Usage\n\nLike with other `gym` environments, it's very easy to use `flappy-bird-gym`.\nSimply import the package and create the environment with the `make` function.\nTake a look at the sample code below:\n\n```\nimport time\nimport flappy_bird_gym\nenv = flappy_bird_gym.make(\"FlappyBird-v0\")\n\nobs = env.reset()\nwhile True:\n # Next action:\n # (feed the observation to your agent here)\n action = ... # env.action_space.sample() for a random action\n\n # Processing:\n obs, reward, done, info = env.step(action)\n \n # Rendering the game:\n # (remove this two lines during training)\n env.render()\n time.sleep(1 / 30) # FPS\n \n # Checking if the player is still alive\n if done:\n break\n\nenv.close()\n```\n\n## Playing\n\nTo play the game (human mode), run the following command:\n\n $ flappy_bird_gym\n \nTo see a random agent playing, add an argument to the command:\n\n $ flappy_bird_gym --mode random\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "An OpenAI gym environment for the Flappy Bird game.",
"version": "0.3.0",
"split_keywords": [
"flappy-birdgame",
"gym",
"openai-gym",
"reinforcement-learning",
"reinforcement-learning-environment"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "6c524d25fcc8383ae838da862f1998b2",
"sha256": "afca1c2099fde28a306782ec8e359964bff304e2fc137b3afbaabca5f22f622a"
},
"downloads": -1,
"filename": "flappy_bird_gymS-0.3.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "6c524d25fcc8383ae838da862f1998b2",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.6",
"size": 558231,
"upload_time": "2022-12-09T14:30:56",
"upload_time_iso_8601": "2022-12-09T14:30:56.436402Z",
"url": "https://files.pythonhosted.org/packages/65/31/39decbc0b5ed10480cd79b077f985bb5d8b79dee3fdaa8ab5caa3911e94f/flappy_bird_gymS-0.3.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "20c8b3df05c7d8fdc7690e699926fcfa",
"sha256": "048528e141afebbd014d683f82eb363082f1b38aa5b3a9dd1266fbba7ffcfbbd"
},
"downloads": -1,
"filename": "flappy-bird-gymS-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "20c8b3df05c7d8fdc7690e699926fcfa",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 544535,
"upload_time": "2022-12-09T14:30:58",
"upload_time_iso_8601": "2022-12-09T14:30:58.701196Z",
"url": "https://files.pythonhosted.org/packages/53/f2/c26f19c2865cd5bd35b83ffae033d379eafa0c53cd725291145f0cee5275/flappy-bird-gymS-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-09 14:30:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Talendar",
"github_project": "flappy-bird-gym",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "flappy-bird-gyms"
}