Skip to content

G-Redos/MAKERS-W12-Final-Project-Tetris-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

header# Tech Stack

IDE

Languages

Frameworks & Library

Rspec

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.

footer