Skip to content

Ahmad3oda/Tetris-Solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 

Repository files navigation

Tetris Game Solving - Using Multi-Threading in Java

  • This project is based on Tetris game.
  • The program handles several pieces of different shapes, aiming to fit all of them into a 4x4 grid.
  • The objective is to arrange the pieces without any gaps, ensuring that all the components find a suitable place within the grid.

The Workflow Procedure

  • Initially, the program does a pre-processing to get all the valid ways to postion each piece, so that it's ready to use whenever it's needed later on during the whole excution proccess.

  • The core concept involves implementing a backtracking algorithm using threads. Each thread manages its own 4x4 grid and begins by strategically placing valid pieces. Then, it invokes another thread, acting as a child, to complete the process.

  • The advantage is that the parent thread does not pause or wait for its child to finish, enabling both of them to proceed with their work concurrently. Both threads operate simultaneously, continuously adding pieces and generating children in an uninterrupted manner.

  • In summary, the entire tree formed by the backtracking algorithm operates concurrently, leading to a faster and more efficient way to achieve an optimal result.

For more Details, Take a look at the Attached Documentation.

How to use?

  • The program shows various letter-shaped blocks (L, T, I, O, Z, S) that can be arranged.
  • As a user, you pick the quantity of each shape, and the program provides a potential arrangement solution for the Tetris board.
  • Each time you run the program with the same input, it usually gives a different valid solution.

The Final Result

  • In case of valid query, the program visualize the steps for the solution :

123 456

  • In case of invalid query :

789

About

Solving the famous game "Tetris" using Multi-Threading and OOP in Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages