<commit_before>function createPlayer(name){
  var player = {}
  player.status = 'alive';
  player.name = name;
  player.vision = '2';
  player.speed = '1';
  player.apples = 0;
  player.path = process.cwd()+'/programs/'+name;

  player.move = function(action){
    var newCoords = [];
    if (action.raw[1] == 'left')  { newCoords = [this.row, this.col-this.speed]; }
    else if (action.raw[1] == 'up')    { newCoords = [this.row-this.speed, this.col]; }
    else if (action.raw[1] == 'right') { newCoords = [this.row, this.col+this.speed]; }
    else if (action.raw[1] == 'down')  { newCoords = [this.row+this.speed, this.col]; }
    return newCoords;
  }

  player.getPosition = function(){
    return [this.row, this.col];
  }

  player.hasEnoughApples = function(myAction, otherAction){
    if (myAction.raw[0] === 'steal' && otherAction.raw[0] === 'steal'){
      if (this.apples > 1){ return true; }
      else{ return false; }
    }
    else if (myAction.raw[0] === 'share' && otherAction.raw[0] === 'steal'){
      if (this.apples > 8){ return true; }
      else{ return false; }
    }
    else{ return true; }
  }

  player.canSee = function(gameObjName){
    var filteredMyWorld = this.myWorld.filter(function(gameObj){
      if (gameObj === gameObjName){
        return true;
      }else{ return false; }
    });
    if (filteredMyWorld[0] === gameObjName){
      return true;
    }else{
      return false;
    }
  }

  player.toString = function(){
    var representation = {};
    representation.status = player.status;
    representation.name = name;
    representation.vision = '2';
    representation.speed = '1';
    representation.apples = 0;
    representation.row = this.row;
    representation.col = this.col;
    representation.myWorld = this.myWorld;
    return JSON.stringify(representation);    
  }

  return player;
}

module.exports = createPlayer;<commit_msg>patch: better JSON stdin input by not nesting JSON objects<commit_after>function createPlayer(name){
  var player = {}
  player.status = 'alive';
  player.name = name;
  player.vision = '2';
  player.speed = '1';
  player.apples = 0;
  player.path = process.cwd()+'/programs/'+name;

  player.move = function(action){
    var newCoords = [];
    if (action.raw[1] == 'left')  { newCoords = [this.row, this.col-this.speed]; }
    else if (action.raw[1] == 'up')    { newCoords = [this.row-this.speed, this.col]; }
    else if (action.raw[1] == 'right') { newCoords = [this.row, this.col+this.speed]; }
    else if (action.raw[1] == 'down')  { newCoords = [this.row+this.speed, this.col]; }
    return newCoords;
  }

  player.getPosition = function(){
    return [this.row, this.col];
  }

  player.hasEnoughApples = function(myAction, otherAction){
    if (myAction.raw[0] === 'steal' && otherAction.raw[0] === 'steal'){
      if (this.apples > 1){ return true; }
      else{ return false; }
    }
    else if (myAction.raw[0] === 'share' && otherAction.raw[0] === 'steal'){
      if (this.apples > 8){ return true; }
      else{ return false; }
    }
    else{ return true; }
  }

  player.canSee = function(gameObjName){
    var filteredMyWorld = this.myWorld.filter(function(gameObj){
      if (gameObj === gameObjName){
        return true;
      }else{ return false; }
    });
    if (filteredMyWorld[0] === gameObjName){
      return true;
    }else{
      return false;
    }
  }

  player.toString = function(){
    var representation = {};
    representation.status = player.status;
    representation.name = name;
    representation.vision = '2';
    representation.speed = '1';
    representation.apples = 0;
    representation.row = this.row;
    representation.col = this.col;
    representation.myWorld = this.myWorld;
    return representation;    
  }

  return player;
}

module.exports = createPlayer;
{'fraction_non_alphanumeric': 0.16224730900498818, 'fraction_numerical': 0.008926227356261486, 'mean_word_length': 2.981191222570533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7268117', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1268, 'n_words': 276}