All Projects → kingyuluk → RL-FlappyBird

kingyuluk / RL-FlappyBird

Licence: MIT license
Using reinforcement learning to train FlappyBird.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to RL-FlappyBird

Deep Rl Trading
playing idealized trading games with deep reinforcement learning
Stars: ✭ 228 (+235.29%)
Mutual labels:  dqn
DQN-using-PyTorch-and-ML-Agents
A simple example of how to implement vector based DQN using PyTorch and a ML-Agents environment
Stars: ✭ 81 (+19.12%)
Mutual labels:  dqn
Deep-Reinforcement-Learning-With-Python
Master classic RL, deep RL, distributional RL, inverse RL, and more using OpenAI Gym and TensorFlow with extensive Math
Stars: ✭ 222 (+226.47%)
Mutual labels:  dqn
Aleph star
Reinforcement learning with A* and a deep heuristic
Stars: ✭ 235 (+245.59%)
Mutual labels:  dqn
Drl based selfdrivingcarcontrol
Deep Reinforcement Learning (DQN) based Self Driving Car Control with Vehicle Simulator
Stars: ✭ 249 (+266.18%)
Mutual labels:  dqn
omd
JAX code for the paper "Control-Oriented Model-Based Reinforcement Learning with Implicit Differentiation"
Stars: ✭ 43 (-36.76%)
Mutual labels:  dqn
Hands On Intelligent Agents With Openai Gym
Code for Hands On Intelligent Agents with OpenAI Gym book to get started and learn to build deep reinforcement learning agents using PyTorch
Stars: ✭ 189 (+177.94%)
Mutual labels:  dqn
Rainy
☔ Deep RL agents with PyTorch☔
Stars: ✭ 39 (-42.65%)
Mutual labels:  dqn
king-pong
Deep Reinforcement Learning Pong Agent, King Pong, he's the best
Stars: ✭ 23 (-66.18%)
Mutual labels:  dqn
pytorch-distributed
Ape-X DQN & DDPG with pytorch & tensorboard
Stars: ✭ 98 (+44.12%)
Mutual labels:  dqn
Learning To Communicate Pytorch
Learning to Communicate with Deep Multi-Agent Reinforcement Learning in PyTorch
Stars: ✭ 236 (+247.06%)
Mutual labels:  dqn
Reinforcement Learning
Minimal and Clean Reinforcement Learning Examples
Stars: ✭ 2,863 (+4110.29%)
Mutual labels:  dqn
breakout-Deep-Q-Network
Reinforcement Learning | tensorflow implementation of DQN, Dueling DQN and Double DQN performed on Atari Breakout
Stars: ✭ 69 (+1.47%)
Mutual labels:  dqn
Pytorch Drl
PyTorch implementations of various Deep Reinforcement Learning (DRL) algorithms for both single agent and multi-agent.
Stars: ✭ 233 (+242.65%)
Mutual labels:  dqn
UAV-DDPG
Code for paper "Computation Offloading Optimization for UAV-assisted Mobile Edge Computing: A Deep Deterministic Policy Gradient Approach"
Stars: ✭ 133 (+95.59%)
Mutual labels:  dqn
Deeprl
Modularized Implementation of Deep RL Algorithms in PyTorch
Stars: ✭ 2,640 (+3782.35%)
Mutual labels:  dqn
djl
An Engine-Agnostic Deep Learning Framework in Java
Stars: ✭ 3,080 (+4429.41%)
Mutual labels:  djl
pacman-ai
A.I. plays the original 1980 Pacman using Neuroevolution of Augmenting Topologies and Deep Q Learning
Stars: ✭ 26 (-61.76%)
Mutual labels:  dqn
dqn-obstacle-avoidance
Deep Reinforcement Learning for Fixed-Wing Flight Control with Deep Q-Network
Stars: ✭ 57 (-16.18%)
Mutual labels:  dqn
reinforcement learning with Tensorflow
Minimal implementations of reinforcement learning algorithms by Tensorflow
Stars: ✭ 28 (-58.82%)
Mutual labels:  dqn

RL Flappy Bird

Overview

This project is a basic application of Reinforcement Learning.

It integrates Deep Java Library (DJL) to uses DQN to train agent. The pretrained model are trained with 3M steps on a single GPU.

You can find article explaining the training process on towards data science, or 中文版文章.

Build the project and run

This project supports building with Maven, you can use the following command to build:

mvn compile  

The following command will start to train without graphics:

mvn exec:java -Dexec.mainClass="com.kingyu.rlbird.ai.TrainBird"

The above command will train from scratch. You can also try to train with the pretrained weight:

mvn exec:java -Dexec.mainClass="com.kingyu.rlbird.ai.TrainBird" -Dexec.args="-p"

To test with the model directly, you can do the followings

mvn exec:java -Dexec.mainClass="com.kingyu.rlbird.ai.TrainBird" -Dexec.args="-p -t"  
Argument Comments
-g Training with graphics.
-b Batch size to use for training.
-p Use pre-trained weights.
-t Test the trained model.

Deep Q-Network Algorithm

The pseudo-code for the Deep Q Learning algorithm, as given in Human-level Control through Deep Reinforcement Learning. Nature, can be found below:

Initialize replay memory D to size N
Initialize action-value function Q with random weights
for episode = 1, M do
    Initialize state s_1
    for t = 1, T do
        With probability ϵ select random action a_t
        otherwise select a_t=max_a  Q(s_t,a; θ_i)
        Execute action a_t in emulator and observe r_t and s_(t+1)
        Store transition (s_t,a_t,r_t,s_(t+1)) in D
        Sample a minibatch of transitions (s_j,a_j,r_j,s_(j+1)) from D
        Set y_j:=
            r_j for terminal s_(j+1)
            r_j+γ*max_(a^' )  Q(s_(j+1),a'; θ_i) for non-terminal s_(j+1)
        Perform a gradient step on (y_j-Q(s_j,a_j; θ_i))^2 with respect to θ
    end for
end for

Notes

Trained Model

  • It may take 10+ hours to train a bird to a perfect state. You can find the model trained with three million steps in project resource folder: src/main/resources/model/dqn-trained-0000-params

Troubleshooting

This work is based on the following repos:

License

MIT © Kingyu Luk

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].