Step 0: Installation/Setup
Pull from the repo
git clone <https://github.com/allengu01/flappy-starter.git> <name of folder>
Installing Python
Make sure you have Python 3.7.7 by opening command line and using:
python3 --version
If not, follow these instructions to install Python.
Linux (Ubuntu): sudo apt install python3
macOS: Download from this website: Python 3
Windows: Download from this website: Python 3
Setting Up a Virtual Environment
Python virtual environments let us separate and manage different environments for each project we create. Why do we need them?
python3 -m venv .venv
source .venv/bin/activate
deactivate
If you want to learn more about Python virtual environments, take a look here: https://realpython.com/python-virtual-environments-a-primer/
Installing Pygame
Pygame will be the package we use to create our game.
python3 -m pip install -U pygame
python3 -m pygame.examples.aliens
If running the demo game works, you're good to go.
Installing NEAT-Python
NEAT-Python is a package that implements the NEAT (Neuro-Evolution of Augmenting Topologies) algorithm. The algorithm will be used to teach the machine how to play the game you develop.
pip install neat-python
Step 2: Starting the first Pygame file
import pygame;
pygame.init()
SCREEN_WIDTH, SCREEN_HEIGHT = 500, 768
SCREEN = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("NEAT - Flappy Bird")
def main():
run = True
clock = pygame.time.Clock()
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
SCREEN.fill((255, 255, 255))
pygame.display.update()
clock.tick(60)
if __name__ == "__main__":
main()