Skip to content

lufficc/dqn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deep Q Network

An implementation of q algorithm of Reinforcement Learning.

Installation Dependencies:

  1. Python 3
  2. TensorFlow 1.0.1
  3. pygame
  4. gym

How to Run?

git clone https://github.com/lufficc/dqn.git
cd dqn
python run.py

Tricks for flappybird

Remove background image: remove-bg

clip useless part: clip

resize and using binary image: bin

decayed ε-greedy exploration, and when exploration, 0.95 probability to do nothing(because in flappy bird, most time wo do nothing). This is very important. It makes model converge in less than 2 hours.

def egreedy_action(self, state):
    #Exploration
    if random.random() <= self.epsilon:
        if random.random() < 0.95:
            action_index = 0
        else:
            action_index = 1
        # action_index = random.randint(0, self.num_actions - 1)
    else:
        #Exploitation
        action_index = self.action(state)
    if self.epsilon > self.final_epsilon:
        self.epsilon *= self.decay_factor
    return action_index

Thanks

  1. DeepLearningFlappyBird
  2. Guest Post (Part I): Demystifying Deep Reinforcement Learning
  3. UCL Course on RL
  4. A Painless Q-Learning Tutorial
  5. DQN 从入门到放弃1 DQN与增强学习