<commit_before>$(document).ready(function() {
  // This is called after the document has loaded in its entirety
  // This guarantees that any elements we bind to will exist on the page
  // when we try to bind to them

  // See: http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
});

******************DID SOME STUFF CHECK IT OUT - BEN***************************

var Game = function(){

  this.player1 = new Player();
  this.player2 = new Player();

  this.connectFour = [];

// this.players = [player1, player2];

this.board = {
c1:{'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
c2: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
c3: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
c4: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
c5: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
c6: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
c7: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''}
  };
};

// possible solution for diagonal wins

// for (var col = 7; col > 0; col--){
//     for (var row = 6; row > 0;row--){
//       if(this.board['c' + col][row] == 'r'){
//          this.connectFour.push('r')

//   }
// }
Game.prototype.checkColumn = function(column){
  if this.board
}


Game.prototype.placePiece = function(column, color){

  var i = 7
  while(i--){
    if (this.board[column][i] === ''){
      this.board[column][i] = color
      return;
    } else {
      console.log('column is full!')
    };
    };
  };
};

// Game.prototype.startGame = function(){
//   this.players =
// }

var Player = function(number) {
  this.enabled = false;
  this.column = '';
};


Game.prototype.startGame = function(){
  this.player1.enabled = true;
};

Game.prototype.makeMove = function(){

  if(this.player1.enabled === true){
    this.player1.column = 'c1'; // player chooses column
    this.placePiece(this.player1.column,'r');
    this.player1.enabled = false;
    this.player2.enabled = true;
    this.scanR('c1');
  }
  else if(this.player2.enabled === true){
    this.player2.column = 'c1'; // player chooses column
    this.placePiece(this.player2.column, 'r');
    this.player2.enabled = false;
    this.player1.enabled = true;
    this.scanB('c1');
  };
};

Game.prototype.scanR = function(column){
  // var i = 7;

  for (var i = 7; i > 0; i--){
   // while(i--)
    if (this.board[column][i] === 'r'){
      this.connectFour.push('r');
      this.checkWin();
    } else {
      this.connectFour = [];
      };
    };
};

Game.prototype.scanB = function(column){
  // while(i--)
  for (var i = 7; i > 0; i--){
    if (this.board[column][i] === 'r') {
      this.connectFour.push('r');
      this.checkWin();
    } else {
      this.connectFour = [];
      };
  };
};

Game.prototype.checkWin = function(){
  if(this.connectFour.length === 4){
    console.log("you win!")
  };
};


var game = new Game();
game.startGame();
game.makeMove();


// keys needed to match for consecutive red or black pieces

// 1234, 2345, 3456, 6543, 5432, 4321

// game.board.c1[1] = 'r';

// Game.prototype.checkSpace = function(column){
//   var i = 6
//   while(i--){
//     if (Board.column[i] === ''){

//     }
//   }
// }

// for(var col = 1; col < 8; col++){
//   for(var i = 1; i < 7; i++){
//     (c + 'col')['i'] = '';
//   }
// }

// console.dir(board)

<commit_msg>add JS model of connect4 minus diagonal win<commit_after>// $(document).ready(function() {
//   // This is called after the document has loaded in its entirety
//   // This guarantees that any elements we bind to will exist on the page
//   // when we try to bind to them

//   // See: http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
// });


var Player = function() {
  this.enabled = false;
  this.choiceColumn = null;
};


var Game = function(){

  this.player1 = new Player();
  this.player2 = new Player();

  this.columnConnectFour = [];
  this.rowConnectFour = [];

// this.players = [player1, player2];

  this.board = {
    c1: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
    c2: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
    c3: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
    c4: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
    c5: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
    c6: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''},
    c7: {'1': '', '2': '', '3': '', '4': '', '5': '', '6': ''}
  };
};

// possible solution for diagonal wins

// for (var col = 7; col > 0; col--){
//     for (var row = 6; row > 0;row--){
//       if(this.board['c' + col][row] == 'r'){
//          this.connectFour.push('r')

//   }
// }
// Game.prototype.checkColumn = function(column){
//   if this.board
// }


