Skip to content

This project aims at playing the game of Tetris using Genetic Algorithm

Notifications You must be signed in to change notification settings

shashank3199/Tetrominoes-NEAT_AI

Repository files navigation

Version Tag Python Tag NEAT Tag

Tetrominoes-NEAT_AI

This project aims at playing the game of Tetris using Genetic Algorithm. This project is developed over the Tetris game version developed by me, refer here. Each line of code is accompanied by a comment to explain it better.

The feature of this project that makes it unique of all the other existing similar projects, is it's ability to use the advantage that humans have against computers w.r.t. the game of Tetris, i.e. the ability to view the next piece and take the best possible decision based on that.

Game -

Game Image

Files in the Repository -

The files in the repository are :

README.md

The Description file containing details about the repository. The file that you looking at right now.

__init__.py

The __init__.py file is to make Python treat directories containing the file as packages.

config.txt

The configuration file specifies parameters particular to the genetic NEAT algorithm such as fitness_threshold, population_size, etc.

requirements.txt

This file contains the respective packages needed to be installed. To install the respective packages, use -

pip3 install -r requirements.txt

or 

pip install -r requirements.txt

test_main.py

This file is used to test the winner model after the training. To test the model -

python3 test_main.py

train_main.py

This file is used for training the genetic algorithm.. To train the models -

python3 train_main.py

utils.py

This file contains utility functions and Parameter class TetrisParams for evaluating game metrics.

winner.pickle

This file corresponds to the winner genome in my case of training 20 generations, with population size as 100. I was able to achieve the threshold by the end of second generation.

Tetris -

  • __init__.py

    The __init__.py file is to make Python treat directories containing the file as packages.

  • global_variables.py

    This file contains the global variables that are used in the game such as SCREEN_WIDTH, SCREEN_HEIGHT, etc.

  • piece.py

    This file contains the class templates for the various shapes of pieces in the game i.e. Piece class.

  • shapes.py

    This file contains the shapes of each of the game pieces as lists of lists, it also contains information about the color of each block in RGB format.

  • tetris.py

    This file contains the class template for the main game-play i.e. Tetris class.

.images

This directory contains the images for the game icon and media for the README File.

Bibliography

Footnote

The Title of this project is inspired by the title of a book owned by my dear friend on the Tetris game. 😉

Developers Tag
Friend Tag

Releases

No releases published

Packages

No packages published

Languages