- Attempt to stop AI players in multiplayer games from always only attacking the human until dead. They will now gang up on an opponent with less than 8 life but otherwise attack a random opponent. Feel free to improve the ai.

This commit is contained in:
moomarc
2014-02-17 15:47:04 +00:00
parent 9d90ca99cb
commit 89c2130ff6
2 changed files with 33 additions and 17 deletions

View File

@@ -323,18 +323,18 @@ public class Player extends GameEntity implements Comparable<Player> {
* @return
*/
public final Player getWeakestOpponent() {
List<Player> opponnets = this.getOpponents();
Player weakest = opponnets.get(0);
for (int i = 1; i < opponnets.size(); i++) {
if (weakest.getLife() > opponnets.get(i).getLife()) {
weakest = opponnets.get(i);
List<Player> opponents = this.getOpponents();
Player weakest = opponents.get(0);
for (int i = 1; i < opponents.size(); i++) {
if (weakest.getLife() > opponents.get(i).getLife()) {
weakest = opponents.get(i);
}
}
return weakest;
}
public boolean isOpponentOf(Player other) {
return other != this && other != null && ( other.teamNumber < 0 || other.teamNumber != this.teamNumber );
return other != this && other != null && ( other.teamNumber < 0 || other.teamNumber != this.teamNumber );
}