Removed old deckgen data

This commit is contained in:
austinio7116
2018-05-13 07:00:18 +01:00
committed by maustin
parent ff12e5b088
commit 05bc65aba9

View File

@@ -37,7 +37,6 @@ public final class CardArchetypeLDAGenerator {
List<String> formatStrings = new ArrayList<>();
formatStrings.add(FModel.getFormats().getStandard().getName());
formatStrings.add(FModel.getFormats().getModern().getName());
formatStrings.add(DeckFormat.Commander.toString());
for (String formatString : formatStrings){
if(!initializeFormat(formatString)){
@@ -58,8 +57,6 @@ public final class CardArchetypeLDAGenerator {
formatMap = loadFormat(FModel.getFormats().getStandard(), lda);
} else if (format.equals(FModel.getFormats().getModern().getName())) {
formatMap = loadFormat(FModel.getFormats().getModern(), lda);
} else {
//formatMap = initializeCommanderFormat();
}
CardThemedLDAIO.saveLDA(format, formatMap);
}catch (Exception e){
@@ -128,126 +125,4 @@ public final class CardArchetypeLDAGenerator {
}
return false;
}
public static HashMap<String,List<Map.Entry<PaperCard,Integer>>> initializeCommanderFormat(){
IStorage<Deck> decks = new StorageImmediatelySerialized<Deck>("Generator",
new DeckStorage(new File(ForgeConstants.DECK_GEN_DIR,DeckFormat.Commander.toString()),
ForgeConstants.DECK_GEN_DIR, false),
true);
//get all cards
final Iterable<PaperCard> cards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCards()
, Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES), PaperCard.FN_GET_RULES));
List<PaperCard> cardList = Lists.newArrayList(cards);
cardList.add(FModel.getMagicDb().getCommonCards().getCard("Wastes"));
Map<String, Integer> cardIntegerMap = new HashMap<>();
Map<Integer, PaperCard> integerCardMap = new HashMap<>();
Map<String, Integer> legendIntegerMap = new HashMap<>();
Map<Integer, PaperCard> integerLegendMap = new HashMap<>();
//generate lookups for cards to link card names to matrix columns
for (int i=0; i<cardList.size(); ++i){
cardIntegerMap.put(cardList.get(i).getName(), i);
integerCardMap.put(i, cardList.get(i));
}
//filter to just legal commanders
List<PaperCard> legends = Lists.newArrayList(Iterables.filter(cardList,Predicates.compose(
new Predicate<CardRules>() {
@Override
public boolean apply(CardRules rules) {
return DeckFormat.Commander.isLegalCommander(rules);
}
}, PaperCard.FN_GET_RULES)));
//generate lookups for legends to link commander names to matrix rows
for (int i=0; i<legends.size(); ++i){
legendIntegerMap.put(legends.get(i).getName(), i);
integerLegendMap.put(i, legends.get(i));
}
int[][] matrix = new int[legends.size()][cardList.size()];
//loop through commanders and decks
for (PaperCard legend:legends){
for (Deck deck:decks){
//if the deck has the commander
if (deck.getCommanders().contains(legend)){
//update the matrix by incrementing the connectivity count for each card in the deck
updateLegendMatrix(deck, legend, cardIntegerMap, legendIntegerMap, matrix);
}
}
}
//convert the matrix into a map of pools for each commander
HashMap<String,List<Map.Entry<PaperCard,Integer>>> cardPools = new HashMap<>();
for (PaperCard card:legends){
int col=legendIntegerMap.get(card.getName());
int[] distances = matrix[col];
int max = (Integer) Collections.max(Arrays.asList(ArrayUtils.toObject(distances)));
if (max>0) {
List<Map.Entry<PaperCard,Integer>> deckPool=new ArrayList<>();
for(int k=0;k<cardList.size(); k++){
if(matrix[col][k]>0){
deckPool.add(new AbstractMap.SimpleEntry<PaperCard, Integer>(integerCardMap.get(k),matrix[col][k]));
}
}
cardPools.put(card.getName(), deckPool);
}
}
return cardPools;
}
//update the matrix by incrementing the connectivity count for each card in the deck
public static void updateLegendMatrix(Deck deck, PaperCard legend, Map<String, Integer> cardIntegerMap,
Map<String, Integer> legendIntegerMap, int[][] matrix){
for (PaperCard pairCard:Iterables.filter(deck.getMain().toFlatList(),
Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND_NOT_WASTES), PaperCard.FN_GET_RULES))){
if (!pairCard.getName().equals(legend.getName())){
try {
int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())];
matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(pairCard.getName())] = old + 1;
}catch (NullPointerException ne){
//Todo: Not sure what was failing here
ne.printStackTrace();
}
}
}
//add partner commanders to matrix
if(deck.getCommanders().size()>1){
for(PaperCard partner:deck.getCommanders()){
if(!partner.equals(legend)){
int old = matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(partner.getName())];
matrix[legendIntegerMap.get(legend.getName())][cardIntegerMap.get(partner.getName())] = old + 1;
}
}
}
}
public static class ArrayIndexComparator implements Comparator<Integer>
{
private final Integer[] array;
public ArrayIndexComparator(Integer[] array)
{
this.array = array;
}
public Integer[] createIndexArray()
{
Integer[] indexes = new Integer[array.length];
for (int i = 0; i < array.length; i++)
{
indexes[i] = i; // Autoboxing
}
return indexes;
}
@Override
public int compare(Integer index1, Integer index2)
{
// Autounbox from Integer to int to use as array indexes
return array[index1].compareTo(array[index2]);
}
}
}