Prog 6: 1024 Linked List

Modify your solution (or mine) to your solution to Program #5, this time storing every move using a linked list.  Entering 'u' indicates the user would like to undo the previously made move.  Use the linked list to allow undoing moves, back to the beginning of the game.  Attempting undo at the beginning of the game should give an error message and allow the user to retry making a move.

For example, running your program should look like:

Dale Reed

UIC CS 141, Spring 2014

Welcome to 1024 and More.

This program is based off of Gabriele Cirulli's game online at

    bit.ly/great2048

For each move enter a direction as a letter key, as follows:

    W

  A S D

where A=left,W=up, D=right and S=down.

After a move, when two identical valued tiles come together they 

join to become a new single tile with the value of the sum of the 

two originals. This value gets added to the score.  On each move 

one new randomly chosen value of 2 or 4 is placed in a random open 

square.  User input of r restarts the game, and x exits the game.

Enter the size board you want, between 4 and 12: 4

Game ends when you reach 1024. 

Score: 0

   .   .   .   .

   2   .   .   .

   .   .   2   .

   .   .   .   .

1. Your move: u

*** You cannot undo at the beginning of the game. Retry.

1. Your move: a

Score: 0

   .   .   4   .

   2   .   .   .

   2   .   .   .

   .   .   .   .

2. Your move: s

Score: 4

   .   .   .   .

   .   .   .   .

   .   2   .   .

   4   .   4   .

3. Your move: u

Score: 0

   .   .   4   .

   2   .   .   .

   2   .   .   .

   .   .   .   .

2. Your move: u

Score: 0

   .   .   .   .

   2   .   .   .

   .   .   2   .

   .   .   .   .

1. Your move: w

Score: 0

   2   .   2   .

   2   .   .   .

   .   .   .   .

   .   .   .   .

2. Your move: w

Score: 4

   4   .   2   .

   .   .   .   .

   .   2   .   .

   .   .   .   .

3. Your move: 

 

.

.

.

Your program should free up any memory that is deleted from the list.