list.size > 0 changed to !list.isEmpty

We care about if it's empty or not, not about it's size
This commit is contained in:
vraskulin 2017-01-27 16:04:56 +03:00
parent 0de8bd2f70
commit fc54c0156c
366 changed files with 532 additions and 548 deletions

View file

@ -272,7 +272,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
while (actions.peek() != null) {
Ability ability = actions.poll();
logger.info(new StringBuilder("===> Act [").append(game.getPlayer(playerId).getName()).append("] Action: ").append(ability.toString()).toString());
if (ability.getTargets().size() > 0) {
if (!ability.getTargets().isEmpty()) {
for (Target target : ability.getTargets()) {
for (UUID id : target.getTargets()) {
target.updateTarget(id, game);
@ -318,7 +318,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
//int bestScore = addActionsTimed(new FilterAbility());
currentScore = GameStateEvaluator2.evaluate(playerId, game);
addActionsTimed();
if (root.children.size() > 0) {
if (!root.children.isEmpty()) {
root = root.children.get(0);
//GameStateEvaluator2.evaluate(playerId, root.getGame());
int bestScore = root.getScore();
@ -335,10 +335,10 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
}
protected boolean getNextAction(Game game) {
if (root != null && root.children.size() > 0) {
if (root != null && !root.children.isEmpty()) {
SimulationNode2 test = root;
root = root.children.get(0);
while (root.children.size() > 0 && !root.playerId.equals(playerId)) {
while (!root.children.isEmpty() && !root.playerId.equals(playerId)) {
test = root;
root = root.children.get(0);
}
@ -525,7 +525,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
UUID currentPlayerId = node.getGame().getPlayerList().get();
//logger.info("reached - " + val + ", playerId=" + playerId + ", node.pid="+currentPlayerId);
return val;
} else if (node.getChildren().size() > 0) {
} else if (!node.getChildren().isEmpty()) {
logger.trace("Add actions -- something added children:" + node.getChildren().size());
val = minimaxAB(node, depth - 1, alpha, beta);
return val;
@ -542,7 +542,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
if (game.gameOver(null)) {
val = GameStateEvaluator2.evaluate(playerId, game);
} else if (node.getChildren().size() > 0) {
} else if (!node.getChildren().isEmpty()) {
//declared attackers or blockers or triggered abilities
logger.debug("Add actions -- attack/block/trigger added children:" + node.getChildren().size());
val = minimaxAB(node, depth - 1, alpha, beta);
@ -568,7 +568,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
SimulationNode2 bestNode = null;
List<Ability> allActions = currentPlayer.simulatePriority(game);
optimize(game, allActions);
if (logger.isInfoEnabled() && allActions.size() > 0 && depth == maxDepth) {
if (logger.isInfoEnabled() && !allActions.isEmpty() && depth == maxDepth) {
logger.info("ADDED ACTIONS (" + allActions.size() + ") " + ' ' + allActions);
}
int counter = 0;
@ -614,9 +614,9 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
.append(listTargets(game, action.getTargets())).append(')')
.append(logger.isTraceEnabled() ? " #" + newNode.hashCode() : "");
SimulationNode2 logNode = newNode;
while (logNode.getChildren() != null && logNode.getChildren().size() > 0) {
while (logNode.getChildren() != null && !logNode.getChildren().isEmpty()) {
logNode = logNode.getChildren().get(0);
if (logNode.getAbilities() != null && logNode.getAbilities().size() > 0) {
if (logNode.getAbilities() != null && !logNode.getAbilities().isEmpty()) {
sb.append(" -> [").append(logNode.getDepth()).append(']').append(logNode.getAbilities().toString()).append('<').append(logNode.getScore()).append('>');
}
}
@ -634,7 +634,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
alpha = val;
bestNode = newNode;
bestNode.setScore(val);
if (newNode.getChildren().size() > 0) {
if (!newNode.getChildren().isEmpty()) {
bestNode.setCombat(newNode.getChildren().get(0).getCombat());
}
/*
@ -660,7 +660,7 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
beta = val;
bestNode = newNode;
bestNode.setScore(val);
if (newNode.getChildren().size() > 0) {
if (!newNode.getChildren().isEmpty()) {
bestNode.setCombat(newNode.getChildren().get(0).getCombat());
}
}

View file

@ -164,7 +164,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
addActionsTimed();
logger.trace("After add actions timed: root.children.size = " + root.children.size());
if (root.children.size() > 0) {
if (!root.children.isEmpty()) {
root = root.children.get(0);
// int bestScore = root.getScore();
// if (bestScore > currentScore || allowBadMoves) {
@ -204,7 +204,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
logger.debug("Sim Calculate post combat actions ----------------------------------------------------------------------------------------");
addActionsTimed();
if (root != null && root.children.size() > 0) {
if (root != null && !root.children.isEmpty()) {
root = root.children.get(0);
int bestScore = root.getScore();
if (bestScore > currentScore || allowBadMoves) {
@ -244,7 +244,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
} while ((logNode.getParent() != null));
logger.trace(sb);
}
} else if (node.getChildren().size() > 0) {
} else if (!node.getChildren().isEmpty()) {
if (logger.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Add Action [").append(depth)
.append("] -- something added children ")
@ -299,7 +299,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
val = GameStateEvaluator2.evaluate(playerId, game);
*/
}
} else if (node.getChildren().size() > 0) {
} else if (!node.getChildren().isEmpty()) {
if (logger.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Add Action [").append(depth)
.append("] -- trigger ")
@ -411,7 +411,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
beta = val;
bestNode = newNode;
bestNode.setScore(val);
if (newNode.getChildren().size() > 0) {
if (!newNode.getChildren().isEmpty()) {
bestNode.setCombat(newNode.getChildren().get(0).getCombat());
}
}
@ -419,7 +419,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
alpha = val;
bestNode = newNode;
bestNode.setScore(val);
if (newNode.getChildren().size() > 0) {
if (!newNode.getChildren().isEmpty()) {
bestNode.setCombat(newNode.getChildren().get(0).getCombat());
}
}
@ -460,7 +460,7 @@ public class ComputerPlayer7 extends ComputerPlayer6 {
}
Game sim = game.copy();
for (CombatGroup group : engagement.getGroups()) {
if (group.getAttackers().size() > 0) {
if (!group.getAttackers().isEmpty()) {
UUID attackerId = group.getAttackers().get(0);
for (UUID blockerId : group.getBlockers()) {
sim.getPlayer(defenderId).declareBlocker(defenderId, blockerId, attackerId, sim);

View file

@ -60,7 +60,7 @@ public class SimulatedAction2 {
}
public boolean usesStack() {
if (abilities != null && abilities.size() > 0) {
if (abilities != null && !abilities.isEmpty()) {
return abilities.get(abilities.size() -1).isUsesStack();
}
return true;

View file

@ -103,7 +103,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
if (logger.isTraceEnabled()) {
for (Ability a : allActions) {
logger.info("ability==" + a);
if (a.getTargets().size() > 0) {
if (!a.getTargets().isEmpty()) {
MageObject mageObject = game.getObject(a.getFirstTarget());
if (mageObject != null) {
logger.info(" target=" + mageObject.getName());
@ -177,7 +177,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
}
card.adjustTargets(newAbility, game);
// add the different possible target option for the specific X value
if (newAbility.getTargets().getUnchosen().size() > 0) {
if (!newAbility.getTargets().getUnchosen().isEmpty()) {
addTargetOptions(options, newAbility, targetNum, game);
}
}
@ -240,7 +240,7 @@ public class SimulatedPlayer2 extends ComputerPlayer {
}
List<Ability> filtered = new ArrayList<>();
for (Ability option : options) {
if (option.getTargets().size() > 0 && option.getTargets().get(0).getMaxNumberOfTargets() == 1) {
if (!option.getTargets().isEmpty() && option.getTargets().get(0).getMaxNumberOfTargets() == 1) {
Card card = game.getCard(ability.getSourceId());
for (String s : suggested) {
String[] groups = s.split(";");

View file

@ -212,7 +212,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
if (target.getOriginalTarget() instanceof TargetDiscard) {
findPlayables(game);
if (unplayable.size() > 0) {
if (!unplayable.isEmpty()) {
for (int i = unplayable.size() - 1; i >= 0; i--) {
if (target.canTarget(unplayable.values().toArray(new Card[0])[i].getId(), game)) {
target.add(unplayable.values().toArray(new Card[0])[i].getId(), game);
@ -222,7 +222,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
}
}
if (hand.size() > 0) {
if (!hand.isEmpty()) {
for (int i = 0; i < hand.size(); i++) {
if (target.canTarget(hand.toArray(new UUID[0])[i], game)) {
target.add(hand.toArray(new UUID[0])[i], game);
@ -467,7 +467,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
Cards cards = new CardsImpl(target.possibleTargets(source.getSourceId(), getId(), game));
ArrayList<Card> cardsInHand = new ArrayList<>(cards.getCards(game));
while (!target.isChosen()
&& target.possibleTargets(source.getSourceId(), getId(), game).size() > 0
&& !target.possibleTargets(source.getSourceId(), getId(), game).isEmpty()
&& target.getMaxNumberOfTargets() > target.getTargets().size()) {
Card card = pickBestCard(cardsInHand, null, target, source, game);
if (card != null) {
@ -482,7 +482,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
} else {
findPlayables(game);
if (unplayable.size() > 0) {
if (!unplayable.isEmpty()) {
for (int i = unplayable.size() - 1; i >= 0; i--) {
if (target.canTarget(getId(), unplayable.values().toArray(new Card[0])[i].getId(), source, game)) {
target.addTarget(unplayable.values().toArray(new Card[0])[i].getId(), source, game);
@ -492,7 +492,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
}
}
if (hand.size() > 0) {
if (!hand.isEmpty()) {
for (int i = 0; i < hand.size(); i++) {
if (target.canTarget(getId(), hand.toArray(new UUID[0])[i], source, game)) {
target.addTarget(hand.toArray(new UUID[0])[i], source, game);
@ -674,7 +674,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
return target.isChosen();
}
if (target.getOriginalTarget() instanceof TargetSpell) {
if (game.getStack().size() > 0) {
if (!game.getStack().isEmpty()) {
Iterator<StackObject> it = game.getStack().iterator();
while (it.hasNext()) {
StackObject o = it.next();
@ -708,7 +708,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
}
}
if (game.getStack().size() > 0) {
if (!game.getStack().isEmpty()) {
Iterator<StackObject> it = game.getStack().iterator();
while (it.hasNext()) {
StackObject stackObject = it.next();
@ -878,7 +878,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
break;
case PRECOMBAT_MAIN:
findPlayables(game);
if (playableAbilities.size() > 0) {
if (!playableAbilities.isEmpty()) {
for (ActivatedAbility ability : playableAbilities) {
if (ability.canActivate(playerId, game)) {
if (ability.getEffects().hasOutcome(Outcome.PutLandInPlay)) {
@ -909,7 +909,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
case POSTCOMBAT_MAIN:
findPlayables(game);
if (game.getStack().isEmpty()) {
if (playableNonInstant.size() > 0) {
if (!playableNonInstant.isEmpty()) {
for (Card card : playableNonInstant) {
if (card.getSpellAbility().canActivate(playerId, game)) {
if (this.activateAbility(card.getSpellAbility(), game)) {
@ -918,7 +918,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
}
}
if (playableAbilities.size() > 0) {
if (!playableAbilities.isEmpty()) {
for (ActivatedAbility ability : playableAbilities) {
if (ability.canActivate(playerId, game)) {
if (!(ability.getEffects().get(0) instanceof BecomesCreatureSourceEffect)) {
@ -975,7 +975,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
lands.add(landCard);
}
while (lands.size() > 0 && this.canPlayLand()) {
while (!lands.isEmpty() && this.canPlayLand()) {
if (lands.size() == 1) {
this.playLand(lands.iterator().next(), game, false);
} else {
@ -1030,7 +1030,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
for (Card card : nonLands) {
ManaOptions options = card.getManaCost().getOptions();
if (card.getManaCost().getVariableCosts().size() > 0) {
if (!card.getManaCost().getVariableCosts().isEmpty()) {
//don't use variable mana costs unless there is at least 3 extra mana for X
for (Mana option : options) {
option.add(Mana.GenericMana(3));
@ -1062,7 +1062,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
continue;
}
ManaOptions abilityOptions = ability.getManaCosts().getOptions();
if (ability.getManaCosts().getVariableCosts().size() > 0) {
if (!ability.getManaCosts().getVariableCosts().isEmpty()) {
//don't use variable mana costs unless there is at least 3 extra mana for X
for (Mana option : abilityOptions) {
option.add(Mana.GenericMana(3));
@ -1386,7 +1386,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
for (Permanent permanent : game.getBattlefield().getActivePermanents(this.getId(), game)) {
if (game.getOpponents(this.getId()).contains(permanent.getControllerId())
&& permanent.getCardType().contains(CardType.CREATURE)
&& permanent.getSubtype(game).size() > 0) {
&& !permanent.getSubtype(game).isEmpty()) {
if (choice.getChoices().contains(permanent.getSubtype(game).get(0))) {
choice.setChoice(permanent.getSubtype(game).get(0));
break;
@ -1398,7 +1398,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
for (UUID opponentId : game.getOpponents(this.getId())) {
Player opponent = game.getPlayer(opponentId);
for (Card card : opponent.getGraveyard().getCards(game)) {
if (card != null && card.getCardType().contains(CardType.CREATURE) && card.getSubtype(game).size() > 0) {
if (card != null && card.getCardType().contains(CardType.CREATURE) && !card.getSubtype(game).isEmpty()) {
if (choice.getChoices().contains(card.getSubtype(game).get(0))) {
choice.setChoice(card.getSubtype(game).get(0));
break;
@ -1414,7 +1414,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
// choose a creature type of hand or library
for (UUID cardId : this.getHand()) {
Card card = game.getCard(cardId);
if (card != null && card.getCardType().contains(CardType.CREATURE) && card.getSubtype(game).size() > 0) {
if (card != null && card.getCardType().contains(CardType.CREATURE) && !card.getSubtype(game).isEmpty()) {
if (choice.getChoices().contains(card.getSubtype(game).get(0))) {
choice.setChoice(card.getSubtype(game).get(0));
break;
@ -1424,7 +1424,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
if (!choice.isChosen()) {
for (UUID cardId : this.getLibrary().getCardList()) {
Card card = game.getCard(cardId);
if (card != null && card.getCardType().contains(CardType.CREATURE) && card.getSubtype(game).size() > 0) {
if (card != null && card.getCardType().contains(CardType.CREATURE) && !card.getSubtype(game).isEmpty()) {
if (choice.getChoices().contains(card.getSubtype(game).get(0))) {
choice.setChoice(card.getSubtype(game).get(0));
break;
@ -1545,7 +1545,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
MageObject object = game.getObject(ability.getSourceId());
if (object != null) {
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getSpellAbilities(object, game.getState().getZone(object.getId()), game);
if (useableAbilities != null && useableAbilities.size() > 0) {
if (useableAbilities != null && !useableAbilities.isEmpty()) {
game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(useableAbilities.values()));
// TODO: Improve this
return (SpellAbility) useableAbilities.values().iterator().next();
@ -1584,7 +1584,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
public TriggeredAbility chooseTriggeredAbility(List<TriggeredAbility> abilities, Game game) {
log.debug("chooseTriggeredAbility: " + abilities.toString());
//TODO: improve this
if (abilities.size() > 0) {
if (!abilities.isEmpty()) {
return abilities.get(0);
}
return null;
@ -1729,7 +1729,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
@Override
public void construct(Tournament tournament, Deck deck) {
if (deck != null && deck.getCards().size() < 40 && deck.getSideboard().size() > 0) {
if (deck != null && deck.getCards().size() < 40 && !deck.getSideboard().isEmpty()) {
//pick the top 23 cards
if (chosenColors == null) {
for (Card card : deck.getSideboard()) {

View file

@ -52,7 +52,7 @@ public class MCTSPlayer extends ComputerPlayer {
private NextAction nextAction;
public enum NextAction {
PRIORITY, SELECT_ATTACKERS, SELECT_BLOCKERS;
PRIORITY, SELECT_ATTACKERS, SELECT_BLOCKERS
}
public MCTSPlayer(UUID id) {
@ -83,7 +83,7 @@ public class MCTSPlayer extends ComputerPlayer {
for (Ability ability: playables) {
List<Ability> options = game.getPlayer(playerId).getPlayableOptions(ability, game);
if (options.isEmpty()) {
if (ability.getManaCosts().getVariableCosts().size() > 0) {
if (!ability.getManaCosts().getVariableCosts().isEmpty()) {
simulateVariableCosts(ability, all, game);
}
else {
@ -92,7 +92,7 @@ public class MCTSPlayer extends ComputerPlayer {
}
else {
for (Ability option: options) {
if (ability.getManaCosts().getVariableCosts().size() > 0) {
if (!ability.getManaCosts().getVariableCosts().isEmpty()) {
simulateVariableCosts(option, all, game);
}
else {

View file

@ -124,7 +124,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
ability = options.get(RandomUtil.nextInt(options.size()));
}
}
if (ability.getManaCosts().getVariableCosts().size() > 0) {
if (!ability.getManaCosts().getVariableCosts().isEmpty()) {
int amount = getAvailableManaProducers(game).size() - ability.getManaCosts().convertedManaCost();
if (amount > 0) {
ability = ability.copy();
@ -221,7 +221,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
int check = RandomUtil.nextInt(numGroups + 1);
if (check < numGroups) {
CombatGroup group = game.getCombat().getGroups().get(check);
if (group.getAttackers().size() > 0) {
if (!group.getAttackers().isEmpty()) {
this.declareBlocker(this.getId(), blocker.getId(), group.getAttackers().get(0), game);
}
}

View file

@ -161,7 +161,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
else
addActions(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s");
if (root.children.size() > 0) {
if (!root.children.isEmpty()) {
root = root.children.get(0);
actions = new LinkedList<Ability>(root.abilities);
combat = root.combat;
@ -174,10 +174,10 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
}
protected boolean getNextAction(Game game) {
if (root != null && root.children.size() > 0) {
if (root != null && !root.children.isEmpty()) {
SimulationNode test = root;
root = root.children.get(0);
while (root.children.size() > 0 && !root.playerId.equals(playerId)) {
while (!root.children.isEmpty() && !root.playerId.equals(playerId)) {
test = root;
root = root.children.get(0);
}
@ -335,7 +335,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
logger.debug(indent(node.depth) + "simulating -- reached end state");
val = GameStateEvaluator.evaluate(playerId, game);
}
else if (node.getChildren().size() > 0) {
else if (!node.getChildren().isEmpty()) {
logger.debug(indent(node.depth) + "simulating -- somthing added children:" + node.getChildren().size());
val = minimaxAB(node, alpha, beta);
}
@ -361,7 +361,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
if (game.gameOver(null)) {
val = GameStateEvaluator.evaluate(playerId, game);
}
else if (node.getChildren().size() > 0) {
else if (!node.getChildren().isEmpty()) {
//declared attackers or blockers or triggered abilities
logger.debug(indent(node.depth) + "simulating -- attack/block/trigger added children:" + node.getChildren().size());
val = minimaxAB(node, alpha, beta);
@ -430,9 +430,9 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
alpha = val;
bestNode = newNode;
node.setCombat(newNode.getCombat());
if (node.getTargets().size() > 0)
if (!node.getTargets().isEmpty())
targets = node.getTargets();
if (node.getChoices().size() > 0)
if (!node.getChoices().isEmpty())
choices = node.getChoices();
}
if (val == GameStateEvaluator.WIN_SCORE) {
@ -673,7 +673,7 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
@Override
public void selectBlockers(Game game, UUID defendingPlayerId) {
logger.debug("selectBlockers");
if (combat != null && combat.getGroups().size() > 0) {
if (combat != null && !combat.getGroups().isEmpty()) {
List<CombatGroup> groups = game.getCombat().getGroups();
for (int i = 0; i < groups.size(); i++) {
if (i < combat.getGroups().size()) {

View file

@ -139,7 +139,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
else
addActions(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s");
if (root.children.size() > 0) {
if (!root.children.isEmpty()) {
root = root.children.get(0);
actions = new LinkedList<Ability>(root.abilities);
combat = root.combat;
@ -163,7 +163,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
else
addActions(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
logger.info(name + " simulated " + nodeCount + " nodes in " + thinkTime/1000000000.0 + "s - average " + nodeCount/(thinkTime/1000000000.0) + " nodes/s");
if (root.children.size() > 0) {
if (!root.children.isEmpty()) {
root = root.children.get(0);
actions = new LinkedList<Ability>(root.abilities);
combat = root.combat;
@ -189,7 +189,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
logger.debug(indent(node.depth) + "simulating -- reached end state");
val = GameStateEvaluator.evaluate(playerId, game);
}
else if (node.getChildren().size() > 0) {
else if (!node.getChildren().isEmpty()) {
logger.debug(indent(node.depth) + "simulating -- somthing added children:" + node.getChildren().size());
val = minimaxAB(node, alpha, beta);
}
@ -238,7 +238,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
val = GameStateEvaluator.evaluate(playerId, game);
}
}
else if (node.getChildren().size() > 0) {
else if (!node.getChildren().isEmpty()) {
logger.debug(indent(node.depth) + "simulating -- trigger added children:" + node.getChildren().size());
val = minimaxAB(node, alpha, beta);
}
@ -388,7 +388,7 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
}
Game sim = game.copy();
for (CombatGroup group: engagement.getGroups()) {
if (group.getAttackers().size() > 0) {
if (!group.getAttackers().isEmpty()) {
UUID attackerId = group.getAttackers().get(0);
for (UUID blockerId: group.getBlockers()) {
sim.getPlayer(defenderId).declareBlocker(defenderId, blockerId, attackerId, sim);

View file

@ -60,7 +60,7 @@ public class SimulatedAction {
}
public boolean usesStack() {
if (abilities != null && abilities.size() > 0) {
if (abilities != null && !abilities.isEmpty()) {
return abilities.get(abilities.size() -1).isUsesStack();
}
return true;

View file

@ -90,7 +90,7 @@ public class SimulatedPlayer extends ComputerPlayer {
for (Ability ability: playables) {
List<Ability> options = game.getPlayer(playerId).getPlayableOptions(ability, game);
if (options.isEmpty()) {
if (ability.getManaCosts().getVariableCosts().size() > 0) {
if (!ability.getManaCosts().getVariableCosts().isEmpty()) {
simulateVariableCosts(ability, game);
}
else {
@ -101,7 +101,7 @@ public class SimulatedPlayer extends ComputerPlayer {
else {
// ExecutorService simulationExecutor = Executors.newFixedThreadPool(4);
for (Ability option: options) {
if (ability.getManaCosts().getVariableCosts().size() > 0) {
if (!ability.getManaCosts().getVariableCosts().isEmpty()) {
simulateVariableCosts(option, game);
}
else {

View file

@ -726,7 +726,7 @@ public class HumanPlayer extends PlayerImpl {
}
if (actingPlayer != null) {
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = actingPlayer.getUseableActivatedAbilities(object, zone, game);
if (useableAbilities != null && useableAbilities.size() > 0) {
if (useableAbilities != null && !useableAbilities.isEmpty()) {
activateAbility(useableAbilities, object, game);
result = true;
}
@ -912,7 +912,7 @@ public class HumanPlayer extends PlayerImpl {
Zone zone = game.getState().getZone(object.getId());
if (zone != null) {
LinkedHashMap<UUID, ActivatedManaAbilityImpl> useableAbilities = getUseableManaAbilities(object, zone, game);
if (useableAbilities != null && useableAbilities.size() > 0) {
if (useableAbilities != null && !useableAbilities.isEmpty()) {
useableAbilities = ManaUtil.tryToAutoPay(unpaid, useableAbilities); // eliminates other abilities if one fits perfectly
currentlyUnpaidMana = unpaid;
activateAbility(useableAbilities, object, game);
@ -940,7 +940,7 @@ public class HumanPlayer extends PlayerImpl {
}
}
options.put(Constants.Option.POSSIBLE_ATTACKERS, (Serializable) possibleAttackers);
if (possibleAttackers.size() > 0) {
if (!possibleAttackers.isEmpty()) {
options.put(Constants.Option.SPECIAL_BUTTON, (Serializable) "All attack");
}
@ -1330,7 +1330,7 @@ public class HumanPlayer extends PlayerImpl {
LinkedHashMap<UUID, ActivatedAbility> useableAbilities = getSpellAbilities(object, game.getState().getZone(object.getId()), game);
if (useableAbilities != null && useableAbilities.size() == 1) {
return (SpellAbility) useableAbilities.values().iterator().next();
} else if (useableAbilities != null && useableAbilities.size() > 0) {
} else if (useableAbilities != null && !useableAbilities.isEmpty()) {
game.fireGetChoiceEvent(playerId, name, object, new ArrayList<>(useableAbilities.values()));
waitForResponse(game);
if (response.getUUID() != null) {
@ -1378,7 +1378,7 @@ public class HumanPlayer extends PlayerImpl {
modeMap.put(mode.getId(), modeText);
}
}
if (modeMap.size() > 0) {
if (!modeMap.isEmpty()) {
boolean done = false;
while (!done) {
game.fireGetModeEvent(playerId, "Choose Mode", modeMap);