flappy-bird-gymnasium


Nameflappy-bird-gymnasium JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/markub3327/flappy-bird-gymnasium
SummaryA Gymnasium environment for the Flappy Bird game.
upload_time2024-02-29 13:12:51
maintainer
docs_urlNone
authorMartin Kubovcik
requires_python>=3.9
licenseMIT License
keywords flappy-birdgame gymnasium farama-foundation reinforcement-learning reinforcement-learning-environment
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Flappy Bird for Gymnasium

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

This repository contains the implementation of Gymnasium environment for
the Flappy Bird game. The implementation of the game's logic and graphics was
based on the [flappy-bird-gym](https://github.com/Talendar/flappy-bird-gym) project, by
[@Talendar](https://github.com/Talendar). 

## State space

The "FlappyBird-v0" environment, yields simple numerical information about the game's state as
observations or RGB-arrays (images) representing the game's screen.

### `FlappyBird-v0`
1. option
* The LIDAR sensor 180 readings

2. option
* the last pipe's horizontal position
* the last top pipe's vertical position
* the last bottom pipe's vertical position
* the next pipe's horizontal position
* the next top pipe's vertical position
* the next bottom pipe's vertical position
* the next next pipe's horizontal position
* the next next top pipe's vertical position
* the next next bottom pipe's vertical position
* player's vertical position
* player's vertical velocity
* player's rotation

3. option
* or RGB-array (image) representing the game's screen

## Action space

* 0 - **do nothing**
* 1 - **flap**

## Rewards

* +0.1 - **every frame it stays alive**
* +1.0 - **successfully passing a pipe**
* -1.0 - **dying**
* −0.5 - **touch the top of the screen**

<br>

<p align="center">
  <img align="center" 
       src="https://github.com/markub3327/flappy-bird-gymnasium/blob/main/imgs/dqn.gif?raw=true" 
       width="200"/>
</p>

## Installation

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

    $ pip install flappy-bird-gymnasium
    
## Usage

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

```python
import flappy_bird_gymnasium
import gymnasium
env = gymnasium.make("FlappyBird-v0", render_mode="human", use_lidar=True)

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

    # Processing:
    obs, reward, terminated, _, info = env.step(action)
    
    # Checking if the player is still alive
    if terminated:
        break

env.close()
```

## Playing

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

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

    $ flappy_bird_gymnasium --mode random

To see a Deep Q Network agent playing, add an argument to the command:

    $ flappy_bird_gymnasium --mode dqn

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/markub3327/flappy-bird-gymnasium",
    "name": "flappy-bird-gymnasium",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "Flappy-BirdGame Gymnasium Farama-Foundation Reinforcement-Learning Reinforcement-Learning-Environment",
    "author": "Martin Kubovcik",
    "author_email": "markub3327@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6a/46/de0965899428dccfe14d9f5242f7fbaca91d66a083d6bcbc380567cffcdd/flappy-bird-gymnasium-0.4.0.tar.gz",
    "platform": null,
    "description": "# Flappy Bird for Gymnasium\n\n![Python versions](https://img.shields.io/pypi/pyversions/flappy-bird-gymnasium)\n[![PyPI](https://img.shields.io/pypi/v/flappy-bird-gymnasium)](https://pypi.org/project/flappy-bird-gymnasium/)\n[![License](https://img.shields.io/github/license/markub3327/flappy-bird-gymnasium)](https://github.com/markub3327/flappy-bird-gymnasium/blob/master/LICENSE)\n\nThis repository contains the implementation of Gymnasium environment for\nthe Flappy Bird game. The implementation of the game's logic and graphics was\nbased on the [flappy-bird-gym](https://github.com/Talendar/flappy-bird-gym) project, by\n[@Talendar](https://github.com/Talendar). \n\n## State space\n\nThe \"FlappyBird-v0\" environment, yields simple numerical information about the game's state as\nobservations or RGB-arrays (images) representing the game's screen.\n\n### `FlappyBird-v0`\n1. option\n* The LIDAR sensor 180 readings\n\n2. option\n* the last pipe's horizontal position\n* the last top pipe's vertical position\n* the last bottom pipe's vertical position\n* the next pipe's horizontal position\n* the next top pipe's vertical position\n* the next bottom pipe's vertical position\n* the next next pipe's horizontal position\n* the next next top pipe's vertical position\n* the next next bottom pipe's vertical position\n* player's vertical position\n* player's vertical velocity\n* player's rotation\n\n3. option\n* or RGB-array (image) representing the game's screen\n\n## Action space\n\n* 0 - **do nothing**\n* 1 - **flap**\n\n## Rewards\n\n* +0.1 - **every frame it stays alive**\n* +1.0 - **successfully passing a pipe**\n* -1.0 - **dying**\n* \u22120.5 - **touch the top of the screen**\n\n<br>\n\n<p align=\"center\">\n  <img align=\"center\" \n       src=\"https://github.com/markub3327/flappy-bird-gymnasium/blob/main/imgs/dqn.gif?raw=true\" \n       width=\"200\"/>\n</p>\n\n## Installation\n\nTo install `flappy-bird-gymnasium`, simply run the following command:\n\n    $ pip install flappy-bird-gymnasium\n    \n## Usage\n\nLike with other `gymnasium` environments, it's very easy to use `flappy-bird-gymnasium`.\nSimply import the package and create the environment with the `make` function.\nTake a look at the sample code below:\n\n```python\nimport flappy_bird_gymnasium\nimport gymnasium\nenv = gymnasium.make(\"FlappyBird-v0\", render_mode=\"human\", use_lidar=True)\n\nobs, _ = env.reset()\nwhile True:\n    # Next action:\n    # (feed the observation to your agent here)\n    action = env.action_space.sample()\n\n    # Processing:\n    obs, reward, terminated, _, info = env.step(action)\n    \n    # Checking if the player is still alive\n    if terminated:\n        break\n\nenv.close()\n```\n\n## Playing\n\nTo play the game (human mode), run the following command:\n\n    $ flappy_bird_gymnasium\n    \nTo see a random agent playing, add an argument to the command:\n\n    $ flappy_bird_gymnasium --mode random\n\nTo see a Deep Q Network agent playing, add an argument to the command:\n\n    $ flappy_bird_gymnasium --mode dqn\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A Gymnasium environment for the Flappy Bird game.",
    "version": "0.4.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/markub3327/flappy-bird-gymnasium/issues",
        "Download": "https://github.com/markub3327/flappy-bird-gymnasium/releases",
        "Homepage": "https://github.com/markub3327/flappy-bird-gymnasium"
    },
    "split_keywords": [
        "flappy-birdgame",
        "gymnasium",
        "farama-foundation",
        "reinforcement-learning",
        "reinforcement-learning-environment"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ad8621717daf58d737671f5f08f8bd2e39cabe401f9c17a9d97765bfb81eb858",
                "md5": "d1289f4a9df8d1fa2edad3d722dc7f6b",
                "sha256": "f215be1d747320a3b07b6934ed0d08ac7ee8fbf50dd45a5be77b7381a6ebf880"
            },
            "downloads": -1,
            "filename": "flappy_bird_gymnasium-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d1289f4a9df8d1fa2edad3d722dc7f6b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 37336957,
            "upload_time": "2024-02-29T13:12:46",
            "upload_time_iso_8601": "2024-02-29T13:12:46.665110Z",
            "url": "https://files.pythonhosted.org/packages/ad/86/21717daf58d737671f5f08f8bd2e39cabe401f9c17a9d97765bfb81eb858/flappy_bird_gymnasium-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6a46de0965899428dccfe14d9f5242f7fbaca91d66a083d6bcbc380567cffcdd",
                "md5": "c13cc2a4b6b07952a56283590402c70b",
                "sha256": "78358e9a73740e5214b6bb7d965971bc645d9baecc092c86ef02726b9d62347b"
            },
            "downloads": -1,
            "filename": "flappy-bird-gymnasium-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c13cc2a4b6b07952a56283590402c70b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 37321242,
            "upload_time": "2024-02-29T13:12:51",
            "upload_time_iso_8601": "2024-02-29T13:12:51.572629Z",
            "url": "https://files.pythonhosted.org/packages/6a/46/de0965899428dccfe14d9f5242f7fbaca91d66a083d6bcbc380567cffcdd/flappy-bird-gymnasium-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-29 13:12:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "markub3327",
    "github_project": "flappy-bird-gymnasium",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "flappy-bird-gymnasium"
}
        
Elapsed time: 0.22070s