module.exports = 
{
    "harvester" : 
    {
        behaviour : require ('creep_harvester')
    },
    
    "guard" : 
    {
        behaviour : function (creep)
        {
            var targets = creep.room.find(FIND_HOSTILE_CREEPS).filter (function (creep) { return creep.owner.username != "Source Keeper" });
        	if(targets.length >= 1)
        	{
                targets.sort (function (a,b)
                {
                    return creep.getRangeTo (b) - creep.getRangeTo (a);      
                });
        		creep.moveTo(targets[0]);
        		creep.attack(targets[0]);
        	}
        }
    },
    
    "shooter" : 
    {
        behaviour : function (creep)
        {
            var targets = creep.room.find(FIND_HOSTILE_CREEPS).filter (function (creep) { return creep.owner.username != "Source Keeper" });
        	if(targets.length >= 1)
        	{
                targets.sort (function (a,b)
                {
                    return creep.getRangeTo (b) - creep.getRangeTo (a);      
                });
        	    
        	    if (creep.pos.getRangeTo (targets[0].pos) > 3)
        	    {
        	       creep.moveTo(targets[0]); 
        	    }
        		
        		creep.rangedAttack(targets[0]);
        		
        	}
        }
    },
    
    "upgrader" : 
    {
        behaviour : function (creep)
        {
            if(creep.carry.energy < creep.carryCapacity) 
            {
                var spawn = Game.spawns.Spawn1
            	creep.moveTo (spawn)
                spawn.transferEnergy (creep);
            }
            else 
            {
                var controller = creep.room.controller;
            	creep.moveTo(controller);
            	creep.upgradeController(controller)
            }
        }
    },
    
    "builder" : 
    {
        behaviour : function (creep)
        {
            var spawn =  Game.spawns.Spawn1
            if (creep.carry.energy == 0)
            {
                creep.moveTo (spawn)
                spawn.transferEnergy (creep)
            }
            else
            {
                var targets = creep.room.find(FIND_CONSTRUCTION_SITES);
        		if(targets.length) 
        		{
        			creep.moveTo(targets[0]);
        		    creep.build(targets[0]);
        		}
            } 
        }
    },
    
    "healer" : 
    {
        behaviour : function (creep)
        {
            // Creeps with health less then maximum
            var targets = creep.room.find(FIND_MY_CREEPS).filter (function (creep) {return creep.hitsMax > creep.hits});
        	if(targets.length >= 1)
        	{
        		creep.moveTo(targets[0]);
        		creep.heal(targets[0]);
        	}
        }
    }
}
@@ -439,32 +439,36 @@
    return creep.
+pos.
 getRangeTo (b) -
@@ -466,32 +466,36 @@
 eTo (b) - creep.
+pos.
 getRangeTo (a); 
@@ -972,24 +972,28 @@
 eturn creep.
+pos.
 getRangeTo (
@@ -1003,16 +1003,20 @@
 - creep.
+pos.
 getRange

fix closest enemy search