Skip to content

mobahug/Fillit_42

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Not Tetris, but space optimization algorithm

HOW IT WORKS?

First, the program reads each tetromino from its given file, and during the reading, process checking is it a valid piece or not. If it's not, then the program outputting error. After the valid piece gets its shape and with all the data transforming each piece to alphabetical characters and recursive backtracking way solving the task; to get the smallest square from it. (Place the pieces that between them are not at all/or just a small gap in the shortest amount of time.) (You can find comments as well with small explanations in the codes.)

The reader.c file:

• Checking for '#' connections and counting them (must be 6 or 8)

• Checking is it a valid character ('.' and/or '#')

• Checking is end of line '\n'

• Checking the lines length

The encode.c file:

• Bitwise mode shifting the bits to their shape

• Measuring each individual tetrominoes width and height

• Adding these data to the final function what we call in reader functions

The solve.c file:

• Using recursive backtracking to check all possibilities for each tetromino and get place them on the map

• For optimization purposes important that the solving part don't do unnecessary computing except what it's made for

The printer.c file:

• Adding to the board with shifting bitwise operators the tetrominoes

• Allocating for the board memory and printing them out

Valid tetriminos:

Screen Shot 2022-01-17 at 10 10 07 AM

Maximum valid grids: 26

According to the English alphabet.

To execute in default the program, just enter:

make

After compiling type:

./fillit <valid_file.fillit>

You can also use the time argument to check how fast solving the algorithm the task:

time ./fillit <valid_file.fillit>

Screen Shot 2022-01-17 at 8 55 13 AM

If you want to get the result in a colourful version just enter:

make color

To remove it:

make fclean_color

The purpose of this was, to see better each tetromino, and to be accepted by the 42 school project checker AI, had to modify the Makefile and split into two-part, so by default the result will be black and white, but available the colourful version as well.

Screen Shot 2022-01-17 at 8 58 07 AM

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published