Fix build for Player AI projects

This commit is contained in:
Quercitron 2014-06-13 20:21:07 +04:00
parent a0fb5bfe22
commit f2114f4701
3 changed files with 36 additions and 42 deletions

View file

@ -148,7 +148,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
target.add(playerId, game);
return true;
}
if (target.isRequired()) {
if (target.isRequired(sourceId, game)) {
if (target.canTarget(opponentId, game)) {
target.add(opponentId, game);
return true;
@ -159,7 +159,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
target.add(opponentId, game);
return true;
}
if (target.isRequired()) {
if (target.isRequired(sourceId, game)) {
if (target.canTarget(playerId, game)) {
target.add(playerId, game);
return true;
@ -266,7 +266,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
return true;
}
}
if (!target.isRequired()) {
if (!target.isRequired(sourceId, game)) {
return false;
}
}
@ -299,7 +299,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
return true;
}
}
if (!target.isRequired()) {
if (!target.isRequired(sourceId, game)) {
return false;
}
throw new IllegalStateException("TargetPermanentOrPlayer wasn't handled. class:" + target.getClass().toString());
@ -350,7 +350,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
target.addTarget(playerId, source, game);
return true;
}
if (target.isRequired()) {
if (target.isRequired(source)) {
if (target.canTarget(opponentId, source, game)) {
target.addTarget(opponentId, source, game);
return true;
@ -362,7 +362,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
target.addTarget(opponentId, source, game);
return true;
}
if (target.isRequired()) {
if (target.isRequired(source)) {
if (target.canTarget(playerId, source, game)) {
target.addTarget(playerId, source, game);
return true;
@ -438,7 +438,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
else {
targets = threats(opponentId, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets());
}
if (targets.isEmpty() && target.isRequired()) {
if (targets.isEmpty() && target.isRequired(source)) {
targets = threats(null, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets());
Collections.reverse(targets);
outcomeTargets = false;
@ -479,7 +479,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
}
}
if (targets.isEmpty() && target.isRequired()) {
if (targets.isEmpty() && target.isRequired(source)) {
targets = game.getBattlefield().getActivePermanents(((FilterCreatureOrPlayer)t.getFilter()).getCreatureFilter(), playerId, game);
}
for (Permanent permanent : targets) {
@ -573,7 +573,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
else {
targets = threats(opponentId, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets());
}
if (targets.isEmpty() && target.isRequired()) {
if (targets.isEmpty() && target.isRequired(source)) {
targets = threats(null, source == null?null:source.getSourceId(), ((TargetPermanent)target).getFilter(), game, target.getTargets());
Collections.reverse(targets);
outcomeTargets = false;
@ -1187,7 +1187,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
log.debug("chooseTarget");
if (cards == null || cards.isEmpty()) {
if (!target.isRequired()) {
if (!target.isRequired(source)) {
return false;
}
return true;
@ -1211,9 +1211,6 @@ public class ComputerPlayer extends PlayerImpl implements Player {
public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
log.debug("choose 2");
if (cards == null || cards.isEmpty()) {
if (!target.isRequired()) {
return false;
}
return true;
}

View file

@ -220,13 +220,9 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
protected boolean chooseRandom(Target target, Game game) {
Set<UUID> possibleTargets = target.possibleTargets(playerId, game);
if (possibleTargets.isEmpty())
return !target.isRequired();
if (!target.isRequired()) {
if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
if (possibleTargets.isEmpty()) {
return false;
}
}
if (possibleTargets.size() == 1) {
target.add(possibleTargets.iterator().next(), game);
return true;
@ -245,7 +241,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
if (possibleTargets.isEmpty())
return false;
if (!target.isRequired()) {
if (!target.isRequired(source)) {
if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
return false;
}
@ -281,11 +277,13 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
@Override
public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
if (this.isHuman()) {
if (cards.isEmpty())
return !target.isRequired();
if (cards.isEmpty()) {
return false;
}
Set<UUID> possibleTargets = target.possibleTargets(playerId, cards, game);
if (possibleTargets.isEmpty())
return !target.isRequired();
if (possibleTargets.isEmpty()) {
return false;
}
Iterator<UUID> it = possibleTargets.iterator();
int targetNum = rnd.nextInt(possibleTargets.size());
UUID targetId = it.next();
@ -306,7 +304,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
@Override
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
if (cards.isEmpty())
return !target.isRequired();
return !target.isRequired(source);
Card card = cards.getRandom(game);
target.addTarget(card.getId(), source, game);
return true;
@ -316,8 +314,8 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
if (possibleTargets.isEmpty())
return !target.isRequired();
if (!target.isRequired()) {
return !target.isRequired(source);
if (!target.isRequired(source)) {
if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
return false;
}

View file

@ -220,13 +220,9 @@ public class RandomPlayer extends ComputerPlayer {
protected boolean chooseRandom(Target target, Game game) {
Set<UUID> possibleTargets = target.possibleTargets(playerId, game);
if (possibleTargets.isEmpty())
return !target.isRequired();
if (!target.isRequired()) {
if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
if (possibleTargets.isEmpty()) {
return false;
}
}
if (possibleTargets.size() == 1) {
target.add(possibleTargets.iterator().next(), game);
return true;
@ -245,7 +241,7 @@ public class RandomPlayer extends ComputerPlayer {
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
if (possibleTargets.isEmpty())
return false;
if (!target.isRequired()) {
if (!target.isRequired(source)) {
if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
return false;
}
@ -276,11 +272,13 @@ public class RandomPlayer extends ComputerPlayer {
@Override
public boolean choose(Outcome outcome, Cards cards, TargetCard target, Game game) {
if (cards.isEmpty())
return !target.isRequired();
if (cards.isEmpty()) {
return false;
}
Set<UUID> possibleTargets = target.possibleTargets(playerId, cards, game);
if (possibleTargets.isEmpty())
return !target.isRequired();
if (possibleTargets.isEmpty()) {
return !false;
}
Iterator<UUID> it = possibleTargets.iterator();
int targetNum = rnd.nextInt(possibleTargets.size());
UUID targetId = it.next();
@ -299,7 +297,7 @@ public class RandomPlayer extends ComputerPlayer {
@Override
public boolean chooseTarget(Outcome outcome, Cards cards, TargetCard target, Ability source, Game game) {
if (cards.isEmpty())
return !target.isRequired();
return !target.isRequired(source);
Card card = cards.getRandom(game);
target.addTarget(card.getId(), source, game);
return true;
@ -308,9 +306,10 @@ public class RandomPlayer extends ComputerPlayer {
@Override
public boolean chooseTargetAmount(Outcome outcome, TargetAmount target, Ability source, Game game) {
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
if (possibleTargets.isEmpty())
return !target.isRequired();
if (!target.isRequired()) {
if (possibleTargets.isEmpty()) {
return !target.isRequired(source);
}
if (!target.isRequired(source)) {
if (rnd.nextInt(possibleTargets.size() + 1) == 0) {
return false;
}