Fixed AI infinite loop on wrong answers input (tests affected)

This commit is contained in:
Oleg Agafonov 2018-01-04 18:14:22 +04:00
parent 401146f65f
commit 3d53d28f5e
3 changed files with 9 additions and 3 deletions

View file

@ -767,7 +767,9 @@ public class ComputerPlayer6 extends ComputerPlayer /*implements Player*/ {
return super.choose(outcome, choice, game);
}
if (!choice.isChosen()) {
return choice.setChoiceByAnswers(choices, true);
if(!choice.setChoiceByAnswers(choices, true)){
choice.setRandomChoice();
}
}
return true;
}

View file

@ -478,7 +478,9 @@ public class ComputerPlayer2 extends ComputerPlayer implements Player {
}
if (!choice.isChosen()) {
return choice.setChoiceByAnswers(choices, true);
if(!choice.setChoiceByAnswers(choices, true)){
choice.setRandomChoice();
}
}
return true;

View file

@ -740,7 +740,9 @@ public class TestPlayer implements Player {
@Override
public boolean choose(Outcome outcome, Choice choice, Game game) {
if (!choices.isEmpty()) {
return choice.setChoiceByAnswers(choices, true);
if(choice.setChoiceByAnswers(choices, true)){
return true;
}
}
return computerPlayer.choose(outcome, choice, game);
}