Improved deck generation code - ensure keycard is non-land for LDA deck generation and improve handling of basic lands to ensure no colour is missed.

This commit is contained in:
maustin
2018-06-11 18:03:56 +01:00
parent 75931881f7
commit 8de0472048
2 changed files with 18 additions and 4 deletions

View File

@@ -230,7 +230,13 @@ public class DeckgenUtil {
*/
public static Deck buildLDACArchetypeDeck(Archetype archetype, GameFormat format, boolean isForAI){
List<Pair<String, Double>> preSelectedCardNames = archetype.getCardProbabilities();
PaperCard card = StaticData.instance().getCommonCards().getUniqueByName(preSelectedCardNames.get(0).getLeft());
PaperCard card = null;
for(Pair<String, Double> pair : preSelectedCardNames){
card = StaticData.instance().getCommonCards().getUniqueByName(pair.getLeft());
if(!card.getRules().getType().isLand()){
break;
}
}
List<PaperCard> selectedCards = new ArrayList<>();
for(Pair<String, Double> pair:preSelectedCardNames){
String name = pair.getLeft();
@@ -248,7 +254,7 @@ public class DeckgenUtil {
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
if( i > 4 && 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++;

View File

@@ -99,7 +99,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
targetSize=deckFormat.getMainRange().getMinimum();
FullDeckColors deckColors = new FullDeckColors();
int cardCount=0;
int colourCheckAmount = 20;
int colourCheckAmount = 30;
if (targetSize < 60){
colourCheckAmount = 10;//lower amount for planar decks
}
@@ -623,12 +623,20 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
numColors++;
}
}
// add one of each land required first so that any rounding errors do not remove the only land of a colour
for (int i = 0; i < 5; i++) {
if (clrCnts[i] > 0) {
deckList.add(getBasicLand(i));
landsNeeded--;
}
}
// do not update landsNeeded until after the loop, because the
// calculation involves landsNeeded
for (int i = 0; i < 5; i++) {
if (clrCnts[i] > 0) {
// calculate number of lands for each color
// calculate remaining number of lands for each color
float p = (float) clrCnts[i] / (float) totalColor;
int nLand = Math.round(landsNeeded * p); // desired truncation to int
if (logToConsole) {