<commit_before>(function(globals){
// Don't worry if that seems a little funky...

  /**
   * Internal representation of the game board in its current state.
   *
   * @see game.board
   * @see game.tracer
   * @see initial
   * @var {Array} of {Array} of {String|null}
   */
  var board = initial(); // initialize the `board`

  /**
   * List of moves for the "Catalan Opening: Closed Variation" suitable for use
   * as arguments to `applyMove` below.
   *
   * @see applyMove
   * @var {Array} of...?
   */
  var moves = [
    // {from: {rank: 6, file: 3},
    // to: {rank: 4, file: 3}},
    // {from: {rank: 0, file: 6},
    // to: {rank: 2, file: 5}},
    // {from: {rank: 6, file: 2},
    // to: {rank: 4, file: 2}},
    // {from: {rank: 1, file: 4},
    // to: {rank: 2, file: 4}},
    // {from: {rank: 6, file: 6},
    // to: {rank: 5, file: 6}},
    // {from: {rank: 1, file: 3},
    // to: {rank: 3, file: 3}},
    // {from: {rank: 7, file: 5},
    // to: {rank: 6, file: 6}},
    // {from: {rank: 0, file: 5},
    // to: {rank: 1, file: 4}},
    // {from: {rank: 7, file: 6},
    // to: {rank: 5, file: 5}}
    [6, 3, 4, 3],
    [0, 6, 2, 5],
    [6, 2, 4, 2],
    [1, 4, 2, 4],
    [6, 6, 5, 6],
    [1, 3, 3, 3],
    [7, 5, 6, 6],
    [0, 5, 1, 4],
    [7, 6, 5, 5]

    // TODO: Fill me in!
  ]; // END moves

  // Created var to keep track of moves
  var cmCounter = 0;
  // var current; TODO: do we need this?

  // You don't need to understand `globals` yet...
  var game = globals.game = {
    /**
     * Provide a _copy_ of the game board in order to update the View from it
     *
     * @return {Array} of {Array} of {String|null}
     */
    board: function(){
      return board.map(function(row){
        return row.slice();
      });
    },
    /**
     * Reset the internal game board to it's initial state.
     *
     * @return {Object} the game object for Method Chaining
     */
    reset: function(){
      board = initial();
      cmCounter = 0;
      return this; // "this" in the context of a function, refers to the object to which the function belongs.  In this case "this" refers to the object which reset belongs and it belongs to the game object.
    },
    /**
     * Advance the internal game board to the next move.
     *
     * @return {Object} the game object for Method Chaining
     * @todo Make this work!
     */
    next: function(){
      // Doesn't this seem to be missing something?
      // Super simple dummy test...
      //game.applyMove(6, 3, 4, 3);

      // Slightly smarter test with array of moves...
      var move = moves[cmCounter];
      console.log(move);
      game.applyMove(move[0], move[1], move[2], move[3]);
      cmCounter = cmCounter + 1;


      // End goal test with json of moves...
      // $.each(moves, function(key, value) {
      //   console.log(key + "=" + value);
      //   $.each(key, function(key, value) {
      //     console.log (key + "=" + value);
      //   });
      // });

      // For when we need to keep track of moves...
      // if (cmCounter < totalMoves) {
      //   cmCounter = cmCounter + 1;
      // } else {
      //   alert("Sorry, that is the end of the opening!!!");
      // }

      return this;
    },
    /**
     * Advance the internal game board to the previous move.
     *
     * @return {Object} the game object for Method Chaining
     * @todo Make this work!
     */
    prev: function(){
      // Another good place for code...

      // Super simple dummy test...
      //game.applyMove(2, 5, 0, 6);

      // Like next but in reverse...
      cmCounter = cmCounter - 1;
      var move = moves[cmCounter];<commit_msg>Added comments to prevent our counter from exceeding array length in either direction<commit_after>(function(globals){
// Don't worry if that seems a little funky...

  /**
   * Internal representation of the game board in its current state.
   *
   * @see game.board
   * @see game.tracer
   * @see initial
   * @var {Array} of {Array} of {String|null}
   */
  var board = initial(); // initialize the `board`

  /**
   * List of moves for the "Catalan Opening: Closed Variation" suitable for use
   * as arguments to `applyMove` below.
   *
   * @see applyMove
   * @var {Array} of...?
   */
  var moves = [
    // {from: {rank: 6, file: 3},
    // to: {rank: 4, file: 3}},
    // {from: {rank: 0, file: 6},
    // to: {rank: 2, file: 5}},
    // {from: {rank: 6, file: 2},
    // to: {rank: 4, file: 2}},
    // {from: {rank: 1, file: 4},
    // to: {rank: 2, file: 4}},
    // {from: {rank: 6, file: 6},
    // to: {rank: 5, file: 6}},
    // {from: {rank: 1, file: 3},
    // to: {rank: 3, file: 3}},
    // {from: {rank: 7, file: 5},
    // to: {rank: 6, file: 6}},
    // {from: {rank: 0, file: 5},
    // to: {rank: 1, file: 4}},
    // {from: {rank: 7, file: 6},
    // to: {rank: 5, file: 5}}
    [6, 3, 4, 3],
    [0, 6, 2, 5],
    [6, 2, 4, 2],
    [1, 4, 2, 4],
    [6, 6, 5, 6],
    [1, 3, 3, 3],
    [7, 5, 6, 6],
    [0, 5, 1, 4],
    [7, 6, 5, 5]

    // TODO: Fill me in!
  ]; // END moves

  // Created var to keep track of moves
  var cmCounter = 0;
  // var current; TODO: do we need this?

  // You don't need to understand `globals` yet...
  var game = globals.game = {
    /**
     * Provide a _copy_ of the game board in order to update the View from it
     *
     * @return {Array} of {Array} of {String|null}
     */
    board: function(){
      return board.map(function(row){
        return row.slice();
      });
    },
    /**
     * Reset the internal game board to it's initial state.
     *
     * @return {Object} the game object for Method Chaining
     */
    reset: function(){
      board = initial();
      cmCounter = 0;
      return this; // "this" in the context of a function, refers to the object to which the function belongs.  In this case "this" refers to the object which reset belongs and it belongs to the game object.
    },
    /**
     * Advance the internal game board to the next move.
     *
     * @return {Object} the game object for Method Chaining
     * @todo Make this work!
     */
    next: function(){
      // Doesn't this seem to be missing something?
      // Super simple dummy test...
      //game.applyMove(6, 3, 4, 3);

      // Set a condition to ensure that your counter doesn't exceed the length of the array.

      // Slightly smarter test with array of moves...
      var move = moves[cmCounter];
      console.log(move);
      game.applyMove(move[0], move[1], move[2], move[3]);
      cmCounter = cmCounter + 1;


      // End goal test with json of moves...
      // $.each(moves, function(key, value) {
      //   console.log(key + "=" + value);
      //   $.each(key, function(key, value) {
      //     console.log (key + "=" + value);
      //   });
      // });

      // For when we need to keep track of moves...
      // if (cmCounter < totalMoves) {
      //   cmCounter = cmCounter + 1;
      // } else {
      //   alert("Sorry, that is the end of the opening!!!");
      // }

      return this;
    },
    /**
     * Advance the internal game board to the previous move.
     *
     * @return {Object} the game object for Method Chaining
     * @todo Make this work!
     */
    prev: function(){
      // Another good place for code...

      // Super simple dummy test...
      //game.applyMove(2, 5, 0, 6);

      // Set a condition to ensure that your counter doesn't exceed the length of the array.

      // Like next but in reverse...
      cmCounter = cmCounter - 1;
      var move = moves[cmCounter];
{'fraction_non_alphanumeric': 0.16375198728139906, 'fraction_numerical': 0.023582405935347113, 'mean_word_length': 1.9068155564112437, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4683173', 'n_tokens_mistral': 2670, 'n_tokens_neox': 2470, 'n_words': 947}