@Override public int getNumberOfSpecialCommons() { // Then about an eighth of the packs will have a second double-faced card, which will be a rare or mythic rare. return RandomUtil.nextInt(8) == 0 ? 1 : 0; }
@Override public boolean chooseMulligan(Game game) { return RandomUtil.nextBoolean(); }
protected void shufflePlayers() { Collections.shuffle(this.players, RandomUtil.getRandom()); }
if (RandomUtil.nextDouble() < rejectMissingColorProbability) { return false; if (RandomUtil.nextDouble() < rejectSameColorUncommonsProbability) { return false;
public String nextString() { for (int idx = 0; idx < buf.length; ++idx) { buf[idx] = symbols[RandomUtil.nextInt(symbols.length)]; } return new String(buf); } }
@Override public boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game) { if (this.isHuman()) { return RandomUtil.nextBoolean(); } return super.choosePile(outcome, message, pile1, pile2, game); }
@Override public int announceXCost(int min, int max, String message, Game game, Ability ability, VariableCost variablCost) { log.debug("announceXCost"); //TODO: improve this int value = RandomUtil.nextInt(max + 1); if (value < min) { value = min; } if (value < max) { value++; } return value; }
@Override public boolean chooseUse(Outcome outcome, String message, Ability source, Game game) { if (this.isHuman()) { return RandomUtil.nextBoolean(); } return super.chooseUse(outcome, message, source, game); }
@Override public int getAmount(int min, int max, String message, Game game) { log.debug("getAmount"); if (message.startsWith("Assign damage to ")) { return min; } //TODO: improve this if (min < max && min == 0) { return RandomUtil.nextInt(max + 1); } return min; }
|| (depth == maxDepth && val == alpha && RandomUtil.nextBoolean())) { // Adding random for equal value to get change sometimes alpha = val; bestNode = newNode;
private TournamentPlayer getNextAvailablePlayer(List<TournamentPlayer> roundPlayers, List<TournamentPlayer> playerWithByes) { TournamentPlayer nextPlayer; if (playerWithByes.isEmpty()) { int i = RandomUtil.nextInt(roundPlayers.size()); nextPlayer = roundPlayers.get(i); roundPlayers.remove(i); } else { // prefer players with byes to pair Iterator<TournamentPlayer> iterator = playerWithByes.iterator(); nextPlayer = iterator.next(); iterator.remove(); roundPlayers.remove(nextPlayer); } return nextPlayer; }
game.informPlayers(getLogName() + " chose " + CardUtil.booleanToFlipName(chosen)); boolean result = RandomUtil.nextBoolean(); FlipCoinEvent event = new FlipCoinEvent(playerId, source.getSourceId(), result, chosen, winnable); event.addAppliedEffects(appliedEffects); boolean canChooseTails = !event.getResult(); for (int i = 1; i < event.getFlipCount(); i++) { boolean tempFlip = RandomUtil.nextBoolean(); canChooseHeads = canChooseHeads || tempFlip; canChooseTails = canChooseTails || !tempFlip;
/** * @param name * @return random card with the provided name or null if none is found */ public CardInfo findCard(String name) { List<CardInfo> cards = findCards(name); if (!cards.isEmpty()) { return cards.get(RandomUtil.nextInt(cards.size())); } return null; }
protected void addToBooster(List<Card> booster, List<CardInfo> cards) { if (!cards.isEmpty()) { CardInfo cardInfo = cards.remove(RandomUtil.nextInt(cards.size())); if (cardInfo != null) { Card card = cardInfo.getCard(); if (card != null) { booster.add(card); } } } }
/** * Don't use this directly. Use <player.shuffleLibrary(game)> instead. */ public void shuffle() { UUID[] shuffled = library.toArray(new UUID[0]); for (int n = shuffled.length - 1; n > 0; n--) { int r = RandomUtil.nextInt(n + 1); UUID temp = shuffled[n]; shuffled[n] = shuffled[r]; shuffled[r] = temp; } library.clear(); library.addAll(Arrays.asList(shuffled)); }
@Override public TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game) { if (this.isHuman()) { return abilities.get(RandomUtil.nextInt(abilities.size())); } return super.chooseTriggeredAbility(abilities, game); }
@Override public int chooseReplacementEffect(Map<String, String> rEffects, Game game) { if (this.isHuman()) { return RandomUtil.nextInt(rEffects.size()); } return super.chooseReplacementEffect(rEffects, game); }
protected boolean chooseRandom(Target target, Game game) { Set<UUID> possibleTargets = target.possibleTargets(playerId, game); if (possibleTargets.isEmpty()) { return false; } if (possibleTargets.size() == 1) { target.add(possibleTargets.iterator().next(), game); return true; } Iterator<UUID> it = possibleTargets.iterator(); int targetNum = RandomUtil.nextInt(possibleTargets.size()); UUID targetId = it.next(); for (int i = 0; i < targetNum; i++) { targetId = it.next(); } target.add(targetId, game); return true; }
@Override public void setExpansionSetCodeForImage(String code) { super.setExpansionSetCodeForImage(code); if (getOriginalExpansionSetCode().equals("BFZ")) { this.setTokenType(RandomUtil.nextInt(3) + 1); // 3 different images } if (getOriginalExpansionSetCode().equals("OGW")) { this.setTokenType(RandomUtil.nextInt(6) + 1); // 6 different images } }
@Override public UUID chooseAttackerOrder(List<Permanent> attackers, Game game) { if (this.isHuman()) { return attackers.get(RandomUtil.nextInt(attackers.size())).getId(); } return super.chooseAttackerOrder(attackers, game); }