   true
 
 noValidMove = (board) ->
-  direction = 'right' #FIXME: Handle other directions
   newBoard = move(board, direction)
   if moveIsValid(board, newBoard)
     return false

setRow = (row, index, board) ->
  board[index] = row

mergeCells = (row, direction) ->

  merge = (row) ->
    for a in [3...0]
      for b in [a-1..0]

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

  if direction is 'right'
    merge row
  else if direction is 'left'
    merge(row.reverse()).reverse()

collapseCells = (row, direction) ->
  row = row.filter (ele) -> ele isnt 0
  if direction is 'right'
    while row.length < 4
      row.unshift 0
  else if direction is 'left'
    while row.length < 4
      row.push 0
  row

moveIsValid = (originalBoard, newBoard) ->
  for row in [0..3]

        else
          # show board
          showBoard(@board)
      else
        console.log "Invalid"

