Search in sources :

Example 11 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class AI method isHeroVulnerable.

/**
 * returns true if the given hero would be killed by an attack from each of the opponents minions
 * @param h hero to evaluate
 * @return result
 */
public static boolean isHeroVulnerable(Hero h) {
    Hero enemy = null;
    if (h == Board.topHero) {
        enemy = Board.botHero;
    } else {
        enemy = Board.topHero;
    }
    int damagePotential = 0;
    for (Minion m : enemy.minions.getStorage()) {
        if (m == null)
            continue;
        damagePotential += m.attack;
    }
    return damagePotential >= h.health;
}
Also used : Minion(Minions.Minion) Hero(cardgame1.Hero)

Example 12 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class MockBattlefield method getBestTarget.

// AI METHODS
/**
 * returns the best minoin target for the given minion
 * sometimes there is no good trade, and this method will return the "least bad" trade.
 * @param attacker minion that will be attacking
 * @return Best target
 */
public Minion getBestTarget(Minion attacker) {
    int bestValue = -99999999;
    Minion bestTarget = null;
    if (friendlies.contains(attacker)) {
        // is a friendly minion
        for (Minion target : enemies) {
            int value = AI.getTradeValue(attacker, target);
            if (value > bestValue) {
                bestValue = value;
                bestTarget = target;
            }
        }
        return bestTarget;
    } else if (enemies.contains(attacker)) {
        // is an enemy minion
        for (Minion target : friendlies) {
            int value = AI.getTradeValue(attacker, target);
            if (value > bestValue) {
                bestValue = value;
                bestTarget = target;
            }
        }
        return bestTarget;
    }
    System.out.println("error finding best target for " + attacker);
    return null;
}
Also used : Minion(Minions.Minion)

Example 13 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class FireSpearCard method tick.

@Override
public void tick() {
    intrinsicValue = -4;
    int potential = 0;
    for (Minion m : owner.opponent.minions.getOccupants()) {
        if (m.attack >= 5 && AI.AI.getWorth(m) > potential) {
            potential = AI.AI.getWorth(m);
        }
    }
    intrinsicValue += potential;
}
Also used : Minion(Minions.Minion)

Example 14 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class ZombieBiteSpell method smartCast.

/**
 * plays the card the best way possible
 */
@Override
public void smartCast() {
    int valueOnEnemy = 0;
    Minion bestTargetEnemy = null;
    for (Minion m : owner.opponent.minions.getOccupants()) {
        if (m.attack + m.health > (attack + health)) {
            int potentialValue = m.attack + m.health - (attack + health);
            if (potentialValue > valueOnEnemy) {
                valueOnEnemy = potentialValue;
                bestTargetEnemy = m;
            }
        }
    }
    if (valueOnEnemy > 1 && AI.isVulnerable(new SimulatedMinion(attack, health, owner.opponent))) {
        valueOnEnemy += 2;
    }
    int valueOnSelf = 0;
    Minion bestTargetSelf = null;
    for (Minion m : owner.minions.getOccupants()) {
        if (m.attack + m.health < (attack + health)) {
            int potentialValue = (attack + health) - m.attack - m.health;
            if ((!AI.canFavorablyTrade(m) || !m.canAttack()) && AI.canFavorablyTrade(new SimulatedMinion(4, 2, owner))) {
                potentialValue = AI.getWorth(AI.getBestTarget(new SimulatedMinion(4, 2, owner)));
            }
            if (potentialValue > valueOnSelf) {
                valueOnSelf = potentialValue;
                bestTargetSelf = m;
            }
        }
    }
    if (valueOnEnemy > valueOnSelf) {
        // better to cast on an enemy
        this.cast(bestTargetEnemy);
        return;
    } else {
        // better to cast on self
        this.cast(bestTargetSelf);
        return;
    }
}
Also used : Minion(Minions.Minion)

Example 15 with Minion

use of Minions.Minion in project cardgame1 by joey101937.

the class ZombieBiteSpell method tick.

/**
 * constantly updates value of the card for AI
 */
@Override
public void tick() {
    if (owner.minions.numOccupants() == 0 && owner.opponent.minions.numOccupants() == 0) {
        intrinsicValue = -2;
        return;
    }
    intrinsicValue = -2;
    int valueOnEnemy = 0;
    Minion bestTargetEnemy = null;
    for (Minion m : owner.opponent.minions.getOccupants()) {
        if (m.attack + m.health > (attack + health)) {
            int potentialValue = m.attack + m.health - (attack + health);
            if (potentialValue > valueOnEnemy) {
                valueOnEnemy = potentialValue;
                bestTargetEnemy = m;
            }
        }
    }
    if (valueOnEnemy > 1 && AI.isVulnerable(new SimulatedMinion(attack, health, owner.opponent))) {
        valueOnEnemy += 2;
    }
    int valueOnSelf = 0;
    Minion bestTargetSelf = null;
    for (Minion m : owner.minions.getOccupants()) {
        if (m.attack + m.health < (attack + health)) {
            int potentialValue = (attack + health) - m.attack - m.health;
            if (AI.isVulnerable(m) && !AI.isVulnerable(new SimulatedMinion(attack, health, owner))) {
                potentialValue = AI.getWorth(m);
            }
            if (potentialValue > valueOnSelf) {
                valueOnSelf = potentialValue;
                bestTargetSelf = m;
            }
        }
    }
    if (valueOnEnemy > valueOnSelf) {
        intrinsicValue += valueOnEnemy;
    } else {
        intrinsicValue += valueOnSelf;
    }
}
Also used : Minion(Minions.Minion)

Aggregations

Minion (Minions.Minion)28 Sticker (cardgame1.Sticker)7 Hero (cardgame1.Hero)5 ArrayList (java.util.ArrayList)3 ConcurrentModificationException (java.util.ConcurrentModificationException)2 SimulatedMinion (AI.SimulatedMinion)1 Card (Cards.Card)1 Trap (Cards.CardPurpose.Trap)1 BaitfishCard (Cards.Fish.BaitfishCard)1 SkeletonMinion (Minions.Undead.SkeletonMinion)1 Trap (Traps.Trap)1