 
     switch(dir) {
         case UP:
-            // TODO
+            for (int j = 0; j <= 3; j++) {
+                for (int i = 0; i <= 3; i++) {
+                    if (i == 0) {
+                        continue;
+                    }
+                    movedAnythingYet = attemptTileMove(i, j, i - 1, j) || movedAnythingYet;
+                }
+            }
         break;
 
         case RIGHT:
-            // TODO
+            for (int i = 0; i <= 3; i++) {
+                for (int j = 3; j >= 0; j--) {
+                    if (j == 3) {
+                        continue;
+                    }
+                    movedAnythingYet = attemptTileMove(i, j, i, j + 1) || movedAnythingYet;
+                }
+            }
         break;
 
         case DOWN:
-            // TODO
+            for (int j = 0; j <= 3; j++) {
+                for (int i = 3; i >= 0; i--) {
+                    if (i == 3) {
+                        continue;
+                    }
+                    movedAnythingYet = attemptTileMove(i, j, i + 1, j) || movedAnythingYet;
+                }
+            }
         break;
 
         case LEFT:
-            for (int i = 0; i < 4; i++) {
-                for (int j = 0; j < 4; j++) {
+            for (int i = 0; i <= 3; i++) {
+                for (int j = 0; j <= 3; j++) {
                     if (j == 0) {
                         continue;
                     }
-
                     movedAnythingYet = attemptTileMove(i, j, i, j - 1) || movedAnythingYet;
                 }
             }

        return false;
    }

    // Otherwise, it was valid, so add a new tile
    // TODO

    return true;
}

boolean gameInProgress = false;
boolean buttonPressed = false;

// Pins for inputs (push buttons)
const int UP_PIN = A0;
const int RIGHT_PIN = A1;
const int DOWN_PIN = A2;
const int LEFT_PIN = A3;

// Pins for outputs (shift registers / LEDs)
const int LATCH_PIN = 8; // green
const int CLOCK_PIN = 12; // yellow
const int DATA_PIN = 11; // blue

/* Initializes all connections and creates a new game. */
void setup() {
    // Initialize serial
    Serial.begin(9600);

    // Initialize inputs (push buttons) and outputs (shift registers and LEDs)
    pinMode(UP_PIN, INPUT);
    pinMode(RIGHT_PIN, INPUT);
    pinMode(DOWN_PIN, INPUT);
    pinMode(LEFT_PIN, INPUT);

    pinMode(LATCH_PIN, OUTPUT);
    pinMode(CLOCK_PIN, OUTPUT);
    pinMode(DATA_PIN, OUTPUT);

    // Seed the PRNG with the read from an unconnected pin
    randomSeed(analogRead(A4));

    // Begin game
    newGame();
