AI: fixed not working choice with key-value dialogs, random refactor

This commit is contained in:
Oleg Agafonov 2018-01-04 00:23:20 +04:00
parent ec50a123ec
commit 3dda5712db
8 changed files with 77 additions and 64 deletions

View file

@ -367,13 +367,7 @@ public class RandomPlayer extends ComputerPlayer {
@Override
public boolean choose(Outcome outcome, Choice choice, Game game) {
Iterator<String> it = choice.getChoices().iterator();
String sChoice = it.next();
int choiceNum = rnd.nextInt(choice.getChoices().size());
for (int i = 0; i < choiceNum; i++) {
sChoice = it.next();
}
choice.setChoice(sChoice);
choice.setRandomChoice();
return true;
}

View file

@ -740,15 +740,7 @@ public class TestPlayer implements Player {
@Override
public boolean choose(Outcome outcome, Choice choice, Game game) {
if (!choices.isEmpty()) {
for (String choose2 : choices) {
for (String choose1 : choice.getChoices()) {
if (choose1.equals(choose2)) {
choice.setChoice(choose2);
choices.remove(choose2);
return true;
}
}
}
return choice.setChoiceByAnswers(choices, true);
}
return computerPlayer.choose(outcome, choice, game);
}