function sequenceDetonations(first) {
  if (first) {
    sequenceDetonations.lastX = NaN;
    sequenceDetonations.lastY = NaN;
    if (inputMode !== inputModes.START) {
      inputMode = inputModes.BUSY;
    }
    setHoverClass(false);
  }
  var bestScore = -1;
  var bestX = NaN;
  var bestY = NaN;
  for (var x = 0; x < WIDTH; x++) {
    for (var y = 0; y < HEIGHT; y++) {
      if (liveField.getSquare(x, y).isOverloaded()) {
        var owner = liveField.getSquare(x, y).owner;
        var thisScore = Math.random();
        var neighbours = liveField.getNeighbours(x, y);
        for (var i = 0, neighbour; (neighbour = neighbours[i]); i++) {
          if (neighbour.bombs !== 0 && neighbour.owner !== owner) {
            thisScore += 2;
          }
        }
        if (x === sequenceDetonations.lastX &&
            (y === sequenceDetonations.lastY - 1 || y === sequenceDetonations.lastY + 1)) {
          thisScore++;
        }
        if (y === sequenceDetonations.lastY &&
            (x === sequenceDetonations.lastX - 1 || x === sequenceDetonations.lastX + 1)) {
          thisScore++;
        }
        if (thisScore > bestScore) {
          bestScore = thisScore;
          bestX = x;
          bestY = y;
        }
      }
    }
  }
  sequenceDetonations.lastX = bestX;
  sequenceDetonations.lastY = bestY;
  if (bestScore > -1) {
    detonateWithGraphics(bestX, bestY);
  } else {
    startNextTurn();
  }
}
// Yes, this is overly picky, but the player spends a lot of time watching this.
Yes, this is overly picky, but the player spends a lot of time watching this.
Yes this is overly picky but the player spends a lot of time watching this .
function sequenceDetonations(first) {
  if (first) {
    sequenceDetonations.lastX = NaN;
    sequenceDetonations.lastY = NaN;
    if (inputMode !== inputModes.START) {
      inputMode = inputModes.BUSY;
    }
    setHoverClass(false);
  }
  var bestScore = -1;
  var bestX = NaN;
  var bestY = NaN;
  for (var x = 0; x < WIDTH; x++) {
    for (var y = 0; y < HEIGHT; y++) {
      if (liveField.getSquare(x, y).isOverloaded()) {
        var owner = liveField.getSquare(x, y).owner;
        var thisScore = Math.random();
        var neighbours = liveField.getNeighbours(x, y);
        for (var i = 0, neighbour; (neighbour = neighbours[i]); i++) {
          if (neighbour.bombs !== 0 && neighbour.owner !== owner) {
            thisScore += 2;
          }
        }
        if (x === sequenceDetonations.lastX &&
            (y === sequenceDetonations.lastY - 1 || y === sequenceDetonations.lastY + 1)) {
          thisScore++;
        }
        if (y === sequenceDetonations.lastY &&
            (x === sequenceDetonations.lastX - 1 || x === sequenceDetonations.lastX + 1)) {
          thisScore++;
        }
        if (thisScore > bestScore) {
          bestScore = thisScore;
          bestX = x;
          bestY = y;
        }
      }
    }
  }
  sequenceDetonations.lastX = bestX;
  sequenceDetonations.lastY = bestY;
  if (bestScore > -1) {
    detonateWithGraphics(bestX, bestY);
  } else {
    startNextTurn();
  }
}
function sequenceDetonations ( first ) { if ( first ) { sequenceDetonations . lastX = NaN ; sequenceDetonations . lastY = NaN ; if ( inputMode !== inputModes . START ) { inputMode = inputModes . BUSY ; } setHoverClass ( false ) ; } var bestScore = - 1 ; var bestX = NaN ; var bestY = NaN ; for ( var x = 0 ; x < WIDTH ; x ++ ) { for ( var y = 0 ; y < HEIGHT ; y ++ ) { if ( liveField . getSquare ( x , y ) . isOverloaded ( ) ) { var owner = liveField . getSquare ( x , y ) . owner ; var thisScore = Math . random ( ) ; var neighbours = liveField . getNeighbours ( x , y ) ; for ( var i = 0 , neighbour ; ( neighbour = neighbours [ i ] ) ; i ++ ) { if ( neighbour . bombs !== 0 && neighbour . owner !== owner ) { thisScore += 2 ; } } if ( x === sequenceDetonations . lastX && ( y === sequenceDetonations . lastY - 1 || y === sequenceDetonations . lastY + 1 ) ) { thisScore ++ ; } if ( y === sequenceDetonations . lastY && ( x === sequenceDetonations . lastX - 1 || x === sequenceDetonations . lastX + 1 ) ) { thisScore ++ ; } if ( thisScore > bestScore ) { bestScore = thisScore ; bestX = x ; bestY = y ; } } } } sequenceDetonations . lastX = bestX ; sequenceDetonations . lastY = bestY ; if ( bestScore > - 1 ) { detonateWithGraphics ( bestX , bestY ) ; } else { startNextTurn ( ) ; } }
Yes, this is overly picky, but the player spends a lot of time watching this.
Yes this is overly picky but the player spends a lot of time watching this .