Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions ple/games/flappybird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pygame
from pygame.constants import K_w
from .. import base

from collections import OrderedDict

class BirdPlayer(pygame.sprite.Sprite):

Expand Down Expand Up @@ -330,7 +330,26 @@ def getGameState(self):
if next_next_pipe.x < next_pipe.x:
next_pipe, next_next_pipe = next_next_pipe, next_pipe


# ordered dictionary outputs the keys value pairs in same order as they are inserted
state = OrderedDict()
state['player_y'] = self.player.pos_y
state['player_vel'] = self.player.vel

state['next_pipe_dist_to_player'] = next_pipe.x + next_pipe.width/2 - self.player.pos_x
state['next_pipe_top_y'] = next_pipe.gap_start
state['next_pipe_bottom_y'] = next_pipe.gap_start + self.pipe_gap

state['next_next_pipe_dist_to_player'] = next_next_pipe.x + next_next_pipe.width/2 - self.player.pos_x
state['next_next_pipe_top_y'] = next_next_pipe.gap_start
state['next_next_pipe_bottom_y'] = next_next_pipe.gap_start + self.pipe_gap

# this does not maintains the order of key value pairs

'''

state = {

"player_y": self.player.pos_y,
"player_vel": self.player.vel,

Expand All @@ -342,7 +361,7 @@ def getGameState(self):
"next_next_pipe_top_y": next_next_pipe.gap_start,
"next_next_pipe_bottom_y": next_next_pipe.gap_start + self.pipe_gap
}

'''
return state

def getScore(self):
Expand Down