 generateTile = (board) ->
   value = randomValue()
   [row, column] = randomCellIndicies()
-  console.log "Tile location: #{row} | #{column}"
   if board[row][column] is 0
     board[row][column] = value
   else

  for row in [0..3]
    for col in [0..3]
      $(".r#{row}.c#{col} > div").html(board[row][col])
  console.log "show board"

printArray = (array) ->
  console.log "--- Start ---"

    console.log row
  console.log "--- End ---"


move = (board, direction) ->
  for i in [0..3]
    if direction == 'right' or  'left'
      row = getRow(i, board)
      row = mergeCells(row, direction)
      row = collapseCells(row, direction)
      console.log row

getRow = (r, board) ->
  [board[r][0], board[r][1], board[r][2], board[r][3]]

mergeCells = (row, direction) ->

  if direction is 'right'
    for a in [3...0]
      for b in [a-1..0]

        if row[a] is 0 then break
        else if row[a] == row[b]
