<commit_before>package com.jking31cs;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.jking31cs.state.Team;

import static com.jking31cs.IdGenerator.randomId;

/**
 * Created by jking31 on 11/8/16.
 */
public class DataGenerationDriver {
    public GeneratedData generatedData = new GeneratedData();

    public DataGenerationDriver() throws IOException {
        File outputDirectory = new File("output");
        if (!outputDirectory.exists()) {
            outputDirectory.mkdir();
        }
        buildTeams();
        simulateBattleTrees();
    }

    public static void main(String[] args) throws IOException {
        DataGenerationDriver driver = new DataGenerationDriver();
    }

    private void buildTeams() throws IOException {
        Map<String, PokemonWithTypes> allPokemon = PokemonListingCache.getAll();
        List<String> names = allPokemon.keySet().stream().collect(Collectors.toList());
        for (int i = 0; i < names.size() - 2; i++) {
            for (int j = i + 1; j < names.size() - 1; j++) {
                for (int k = j + 1; k < names.size(); k++) {
                    Team team = new Team(
                            randomId(),
                            names.get(i),
                            names.get(j),
                            names.get(k)

                    );
                    this.generatedData.addTeam(team);
                }
            }
        }
        System.out.println("Created all teams, size:" + generatedData.teams.size());
        new ObjectMapper().writeValue(new File("output/teams.json"), generatedData.teams);
    }

    private void simulateBattleTrees() throws IOException {
        int count = 0;
        for (Team t1 : generatedData.teams.values()) {
            int battleCount = 0;
            while (battleCount < 5) {
                Team t2 = generatedData.teams.values().stream().collect(Collectors.toList()).get(
                    new Random().nextInt(generatedData.teams.size())
                );
                if (t1.equals(t2)) {
                    continue; //Not doing mirror matches, blah
                }
                generatedData.addBattleTree(BattleTreeBuilder.createBattleTree(t1, t2));
                ++battleCount;
            }
            ++count;
            System.out.println(String.format("Percent Complete: %.5f", ((1.0d * (count)) /  generatedData.teams.size())));
            File resultFile = new File("output/simulated-battles" + count + ".json");
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.registerModule(new GuavaModule());
            objectMapper.writeValue(resultFile, generatedData.battleTrees);
            generatedData.battleTrees = new HashMap<>();
        }
    }

}<commit_msg>Added new indexing and fixed issue of combination/permuation, increasing teams size<commit_after>package com.jking31cs;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
import com.jking31cs.state.Team;

import static com.jking31cs.IdGenerator.randomId;

/**
 * Created by jking31 on 11/8/16.
 */
public class DataGenerationDriver {
    public GeneratedData generatedData = new GeneratedData();

    public DataGenerationDriver() throws IOException {
        File outputDirectory = new File("output");
        if (!outputDirectory.exists()) {
            outputDirectory.mkdir();
        }
        buildTeams();
        simulateBattleTrees();
    }

    public static void main(String[] args) throws IOException {
        DataGenerationDriver driver = new DataGenerationDriver();
    }

    private void buildTeams() throws IOException {
        Map<String, PokemonWithTypes> allPokemon = PokemonListingCache.getAll();
        List<String> names = allPokemon.keySet().stream().collect(Collectors.toList());
        for (int i = 0; i < names.size(); i++) {
            for (int j = 0; j < names.size(); j++) {
                if (j == i) continue;
                for (int k = 0; k < names.size(); k++) {
                    if (k == i || j == k) continue;
                    Team team = new Team(
                            randomId(),
                            names.get(i),
                            names.get(j),
                            names.get(k)

                    );
                    this.generatedData.addTeam(team);
                }
            }
        }
        System.out.println("Created all teams, size:" + generatedData.teams.size());
        new ObjectMapper().writeValue(new File("output/teams.json"), generatedData.teams);
    }

    private void simulateBattleTrees() throws IOException {
        int count = 0;
        for (Team t1 : generatedData.teams.values()) {
            int battleCount = 0;
            while (battleCount < 5) {
                Team t2 = generatedData.teams.values().stream().collect(Collectors.toList()).get(
                    new Random().nextInt(generatedData.teams.size())
                );
                if (t1.equals(t2)) {
                    continue; //Not doing mirror matches, blah
                }
                generatedData.addBattleTree(BattleTreeBuilder.createBattleTree(t1, t2));
                ++battleCount;
            }
            ++count;
            System.out.println(String.format("Percent Complete: %.5f", ((100.0d * (count)) /  generatedData.teams.size())));
            File outputDir = new File("output/simulated-battles");
            if (!outputDir.exists()) outputDir.mkdir();
            String subDir = t1.getId().substring(0,2);
            File targetDir = new File(outputDir, subDir);
            if (!targetDir.exists()) targetDir.mkdir();
            File resultFile = new File(targetDir, "battle-" + t1.getId() + ".json");
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.registerModule(new GuavaModule());
            objectMapper.writeValue(resultFile, generatedData.battleTrees);
            generatedData.battleTrees = new HashMap<>();
        }
    }

}
{'fraction_non_alphanumeric': 0.11964092245782387, 'fraction_numerical': 0.009905587370376103, 'mean_word_length': 2.04811320754717, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4819116', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1714, 'n_words': 385}