Classic Tetris game for 1-4 players, featuring an AI client. Compete with up to 4 clients on the same network (you may add AI players).
Made by Aviv Friedman 2024 as part of a final project of the year at school.
- Single-player mode: Enjoy the classic Tetris experience on your own.
- Multiplayer mode: Compete with up to 4 players on the same network.
- AI players: Add AI players to the game to increase the challenge.
- Network Play: Play against friends or AI over a local network.
- Hold Feature: Hold pieces for later use to strategize your game.
- Next Piece Preview: See the next piece to plan your moves ahead.
- Score Tracking: Keep track of your score and aim for the high score.
- Dynamic Speed Increase: Game speed increases as you progress, making the game more challenging.
- Ghost Piece: Preview where the current piece will land to make precise moves.
- Clear Lines and Send to Opponents: Send lines to opponents when you clear lines, adding a competitive edge.
- Game Over and Restart Options: Easily restart the game or go back to the main menu after a game over.
- High Score Database: Track the best scores and see who holds the top spot.
To run this project, you will need to follow the next steps:
- Download all provided files.
- Start the server:
python server.py - Run the game on each computer you want to play:
python game.py - (Optional) Run the AI client:
python ai_bot.py - Insert the server IP in the game clients (can be found using
ipconfigin Command Prompt)
I integrated an AI bot using the logic made by Yiyuan Lee. Full explanation can be found on Yiyuan Lee's Tetris AI GitHub repository.
The AI bot uses a combination of heuristics to decide the best possible moves for each tetromino. These heuristics include:
- Aggregate Height: The sum of the heights of all columns. Lower aggregate heights are preferred.
- Complete Lines: The number of complete lines that will be cleared with the current move. More lines are better.
- Holes: The number of empty spaces that have at least one block above them. Fewer holes are better.
- Bumpiness: The difference in heights between adjacent columns. Less bumpiness is better.
The AI evaluates possible moves based on these heuristics and selects the move with the best overall score.

The single_player.py is uniquely designed to test cognitive load. In addition to offering the classic Tetris experience, this mode serves as a practical tool for evaluating how players manage and respond to increasing mental demands1.
- Left Arrow: Move left
- Right Arrow: Move right
- Up Arrow: Rotate clockwise
- Down Arrow: Soft drop
- Spacebar: Hard drop
- Shift: Hold
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.