A Gymnasium environment for the Flappy Bird game.
Project description
Flappy Bird for Gymnasium
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
- the next pipe's top vertical position
- the next pipe's bottom vertical position
- horizontal distance to the next next pipe
- the next next pipe's top vertical position
- the next next pipe's bottom vertical position
- player's vertical position
- player's vertical velocity
- player's rotation
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, terminated, _, 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 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
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
Built Distribution
File details
Details for the file flappy-bird-gymnasium-0.1.2.tar.gz
.
File metadata
- Download URL: flappy-bird-gymnasium-0.1.2.tar.gz
- Upload date:
- Size: 544.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08371aca6d2a768d0089a749437df6c40357a340f80c5f7056158ccb8f71b115 |
|
MD5 | 3c3f35af7aaf477ad84d83723c154fc4 |
|
BLAKE2b-256 | d6f0e3a420b133ecb41ffbdc11290e97c6ea9b9b6bc8bd1031291079d6c99604 |
File details
Details for the file flappy_bird_gymnasium-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: flappy_bird_gymnasium-0.1.2-py3-none-any.whl
- Upload date:
- Size: 559.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d91b0a08da77322e66f122857468c442b1eb3f61036eca4b172fa0debd4f1db9 |
|
MD5 | 2fd3d347d08a3627a86de27fde1d65ef |
|
BLAKE2b-256 | 3d41c1d76d9e778ccc0b796edf543cf552294a0d388071ec4048731d4035961e |