<commit_before>module.exports  = {

	run : function(creep, source) {
		
		setRepairFlagForCreep(creep);
		
    	
    	if (creep.memory.repair) {     		    
			var structures = getTargetsForRepair(creep);
			var item = getTargetWithMostNeedForRepair(structures);
		
			if (!creep.pos.isNearTo(item)) {
				creep.moveTo(item);
			} else {
				creep.repair(item);
			}
    	}else{
    		if(creep.harvest(source) == ERR_NOT_IN_RANGE) {  	    		
    			creep.moveTo(source);    			
    		}
    	}
	}
}

function getTargetWithMostNeedForRepair(structures){
	var mostNeedForRepair = structures[0];
	for (var i=0; i<structures.length;i++){
		var item = structures[i];
		var hitsDiffMax = mostNeedForRepair.hitsMax - mostNeedForRepair.hits;
		var hitsDiffTmp = item.hitsMax - item.hits;
		
		if (hitsDiffMax < hitsDiffTmp){
			mostNeedForRepair =  item;
		}			
	}
	console.log(mostNeedForRepair.structureType+" has "+mostNeedForRepair.hits+ " from "+mostNeedForRepair.maxHits);	
}

function setRepairFlagForCreep(creep){	<commit_msg>Bugfix<commit_after>module.exports  = {

	run : function(creep, source) {
		
		setRepairFlagForCreep(creep);
		
    	
    	if (creep.memory.repair) {     		    
			var structures = getTargetsForRepair(creep);
			var item = getTargetWithMostNeedForRepair(structures);
		
			if (!creep.pos.isNearTo(item)) {
				creep.moveTo(item);
			} else {
				creep.repair(item);
			}
    	}else{
    		if(creep.harvest(source) == ERR_NOT_IN_RANGE) {  	    		
    			creep.moveTo(source);    			
    		}
    	}
	}
}

function getTargetWithMostNeedForRepair(structures){
	var mostNeedForRepair = structures[0];
	for (var i=0; i<structures.length;i++){
		var item = structures[i];
		var hitsDiffMax = mostNeedForRepair.hitsMax - mostNeedForRepair.hits;
		var hitsDiffTmp = item.hitsMax - item.hits;
		
		if (hitsDiffMax < hitsDiffTmp){
			mostNeedForRepair =  item;
		}			
	}
	console.log(mostNeedForRepair.structureType+" has "+mostNeedForRepair.hits+ " from "+mostNeedForRepair.hitsMax);	
}

function setRepairFlagForCreep(creep){	
{'fraction_non_alphanumeric': 0.11954924056834886, 'fraction_numerical': 0.0019598236158745713, 'mean_word_length': 3.335456475583864, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1946763', 'n_tokens_mistral': 869, 'n_tokens_neox': 773, 'n_words': 108}