Game.prototype.placePiece = function(column, color){

  var piecesInColumn = 0;
  var row = 6 + 1; // offset by 1 to support while() loop

  while(row--){
    if (this.board[column][row] === ''){
      this.board[column][row] = color;
      return [column, row];

    } else {
      piecesInColumn++
      if (piecesInColumn === 6) {
        console.log('column is full!')
      }

    }
  }
}

// Game.prototype.startGame = function(){
//   this.players =
// }

Game.prototype.startGame = function(){
  this.player1.enabled = true;
};

Game.prototype.makeMove = function(){

  if(this.player1.enabled === true){
    // this.player1.choiceColumn = 'c1'; // player chooses column
    var position = this.placePiece(this.player1.choiceColumn,'r');
    this.player1.enabled = false;
    this.player2.enabled = true;
    this.scanColumnForR(this.player1.choiceColumn);
    this.scanRowForR(position[1]); // position[1] selects row
  }
  else if(this.player2.enabled === true){
    // this.player2.choiceColumn = 'c1'; // player chooses column
    var position = this.placePiece(this.player2.choiceColumn, 'b');
    this.player2.enabled = false;
    this.player1.enabled = true;
    this.scanColumnForB(this.player2.choiceColumn);
    this.scanRowForB(position[1]); // position[1] selects row
  };
};

Game.prototype.scanColumnForR = function(column){
  // var i = 7;

  for (var row = 6; row > 0; row--){
    if (this.board[column][row] === 'r'){
      this.columnConnectFour.push('r');
      this.checkWin();
    } else {
      this.columnConnectFour = [];
      };
  };
};

Game.prototype.scanColumnForB = function(column){
  for (var row = 6; row > 0; row--){
    if (this.board[column][row] === 'b') { // change to 'b'
      this.columnConnectFour.push('b');
      this.checkWin();
    } else {
      this.columnConnectFour = [];
      };
  };
};

Game.prototype.scanRowForR = function(row){

  for (var columnNumber = 7; columnNumber > 0; columnNumber--){
    if (this.board['c' + columnNumber][row] === 'r') { // change to 'b'
      this.rowConnectFour.push('r');
      this.checkWin();
    } else {
      this.rowConnectFour = [];
    };
  };
};

Game.prototype.scanRowForB = function(row){

  for (var columnNumber = 7; columnNumber > 0; columnNumber--){

    if (this.board['c' + columnNumber][row] === 'b') { // change to 'b'
      this.rowConnectFour.push('b');
      this.checkWin();
    } else {
      this.rowConnectFour = [];
      };
  };
};




Game.prototype.checkWin = function(){
  if(this.columnConnectFour.length === 4 || this.rowConnectFour.length === 4){
    console.log("you win!");
  };
};


var game = new Game();

game.startGame();

game.player1.choiceColumn = 'c1';
game.makeMove();

game.player2.choiceColumn = 'c6';
game.makeMove();

game.player1.choiceColumn = 'c2';
game.makeMove();

game.player2.choiceColumn = 'c6';
game.makeMove();

game.player1.choiceColumn = 'c3';
game.makeMove();

game.player2.choiceColumn = 'c5';
game.makeMove();

game.player1.choiceColumn = 'c4';
game.makeMove();

// game.player1.choiceColumn = 'c4';
// game.makeMove();

// game.player2.choiceColumn = 'c5';
// game.makeMove();


// keys needed to match for consecutive red or black pieces

// 1234, 2345, 3456, 6543, 5432, 4321

// game.board.c1[1] = 'r';

// Game.prototype.checkSpace = function(column){
//   var i = 6
//   while(i--){
//     if (Board.column[i] === ''){

//     }
//   }
// }

// for(var col = 1; col < 8; col++){
//   for(var i = 1; i < 7; i++){
//     (c + 'col')['i'] = '';
//   }
// }

// console.dir(board)


{'fraction_non_alphanumeric': 0.24338688247372872, 'fraction_numerical': 0.030438458751056892, 'mean_word_length': 2.72972972972973, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '1259319', 'n_tokens_mistral': 3121, 'n_tokens_neox': 2978, 'n_words': 658}