<commit_before>var roleHarvester = {

    count: 4,

    /** @param {Creep} creep **/
    run: function(creep) {
        if(creep.carry.energy < creep.carryCapacity && creep.memory.harvest) {
            var sources = _.filter(this.findSource(creep.room), (source) => {
                return _.indexOf(creep.memory.blockSources, source.structureType) == -1
            });

            /* debug
            if(!_.isEmpty(creep.memory.blockSources)) {
                console.log('blocked sources:', creep.name, creep.memory.blockSources);
            }
            console.log('--', sources);
            _.forEach(sources, (source) => console.log(source.id, source.energy));
            */

            if (sources[0]) {
                if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE
                || creep.pickup(sources[0]) == ERR_NOT_IN_RANGE
                || creep.withdraw(sources[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
                    creep.moveTo(sources[0].pos);
                }
            } else {
                creep.moveTo(20, 15);
                creep.sayDelay('noSources', 5);
                creep.memory.blockSources = [];
                creep.memory.harvest = false;

                var msg = '<div style="color:red;">NoSources left</div>room['+creep.room.name+']';
                Game.notify(msg, 5);
            }
        }
        else {
            creep.memory.harvest = false;
            var targets = creep.room.find(FIND_STRUCTURES, {
                    filter: (structure) => {
                        return (structure.structureType == STRUCTURE_EXTENSION ||
                                structure.structureType == STRUCTURE_SPAWN ||
                                structure.structureType == STRUCTURE_TOWER) && structure.energy < structure.energyCapacity;
                    }
            });
            if(targets.length > 0) {
                targets = _.sortBy(targets, (structure) => structure.structureType);
                var transfer = creep.transfer(targets[0], RESOURCE_ENERGY);
                if(transfer == ERR_NOT_IN_RANGE) {
                    creep.moveTo(targets[0]);
                }
                if(transfer == OK) {
                    creep.memory.blockSources = [];
                }
            } else {
                var container = creep.room.find(FIND_STRUCTURES, {
                    filter: (structure) => structure.structureType == STRUCTURE_CONTAINER && structure.store[RESOURCE_ENERGY] < structure.storeCapacity
                });

                if (container) {
                    var transfer = creep.transfer(container[0], RESOURCE_ENERGY);
                    if(transfer == ERR_NOT_IN_RANGE) {<commit_msg>"autobuild-update"<commit_after>var roleHarvester = {

    count: 4,

    /** @param {Creep} creep **/
    run: function(creep) {
        if(creep.carry.energy < creep.carryCapacity && creep.memory.harvest) {
            var sources = _.filter(this.findSource(creep.room), (source) => {
                return _.indexOf(creep.memory.blockSources, source.structureType) == -1
            });

            /* debug
            if(!_.isEmpty(creep.memory.blockSources)) {
                console.log('blocked sources:', creep.name, creep.memory.blockSources);
            }
            console.log('--', sources);
            _.forEach(sources, (source) => console.log(source.id, source.energy));
            */

            if (sources[0]) {
                if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE
                || creep.pickup(sources[0]) == ERR_NOT_IN_RANGE
                || creep.withdraw(sources[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
                    creep.moveTo(sources[0].pos);
                }
            } else {
                creep.moveTo(20, 15);
                creep.sayDelay('noSources', 5);
                creep.memory.blockSources = [];
                creep.memory.harvest = false;

                //var msg = '<div style="color:red;">NoSources left</div>room['+creep.room.name+']';
                //Game.notify(msg, 5);
            }
        }
        else {
            creep.memory.harvest = false;
            var targets = creep.room.find(FIND_STRUCTURES, {
                    filter: (structure) => {
                        return (structure.structureType == STRUCTURE_EXTENSION ||
                                structure.structureType == STRUCTURE_SPAWN ||
                                structure.structureType == STRUCTURE_TOWER) && structure.energy < structure.energyCapacity;
                    }
            });
            if(targets.length > 0) {
                targets = _.sortBy(targets, (structure) => structure.structureType);
                var transfer = creep.transfer(targets[0], RESOURCE_ENERGY);
                if(transfer == ERR_NOT_IN_RANGE) {
                    creep.moveTo(targets[0]);
                }
                if(transfer == OK) {
                    creep.memory.blockSources = [];
                }
            } else {
                var container = creep.room.find(FIND_STRUCTURES, {
                    filter: (structure) => structure.structureType == STRUCTURE_CONTAINER && structure.store[RESOURCE_ENERGY] < structure.storeCapacity
                });

                if (container) {
                    var transfer = creep.transfer(container[0], RESOURCE_ENERGY);
                    if(transfer == ERR_NOT_IN_RANGE) {
{'fraction_non_alphanumeric': 0.12410369553226697, 'fraction_numerical': 0.006251149108291966, 'mean_word_length': 1.5396825396825398, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, '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': '3180419', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1439, 'n_words': 216}