use of Minions.Minion in project cardgame1 by joey101937.
the class AI method isFavorableCast.
/**
* is casting the spell c a good value?
* @param c untargeted spell to cast
* @return if the spell is a favorable thing to do
*/
public static boolean isFavorableCast(Card c) {
int intrinsicValue = (c.cost * 2) + 1;
// raw value it would provide
int rawGains = 0;
if (c.getOwner() == Board.botHero) {
for (Minion t : Board.topHero.minions.getStorage()) {
rawGains += (AI.getWorth(t) - AI.getWorthAfterDamage(t, c.spellDamage));
}
} else {
// tophero
for (Minion t : Board.botHero.minions.getStorage()) {
rawGains += (AI.getWorth(t) - AI.getWorthAfterDamage(t, c.spellDamage));
}
}
return rawGains > intrinsicValue;
}
use of Minions.Minion in project cardgame1 by joey101937.
the class AI method getTradeValue.
/**
* gets the value presented by making the attacker attack the defneder. May be negative, higher is better.
* @param attacker minion that we are using
* @param defender potential target
* @return how good of an idea it is to attack
*/
public static int getTradeValue(Minion attacker, Minion defender) {
int myPreviousValue = AI.getWorth(attacker);
int theirPreviousValue = AI.getWorth(defender);
int myNewValue = AI.getWorthAfterCombat(attacker, defender);
int theirNewValue = AI.getWorthAfterCombat(defender, attacker);
int ValueGained = (theirPreviousValue - theirNewValue) - (myPreviousValue - myNewValue);
// minions with higher attack are worth a tad more
if (attacker.attack < defender.attack)
ValueGained++;
int damagePotential = 0;
for (Minion m : attacker.owner.minions.getOccupants()) {
damagePotential += m.attack;
}
if (defender.intrinsicValue > attacker.intrinsicValue && defender == AI.getBiggestThreatOf(defender.owner) && damagePotential >= defender.health) {
ValueGained += defender.intrinsicValue;
}
if (theirNewValue == 0 && attacker.owner.health < defender.owner.health)
ValueGained++;
return ValueGained;
}
use of Minions.Minion in project cardgame1 by joey101937.
the class AI method takeTurn.
/**
* core of the AI player, makes plays and casts cards the most efficient way possible and ends turn when done
* @param h the AI will make plays on behalf on this hero
*/
public static void takeTurn(Hero h) {
Hero enemy = null;
if (h == Board.topHero)
enemy = Board.botHero;
else
enemy = Board.topHero;
tradeOnBoard(h, false);
playOutHand(h);
Main.wait(speed);
tradeOnBoard(h, false);
for (Minion m : h.minions.getStorage()) {
if (!AI.isHeroVulnerable(h)) {
if (m == null)
continue;
Main.wait(speed);
m.attack(enemy);
} else {
if (m == null)
continue;
Main.wait(speed);
// if we are vulnerable, attack on board as best as possible
m.attack(AI.getBestTarget(m));
}
}
Main.wait(speed);
Board.controller.nextTurn();
/*
for(Card c : h.hand){
System.out.println(c + " == " + AI.getValueOfCard(c));
}
*/
}
use of Minions.Minion in project cardgame1 by joey101937.
the class FireSpearCard method smartCast.
@Override
public void smartCast() {
int bestvalue = -10;
Minion bestTarget = null;
for (Minion m : owner.opponent.minions.getOccupants()) {
if (m.attack >= 5 && AI.AI.getWorth(m) > bestvalue) {
bestvalue = AI.AI.getWorth(m);
bestTarget = m;
}
}
if (bestTarget == null)
System.out.println("Error finding target for fire spear");
this.cast(bestTarget);
}
use of Minions.Minion in project cardgame1 by joey101937.
the class SkeletonArmySpell method tick.
@Override
public void tick() {
this.intrinsicValue = -4;
if (owner.minions.numOccupants() == 0)
intrinsicValue += 2;
int numSpawned = PlayArea.MAX_SIZE - owner.minions.numOccupants();
intrinsicValue += (3 * numSpawned);
for (Minion m : owner.opponent.minions.getOccupants()) {
if (m.health <= 2 == AI.AI.getWorth(m) > 3) {
// if a minion will die to a skeleton, gain that minion's value instead of the skeleton's
intrinsicValue -= 3;
intrinsicValue += AI.AI.getWorth(m);
}
}
}
Aggregations