<commit_before>'use strict';

angular.module('randomTiles', [])
.controller('RandomTilesCtrl', ['$scope', function($scope) {

      var LONG_DISTANCE = 8;
      var SHORT_DISTANCE = 1;
      var MAX_CHANCE = 12;

      var tileSize = 20;

      $scope.generateTilesArrangement = function (roomWidth, roomLength) {
        initTilesFamilies();
        var rows = Math.ceil(roomLength / tileSize);
        var columns = Math.ceil(roomWidth / tileSize);
        $scope.tilesRows = [];
        for (var row = 0; row < rows; row++) {
          $scope.tilesRows[row] = {
            tiles: []
          };
          for (var column = 0; column < columns; column++) {
            var typeId = randomTileTypeIdFor(row, column);
            $scope.tilesRows[row].tiles[column] = {
              typeId: typeId
            };
            if (typeId.familyName != "error") {
              useTileOf(typeId);
            }
          }
        }
        logTilesLeftReport();
      };

      function logTilesLeftReport() {
        console.log("Tiles left:");
        $scope.tilesFamilies.forEach(function(family) {
          console.log("[" + family.name + "]");
          family.groups.forEach(function (group) {
            console.log("  " + group.amount + " x " + family.name + "-"  + group.type);
          });
        });
      }

      function useTileOf(typeId) {
        var family = familyWithName(typeId.familyName);
        var group = groupOfType(typeId.type, family);
        group.amount--;
        if (group.amount <= 0) {
          removeGroup(family, typeId.type);
        }
      }

      function removeGroup(family, type) {
        var indexToRemove = -1;
        for (var index = 0; index < family.groups.length; index++) {
          if (family.groups[index].type === type) {
            indexToRemove = index;
          }
        }
        family.groups = family.groups.slice(0, indexToRemove).concat(family.groups.slice(indexToRemove + 1));
      }

      function randomTileTypeIdFor(row, column) {
        var accumulation = accumulateFamiliesInNeighbourhoodOf(row, column);
        var options = optionsFor(accumulation);
        if (options.length === 0) {
          return {
            familyName: "error",
            type: "error"<commit_msg>Show report about left tiles<commit_after>'use strict';

angular.module('randomTiles', [])
.controller('RandomTilesCtrl', ['$scope', '$window', function($scope, $window) {

      var LONG_DISTANCE = 8;
      var SHORT_DISTANCE = 1;
      var MAX_CHANCE = 12;

      var tileSize = 20;

      $scope.generateTilesArrangement = function (roomWidth, roomLength) {
        initTilesFamilies();
        var rows = Math.ceil(roomLength / tileSize);
        var columns = Math.ceil(roomWidth / tileSize);
        $scope.tilesRows = [];
        for (var row = 0; row < rows; row++) {
          $scope.tilesRows[row] = {
            tiles: []
          };
          for (var column = 0; column < columns; column++) {
            var typeId = randomTileTypeIdFor(row, column);
            $scope.tilesRows[row].tiles[column] = {
              typeId: typeId
            };
            if (typeId.familyName != "error") {
              useTileOf(typeId);
            }
          }
        }
        reportLeftTiles();
      };

      function reportLeftTiles() {
        var report = "";
        report += ("Pozostałe płytki:\n");
        $scope.tilesFamilies.forEach(function(family) {
          family.groups.forEach(function (group) {
            report += group.amount + " x " + family.name + "-"  + group.type + "\n";
          });
        });
        $window.alert(report);
      }

      function useTileOf(typeId) {
        var family = familyWithName(typeId.familyName);
        var group = groupOfType(typeId.type, family);
        group.amount--;
        if (group.amount <= 0) {
          removeGroup(family, typeId.type);
        }
      }

      function removeGroup(family, type) {
        var indexToRemove = -1;
        for (var index = 0; index < family.groups.length; index++) {
          if (family.groups[index].type === type) {
            indexToRemove = index;
          }
        }
        family.groups = family.groups.slice(0, indexToRemove).concat(family.groups.slice(indexToRemove + 1));
      }

      function randomTileTypeIdFor(row, column) {
        var accumulation = accumulateFamiliesInNeighbourhoodOf(row, column);
        var options = optionsFor(accumulation);
        if (options.length === 0) {
          return {
            familyName: "error",
            type: "error"
{'fraction_non_alphanumeric': 0.13187294633077765, 'fraction_numerical': 0.006133625410733845, 'mean_word_length': 1.9344473007712082, 'pattern_counts': {'":': 0, '<': 11, '<?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': '2934257', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1312, 'n_words': 266}