<commit_before>(function() {
  'use strict';

  var socket = io();

  socket.on('tick', function(worldChanges) {
    worldChanges.forEach(function(change) {
      var row = $($('#board').children()[change.x]);
      $(row.children()[change.y]).css('background-color', getBackgroundColor(change.grass.state));
    });
  });
  
  function getBackgroundColor(grass) {
    var depth = Math.floor(255 * Math.abs(1 - grass));
    return 'rgb(' +
      depth + ',' + depth + ',' + depth +
      ')';
  }

  function buildRow(row) {
    var domRow = '<div class="row">';
    row.forEach(function(cell) {
      domRow += '<div class="cell"';
      if (cell.grass.state) {
        domRow += 'style="background-color: ' + getBackgroundColor(cell.grass.state) + '";';
      }
      domRow += '></div>';
    });
    domRow += '</div>';
    return domRow;
  }

  $.ajax('/world').then(function(response) {
    var $board = $('#board');
    response.forEach(function addRow(row) {
      $board.append(buildRow(row));
    });
  });<commit_msg>Ensures clean board on restart<commit_after>(function() {
  'use strict';

  var socket = io();

  socket.on('tick', function(worldChanges) {
    worldChanges.forEach(function(change) {
      var row = $($('#board').children()[change.x]);
      $(row.children()[change.y]).css('background-color', getBackgroundColor(change.grass.state));
    });
  });
  
  function getBackgroundColor(grass) {
    var depth = Math.floor(255 * Math.abs(1 - grass));
    return 'rgb(' +
      depth + ',' + depth + ',' + depth +
      ')';
  }

  function buildRow(row) {
    var domRow = '<div class="row">';
    row.forEach(function(cell) {
      domRow += '<div class="cell"';
      if (cell.grass.state) {
        domRow += 'style="background-color: ' + getBackgroundColor(cell.grass.state) + '";';
      }
      domRow += '></div>';
    });
    domRow += '</div>';
    return domRow;
  }

  socket.on('connect', function() {
    $.ajax('/world').then(function(response) {
      var $board = $('#board');
      $board.html('');
      response.forEach(function addRow(row) {
        $board.append(buildRow(row));
      });
    });
  });
{'fraction_non_alphanumeric': 0.20949720670391062, 'fraction_numerical': 0.0037243947858473, 'mean_word_length': 2.9215328467153285, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5235215', 'n_tokens_mistral': 705, 'n_tokens_neox': 684, 'n_words': 115}