mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
AI: fixed not working choice with key-value dialogs, random refactor
This commit is contained in:
parent
ec50a123ec
commit
3dda5712db
8 changed files with 77 additions and 64 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue