Code cleanup before merge

This commit is contained in:
austinio7116
2018-05-12 22:45:49 +01:00
committed by maustin
parent ccb1aa9ef0
commit c003ddeeac
3 changed files with 3 additions and 168 deletions

View File

@@ -199,10 +199,10 @@ public class SimulateMatch {
} }
Collections.reverse(log); Collections.reverse(log);
for(GameLogEntry l : log) { for(GameLogEntry l : log) {
//System.out.println(l); System.out.println(l);
} }
//System.out.println(String.format("\nGame %d ended in %d ms. %s has won!\n", 1+iGame, sw.getTime(), g1.getOutcome().getWinningLobbyPlayer().getName())); System.out.println(String.format("\nGame %d ended in %d ms. %s has won!\n", 1+iGame, sw.getTime(), g1.getOutcome().getWinningLobbyPlayer().getName()));
} }
private static void simulateTournament(Map<String, List<String>> params, GameRules rules, boolean outputGamelog) { private static void simulateTournament(Map<String, List<String>> params, GameRules rules, boolean outputGamelog) {

View File

@@ -145,49 +145,6 @@ public class DeckgenUtil {
for(String cardName:uniqueCards){ for(String cardName:uniqueCards){
selectedCards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName)); selectedCards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName));
} }
/*
if(secondKeycard == null){
//get second keycard
for(Map.Entry<PaperCard,Integer> pair:potentialCards){
preSelectedCards.add(pair.getKey());
}
//filter out land cards and if for AI non-playable cards as potential second key cards and remove cards not legal in format
Iterable<PaperCard> preSelectedNonLandCards;
preSelectedNonLandCards=Iterables.filter(preSelectedCards,Predicates.and(
Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard.FN_GET_RULES),
Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard.FN_GET_RULES),
format.getFilterPrinted()));
preSelectedCards= Lists.newArrayList(preSelectedNonLandCards);
//choose a second card randomly from the top 8 cards if possible
int randMax=4;
if(preSelectedCards.size()<randMax){
randMax=preSelectedCards.size();
}
secondKeycard = preSelectedCards.get(MyRandom.getRandom().nextInt(randMax));
}
List<Map.Entry<PaperCard,Integer>> potentialSecondCards = CardRelationMatrixGenerator.cardPools.get(FModel.getFormats().getStandard().getName()).get(secondKeycard.getName());
//combine card distances from second key card and re-sort
if(potentialSecondCards !=null && potentialSecondCards.size()>0) {
combineDistances(potentialCards, potentialSecondCards);
Collections.sort(potentialCards, new CardDistanceComparator());
Collections.reverse(potentialCards);
}
List<PaperCard> selectedCards = new ArrayList<>();
selectedCards.add(card);
selectedCards.add(secondKeycard);
for(Map.Entry<PaperCard,Integer> pair:potentialCards){
PaperCard potentialCard = pair.getKey();
if (!potentialCard.getName().equals(card.getName())
&& (forCommander || !potentialCard.getName().equals(secondKeycard.getName()))
&& format.getFilterPrinted().apply(potentialCard)) {
selectedCards.add(pair.getKey());
}
}*/
//build deck from combined list //build deck from combined list
CardThemedDeckBuilder dBuilder; CardThemedDeckBuilder dBuilder;
@@ -215,129 +172,7 @@ public class DeckgenUtil {
* @return * @return
*/ */
public static Deck buildCardGenDeck(PaperCard card, PaperCard secondKeycard, GameFormat format, boolean isForAI){ public static Deck buildCardGenDeck(PaperCard card, PaperCard secondKeycard, GameFormat format, boolean isForAI){
return buildLDACardGenDeck(card, format, isForAI); return buildLDACardGenDeck(card, format, isForAI);
/*List<Map.Entry<PaperCard,Integer>> potentialCards = new ArrayList<>();
potentialCards.addAll(CardRelationLDAGenerator.ldaPools.get(format.getName()).get(card.getName()));
Collections.sort(potentialCards,new CardDistanceComparator());
Collections.reverse(potentialCards);
//get second keycard
List<PaperCard> preSelectedCards = new ArrayList<>();
for(Map.Entry<PaperCard,Integer> pair:potentialCards){
preSelectedCards.add(pair.getKey());
}
//filter out land cards and if for AI non-playable cards as potential second key cards
Iterable<PaperCard> preSelectedNonLandCards;
if(isForAI){
preSelectedNonLandCards=Iterables.filter(preSelectedCards,Predicates.and(
Predicates.compose(CardRulesPredicates.IS_KEPT_IN_AI_DECKS, PaperCard.FN_GET_RULES),
Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard.FN_GET_RULES)));
}else{
preSelectedNonLandCards=Iterables.filter(preSelectedCards,
Predicates.compose(CardRulesPredicates.Presets.IS_NON_LAND, PaperCard.FN_GET_RULES));
}
preSelectedCards= Lists.newArrayList(preSelectedNonLandCards);
//choose a second card randomly from the top 8 cards if possible
if(secondKeycard == null) {
int randMax = 8;
if (preSelectedCards.size() < randMax) {
randMax = preSelectedCards.size();
}
secondKeycard = preSelectedCards.get(MyRandom.getRandom().nextInt(randMax));
}
List<Map.Entry<PaperCard,Integer>> potentialSecondCards = CardRelationMatrixGenerator.cardPools.get(format.getName()).get(secondKeycard.getName());
//combine card distances from second key card and re-sort
if(potentialSecondCards !=null && potentialSecondCards.size()>0) {
combineDistances(potentialCards, potentialSecondCards);
Collections.sort(potentialCards, new CardDistanceComparator());
Collections.reverse(potentialCards);
}
List<PaperCard> selectedCards = new ArrayList<>();
for(Map.Entry<PaperCard,Integer> pair:potentialCards){
selectedCards.add(pair.getKey());
}
*/
/*List<PaperCard> toRemove = new ArrayList<>();
Set<String> uniqueCards = new HashSet<>();
List<PaperCard> selectedCards = new ArrayList<>();
List<List<String>> cardArchetypes = CardRelationLDAGenerator.ldaPools.get(FModel.getFormats().getStandard().getName()).get(card.getName());
for(List<String> archetype:cardArchetypes){
for(String cardName:archetype){
uniqueCards.add(cardName);
}
}
for(String cardName:uniqueCards){
selectedCards.add(StaticData.instance().getCommonCards().getUniqueByName(cardName));
}
//randomly remove cards
int removeCount=0;
int i=0;
for(PaperCard c:selectedCards){
if(MyRandom.getRandom().nextInt(100)>70+(15-(i/selectedCards.size())*selectedCards.size()) && removeCount<4 //randomly remove some cards - more likely as distance increases
&&!c.getName().contains("Urza")){ //avoid breaking Tron decks
toRemove.add(c);
removeCount++;
}
if(c.getName().equals(card.getName())){//may have been added in secondary list
toRemove.add(c);
}
if(c.getName().equals(secondKeycard.getName())){//remove so we can add correct amount
toRemove.add(c);
}
++i;
}
selectedCards.removeAll(toRemove);
//Add keycard
List<PaperCard> playsetList = new ArrayList<>();
int keyCardCount=4;
if(card.getRules().getMainPart().getManaCost().getCMC()>7){
keyCardCount=1+MyRandom.getRandom().nextInt(4);
}else if(card.getRules().getMainPart().getManaCost().getCMC()>5){
keyCardCount=2+MyRandom.getRandom().nextInt(3);
}
for(int j=0;j<keyCardCount;++j) {
playsetList.add(card);
}
//Add 2nd keycard
int keyCard2Count=4;
if(card.getRules().getMainPart().getManaCost().getCMC()>7){
keyCard2Count=1+MyRandom.getRandom().nextInt(4);
}else if(card.getRules().getMainPart().getManaCost().getCMC()>5){
keyCard2Count=2+MyRandom.getRandom().nextInt(3);
}
for(int j=0;j<keyCard2Count;++j) {
playsetList.add(secondKeycard);
}
for (PaperCard c:selectedCards){
for(int j=0;j<4;++j) {
if(MyRandom.getRandom().nextInt(100)<90) {
playsetList.add(c);
}
}
}
//build deck from combined list
CardThemedDeckBuilder dBuilder = new CardThemedDeckBuilder(card,secondKeycard, playsetList,format,isForAI);
Deck deck = dBuilder.buildDeck();
if(deck.getMain().countAll()!=60){
System.out.println(deck.getMain().countAll());
System.out.println("Wrong card count "+deck.getMain().countAll());
deck=buildCardGenDeck(format,isForAI);
}
if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard.FN_GET_RULES))>27){
System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard.FN_GET_RULES)));
deck=buildCardGenDeck(format,isForAI);
}
while(deck.get(DeckSection.Sideboard).countAll()>15){
deck.get(DeckSection.Sideboard).remove(deck.get(DeckSection.Sideboard).get(0));
}
return deck;*/
} }
/** /**

View File

@@ -17,7 +17,7 @@ public class TournamentSwiss extends AbstractTournament {
public TournamentSwiss(List<TournamentPlayer> allPlayers, int pairingAmount) { public TournamentSwiss(List<TournamentPlayer> allPlayers, int pairingAmount) {
// Technically not 100% correct for huge tournaments, but yknow.. close enough. // Technically not 100% correct for huge tournaments, but yknow.. close enough.
super((int)Math.ceil(Math.log(allPlayers.size())/Math.log(2))*2, allPlayers); super((int)Math.ceil(Math.log(allPlayers.size())/Math.log(2)), allPlayers);
this.playersInPairing = pairingAmount; this.playersInPairing = pairingAmount;
} }