mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Tweaked AI attacking.
This commit is contained in:
@@ -1387,6 +1387,18 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return this.getCharacteristics().getSVar(var);
|
return this.getCharacteristics().getSVar(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* hasSVar.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param var
|
||||||
|
* a {@link java.lang.String} object.
|
||||||
|
*/
|
||||||
|
public final boolean hasSVar(final String var) {
|
||||||
|
return this.getCharacteristics().hasSVar(var);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* setSVar.
|
* setSVar.
|
||||||
|
|||||||
@@ -345,6 +345,18 @@ public class CardCharacteristics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* hasSVar.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param var
|
||||||
|
* a {@link java.lang.String} object.
|
||||||
|
*/
|
||||||
|
public final boolean hasSVar(final String var) {
|
||||||
|
return this.sVars.containsKey(var);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* setSVar.
|
* setSVar.
|
||||||
|
|||||||
@@ -637,13 +637,6 @@ public class AiAttackController {
|
|||||||
// compare the ratios, higher = better for ai
|
// compare the ratios, higher = better for ai
|
||||||
final double ratioDiff = aiLifeToPlayerDamageRatio - humanLifeToDamageRatio;
|
final double ratioDiff = aiLifeToPlayerDamageRatio - humanLifeToDamageRatio;
|
||||||
|
|
||||||
/*
|
|
||||||
* System.out.println(String.valueOf(ratioDiff) +
|
|
||||||
* " = ratio difference, higher = better for ai");
|
|
||||||
* System.out.println(String.valueOf(outNumber) +
|
|
||||||
* " = outNumber, higher = better for ai");
|
|
||||||
*/
|
|
||||||
|
|
||||||
// *********************
|
// *********************
|
||||||
// if outnumber and superior ratio work out whether attritional all out
|
// if outnumber and superior ratio work out whether attritional all out
|
||||||
// attacking will work
|
// attacking will work
|
||||||
@@ -744,10 +737,9 @@ public class AiAttackController {
|
|||||||
this.aiAggression = 5; // attack at all costs
|
this.aiAggression = 5; // attack at all costs
|
||||||
} else if (ratioDiff >= 1 && (humanLifeToDamageRatio < 2 || outNumber > 0)) {
|
} else if (ratioDiff >= 1 && (humanLifeToDamageRatio < 2 || outNumber > 0)) {
|
||||||
this.aiAggression = 4; // attack expecting to trade or damage player.
|
this.aiAggression = 4; // attack expecting to trade or damage player.
|
||||||
} else if ((humanLifeToDamageRatio < 2 && ratioDiff >= 0) || ratioDiff > 3
|
} else if (ratioDiff >= 0) {
|
||||||
|| (ratioDiff > 0 && outNumber > 0)) {
|
|
||||||
this.aiAggression = 3; // attack expecting to make good trades or damage player.
|
this.aiAggression = 3; // attack expecting to make good trades or damage player.
|
||||||
} else if (ratioDiff >= 0 || ratioDiff + outNumber >= -1 || aiLifeToPlayerDamageRatio > 1
|
} else if (ratioDiff + outNumber >= -1 || aiLifeToPlayerDamageRatio > 1
|
||||||
|| ratioDiff * -1 < turnsUntilDeathByUnblockable) {
|
|| ratioDiff * -1 < turnsUntilDeathByUnblockable) {
|
||||||
// at 0 ratio expect to potentially gain an advantage by attacking first
|
// at 0 ratio expect to potentially gain an advantage by attacking first
|
||||||
// if the ai has a slight advantage
|
// if the ai has a slight advantage
|
||||||
@@ -769,8 +761,6 @@ public class AiAttackController {
|
|||||||
System.out.println("Normal attack");
|
System.out.println("Normal attack");
|
||||||
|
|
||||||
attackersLeft = this.notNeededAsBlockers(ai, attackersLeft);
|
attackersLeft = this.notNeededAsBlockers(ai, attackersLeft);
|
||||||
System.out.println(attackersLeft.size());
|
|
||||||
|
|
||||||
attackersLeft = this.sortAttackers(attackersLeft);
|
attackersLeft = this.sortAttackers(attackersLeft);
|
||||||
|
|
||||||
int iDefender = combat.getDefenders().indexOf(defender);
|
int iDefender = combat.getDefenders().indexOf(defender);
|
||||||
@@ -900,7 +890,7 @@ public class AiAttackController {
|
|||||||
// the creature
|
// the creature
|
||||||
// see if the defending creature is of higher or lower
|
// see if the defending creature is of higher or lower
|
||||||
// value. We don't want to attack only to lose value
|
// value. We don't want to attack only to lose value
|
||||||
if (isWorthLessThanAllKillers && attacker.getSVar("SacMe").equals("")
|
if (isWorthLessThanAllKillers && !attacker.hasSVar("SacMe")
|
||||||
&& ComputerUtilCard.evaluateCreature(defender) <= ComputerUtilCard.evaluateCreature(attacker)) {
|
&& ComputerUtilCard.evaluateCreature(defender) <= ComputerUtilCard.evaluateCreature(attacker)) {
|
||||||
isWorthLessThanAllKillers = false;
|
isWorthLessThanAllKillers = false;
|
||||||
}
|
}
|
||||||
@@ -930,7 +920,7 @@ public class AiAttackController {
|
|||||||
|
|
||||||
// if the creature cannot block and can kill all opponents they might as
|
// if the creature cannot block and can kill all opponents they might as
|
||||||
// well attack, they do nothing staying back
|
// well attack, they do nothing staying back
|
||||||
if (canKillAll && !CombatUtil.canBlock(attacker) && isWorthLessThanAllKillers) {
|
if (canKillAll && isWorthLessThanAllKillers && !CombatUtil.canBlock(attacker)) {
|
||||||
System.out.println(attacker.getName()
|
System.out.println(attacker.getName()
|
||||||
+ " = attacking because they can't block, expecting to kill or damage player");
|
+ " = attacking because they can't block, expecting to kill or damage player");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user