<commit_before>import {ConstructionSiteManager} from "../../constructionSites/constructionSiteManager"

export namespace Builder {

  export let constructionSites: ConstructionSite[] = ConstructionSiteManager.constructionSites;

  export let targetSource: Resource;
  export let targetContainer: Container;
  export let targetConstructionSite: ConstructionSite;

  /**
   * Run all Builder actions.
   *
   * @export
   * @param {Creep} creep The current creep.
   * @param {Room} room The current room.
   */
  export function run(creep: Creep, room: Room): void {
    if (creep.memory['building'] && creep.carry.energy === 0) {
      creep.memory['building'] = false;
    }

    if (!creep.memory.building && creep.carry.energy === creep.carryCapacity) {
      creep.memory['building'] = true;
    }

    if (creep.memory['building']) {

      targetConstructionSite = ConstructionSiteManager.getConstructionSite()
        ? ConstructionSiteManager.getConstructionSite()
        : null;

      if (creep.pos.isNearTo(targetConstructionSite)) {
        creep.build(targetConstructionSite);
      } else {
        creep.moveTo(targetConstructionSite);
      }

    } else {
      targetSource = creep.pos.findClosestByPath<Resource>(FIND_DROPPED_RESOURCES);

      if (targetSource) {
        if (creep.pos.isNearTo(targetSource)) {
          creep.pickup(targetSource);
        } else {
          creep.moveTo(targetSource);
        }
      } else {
        targetContainer = creep.pos.findClosestByPath<Container>(FIND_STRUCTURES, {
          filter: ((structure) => {
            if (structure.structureType == STRUCTURE_CONTAINER) {
              let container = <Container>structure;
              if (_.sum(container.store) > (500)) {
                return container;
              }
            }
          })
        });

        if (creep.pos.isNearTo(targetContainer)) {
          creep.withdraw(targetContainer, RESOURCE_ENERGY);
        } else {
          creep.moveTo(targetContainer);
        }
      }
    }
  }
}<commit_msg>Truthy checks for Builder targets<commit_after>import {ConstructionSiteManager} from "../../constructionSites/constructionSiteManager"

export namespace Builder {

  export let constructionSites: ConstructionSite[] = ConstructionSiteManager.constructionSites;

  export let targetSource: Resource;
  export let targetContainer: Container;
  export let targetConstructionSite: ConstructionSite;

  /**
   * Run all Builder actions.
   *
   * @export
   * @param {Creep} creep The current creep.
   * @param {Room} room The current room.
   */
  export function run(creep: Creep, room: Room): void {
    if (creep.memory['building'] && creep.carry.energy === 0) {
      creep.memory['building'] = false;
    }

    if (!creep.memory.building && creep.carry.energy === creep.carryCapacity) {
      creep.memory['building'] = true;
    }

    if (creep.memory['building']) {

      targetConstructionSite = ConstructionSiteManager.getConstructionSite()
        ? ConstructionSiteManager.getConstructionSite()
        : null;

      if (targetConstructionSite) {
        if (creep.pos.isNearTo(targetConstructionSite)) {
          creep.build(targetConstructionSite);
        } else {
          creep.moveTo(targetConstructionSite);
        }
      }

    } else {
      targetSource = creep.pos.findClosestByPath<Resource>(FIND_DROPPED_RESOURCES);

      if (targetSource) {
        if (creep.pos.isNearTo(targetSource)) {
          creep.pickup(targetSource);
        } else {
          creep.moveTo(targetSource);
        }
      } else {
        targetContainer = creep.pos.findClosestByPath<Container>(FIND_STRUCTURES, {
          filter: ((structure) => {
            if (structure.structureType == STRUCTURE_CONTAINER) {
              let container = <Container>structure;
              if (_.sum(container.store) > (500)) {
                return container;
              }
            }
          })
        });

        if (targetContainer) {
          if (creep.pos.isNearTo(targetContainer)) {
            creep.withdraw(targetContainer, RESOURCE_ENERGY);
          } else {
            creep.moveTo(targetContainer);
          }
        }
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.11314475873544093, 'fraction_numerical': 0.0019015925837889231, 'mean_word_length': 2.4748142031379023, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '511016', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1166, 'n_words': 214}