Skip to content

matei1608/2048

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Creator: Matei-Cristian Lazarescu
The implementation of the game took about 15 hours.

To start the game, you need to open a new linux terminal inside the directory
and write the commands: "make", and "make run". The Game Menu will appear.

How I implemented the Game:

In the main function, I call the meniu_principal function. This function 
generates a menu with three options: New Game, Resume, and Quit. 
If I select New Game, a new game starts, during which I generate two random 
numbers at two random positions. If I press the down arrow, the program 
makes a move downwards; if I press the up arrow, the program moves upwards; 
if I press the right arrow, the program moves to the right; 
and if I press the left arrow, the program moves to the left.

I have a function that continuously checks if the game has been lost 
(I verify this using copies that simulate the moves and then check if the 
simulated moves are identical to the initial state). I also have a function 
that checks if the game has been won (if the value 2048 has been achieved).

Using variables that keep track of the last input time, an automatic move 
occurs every 30 seconds after the last command (the most efficient move 
considering the remaining free spaces). If I press "q", the program pauses 
the game and calls the meniu_principal function, which creates the main menu. 
At this point, if I select Resume, the game starts from where it was paused. 
If I select New Game, the matrix that holds the values from the board is 
reinitialized to 0, and a new game begins.

About

Developed a version of the 2048 game in C, featuring an auto-mover that analyzes all possible moves and selects the optimal one in under 0.1 seconds.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors