An OpenAI gym environment for the Flappy Bird game.
Project description
Flappy Bird for OpenAI Gym
This repository contains an implementation of an OpenAI Gym environment for the Flappy Bird game. It's based on FlapPyBird, by @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.
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
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
Hashes for flappy_bird_gym-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de7d22bff3d11ab1fde4fcbc904a09290e5780043970ce50a19b781e99fa2b9b |
|
MD5 | 4c73f0310fbeb00597109cb07380894c |
|
BLAKE2b-256 | c09319779319aa7e212e0b21557b64bf59578e3c743eb2b7f3c028e778dbb42b |