function findEnd(startX, startY) {
  var end = null;
  var endSteps = 0;
  var visited = new Set();
  var queue = new Map();
  queue.set(startX + ' ' + startY, 0);
  while (queue.size) {
    var xys_ = queue.entries().next().value;
    var xy = xys_[0];
    var steps = Number(xys_[1]) + 1;
    queue.delete(xy);
    if (visited.has(xy)) {
      continue;
    }
    visited.add(xy);
    var xy_ = xy.split(' ');
    var x = Number(xy_[0]);
    var y = Number(xy_[1]);
    if (isWall(x, y, true)) {
      continue;
    }
    if (steps > endSteps) {
      end = {x: x, y: y};
      endSteps = steps;
    }
    queue.set((x + 1) + ' ' + y, steps);
    queue.set((x - 1) + ' ' + y, steps);
    queue.set(x + ' ' + (y + 1), steps);
    queue.set(x + ' ' + (y - 1), steps);
  }
  return end;
}
// Spider the maze to find the furthest point from the provided start point.
Spider the maze to find the furthest point from the provided start point.
Spider the maze to find the furthest point from the provided start point .
function findEnd(startX, startY) {
  var end = null;
  var endSteps = 0;
  var visited = new Set();
  var queue = new Map();
  queue.set(startX + ' ' + startY, 0);
  while (queue.size) {
    var xys_ = queue.entries().next().value;
    var xy = xys_[0];
    var steps = Number(xys_[1]) + 1;
    queue.delete(xy);
    if (visited.has(xy)) {
      continue;
    }
    visited.add(xy);
    var xy_ = xy.split(' ');
    var x = Number(xy_[0]);
    var y = Number(xy_[1]);
    if (isWall(x, y, true)) {
      continue;
    }
    if (steps > endSteps) {
      end = {x: x, y: y};
      endSteps = steps;
    }
    queue.set((x + 1) + ' ' + y, steps);
    queue.set((x - 1) + ' ' + y, steps);
    queue.set(x + ' ' + (y + 1), steps);
    queue.set(x + ' ' + (y - 1), steps);
  }
  return end;
}
function findEnd ( startX , startY ) { var end = null ; var endSteps = 0 ; var visited = new Set ( ) ; var queue = new Map ( ) ; queue . set ( startX + ' ' + startY , 0 ) ; while ( queue . size ) { var xys_ = queue . entries ( ) . next ( ) . value ; var xy = xys_ [ 0 ] ; var steps = Number ( xys_ [ 1 ] ) + 1 ; queue . delete ( xy ) ; if ( visited . has ( xy ) ) { continue ; } visited . add ( xy ) ; var xy_ = xy . split ( ' ' ) ; var x = Number ( xy_ [ 0 ] ) ; var y = Number ( xy_ [ 1 ] ) ; if ( isWall ( x , y , true ) ) { continue ; } if ( steps > endSteps ) { end = { x : x , y : y } ; endSteps = steps ; } queue . set ( ( x + 1 ) + ' ' + y , steps ) ; queue . set ( ( x - 1 ) + ' ' + y , steps ) ; queue . set ( x + ' ' + ( y + 1 ) , steps ) ; queue . set ( x + ' ' + ( y - 1 ) , steps ) ; } return end ; }
Spider the maze to find the furthest point from the provided start point.
Spider the maze to find the furthest point from the provided start point .