<commit_before>function OpenCoordinates(canvasWidth, canvasHeight) {
  this.canvasWidth  = canvasWidth,
  this.canvasHeight = canvasHeight
}

OpenCoordinates.prototype = {
  create: function(players){
    var newCoords =  { x: Math.floor(Math.random() * (this.canvasWidth - 10) + 5),
                       y: Math.floor(Math.random() * (this.canvasHeight - 10) + 5) };
    var isNotInsidePlayer = false;
    var canWidth = this.canvasWidth;
    var canHeight = this.canvasHeight;

    function checkPlayer(player){
      var xDiff = newCoords.x - player.x;
      var yDiff = newCoords.y - player.y;
      var distance = Math.sqrt( xDiff*xDiff + yDiff*yDiff);
      return distance > (player.mass + 20);
    }

    while(!isNotInsidePlayer){
      isNotInsidePlayer = players.every(checkPlayer);
      if (!isNotInsidePlayer){
        newCoords =  { x: Math.floor(Math.random() * (canWidth - 10) + 5),
                       y: Math.floor(Math.random() * (canHeight - 10) + 5) };
      }
    }
    return newCoords;
  }
};

module.exports = OpenCoordinates;
<commit_msg>refactor check for spawning food outside of players<commit_after>function OpenCoordinates(canvasWidth, canvasHeight) {
  this.canvasWidth  = canvasWidth,
  this.canvasHeight = canvasHeight
}

OpenCoordinates.prototype = {
  create: function(players){
    var newCoords =  { x: Math.floor(Math.random() * (this.canvasWidth - 10) + 5),
                       y: Math.floor(Math.random() * (this.canvasHeight - 10) + 5) };
    var isNotInsidePlayer = false;
    var canWidth = this.canvasWidth;
    var canHeight = this.canvasHeight;

    function checkPlayer(player){
      var xDiff = newCoords.x - player.x;
      var yDiff = newCoords.y - player.y;
      var distance = Math.sqrt( xDiff*xDiff + yDiff*yDiff);
      return distance > (player.mass + 20);
    }

    // while(!isNotInsidePlayer){
    //   isNotInsidePlayer = players.every(checkPlayer);
    //   if (!isNotInsidePlayer){
    //     newCoords =  { x: Math.floor(Math.random() * (canWidth - 10) + 5),
    //                    y: Math.floor(Math.random() * (canHeight - 10) + 5) };
    //   }
    // }

    while(!isNotInsidePlayer){
      newCoords =  { x: Math.floor(Math.random() * (canWidth - 10) + 5),
                     y: Math.floor(Math.random() * (canHeight - 10) + 5) };
      isNotInsidePlayer = players.every(checkPlayer);
    }
    return newCoords;
  }
};

module.exports = OpenCoordinates;

{'fraction_non_alphanumeric': 0.13483606557377048, 'fraction_numerical': 0.013934426229508197, 'mean_word_length': 2.5897058823529413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2096354', 'n_tokens_mistral': 825, 'n_tokens_neox': 770, 'n_words': 161}