Skip to main content

A Gymnasium environment for the Flappy Bird game.

Project description

Flappy Bird for Gymnasium

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
  • player's vertical velocity

         

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:

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

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

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

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

$ flappy_bird_gymnasium --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-gymnasium-0.1.0.tar.gz (544.6 kB view details)

Uploaded Source

Built Distribution

flappy_bird_gymnasium-0.1.0-py3-none-any.whl (558.9 kB view details)

Uploaded Python 3

File details

Details for the file flappy-bird-gymnasium-0.1.0.tar.gz.

File metadata

  • Download URL: flappy-bird-gymnasium-0.1.0.tar.gz
  • Upload date:
  • Size: 544.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for flappy-bird-gymnasium-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5369afa0237d0b1c6c165d0c20863cfa5f30595e3b559dbd02a7afb3acdf592f
MD5 23124857f9f9c13891276f4b6fe23f4f
BLAKE2b-256 5cf263e41107eb2f2e61b516ee040b90a737ae67a06e7008e15e28d71f711adf

See more details on using hashes here.

File details

Details for the file flappy_bird_gymnasium-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flappy_bird_gymnasium-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdb7db73e0d85a8c2f475d4e26de251e1a365b3a707abc9b3e30be712631783f
MD5 d760f2db52b611a15e073f2357a355a5
BLAKE2b-256 27a68fa5113d37cec4533b7696a9ca44fbbedf37596ed3f7608021d47e23c6f6

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