- Fixed draft AI picking the worst cards instead of the best (- yes really).

This commit is contained in:
Sloth
2013-02-13 22:40:08 +00:00
parent a2bdad3b32
commit c9a6d4edab
2 changed files with 11 additions and 10 deletions

View File

@@ -78,26 +78,26 @@ public class BoosterDraftAI {
List<Pair<CardPrinted, Double>> rankedCards = rankCards(chooseFrom); List<Pair<CardPrinted, Double>> rankedCards = rankCards(chooseFrom);
for(Pair<CardPrinted, Double> p : rankedCards) { for(Pair<CardPrinted, Double> p : rankedCards) {
// If a card is not ai playable, somewhat decreare its rating // If a card is not ai playable, somewhat decrease its rating
if( p.getKey().getCard().getRemAIDecks() ) if( p.getKey().getCard().getRemAIDecks() )
p.setValue(p.getValue() - TAKE_BEST_THRESHOLD); p.setValue(p.getValue() + TAKE_BEST_THRESHOLD);
// if I cannot choose more colors, and the card cannot be played with chosen colors, decrease its rating. // if I cannot choose more colors, and the card cannot be played with chosen colors, decrease its rating.
if( !canAddMoreColors && !p.getKey().getCard().getManaCost().canBePaidWithAvaliable(currentChoice)) if( !canAddMoreColors && !p.getKey().getCard().getManaCost().canBePaidWithAvaliable(currentChoice))
p.setValue(p.getValue() - 10); p.setValue(p.getValue() + 10);
} }
int cntBestCards = 0; int cntBestCards = 0;
double bestRating = Double.NEGATIVE_INFINITY; double bestRanking = Double.MAX_VALUE;
CardPrinted bestPick = null; CardPrinted bestPick = null;
for(Pair<CardPrinted, Double> p : rankedCards) { for(Pair<CardPrinted, Double> p : rankedCards) {
double rating = p.getValue(); double rating = p.getValue();
if( rating > bestRating ) if( rating < bestRanking )
{ {
bestRating = rating; bestRanking = rating;
bestPick = p.getKey(); bestPick = p.getKey();
cntBestCards = 1; cntBestCards = 1;
} else if ( rating == bestRating ) { } else if ( rating == bestRanking ) {
cntBestCards++; cntBestCards++;
} }
} }
@@ -105,7 +105,7 @@ public class BoosterDraftAI {
if (cntBestCards > 1) { if (cntBestCards > 1) {
final List<CardPrinted> possiblePick = new ArrayList<CardPrinted>(); final List<CardPrinted> possiblePick = new ArrayList<CardPrinted>();
for(Pair<CardPrinted, Double> p : rankedCards) { for(Pair<CardPrinted, Double> p : rankedCards) {
if ( p.getValue() == bestRating ) if ( p.getValue() == bestRanking )
possiblePick.add(p.getKey()); possiblePick.add(p.getKey());
} }
bestPick = Aggregates.random(possiblePick); bestPick = Aggregates.random(possiblePick);
@@ -114,6 +114,7 @@ public class BoosterDraftAI {
if (canAddMoreColors) if (canAddMoreColors)
deckCols.addColorsOf(bestPick); deckCols.addColorsOf(bestPick);
System.out.println("Player[" + player + "] picked: " + bestPick);
this.deck.get(player).add(bestPick); this.deck.get(player).add(bestPick);
return bestPick; return bestPick;

View File

@@ -93,8 +93,8 @@ public class ReadDraftRankings {
// Basic lands should be excluded from the evaluation --BBU // Basic lands should be excluded from the evaluation --BBU
if (cardName.equals("Island") || cardName.equals("Forest") || cardName.equals("Swamp") if (cardName.equals("Island") || cardName.equals("Forest") || cardName.equals("Swamp")
|| cardName.equals("Plains") || cardName.equals("Mountain")) { || cardName.equals("Plains") || cardName.equals("Mountain")) {
return null; return null;
} }
if (draftRankings.containsKey(edition)) { if (draftRankings.containsKey(edition)) {
String safeName = cardName.replaceAll("-", " ").replaceAll("[^A-Za-z ]", ""); String safeName = cardName.replaceAll("-", " ").replaceAll("[^A-Za-z ]", "");