Skip to content

Commit 3e55f14

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in ee1b611 according to the output from Autopep8. Details: None
1 parent c01c03f commit 3e55f14

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

AI-driven AI Flappy Bird/Flappy_bird.py

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#AI-driven AI Flappy Bird
1+
# AI-driven AI Flappy Bird
22
import pygame
33
import neat
44
import os
@@ -10,19 +10,25 @@
1010

1111
# Bird images
1212
BIRD_IMAGES = [
13-
pygame.transform.scale2x(pygame.image.load(os.path.join("images", "bird1.png"))),
14-
pygame.transform.scale2x(pygame.image.load(os.path.join("images", "bird2.png"))),
15-
pygame.transform.scale2x(pygame.image.load(os.path.join("images", "bird3.png")))
13+
pygame.transform.scale2x(pygame.image.load(
14+
os.path.join("images", "bird1.png"))),
15+
pygame.transform.scale2x(pygame.image.load(
16+
os.path.join("images", "bird2.png"))),
17+
pygame.transform.scale2x(pygame.image.load(
18+
os.path.join("images", "bird3.png")))
1619
]
1720

1821
# Pipe image
19-
PIPE_IMAGE = pygame.transform.scale2x(pygame.image.load(os.path.join("images", "pipe.png")))
22+
PIPE_IMAGE = pygame.transform.scale2x(
23+
pygame.image.load(os.path.join("images", "pipe.png")))
2024

2125
# Base image
22-
BASE_IMAGE = pygame.transform.scale2x(pygame.image.load(os.path.join("images", "base.png")))
26+
BASE_IMAGE = pygame.transform.scale2x(
27+
pygame.image.load(os.path.join("images", "base.png")))
2328

2429
# Background image
25-
BG_IMAGE = pygame.transform.scale2x(pygame.image.load(os.path.join("images", "bg.png")))
30+
BG_IMAGE = pygame.transform.scale2x(
31+
pygame.image.load(os.path.join("images", "bg.png")))
2632

2733

2834
class Bird:
@@ -85,7 +91,8 @@ def draw(self, win):
8591
self.image_count = self.ANIMATION_TIME * 2
8692

8793
rotated_image = pygame.transform.rotate(self.image, self.tilt)
88-
new_rect = rotated_image.get_rect(center=self.image.get_rect(topleft=(self.x, self.y)).center)
94+
new_rect = rotated_image.get_rect(
95+
center=self.image.get_rect(topleft=(self.x, self.y)).center)
8996
win.blit(rotated_image, new_rect.topleft)
9097

9198
def get_mask(self):
@@ -215,7 +222,8 @@ def main(genomes, config):
215222
bird.move()
216223
ge[x].fitness += 0.1
217224

218-
output = nets[x].activate((bird.y, abs(bird.y - pipes[pipe_ind].height), abs(bird.y - pipes[pipe_ind].bottom)))
225+
output = nets[x].activate((bird.y, abs(
226+
bird.y - pipes[pipe_ind].height), abs(bird.y - pipes[pipe_ind].bottom)))
219227

220228
if output[0] > 0.5:
221229
bird.jump()
@@ -279,4 +287,3 @@ def run_neat():
279287
pygame.init()
280288
STAT_FONT = pygame.font.SysFont("comicsans", 50)
281289
run_neat()
282-

0 commit comments

Comments
 (0)