var Board = function(args) {
  this.board = START_BOARD.map(function(row) {
    return row.split("");
  });
}
Board.prototype.getAdjacentTiles = function(args) {
  var x = Math.floor(args.x / 8);
  var y = Math.floor(args.y / 8) - 3;
  return {
    up: {y: y - 1, x: x},
    down: {y: y + 1, x: x},
    left: {y: y, x: x - 1},
    right: {y: y, x: x + 1}
  }
};
Board.prototype.getEmptyTiles = function(tiles) {
  var emptyTiles = new Object;
  for(var prop in tiles) {
    if(tiles[prop] && tiles.hasOwnProperty(prop)) {
      var x = tiles[prop].x;
      var y = tiles[prop].y;
      var currentTile = this.board[y][x];
      if(currentTile != "x" && currentTile != "-") {
        emptyTiles[prop] = tiles[prop];
      }
    }
  }
  return emptyTiles;
};
Board.prototype.getTileDistance = function(tile1, tile2) {
  var width = tile1.x + tile2.x;
  var height = tile1.y + tile2.y;

  return Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
};

@@ -938,12 +938,576 @@
 ht, 2));%0A%7D;%0A
+Board.prototype.getClosestTile = function(args) %7B%0A  var tiles = args.tiles;%0A  var target = %7B%0A    x: Math.floor(args.target.x / 8),%0A    y: Math.floor(args.target.y / 8) - 3%0A  %7D%0A  var closestTile;%0A  for(var prop in tiles) %7B%0A    if(tiles.hasOwnProperty(prop)) %7B%0A      var currentDistance = this.getTileDistance(target, tiles%5Bprop%5D);%0A      if(closestTile) %7B%0A        closestTile = currentDistance %3C this.getTileDistance(target, closestTile) ? tiles%5Bprop%5D : closestTile;%0A      %7D%0A      else %7B%0A        closestTile = tiles%5Bprop%5D;%0A      %7D%0A    %7D%0A  %7D%0A  return closestTile;%0A%7D;%0A

Add getClosestTile to Board