2023-07-01 11:58:00 -04:00
;Task:
Implement a 2D sliding block puzzle game where blocks with numbers are combined to add their values.
;Rules of the game:
:* The rules are that on each turn the player must choose a direction (up, down, left or right).
:* All tiles move as far as possible in that direction, some move more than others.
:* Two adjacent tiles (in that direction only) with matching numbers combine into one bearing the sum of those numbers.
2023-12-16 21:33:55 -08:00
:* A move is valid when at least one tile can be moved, including by combination.
:* A new tile is spawned at the end of each turn at a randomly chosen empty square (if there is one).
:* Most of the time, a new '''2''' is to be added, but occasionally ('''10%''' of the time), a '''4'''.
:* To win, the player must create a tile with the number '''2048'''.
2023-07-01 11:58:00 -04:00
:* The player loses if no valid moves are possible.
The name comes from the popular open-source implementation of this game mechanic, [https://gabrielecirulli.github.io/2048/ 2048].
;Requirements:
2023-12-16 21:33:55 -08:00
* "Non-greedy" movement.<br> The tiles that were created by combining other tiles should not be combined again during the same turn (move).<br> That is to say, that moving the tile row of:
2023-07-01 11:58:00 -04:00
<big><big> [2][2][2][2] </big></big>
:: to the right should result in:
<big><big> ......[4][4] </big></big>
:: and not:
<big><big> .........[8] </big></big>
2023-12-16 21:33:55 -08:00
* "Move direction priority".<br> If more than one variant of combining is possible, move direction shall indicate which combination will take effect. <br> For example, moving the tile row of:
2023-07-01 11:58:00 -04:00
<big><big> ...[2][2][2] </big></big>
:: to the right should result in:
<big><big> ......[2][4] </big></big>
:: and not:
<big><big> ......[4][2] </big></big>
2023-12-16 21:33:55 -08:00
* Check for valid moves. The player shouldn't be able to gain new tile by trying a move that doesn't change the board.
* Check for a win condition.
2023-07-01 11:58:00 -04:00
* Check for a lose condition.
<br><br>