function Game(board){
  this.board = board || '0000202000000000';
}

function get2Or4(){
  var choice = Math.round(Math.random());
  if (choice === 0)
    return 2;
  else return 4;
}

function getRandom0_15(){
  return Math.random() * 15;
}

Game.prototype.toString = function(){
  var finalString = this.board.substr(0,4) + "\n" +
                    this.board.substr(4,4) + "\n" +
                    this.board.substr(8,4) + "\n" +
                    this.board.substr(12,4)

  return finalString;
}

Game.prototype.moveLeft = function(){
  this.moveRowLeft(0); //move row 1 left
  this.moveRowLeft(1); //move row 2 left
  this.moveRowLeft(2); //move row 3 left
  this.moveRowLeft(3); //move row 4 left

}

Game.prototype.moveRowLeft = function(row){
  var currentRow = this.gameArray[row];


}

function collapseLeft(array, colNumber){ //recursive collapse.
  if(colNumber === 0){
    return array;
  }

  //-------------------- fix col 1.
  else if(colNumber === 1){
    if(array[0] === 0){
      a[0] = a[1];
      a[1] = 0;
    }
    else if(array[0] === array[1]){
      a[0] = a[0] + a[1];
      a[1] = 0;
    }
    else { //do nothing

    }
    return collapseLeft(array, 0);
  }

  //------------------------- fix col 2.
  else if(colNumber === 1){
    if(array[1] === 0){
      a[1] = a[2];
      a[2] = 0;
      return collapseLeft(array, 1);
    }
    else if(array[1] === array[2]){
      a[1] = a[1] + a[2];
      a[2] = 0;
      return collapseLeft(array, 1);
    }
    else { //do nothing

    }
    return collapseLeft(array, 1);
  }
  //--------------------- fix col 3 .
  else if(colNumber === 1){
    if(array[0] === 0){
      a[0] = a[1];
      a[1] = 0;
    }
    else if(array[0] === array[1]){
      a[0] = a[0] + a[1];
      a[1] = 0;
    }
    else { //do nothing

    }
    return collapseLeft(array, 2);
  }
}

@@ -920,32 +920,38 @@
 ----------------
+------
  fix col 1.%0A  el
@@ -1169,30 +1169,13 @@
 urn 
-collapseLeft(
 array
-, 0)
 ;%0A  
@@ -1485,39 +1485,34 @@
  %7B //do nothing%0A
-%0A
   
-  %7D%0A
     return colla
@@ -1506,39 +1506,28 @@
  return 
-collapseLeft(array, 1);
+array;%0A    %7D
 %0A  %7D%0A  /
@@ -1577,33 +1577,33 @@
 f(colNumber === 
-1
+2
 )%7B%0A    if(array%5B
@@ -1594,33 +1594,33 @@
 )%7B%0A    if(array%5B
-0
+2
 %5D === 0)%7B%0A      
@@ -1617,32 +1617,32 @@
 0)%7B%0A      a%5B
-0
+2
 %5D = a%5B
-1
+3
 %5D;%0A      a%5B1
@@ -1636,32 +1636,69 @@
 3%5D;%0A      a%5B
-1
+3
 %5D = 0;%0A
+      return collapseLeft(array, 2);%0A
     %7D%0A    el
@@ -1701,33 +1701,33 @@
   else if(array%5B
-0
+2
 %5D === array%5B1%5D)%7B
@@ -1714,33 +1714,33 @@
 ay%5B2%5D === array%5B
-1
+3
 %5D)%7B%0A      a%5B0%5D =
@@ -1731,39 +1731,39 @@
 %5D)%7B%0A      a%5B
-0
+2
 %5D = a%5B
-0
+2
 %5D + a%5B
-1
+3
 %5D;%0A      a%5B1
@@ -1757,32 +1757,69 @@
 3%5D;%0A      a%5B
-1
+3
 %5D = 0;%0A
+      return collapseLeft(array, 2);%0A
     %7D%0A    el
@@ -1828,39 +1828,34 @@
  %7B //do nothing%0A
-%0A
   
-  %7D%0A
     return colla
@@ -1849,38 +1849,27 @@
  return 
-collapseLeft(array, 2);
+array;%0A    %7D
 %0A  %7D%0A%7D%0A

write very basic logic. not tested yet