WeightDraftBot now correctly picks the last card; Fixed drafted cards not being added to bots collections; Fixed pointless draft advancing when bot picked
This commit is contained in:
@@ -172,6 +172,7 @@ public class TableDraftClassic implements TableDraft{
|
||||
String pickedCard = assignedBoosters.get(draftPlayer).pickCard(card);
|
||||
// Add to collection
|
||||
if (draftPlayer instanceof DraftBot) {
|
||||
botCollections.get(((DraftPlayer) draftPlayer)).addItem(pickedCard, 1);
|
||||
return;
|
||||
}
|
||||
DefaultCardCollection pickedCardCollection = new DefaultCardCollection();
|
||||
@@ -310,7 +311,9 @@ public class TableDraftClassic implements TableDraft{
|
||||
chosenCards.put(who, what);
|
||||
|
||||
//Check if all players chose
|
||||
advanceDraft();
|
||||
if (!(who instanceof DraftBot)) {
|
||||
advanceDraft();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,16 +33,11 @@ public class WeightDraftBot extends DraftPlayer implements DraftBot {
|
||||
private List<String> getTopCards(List<String> cardsToPickFrom) {
|
||||
// Sort the cards by value in descending order
|
||||
return cardsToPickFrom.stream()
|
||||
.sorted((card1, card2) -> Double.compare(cardValues.getOrDefault(card2, 0.0), cardValues.getOrDefault(card1, 0.0)))
|
||||
.limit(getTopCardCount(cardsToPickFrom.size()))
|
||||
.sorted((card1, card2) -> Double.compare(cardValues.getOrDefault(card2, 0.1), cardValues.getOrDefault(card1, 0.1)))
|
||||
.limit(2) // Choose from two highest ranked cards
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private int getTopCardCount(int packSize) {
|
||||
// Choose top 3 cards if the pack has more than 5, otherwise choose half of the cards
|
||||
return packSize <= 5 ? packSize / 2 : 3;
|
||||
}
|
||||
|
||||
private double getTotalValue(List<String> topCards) {
|
||||
// Sum up the values of the top N cards
|
||||
return topCards.stream()
|
||||
|
||||
Reference in New Issue
Block a user