<commit_before>"use strict";

var CityTour = CityTour || {};

CityTour.RiverGenerator = (function() {
  var generateRiverCurves = function(middleRow, columnsToGenerate) {
    var SUB_DIVISIONS = 1;
    var MIN_RIVER_BENDS = 3;
    var MAX_RIVER_BENDS = 8;
    var MAX_BEND_AMOUNT = 20 * SUB_DIVISIONS;
    var TOP_BANK_OFFSET = 4 * SUB_DIVISIONS;
    var BOTTOM_BANK_OFFSET = 12 * SUB_DIVISIONS;
    var TOP_BANK_MAX_JITTER = 6 * SUB_DIVISIONS;
    var HALF_TOP_BANK_MAX_JITTER = TOP_BANK_MAX_JITTER / 2;
    var BOTTOM_BANK_MAX_JITTER = 6 * SUB_DIVISIONS;
    var HALF_BOTTOM_BANK_MAX_JITTER = BOTTOM_BANK_MAX_JITTER / 2;

    var i;
    var baseCurvePoints, topCurvePoints, bottomCurvePoints;
    var randomJitter;
    var topCurve, bottomCurve;

    var riverSubDivisions = CityTour.Math.randomInteger(MIN_RIVER_BENDS, MAX_RIVER_BENDS);

    baseCurvePoints = [new THREE.Vector2(0, middleRow)];
    for (i = 1; i <= riverSubDivisions; i++) {
      var column = columnsToGenerate * i * (1 / riverSubDivisions);
      baseCurvePoints.push(new THREE.Vector2(column, middleRow + ((Math.random() * MAX_BEND_AMOUNT) - (MAX_BEND_AMOUNT / 2))));
    }

    topCurvePoints = [];
    bottomCurvePoints = [];
    for (i = 0; i < baseCurvePoints.length; i++) {
      randomJitter = Math.round(((Math.random() * TOP_BANK_MAX_JITTER) - HALF_TOP_BANK_MAX_JITTER));
      topCurvePoints.push(new THREE.Vector2(baseCurvePoints[i].x, baseCurvePoints[i].y + TOP_BANK_OFFSET + randomJitter));

      randomJitter = Math.round(((Math.random() * BOTTOM_BANK_MAX_JITTER) - HALF_BOTTOM_BANK_MAX_JITTER));
      bottomCurvePoints.push(new THREE.Vector2(baseCurvePoints[i].x, baseCurvePoints[i].y + BOTTOM_BANK_OFFSET + randomJitter));
    }

    topCurve = new THREE.SplineCurve(topCurvePoints);
    bottomCurve = new THREE.SplineCurve(bottomCurvePoints);

    return { topCurve: topCurve, bottomCurve: bottomCurve, };
  };


  var addRiver = function(terrainCoordinates, middleRow, columnsToGenerate) {
    var WATER_HEIGHT = 5.0;

    var x, z, xStep;
    var xCoordinate, zCoordinate;
    var minimumRiverBankHeight;<commit_msg>Small refactorings to attempt to make code more clear<commit_after>"use strict";

var CityTour = CityTour || {};

CityTour.RiverGenerator = (function() {
  var generateRiverCurves = function(middleRow, columnsToGenerate) {
    var SUB_DIVISIONS = 1;
    var MIN_RIVER_BENDS = 2;
    var MAX_RIVER_BENDS = 7;
    var MAX_BEND_AMOUNT = 20 * SUB_DIVISIONS;
    var TOP_BANK_OFFSET = 4 * SUB_DIVISIONS;
    var BOTTOM_BANK_OFFSET = 12 * SUB_DIVISIONS;
    var TOP_BANK_MAX_JITTER = 6 * SUB_DIVISIONS;
    var HALF_TOP_BANK_MAX_JITTER = TOP_BANK_MAX_JITTER / 2;
    var BOTTOM_BANK_MAX_JITTER = 6 * SUB_DIVISIONS;
    var HALF_BOTTOM_BANK_MAX_JITTER = BOTTOM_BANK_MAX_JITTER / 2;

    var i;
    var baseCurvePoints, topCurvePoints, bottomCurvePoints;
    var randomJitter;
    var topCurve, bottomCurve;

    var riverBendCount = CityTour.Math.randomInteger(MIN_RIVER_BENDS, MAX_RIVER_BENDS);
    var columnsBetweenBends = columnsToGenerate / (riverBendCount + 1);
    var column, row;

    baseCurvePoints = [new THREE.Vector2(0, middleRow)];
    for (i = 1; i <= riverBendCount + 1; i++) {
      column = i * columnsBetweenBends;
      row = middleRow + ((Math.random() * MAX_BEND_AMOUNT) - (MAX_BEND_AMOUNT / 2));
      baseCurvePoints.push(new THREE.Vector2(column, row));
    }

    topCurvePoints = [];
    bottomCurvePoints = [];
    for (i = 0; i < baseCurvePoints.length; i++) {
      randomJitter = Math.round(((Math.random() * TOP_BANK_MAX_JITTER) - HALF_TOP_BANK_MAX_JITTER));
      topCurvePoints.push(new THREE.Vector2(baseCurvePoints[i].x, baseCurvePoints[i].y + TOP_BANK_OFFSET + randomJitter));

      randomJitter = Math.round(((Math.random() * BOTTOM_BANK_MAX_JITTER) - HALF_BOTTOM_BANK_MAX_JITTER));
      bottomCurvePoints.push(new THREE.Vector2(baseCurvePoints[i].x, baseCurvePoints[i].y + BOTTOM_BANK_OFFSET + randomJitter));
    }

    topCurve = new THREE.SplineCurve(topCurvePoints);
    bottomCurve = new THREE.SplineCurve(bottomCurvePoints);

    return { topCurve: topCurve, bottomCurve: bottomCurve, };
  };


  var addRiver = function(terrainCoordinates, middleRow, columnsToGenerate) {
    var WATER_HEIGHT = 5.0;

    var x, z, xStep;
    var xCoordinate, zCoordinate;
    var minimumRiverBankHeight;
{'fraction_non_alphanumeric': 0.10488704472106962, 'fraction_numerical': 0.010834485938220378, 'mean_word_length': 4.16547619047619, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2956293', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1599, 'n_words': 295}