Fixed AI test class.

This commit is contained in:
LevelX2 2015-06-08 19:46:22 +02:00
parent 3b61a10237
commit 1cf93e6c43
2 changed files with 18 additions and 2 deletions

View file

@ -108,6 +108,7 @@ public class TestPlayer implements Player {
private int maxCallsWithoutAction = 100;
private int foundNoAction = 0;
private boolean AIPlayer;
private final List<PlayerAction> actions = new ArrayList<>();
private final List<String> choices = new ArrayList<>();
@ -119,6 +120,7 @@ public class TestPlayer implements Player {
public TestPlayer(ComputerPlayer computerPlayer) {
this.computerPlayer = computerPlayer;
AIPlayer = false;
}
public TestPlayer(final TestPlayer testPlayer) {
@ -414,7 +416,11 @@ public class TestPlayer implements Player {
}
}
}
computerPlayer.pass(game);
if (AIPlayer) {
computerPlayer.priority(game);
} else {
computerPlayer.pass(game);
}
// check to prevent endless loops
if (numberOfActions == actions.size()) {
foundNoAction++;
@ -1809,4 +1815,12 @@ public class TestPlayer implements Player {
computerPlayer.pickCard(cards, deck, draft);
}
public void setAIPlayer(boolean AIPlayer) {
this.AIPlayer = AIPlayer;
}
public boolean isAIPlayer() {
return AIPlayer;
}
}

View file

@ -58,7 +58,9 @@ public abstract class CardTestPlayerBaseAI extends CardTestPlayerAPIImpl {
@Override
protected TestPlayer createPlayer(String name) {
if (name.equals("PlayerA")) {
return new TestPlayer(new ComputerPlayer7("PlayerA", RangeOfInfluence.ONE, skill));
TestPlayer testPlayer = new TestPlayer(new ComputerPlayer7("PlayerA", RangeOfInfluence.ONE, skill));
testPlayer.setAIPlayer(true);
return testPlayer;
}
return super.createPlayer(name);
}