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.
- 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
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
To run the test suite, run the following command from the root directory of the project:
python -m pytest
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 |
Henrik Haaland |
Håvard Fossdal |
Jon Bergland |
Maia Austigard |
Øystein Kvandal |
Sindre Fossdal |