ntasfi / PyGame-Learning-Environment

PyGame Learning Environment (PLE) -- Reinforcement Learning Environment in Python.
MIT License
1.02k stars 231 forks source link

Flappy Bird Game: Check whether the bird is in the tube in the hit condition #35

Closed randxie closed 7 years ago

randxie commented 7 years ago

I am using the flappy bird game to develop reinforcement learning algorithm. I found that the bird fails at some conditions when it should not fail. So I looked into the code and found that a condition is missing when determining whether the bird hit the tube. Please see my modified code here:

for p in self.pipe_group:
    hit = pygame.sprite.spritecollide(
        self.player, self.pipe_group, False)
    for h in hit:
        is_in_pipe = ((p.x - p.width / 2) <= self.player.pos_x < (p.x - p.width / 2))
        # do check to see if its within the gap.
        top_pipe_check = (
            (self.player.pos_y - self.player.height / 2) <= h.gap_start) and is_in_pipe
        bot_pipe_check = (
            (self.player.pos_y +
             self.player.height) > h.gap_start +
            self.pipe_gap) and is_in_pipe
ntasfi commented 7 years ago

@alirezamika has merged a fix for this! Thank you both :)