mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Further work on trick/lure attacks with held pump spell.
This commit is contained in:
@@ -69,7 +69,7 @@ public class AiCardMemory {
|
|||||||
MANDATORY_ATTACKERS,
|
MANDATORY_ATTACKERS,
|
||||||
TRICK_ATTACKERS,
|
TRICK_ATTACKERS,
|
||||||
HELD_MANA_SOURCES_FOR_MAIN2,
|
HELD_MANA_SOURCES_FOR_MAIN2,
|
||||||
HELD_MANA_SOURCES_FOR_COMBAT,
|
HELD_MANA_SOURCES_FOR_DECLBLK,
|
||||||
ATTACHED_THIS_TURN,
|
ATTACHED_THIS_TURN,
|
||||||
ANIMATED_THIS_TURN,
|
ANIMATED_THIS_TURN,
|
||||||
BOUNCED_THIS_TURN,
|
BOUNCED_THIS_TURN,
|
||||||
@@ -85,7 +85,7 @@ public class AiCardMemory {
|
|||||||
return memTrickAttackers;
|
return memTrickAttackers;
|
||||||
case HELD_MANA_SOURCES_FOR_MAIN2:
|
case HELD_MANA_SOURCES_FOR_MAIN2:
|
||||||
return memHeldManaSources;
|
return memHeldManaSources;
|
||||||
case HELD_MANA_SOURCES_FOR_COMBAT:
|
case HELD_MANA_SOURCES_FOR_DECLBLK:
|
||||||
return memHeldManaSourcesForCombat;
|
return memHeldManaSourcesForCombat;
|
||||||
case ATTACHED_THIS_TURN:
|
case ATTACHED_THIS_TURN:
|
||||||
return memAttachedThisTurn;
|
return memAttachedThisTurn;
|
||||||
@@ -266,7 +266,7 @@ public class AiCardMemory {
|
|||||||
clearMemorySet(MemorySet.MANDATORY_ATTACKERS);
|
clearMemorySet(MemorySet.MANDATORY_ATTACKERS);
|
||||||
clearMemorySet(MemorySet.TRICK_ATTACKERS);
|
clearMemorySet(MemorySet.TRICK_ATTACKERS);
|
||||||
clearMemorySet(MemorySet.HELD_MANA_SOURCES_FOR_MAIN2);
|
clearMemorySet(MemorySet.HELD_MANA_SOURCES_FOR_MAIN2);
|
||||||
clearMemorySet(MemorySet.HELD_MANA_SOURCES_FOR_COMBAT);
|
clearMemorySet(MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK);
|
||||||
clearMemorySet(MemorySet.ATTACHED_THIS_TURN);
|
clearMemorySet(MemorySet.ATTACHED_THIS_TURN);
|
||||||
clearMemorySet(MemorySet.ANIMATED_THIS_TURN);
|
clearMemorySet(MemorySet.ANIMATED_THIS_TURN);
|
||||||
clearMemorySet(MemorySet.BOUNCED_THIS_TURN);
|
clearMemorySet(MemorySet.BOUNCED_THIS_TURN);
|
||||||
|
|||||||
@@ -610,13 +610,18 @@ public class AiController {
|
|||||||
ManaCostBeingPaid cost = ComputerUtilMana.calculateManaCost(sa, true, 0);
|
ManaCostBeingPaid cost = ComputerUtilMana.calculateManaCost(sa, true, 0);
|
||||||
CardCollection manaSources = ComputerUtilMana.getManaSourcesToPayCost(cost, sa, player);
|
CardCollection manaSources = ComputerUtilMana.getManaSourcesToPayCost(cost, sa, player);
|
||||||
|
|
||||||
AiCardMemory.MemorySet memSet = AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2;
|
AiCardMemory.MemorySet memSet;
|
||||||
|
|
||||||
switch (phaseType) {
|
switch (phaseType) {
|
||||||
|
case MAIN2:
|
||||||
|
memSet = AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2;
|
||||||
|
break;
|
||||||
case COMBAT_DECLARE_BLOCKERS:
|
case COMBAT_DECLARE_BLOCKERS:
|
||||||
memSet = AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_COMBAT;
|
memSet = AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
System.out.println("Warning: unsupported mana reservation phase specified for reserveManaSources: "
|
||||||
|
+ phaseType.name() + ", reserving until Main 2 instead. Consider adding support for the phase if needed.");
|
||||||
memSet = AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2;
|
memSet = AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_MAIN2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1167,10 +1167,12 @@ public class ComputerUtilCard {
|
|||||||
|
|
||||||
boolean combatTrick = false;
|
boolean combatTrick = false;
|
||||||
boolean holdCombatTricks = false;
|
boolean holdCombatTricks = false;
|
||||||
|
int chanceToHoldCombatTricks = -1;
|
||||||
|
|
||||||
if (ai.getController().isAI()) {
|
if (ai.getController().isAI()) {
|
||||||
AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
|
AiController aic = ((PlayerControllerAi)ai.getController()).getAi();
|
||||||
holdCombatTricks = aic.getBooleanProperty(AiProps.TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK);
|
holdCombatTricks = aic.getBooleanProperty(AiProps.TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK);
|
||||||
|
chanceToHoldCombatTricks = aic.getIntProperty(AiProps.CHANCE_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!c.canBeTargetedBy(sa)) {
|
if (!c.canBeTargetedBy(sa)) {
|
||||||
@@ -1402,16 +1404,26 @@ public class ComputerUtilCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isHeldCombatTrick = combatTrick && holdCombatTricks && MyRandom.getRandom().nextFloat() < chance;
|
boolean wantToHoldTrick = holdCombatTricks;
|
||||||
|
if (chanceToHoldCombatTricks >= 0) {
|
||||||
|
// Obey the chance specified in the AI profile for holding combat tricks
|
||||||
|
wantToHoldTrick &= MyRandom.percentTrue(chanceToHoldCombatTricks);
|
||||||
|
} else {
|
||||||
|
// Use standard considerations dependent solely on the buff chance determined above
|
||||||
|
wantToHoldTrick &= MyRandom.getRandom().nextFloat() < chance;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isHeldCombatTrick = combatTrick && wantToHoldTrick;
|
||||||
|
|
||||||
if (isHeldCombatTrick) {
|
if (isHeldCombatTrick) {
|
||||||
if (AiCardMemory.isMemorySetEmpty(ai, AiCardMemory.MemorySet.TRICK_ATTACKERS)) {
|
if (AiCardMemory.isMemorySetEmpty(ai, AiCardMemory.MemorySet.TRICK_ATTACKERS)) {
|
||||||
// Attempt to hold combat tricks until blockers are declared, and try to lure the opponent into blocking
|
// Attempt to hold combat tricks until blockers are declared, and try to lure the opponent into blocking
|
||||||
// (The AI will only do it for one attacker at the moment, otherwise it risks running his attackers into
|
// (The AI will only do it for one attacker at the moment, otherwise it risks running his attackers into
|
||||||
// an army of opposing blockers with only one combat trick in hand)
|
// an army of opposing blockers with only one combat trick in hand)
|
||||||
// TODO: somehow ensure that the AI doesn't tap out before it has a chance to buff the attacker
|
|
||||||
AiCardMemory.rememberCard(ai, c, AiCardMemory.MemorySet.MANDATORY_ATTACKERS);
|
AiCardMemory.rememberCard(ai, c, AiCardMemory.MemorySet.MANDATORY_ATTACKERS);
|
||||||
AiCardMemory.rememberCard(ai, c, AiCardMemory.MemorySet.TRICK_ATTACKERS);
|
AiCardMemory.rememberCard(ai, c, AiCardMemory.MemorySet.TRICK_ATTACKERS);
|
||||||
|
// Reserve the mana until Declare Blockers such that the AI doesn't tap out before having a chance to use
|
||||||
|
// the combat trick
|
||||||
if (ai.getController().isAI()) {
|
if (ai.getController().isAI()) {
|
||||||
((PlayerControllerAi) ai.getController()).getAi().reserveManaSources(sa, PhaseType.COMBAT_DECLARE_BLOCKERS);
|
((PlayerControllerAi) ai.getController()).getAi().reserveManaSources(sa, PhaseType.COMBAT_DECLARE_BLOCKERS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -846,10 +846,10 @@ public class ComputerUtilMana {
|
|||||||
|
|
||||||
// For combat tricks, always obey mana reservation
|
// For combat tricks, always obey mana reservation
|
||||||
if (curPhase == PhaseType.COMBAT_DECLARE_BLOCKERS || curPhase == PhaseType.CLEANUP) {
|
if (curPhase == PhaseType.COMBAT_DECLARE_BLOCKERS || curPhase == PhaseType.CLEANUP) {
|
||||||
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_COMBAT);
|
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_COMBAT)) {
|
if (AiCardMemory.isRememberedCard(ai, sourceCard, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_DECLBLK)) {
|
||||||
// This mana source is held elsewhere for a combat trick.
|
// This mana source is held elsewhere for a combat trick.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ USE_BERSERK_AGGRESSIVELY=false
|
|||||||
# Try to hold combat tricks until blockers are declared in an attempt to trick the opponent into blocking a weak creature
|
# Try to hold combat tricks until blockers are declared in an attempt to trick the opponent into blocking a weak creature
|
||||||
# and dying to it (currently has some limitations, the AI will only try to do it to one creature)
|
# and dying to it (currently has some limitations, the AI will only try to do it to one creature)
|
||||||
TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=false
|
TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=false
|
||||||
|
# Chance to hold combat tricks until blockers are declared. If -1 is specified, this chance is not used, and the standard
|
||||||
|
# evaluation for offensive pump buff is used instead.
|
||||||
|
CHANCE_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=-1
|
||||||
|
|
||||||
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
||||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=false
|
|||||||
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
||||||
USE_BERSERK_AGGRESSIVELY=false
|
USE_BERSERK_AGGRESSIVELY=false
|
||||||
# Try to hold combat tricks until blockers are declared in an attempt to trick the opponent into blocking a weak creature
|
# Try to hold combat tricks until blockers are declared in an attempt to trick the opponent into blocking a weak creature
|
||||||
# and dying to it (currently has some limitations, the AI will only try to do it to one creature)
|
# and dying to it (currently has some limitations, the AI will only try to do it to one creature per turn)
|
||||||
TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=false
|
TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=false
|
||||||
|
# Chance to hold combat tricks until blockers are declared. If -1 is specified, this chance is not used, and the standard
|
||||||
|
# evaluation for offensive pump buff is used instead.
|
||||||
|
CHANCE_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=-1
|
||||||
|
|
||||||
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
||||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=false
|
|||||||
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
||||||
USE_BERSERK_AGGRESSIVELY=true
|
USE_BERSERK_AGGRESSIVELY=true
|
||||||
# Try to hold combat tricks until blockers are declared in an attempt to trick the opponent into blocking a weak creature
|
# Try to hold combat tricks until blockers are declared in an attempt to trick the opponent into blocking a weak creature
|
||||||
# and dying to it (currently has some limitations, the AI will only try to do it to one creature)
|
# and dying to it (currently has some limitations, the AI will only try to do it with one creature per turn)
|
||||||
TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=true
|
TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=true
|
||||||
|
# Chance to hold combat tricks until blockers are declared. If -1 is specified, this chance is not used, and the standard
|
||||||
|
# evaluation for offensive pump buff is used instead.
|
||||||
|
CHANCE_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=30
|
||||||
|
|
||||||
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
||||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ ATTACK_INTO_TRADE_WHEN_TAPPED_OUT=true
|
|||||||
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
# When enabled, the AI will use Berserk on offense to try to severely damage the opponent at the expense of the creature
|
||||||
USE_BERSERK_AGGRESSIVELY=true
|
USE_BERSERK_AGGRESSIVELY=true
|
||||||
# Try to hold combat tricks until blockers are declared in an attempt to trick the opponent into blocking a weak creature
|
# Try to hold combat tricks until blockers are declared in an attempt to trick the opponent into blocking a weak creature
|
||||||
# and dying to it (currently has some limitations, the AI will only try to do it to one creature)
|
# and dying to it (currently has some limitations, the AI will only try to do it to one creature per turn)
|
||||||
TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=false
|
TRY_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=false
|
||||||
|
# Chance to hold combat tricks until blockers are declared. If -1 is specified, this chance is not used, and the standard
|
||||||
|
# evaluation for offensive pump buff is used instead.
|
||||||
|
CHANCE_TO_HOLD_COMBAT_TRICKS_UNTIL_BLOCK=-1
|
||||||
|
|
||||||
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
# Trade blocking preferences (enabling these will make the AI trade more aggressively when considering blocks,
|
||||||
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
# but only with creatures that are worse in abilities and have lower or the same power as the attacker). Note
|
||||||
|
|||||||
Reference in New Issue
Block a user