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

  VAGABOND.namespace("VAGABOND.CONTROLLER");

  VAGABOND.CONTROLLER = (function(module) {

    var Controller = {};

    Controller.init = function(controls) {
      this.controls = controls;

      return this;
    };

    Controller.processInput = function(screen, milo, map, level) {
      if (this.controls.eventStack.length > 0) {

        var event = this.controls.eventStack.pop();

        var things = {
          screenUp: {dx: 0, dy: -1, entity: screen, useTurn: false},
          screenDown: {dx: 0, dy: 1, entity: screen, useTurn: false},
          screenLeft: {dx: -1, dy: 0, entity: screen, useTurn: false},
          screenRight: {dx: 1, dy: 0, entity: screen, useTurn: false},
          charUp: {dx: 0, dy: -1, entity: milo, useTurn: true},
          charDown: {dx: 0, dy: 1, entity: milo, useTurn: true},
          charLeft: {dx: -1, dy: 0, entity: milo, useTurn: true},
          charRight: {dx: 1, dy: 0, entity: milo, useTurn: true}
        };

        var move = things[event];

        if (move && move.entity.isValidMove(move.dx, move.dy, map)) {
          move.entity.move(move.dx, move.dy);
        }

        if (move && move.useTurn) {
          level.takeTurn();
        }

        if (event === "normalize") {
          VAGABOND.ALGORITHMS.cellularAutomata(map, 1);
        }

        level.renderTo(screen);
        screen.renderToElement(document.body);
      }
    };

    module.Controller = Controller;

    return module;

  })(VAGABOND.CONTROLLER);
})();
<commit_msg>Refactor code<commit_after>(function() {
  "use strict";

  VAGABOND.namespace("VAGABOND.CONTROLLER");

  VAGABOND.CONTROLLER = (function(module) {

    var Controller = {};

    Controller.init = function(controls) {
      this.controls = controls;

      return this;
    };

    Controller.processInput = function(screen, avatar, map, level) {
      if (this.controls.eventStack.length > 0) {

        var event = this.controls.eventStack.pop();

        var moves = {
          screenUp: {dx: 0, dy: -1, entity: screen, useTurn: false},
          screenDown: {dx: 0, dy: 1, entity: screen, useTurn: false},
          screenLeft: {dx: -1, dy: 0, entity: screen, useTurn: false},
          screenRight: {dx: 1, dy: 0, entity: screen, useTurn: false},
          charUp: {dx: 0, dy: -1, entity: avatar, useTurn: true},
          charDown: {dx: 0, dy: 1, entity: avatar, useTurn: true},
          charLeft: {dx: -1, dy: 0, entity: avatar, useTurn: true},
          charRight: {dx: 1, dy: 0, entity: avatar, useTurn: true}
        };

        var move = moves[event];

        if (move && move.entity.isValidMove(move.dx, move.dy, map)) {
          move.entity.move(move.dx, move.dy);
        }

        if (move && move.useTurn) {
          level.takeTurn();
        }

        if (event === "normalize") {
          VAGABOND.ALGORITHMS.cellularAutomata(map, 1);
        }

        level.renderTo(screen);
        screen.renderToElement(document.body);
      }
    };

    module.Controller = Controller;

    return module;

  })(VAGABOND.CONTROLLER);
})();

{'fraction_non_alphanumeric': 0.15057915057915058, 'fraction_numerical': 0.011583011583011582, 'mean_word_length': 2.2934322033898304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1652591', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1005, 'n_words': 251}