Skip to content

TetrisAI is an AI project by Cogito NTNU, using a genetic algorithm to model heuristic agents for mastering Tetris.

License

Notifications You must be signed in to change notification settings

CogitoNTNU/TetrisAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tetris AI

GitHub Workflow Status (with event) GitHub top language GitHub language count License: MIT Project Version

Cogito Image

Description

This project is our attempt at making an AI that can play Tetris. First of all we made the environment (the game itself) and then we started working on multiple AI's that can play the game. The AI's are based on different algorithms and strategies. We have implmented:

  • Random agent
  • Heuristic agent with set weights
  • Genetic algorithm to find the best weights for the heuristic agent

The game is playable/viable both in the terminal and in a GUI. The GUI is made with Pygame.

How to run and install

  • Have python installed (tested with 3.10+ but should work on older versions as well)
  • Have pip installed
  • Clone the repository
  • Set up a virtual environment (optional but recommended) see here for a guide
  • Install the required packages with pip
pip install -r requirements.txt
  • Done! You are now ready to run the game

Usage

To play the game yourself, run the following command:

python main.py play

To let the agent play the game, run the following command:

python main.py agent <agent>

where <agent> is the agent you want to use. The available agents are: random, heuristic, genetic

To train the genetic agent, run the following command:

python main.py train

Testing

To run the test suite, run the following command from the root directory of the project:

python -m pytest

Team

The team behind this project is a group of students at NTNU in Trondheim, Norway, developed during the spring semester of 2024. The team consists of:

Eduard-Prokhorikhin
Eduard Prokhorikhin
henrinha
Henrik Haaland
HFossdal
Håvard Fossdal
JonBergland
Jon Bergland
maiahi
Maia Austigard
oystkva
Øystein Kvandal
SindreFossdal
Sindre Fossdal

Group picture

About

TetrisAI is an AI project by Cogito NTNU, using a genetic algorithm to model heuristic agents for mastering Tetris.

Topics

Resources

License

Stars

Watchers

Forks

Languages