<commit_before>function processFrame(game, frameNum) {
    var checkSim = false;
    var gameMap = game.frames[frameNum];
    if(checkSim) {
        gameMap = _.cloneDeep(game.frames[frameNum]);
    }
    var moves = game.moves[frameNum];
    var productions = game.productions;
    var width = game.width;
    var height = game.height;
    var numPlayers = game.num_players;

    var STILL = 0;
    var NORTH = 1;
    var EAST  = 2;
    var SOUTH = 3;
    var WEST  = 4;

    var pieces = [];
    var stats = [];

    var p, q, y, x;

    function getLocation(loc, direction) {
        if (direction === STILL) {
            // nothing
        } else if (direction === NORTH) {
            loc.y -= 1;
        } else if (direction === EAST) {
            loc.x += 1;
        } else if (direction === SOUTH) {
            loc.y += 1;
        } else if (direction === WEST) {
            loc.x -= 1;
        }

        if (loc.x < 0) {
            loc.x = width - 1;
        } else {
            loc.x %= width;
        }

        if (loc.y < 0) {
            loc.y = height - 1;
        } else {
            loc.y %= height;
        }
    }

    for (p = 0; p < numPlayers; p++) {
        pieces[p] = [];
        stats[p] = {
            actualProduction: 0,
            playerDamageDealt: 0,
            environmentDamageDealt: 0,
            damageTaken: 0,
            capLosses: 0,
            overkillDamage: 0,
        };
        for (y = 0; y < height; y++) {
            pieces[p][y] = [];
        }
    }

    for (y = 0; y < height; y++) {
        for (x = 0; x < width; x++) {
            var direction = moves[y][x];
            var cell = gameMap[y][x];
            var player = gameMap[y][x].owner - 1;
            var production = productions[y][x];

            if (gameMap[y][x].owner == 0) continue

            if (direction === STILL) {
                if (cell.strength + production <= 255) {
                    stats[player].actualProduction += production;
                    cell.strength += production;
                } else {
                    stats[player].actualProduction += cell.strength - 255;
                    stats[player].capLosses += cell.strength + production - 255;
                    cell.strength = 255;
                }
            }<commit_msg>Stop indirect mutation of gameMap.<commit_after>function processFrame(game, frameNum) {
    var checkSim = false;
    var gameMap = game.frames[frameNum];
    if(checkSim) {
        gameMap = _.cloneDeep(game.frames[frameNum]);
    }
    var moves = game.moves[frameNum];
    var productions = game.productions;
    var width = game.width;
    var height = game.height;
    var numPlayers = game.num_players;

    var STILL = 0;
    var NORTH = 1;
    var EAST  = 2;
    var SOUTH = 3;
    var WEST  = 4;

    var pieces = [];
    var stats = [];

    var p, q, y, x;

    function getLocation(loc, direction) {
        if (direction === STILL) {
            // nothing
        } else if (direction === NORTH) {
            loc.y -= 1;
        } else if (direction === EAST) {
            loc.x += 1;
        } else if (direction === SOUTH) {
            loc.y += 1;
        } else if (direction === WEST) {
            loc.x -= 1;
        }

        if (loc.x < 0) {
            loc.x = width - 1;
        } else {
            loc.x %= width;
        }

        if (loc.y < 0) {
            loc.y = height - 1;
        } else {
            loc.y %= height;
        }
    }

    for (p = 0; p < numPlayers; p++) {
        pieces[p] = [];
        stats[p] = {
            actualProduction: 0,
            playerDamageDealt: 0,
            environmentDamageDealt: 0,
            damageTaken: 0,
            capLosses: 0,
            overkillDamage: 0,
        };
        for (y = 0; y < height; y++) {
            pieces[p][y] = [];
        }
    }

    for (y = 0; y < height; y++) {
        for (x = 0; x < width; x++) {
            var direction = moves[y][x];
            var cell = gameMap[y][x];
            var player = gameMap[y][x].owner - 1;
            var production = productions[y][x];

            if (gameMap[y][x].owner == 0) continue

            if (direction === STILL) {
                cell = { owner: gameMap[y][x].owner, strength: gameMap[y][x].strength };
                if (cell.strength + production <= 255) {
                    stats[player].actualProduction += production;
                    cell.strength += production;
                } else {
                    stats[player].actualProduction += cell.strength - 255;
                    stats[player].capLosses += cell.strength + production - 255;
                    cell.strength = 255;
                }
            }
{'fraction_non_alphanumeric': 0.13452532992762878, 'fraction_numerical': 0.015751383567475522, 'mean_word_length': 1.333167825223436, 'pattern_counts': {'":': 0, '<': 17, '<?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': '7294772', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1397, 'n_words': 363}