<commit_before>var _ = require('lodash')

var roleDistanceHarvester = {

    run: function(creep) {

        var flags = [
            'distanceHarvestA',
            'distanceHarvestB',
            //'distanceHarvestC' // disabled until that player finishes dying
        ];

        // maybe do some roadwork
        if(creep.memory.harvesting == false && creep.carry.energy > 0) {
            console.log(creep.name + ' maybe laying roads');
            roleDistanceHarvester.layOrRepairRoads(creep);
            // if a creep runs out of energy while doing roadwork, give it the previous harvest target
            // again as that is presumably closer
            if(creep.carry.energy == 0) {
                creep.harvesting = true;
            }
        }

        // initialize a new creep correctly
        if(creep.memory.harvesting == undefined || creep.memory.target == undefined) {
            creep.memory.harvesting = false;
        }

        // done harvesting because we dropped at storage, so get a new random target room
        if(creep.carry.energy == 0 && creep.memory.harvesting == false) {
            creep.memory.harvesting = true;
            creep.memory.target = _.shuffle(flags)[0];
        }

        // done harvesting, so go home and dump in storage (doing roadwork along the way as per above)
        if(creep.carry.energy == creep.carryCapacity) {

            creep.memory.harvesting = false;

            if(creep.room.name != Memory.home) {
                creep.moveTo(Game.rooms[Memory.home].controller);
            } else {
                var storage = Game.rooms[Memory.home].storage;
                switch(creep.transfer(storage, RESOURCE_ENERGY)) {
                    case ERR_NOT_IN_RANGE:
                        creep.moveTo(storage);
                        break;
                }
            }

        // go to the target room, then find an energy in it and nom away
        } else if(creep.memory.harvesting) {
            if(creep.room.name != Game.flags[creep.memory.target].pos.roomName) {
                creep.moveTo(Game.flags[creep.memory.target]);
            } else {
               var target = creep.pos.findClosestByPath(FIND_SOURCES);
               if(creep.harvest(target)) {
                 creep.moveTo(target);
               } else {
                  // target is undefined, so try another room
                  creep.memory.target = _.shuffle(flags)[0];
               }
            }
        } else {
            // default to going home
            creep.moveTo(Game.rooms[creep.memory.home].storage)<commit_msg>removing a bad piece of logic<commit_after>var _ = require('lodash')

var roleDistanceHarvester = {

    run: function(creep) {

        var flags = [
            'distanceHarvestA',
            'distanceHarvestB',
            //'distanceHarvestC' // disabled until that player finishes dying
        ];

        // maybe do some roadwork
        if(creep.memory.harvesting == false && creep.carry.energy > 0) {
            console.log(creep.name + ' maybe laying roads');
            roleDistanceHarvester.layOrRepairRoads(creep);
            // if a creep runs out of energy while doing roadwork, give it the previous harvest target
            // again as that is presumably closer
            if(creep.carry.energy == 0) {
                creep.harvesting = true;
            }
        }

        // initialize a new creep correctly
        if(creep.memory.harvesting == undefined || creep.memory.target == undefined) {
            creep.memory.harvesting = false;
        }

        // done harvesting because we dropped at storage, so get a new random target room
        if(creep.carry.energy == 0 && creep.memory.harvesting == false) {
            creep.memory.harvesting = true;
            creep.memory.target = _.shuffle(flags)[0];
        }

        // done harvesting, so go home and dump in storage (doing roadwork along the way as per above)
        if(creep.carry.energy == creep.carryCapacity) {

            creep.memory.harvesting = false;

            if(creep.room.name != Memory.home) {
                creep.moveTo(Game.rooms[Memory.home].controller);
            } else {
                var storage = Game.rooms[Memory.home].storage;
                switch(creep.transfer(storage, RESOURCE_ENERGY)) {
                    case ERR_NOT_IN_RANGE:
                        creep.moveTo(storage);
                        break;
                }
            }

        // go to the target room, then find an energy in it and nom away
        } else if(creep.memory.harvesting) {
            if(creep.room.name != Game.flags[creep.memory.target].pos.roomName) {
                creep.moveTo(Game.flags[creep.memory.target]);
            } else {
               var target = creep.pos.findClosestByPath(FIND_SOURCES);
               if(creep.harvest(target)) {
                 creep.moveTo(target);
               }
            }
        } else {
            // default to going home
            creep.moveTo(Game.rooms[creep.memory.home].storage)
{'fraction_non_alphanumeric': 0.09998024105907924, 'fraction_numerical': 0.0017783046828689982, 'mean_word_length': 1.6392075078206465, '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': '6860438', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1354, 'n_words': 322}