<commit_before>import { PluggableInventoryItemDefinition } from 'app/inventory/item-types';
import { DestinyEnergyType } from 'bungie-api-ts/destiny2';
import { ProcessMod } from './process-worker/types';

export function generateProcessModPermutations(mods: (ProcessMod | null)[]) {
  // Creates a string from the mod permutation containing the unique properties
  // that we care about, so we can reudce to the minimum number of permutations.
  // If two different mods that fit in the same socket have the same energy tyoe
  // and cost, they are identical from the mod assignment perspective.
  // This works because we check to see if we have already recorded this string
  // in heaps algorithm before we add the permutation to the result.
  const createPermutationKey = (permutation: (ProcessMod | null)[]) =>
    permutation
      .map((mod) => {
        if (mod) {
          const energyType = mod.energy?.type || DestinyEnergyType.Any;
          const energyCost = mod.energy?.val || 0;
          return `${energyType}${energyCost}${mod.plugCategoryHash}`;
        }
      })
      .filter(Boolean)
      .join(',');
  return generatePermutationsOfFive(mods, createPermutationKey);
}

export function generateModPermutations(mods: (PluggableInventoryItemDefinition | null)[]) {
  // Creates a string from the mod permutation containing the unique properties
  // that we care about, so we can reudce to the minimum number of permutations.
  // If two different mods that fit in the same socket have the same energy tyoe
  // and cost, they are identical from the mod assignment perspective.
  // This works because we check to see if we have already recorded this string
  // in heaps algorithm before we add the permutation to the result.
  const createPermutationKey = (permutation: (PluggableInventoryItemDefinition | null)[]) =>
    permutation
      .map((mod) => {
        if (mod) {
          const energyType = mod.plug.energyCost?.energyType || DestinyEnergyType.Any;
          const energyCost = mod.plug.energyCost?.energyCost || 0;
          return `${energyType}${energyCost}${mod.plug.plugCategoryHash}`;
        }
      })
      .filter(Boolean)
      .join(',');
  return generatePermutationsOfFive(mods, createPermutationKey);
}

/**
 * This is heaps algorithm implemented for generating mod permutations.
 * https://en.wikipedia.org/wiki/Heap%27s_algorithm<commit_msg>Use tag for process mod string keys<commit_after>import { PluggableInventoryItemDefinition } from 'app/inventory/item-types';
import { DestinyEnergyType } from 'bungie-api-ts/destiny2';
import { ProcessMod } from './process-worker/types';

export function generateProcessModPermutations(mods: (ProcessMod | null)[]) {
  // Creates a string from the mod permutation containing the unique properties
  // that we care about, so we can reudce to the minimum number of permutations.
  // If two different mods that fit in the same socket have the same energy tyoe
  // and cost, they are identical from the mod assignment perspective.
  // This works because we check to see if we have already recorded this string
  // in heaps algorithm before we add the permutation to the result.
  const createPermutationKey = (permutation: (ProcessMod | null)[]) =>
    permutation
      .map((mod) => {
        if (mod) {
          const energyType = mod.energy?.type || DestinyEnergyType.Any;
          const energyCost = mod.energy?.val || 0;
          return `${energyType}${energyCost}${mod.tag}`;
        }
      })
      .filter(Boolean)
      .join(',');
  return generatePermutationsOfFive(mods, createPermutationKey);
}

export function generateModPermutations(mods: (PluggableInventoryItemDefinition | null)[]) {
  // Creates a string from the mod permutation containing the unique properties
  // that we care about, so we can reudce to the minimum number of permutations.
  // If two different mods that fit in the same socket have the same energy tyoe
  // and cost, they are identical from the mod assignment perspective.
  // This works because we check to see if we have already recorded this string
  // in heaps algorithm before we add the permutation to the result.
  const createPermutationKey = (permutation: (PluggableInventoryItemDefinition | null)[]) =>
    permutation
      .map((mod) => {
        if (mod) {
          const energyType = mod.plug.energyCost?.energyType || DestinyEnergyType.Any;
          const energyCost = mod.plug.energyCost?.energyCost || 0;
          return `${energyType}${energyCost}${mod.plug.plugCategoryHash}`;
        }
      })
      .filter(Boolean)
      .join(',');
  return generatePermutationsOfFive(mods, createPermutationKey);
}

/**
 * This is heaps algorithm implemented for generating mod permutations.
 * https://en.wikipedia.org/wiki/Heap%27s_algorithm
{'fraction_non_alphanumeric': 0.09622995209331389, 'fraction_numerical': 0.002082899395959175, 'mean_word_length': 3.4669767441860464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '4729340', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1278, 'n_words': 465}