This is an implementation of the 2048 game in Racket, a dialect of Lisp. Feel free to play around!
- Racket (Make sure Racket is installed on your system)
- Clone the repository:
git clone https://github.com/yourusername/2048-racket.git
- Navigate to the project directory:
cd 2048-racket
- Run the game:
racket main.rkt
- Use the command line to input your moves:
w
: Move tiles upa
: Move tiles lefts
: Move tiles downd
: Move tiles right
- The game will print the board and your score after each move.
- Combine tiles of the same number to create larger numbers.
- The game ends when no more moves are possible.
append
: Appends two lists.reverse
: Reverses a list.len
: Returns the length of a list.index
: Retrieves an element at a specified index in a list.flatten
: Flattens a 2D board into a 1D list.unflatten
: Converts a 1D list back into a 2D board.game-over
: Prints the game over message and the score.print
: Prints the current state of the board and the score.new-num
: Adds a new number (2) to a random empty spot on the board.player-move
: Handles the player's move, combines tiles, and updates the board and score.main
: The main game loop that initializes the board, handles moves, and checks for game over conditions.