mirror of
https://github.com/correl/mage.git
synced 2025-04-09 17:00:09 -09:00
AI: fixed computer's errors if all players quit the game;
This commit is contained in:
parent
d41ccd11bc
commit
c1db466d05
4 changed files with 16 additions and 4 deletions
Mage.Server.Plugins
Mage.Player.AI.MA/src/mage/player/ai
Mage.Player.AI/src/main/java/mage/player/ai/simulators
Mage.Player.AIMinimax/src/mage/player/ai
Mage.Server/src/main/java/mage/server/util
|
@ -26,7 +26,11 @@ public final class GameStateEvaluator2 {
|
|||
|
||||
public static PlayerEvaluateScore evaluate(UUID playerId, Game game) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
Player opponent = game.getPlayer(game.getOpponents(playerId).iterator().next()); // TODO: add multi opponent support?
|
||||
Player opponent = game.getPlayer(game.getOpponents(playerId).stream().findFirst().orElse(null)); // TODO: add multi opponent support?
|
||||
if (opponent == null) {
|
||||
return new PlayerEvaluateScore(WIN_GAME_SCORE);
|
||||
}
|
||||
|
||||
if (game.checkIfGameIsOver()) {
|
||||
if (player.hasLost()
|
||||
|| opponent.hasWon()) {
|
||||
|
|
|
@ -34,7 +34,11 @@ public class ActionSimulator {
|
|||
}
|
||||
|
||||
public int evaluateState() {
|
||||
Player opponent = game.getPlayer(game.getOpponents(player.getId()).iterator().next());
|
||||
Player opponent = game.getPlayer(game.getOpponents(player.getId()).stream().findFirst().orElse(null));
|
||||
if (opponent == null) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
if (game.checkIfGameIsOver()) {
|
||||
if (player.hasLost() || opponent.hasWon()) {
|
||||
return Integer.MIN_VALUE;
|
||||
|
|
|
@ -42,7 +42,11 @@ public final class GameStateEvaluator {
|
|||
|
||||
public static int evaluate(UUID playerId, Game game, boolean ignoreTapped) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
Player opponent = game.getPlayer(game.getOpponents(playerId).iterator().next());
|
||||
Player opponent = game.getPlayer(game.getOpponents(playerId).stream().findFirst().orElse(null));
|
||||
if (opponent == null) {
|
||||
return WIN_SCORE;
|
||||
}
|
||||
|
||||
if (game.checkIfGameIsOver()) {
|
||||
if (player.hasLost() || opponent.hasWon()) {
|
||||
return LOSE_SCORE;
|
||||
|
|
|
@ -376,7 +376,7 @@ public final class SystemUtil {
|
|||
// 3. system commands
|
||||
if (runGroup.isSpecialCommand) {
|
||||
|
||||
Player opponent = game.getPlayer(game.getOpponents(feedbackPlayer.getId()).iterator().next());
|
||||
Player opponent = game.getPlayer(game.getOpponents(feedbackPlayer.getId()).stream().findFirst().orElse(null));
|
||||
|
||||
String info;
|
||||
switch (runGroup.name) {
|
||||
|
|
Loading…
Add table
Reference in a new issue