<commit_before>define(function (require) {

    'use strict';

    var _      = require('underscore');
    var median = require('filters').median;

    var Vector2 = require('common/math/vector2');

    var MovementStrategy = require('models/movement-strategy');

    var HISTORY_LENGTH = 10;

    /**
     * This movement strategy does nothing automatically. It is
     * intended for use when the object in the model to which it
     * applies is to be moved with the mouse.
     */
    var ManualMovementStrategy = function(electron) {
        this.electron = electron;

        this.position = new Vector2(electron.get('position'));
        this.velocity = new Vector2(electron.get('velocity'));

        this.numHistoryEntries;
        this.yPosHistory = [];
        this.yVelHistory = [];
        this.yAccHistory = [];
    };

    /**
     * Instance functions/properties
     */
    _.extend(ManualMovementStrategy.prototype, MovementStrategy.prototype, {

    	update: function(deltaTime) {
            if (this.position) {
                this.numHistoryEntries = Math.min(this.numHistoryEntries + 1, HISTORY_LENGTH);
                this.electron.setPosition(this.position);
                for (var i = this.yPosHistory.length - 1; i > 0; i--)
                    this.yPosHistory[i] = yPosHistory[i - 1];
                this.yPosHistory[0] = this.electron.get('position').y;
                this.computeKinetics();
            }
        },

        computeKinetics: function() {
            var i;
            var vSum = 0;
            var aSum = 0;

            // Compute velocities
            for (i = 0; i < this.numHistoryEntries - 1; i++) {
                var v = this.yPosHistory[i + 1] - this.yPosHistory[i];
                this.yVelHistory[i] = v;
                vSum += v;
            }
            this.velocityAvg = vSum / this.yVelHistory.length;
            this.velocity.x = this.velocityAvg;

            // Compute accelerations
            this.yVelHistory = median(this.yVelHistory, 3);
            for (i = 0; i < this.numHistoryEntries - 2; i++) {
                var a = this.yVelHistory[i + 1] - this.yVelHistory[i];
                this.yAccHistory[i] = a;
                aSum += a;
            }
            this.accelerationAvg = aSum / this.yAccHistory.length;
        },

    	getVelocity: function() {
            return this.velocity;
        },<commit_msg>Trying to figure out why manual mode is so wonky.<commit_after>define(function (require) {

    'use strict';

    var _      = require('underscore');
    var median = require('filters').median;

    var Vector2 = require('common/math/vector2');

    var MovementStrategy = require('models/movement-strategy');

    var HISTORY_LENGTH = 10;

    /**
     * This movement strategy does nothing automatically. It is
     * intended for use when the object in the model to which it
     * applies is to be moved with the mouse.
     */
    var ManualMovementStrategy = function(electron) {
        this.electron = electron;

        this.position = new Vector2(electron.get('position'));
        this.velocity = new Vector2(electron.get('velocity'));

        this.numHistoryEntries;
        this.yPosHistory = [];
        this.yVelHistory = [];
        this.yAccHistory = [];

        this.initHistory();
    };

    /**
     * Instance functions/properties
     */
    _.extend(ManualMovementStrategy.prototype, MovementStrategy.prototype, {

        initHistory: function() {
            for (var i = 0; i < HISTORY_LENGTH; i++) {
                this.yPosHistory.push(0);
                this.yVelHistory.push(0);
                this.yAccHistory.push(0);
            }
        },

    	update: function(deltaTime) {
            if (this.position) {
                this.numHistoryEntries = Math.min(this.numHistoryEntries + 1, HISTORY_LENGTH);
                this.electron.setPosition(this.position);
                for (var i = this.yPosHistory.length - 1; i > 0; i--)
                    this.yPosHistory[i] = this.yPosHistory[i - 1];
                this.yPosHistory[0] = this.electron.get('position').y;
                this.computeKinetics();
            }
        },

        computeKinetics: function() {
            var i;
            var vSum = 0;
            var aSum = 0;

            // Compute velocities
            for (i = 0; i < this.numHistoryEntries - 1; i++) {
                var v = this.yPosHistory[i + 1] - this.yPosHistory[i];
                this.yVelHistory[i] = v;
                vSum += v;
            }
            this.velocityAvg = vSum / this.yVelHistory.length;
            this.velocity.x = this.velocityAvg; // Why the heck is it being stored in the x component???????

            // Compute accelerations
            this.yVelHistory = median(this.yVelHistory, 3);
            for (i = 0; i < this.numHistoryEntries - 2; i++) {
                var a = this.yVelHistory[i + 1] - this.yVelHistory[i];
                this.yAccHistory[i] = a;
                aSum += a;
            }
            this.accelerationAvg = aSum / this.yAccHistory.length;
        },

    	getVelocity: function() {
            return this.velocity;
        },
{'fraction_non_alphanumeric': 0.11651234567901235, 'fraction_numerical': 0.008487654320987654, 'mean_word_length': 1.731822971548999, 'pattern_counts': {'":': 0, '<': 8, '<?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': '4665238', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1428, 'n_words': 331}