Examples of CardSim


Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

        int ret =0;
        ret += vMatch.getAttacker().size();
        Vector<CardSim> cards = field.getCards();
        for (int i = 0; i < cards.size(); i++)
        {
            CardSim card = cards.elementAt(i);
            int subScore=0;
           
            if (card.isCreature())
            {
                subScore += card.getRealPower();
                subScore += card.getRealToughness();

                // should check, whether ability is a good one
                // if "defender", "cant block"... that it should be subtracted - not added
                subScore += (csa.util.UtilityString.countStrings(card.getNowCardAbilities(), ","))+1;
                if (card.hasActivationAbility())
                {
                    subScore+=2;
                }
            }
            else
            {
                if (card.getManaCost() != -1)
                    subScore += card.getManaCost();
                if (card.isEnchantment())
                    subScore += 2*card.getManaCost();
                if (card.isArtifact())
                    subScore += 2*card.getManaCost();
            }
     /*
            if (card.getManaCost() != -1)
                subScore += card.getManaCost()*2;
   */
 
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

        finished = a. finished;
        nextDone = a. nextDone;
        started = a. started;
        cardHome = a. cardHome;
        if (a.cardSim != null)
            cardSim = new CardSim(a.cardSim);
        isSource = a. isSource;
        isTarget = a. isTarget;
        targetIsPlayer = a. targetIsPlayer;
        targetPlayerNumber = a. targetPlayerNumber;
        cancled = a. cancled;
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

        }
    }

    // card that is played/ activated
    public Card getCard() {return card;}
    public void setCard(Card c) {card = c; if (c != null) cardSim = new CardSim(c);}
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

        boolean manaInstant = false;

        for(int c=0; c< possiblePlayableCards.size(); c++)
        {
            CardSim card = possiblePlayableCards.getCard(c);
            key += card.getCard().getUniqueID();
            if (card.isInstant()) manaInstant= true;
        }

        for(int c=0; c< possibleActivateableCards.size(); c++)
        {
            CardSim card = possibleActivateableCards.getCard(c);
            key += card.getCard().getUniqueID();
            if (card.getCard().isManaActivatable()) manaInstant= true;
        }
        if (manaInstant)
        {
            CardSimList possibleManaLand = E.helper.getMaxAvailableManaLand(vMatch);
            key += "(";
            for(int c=0; c< possibleManaLand.size(); c++)
            {
                CardSim card = possibleManaLand.getCard(c);
                key += "L"+card.getCard().getUniqueID(); // HERE UID of CARD in match! - ID is not enough (ALL lands might use the same ID)
            }
            key += ")";
        }
        return key;
    }
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

        if ((vMatch.isLandPlayed(E.pNumber)) || (!landPlay))
        {
            // remove all lands, apart from land that is about to be played
            for (int i = hand.size()-1; i >= 0 ; i--)
            {
                CardSim card = hand.getCard(i);
                if (card.isLand())
                {
                    hand.remove(card);
                }
            }
            possiblePlayableCards = hand;
        }
        else
        {
            possiblePlayableCards = hand;
            // reduce to one land per type
            for (int i=0; i <possiblePlayableCards.size(); i++)
            {
                CardSim c = possiblePlayableCards.getCard(i);
                if (c.getType().equals("Basic Land"))
                {
                    removeButOneLandTypeAndFirstInList(possiblePlayableCards, c);
                    willPlayLand = true;
                }
            }
        }

        if (willPlayLand)
        {
            // reduce land play options to the one we think is best
            CardSimList landsOnly = possiblePlayableCards.getSubListByType("Basic Land");
            possiblePlayableCards = possiblePlayableCards.removeTypes("Basic Land");
            CardSim goodLand = getBestPlayableLand(landsOnly);
            if (goodLand != null)
                possiblePlayableCards.addCard(goodLand);
        }

        if (isMyTurn())
        {
            // and without additional buf/debuf/damage stuff
            // all of them should only be played in Main 2
            if (vMatch.getPhase() == MatchConstants.PHASE_MAIN1)
            {
                // if we can / should not attack
                // than there is no need to try buffing our creatures
                if (!canAttack())
                {
                    // dont consider one turn only Buffs
                    possiblePlayableCards = EAIHelper.removeOneRoundBufs(HintAll.HINT_SITUATION_CARD_PLAYED, possiblePlayableCards);

                    // dont consider one turn only Debufs for opponent Buffs
                    possiblePlayableCards = EAIHelper.removeOneRoundDeBufs(HintAll.HINT_SITUATION_CARD_PLAYED, possiblePlayableCards);
                    removeDebufs = true;
                }
            }
            else if (vMatch.getPhase() == MatchConstants.PHASE_MAIN2)
            {
                // dont consider one turn only Buffs
                possiblePlayableCards = EAIHelper.removeOneRoundBufs(HintAll.HINT_SITUATION_CARD_PLAYED, possiblePlayableCards);

                // dont consider one turn only Debufs for opponent Buffs
                possiblePlayableCards = EAIHelper.removeOneRoundDeBufs(HintAll.HINT_SITUATION_CARD_PLAYED, possiblePlayableCards);
                removeDebufs = true;
            }

        }

        // wenn keine Gegner da sind, keine Debuf / Damage Creature Cards
        if (vMatch.getBattlefield((E.pNumber+1)%).size() == 0)
        {
            if (!removeDebufs)
            {
                possiblePlayableCards = EAIHelper.removeOneRoundDeBufs(HintAll.HINT_SITUATION_CARD_PLAYED, possiblePlayableCards);
            }
            possiblePlayableCards = EAIHelper.removeCreatureOnlyDamages(HintAll.HINT_SITUATION_CARD_PLAYED, possiblePlayableCards);
        }
        if ((vMatch.getPhase() == MatchConstants.PHASE_MAIN1) || (vMatch.getPhase() == MatchConstants.PHASE_MAIN2))
        {
            // remove buf / debug instants
            // this can and will be played in attack / block
            possiblePlayableCards = EAIHelper.removeDeBufInstants(possiblePlayableCards);
        }
       
        CardSimList field = vMatch.getBattlefield(E.pNumber);

        if (restrictMana)
            possiblePlayableCards = EAIHelper.onlyEnoughMana(possiblePlayableCards, possibleMana);

        // in general for all phases

        // only relevant in stacking... but doesnt hurt anything if not stack
        boolean isFinalCall = E.match.isFinalStackCall();

    
        possiblePlayableCards = EAIHelper.onlyAllowedToPlay(possiblePlayableCards, vMatch.getPhase(), myTurn, stack, isFinalCall);

        if (mDoStacking)
        {
            if ((!myTurn) && ((vMatch.getPhase() == MatchConstants.PHASE_COMBAT_DECLARE_ATTACKERS)))
            {
                // remove activatables
                // that are also activateable in Blocker Phase!
                CardSimList alsoInBlocker = EAIHelper.onlyAllowedToPlay(possiblePlayableCards, MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS, myTurn, new Vector<EAIAction>(), false);
                possiblePlayableCards.removeListDirect(alsoInBlocker);
               
                if (vMatch.getAttacker().size()==0)
                {
                    possiblePlayableCards = EAIHelper.removeDeBufInstants(possiblePlayableCards);
                }
            }
        }
       
       
       
        field = field.onlyActivatable(); // possibly add land here
        field = field.removeSick();

        // list of all cards, that can be activated with mana availbal
        CardSimList possibleActivateableCards = field;
        if (restrictMana)
            possibleActivateableCards = EAIHelper.onlyEnoughManaActivate(possibleActivateableCards, possibleMana);

        // in general for all phases
        possibleActivateableCards = EAIHelper.onlyAllowedToActivate(possibleActivateableCards, vMatch.getPhase(), myTurn, vMatch);
        possibleActivateableCards = EAIHelper.onlyUntappedToActivate(possibleActivateableCards);
        if (E.aiPlayer.getEAIConfig().getReducedActivationEvaluation())
        {
            if (!mDoStacking)
                possibleActivateableCards = EAIHelper.reduceActivationEvaluation(possibleActivateableCards, vMatch.getPhase(), myTurn, vMatch);
        }
        if (mDoStacking)
        {
            if ((!myTurn) && ((vMatch.getPhase() == MatchConstants.PHASE_COMBAT_DECLARE_ATTACKERS)))
            {
                // remove activatables
                // that are also activateable in Blocker Phase!
                CardSimList alsoInBlocker = EAIHelper.onlyAllowedToActivate(possibleActivateableCards, MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS, myTurn, vMatch);
                possibleActivateableCards.removeListDirect(alsoInBlocker);

                if (vMatch.getAttacker().size()==0)
                {
                    possibleActivateableCards = EAIHelper.removeDeBufActivations(possibleActivateableCards);
                }
            }
           
        }
       
       
        possiblePlayableCards = EAIHelper.removeRestrictedCards(HintAll.HINT_SITUATION_CARD_PLAYED, possiblePlayableCards, vMatch.getPhase(), myTurn, vMatch);
        // TODO: Limit activateable Cards to same extend as playable cards
boolean NEW_CSA = true;       
        // For Play cards
        if (mDoStacking)
        {
            // if we are in stack reaction
            if (vMatch.getStack().isEmpty())
            {
                // and there is nothing on stack
                // we assume, that all is right, and nothing instant to be done!

                // if not in block phase
                if (vMatch.getPhase() != MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS)
                {
                    for(int c=possiblePlayableCards.size()-1; c>=0; c--)
                    {
                        CardSim card = possiblePlayableCards.getCard(c);

                        if (card.isInstant())
                        {
                            if (EAIHelper.hasPlayRestriction(card, HintAll.HINT_SITUATION_INSTANT))
                                continue;
                            if (EAIHelper.isBufCard(card, HintAll.HINT_SITUATION_INSTANT))
                                possiblePlayableCards.remove(card);
                        }
                    }           
                }
if (NEW_CSA)
{

                // if not in block phase
                if (vMatch.getPhase() != MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS)
                {
                    for(int c=possibleActivateableCards.size()-1; c>=0; c--)
                    {
                        CardSim card = possibleActivateableCards.getCard(c);

                        if (EAIHelper.hasPlayRestriction(card, HintAll.HINT_SITUATION_ACTIVATION))
                            continue;
                        // this is ok here, since we come here only on empty stack
                        if (EAIHelper.isBufCard(card, HintAll.HINT_SITUATION_ACTIVATION))
                            possibleActivateableCards.remove(card);
                    }           
                }
}               
            }
            else // stack is not empty
            {
if (NEW_CSA)
{
                // TODO CSA
                // check if stack is creature damage card, if yes allow
                // bufs
                // if instant is stack influence card -> allow it
                // if instant is player health card -> allow it

                boolean stackIsPlayerDamage = EAIHelper.isStackPlayerDamage(player, stack);
                boolean stackIsCreatureDamage = EAIHelper.isStackCreatureDamage(player, stack);
               
                for(int c=possiblePlayableCards.size()-1; c>=0; c--)
                {
                    CardSim card = possiblePlayableCards.getCard(c);
                    if (!card.isInstant())
                    {
                        possiblePlayableCards.remove(card);
                        continue;
                    }
                    if (stackIsPlayerDamage)
                    {
                        // remove player heals
                        if (!EAIHelper.isHealCard(card, HintAll.HINT_SITUATION_INSTANT))
                        {
                            possiblePlayableCards.remove(card);
                            continue;
                        }
                    }
                    if (stackIsCreatureDamage)
                    {
                        // remove creature bufs
                        if (!EAIHelper.isBufCard(card, HintAll.HINT_SITUATION_INSTANT))
                        {
                            possiblePlayableCards.remove(card);
                            continue;
                        }
                    }
                }           
                for(int c=possibleActivateableCards.size()-1; c>=0; c--)
                {
                    CardSim card = possibleActivateableCards.getCard(c);
                    if (!EAIHelper.hasPlayRestriction(card, HintAll.HINT_SITUATION_ACTIVATION))
                    {
                        possibleActivateableCards.remove(card);
                        continue;
                    }
                    if (stackIsPlayerDamage)
                    {
                        // remove player heals
                        if (!EAIHelper.isHealCard(card, HintAll.HINT_SITUATION_ACTIVATION))
                        {
                            possibleActivateableCards.remove(card);
                            continue;
                        }
                    }
                    if (stackIsCreatureDamage)
                    {
                        // remove creature bufs
                        if (!EAIHelper.isBufCard(card, HintAll.HINT_SITUATION_ACTIVATION))
                        {
                            possibleActivateableCards.remove(card);
                            continue;
                        }
                    }
                }           
               
}               
               
            }
        }
       
        Vector<CardAndMana> cam = new Vector<CardAndMana>();
       
        for(int c=0; c< possiblePlayableCards.size(); c++)
        {
            CardSim card = possiblePlayableCards.getCard(c);
            if (card.getCard().getManaCost()!=-1)
            {
                // non X Mana j
                cam.addElement(new CardAndMana(CardAndMana.CAM_PLAY , card, ManaCollection.getPlayCost(card) ) );
            }
            else
            {
                //X card

                // damagaing X cards only in Main1
                if (EAIHelper.isCreatureDamageCard(card, HintAll.HINT_SITUATION_CARD_PLAYED))
                {
                    if (!EAIHelper.isPlayerDamageCard(card, HintAll.HINT_SITUATION_CARD_PLAYED))
                    {
                        if (vMatch.getPhase() != MatchConstants.PHASE_MAIN1)
                        {
                            continue;
                        }
                    }
                }

                int maxX = MAX_X;
               
                if (maxX==0)
                {
                    ManaCollection baseCost = ManaCollection.getPlayCostBase(card);
                    ManaCollection rest = possibleMana.subMana(baseCost);
                    for (int m=0; m<rest. getManaItems().size(); m++)
                    {
                        baseCost.addMana(rest.getManaItems().elementAt(m));
                        cam.addElement(new CardAndMana(CardAndMana.CAM_PLAY , card, new ManaCollection(baseCost) ) );
                    }
                }
                else
                {
                    int step = (possibleMana.subMana(ManaCollection.getPlayCostBase(card)).getManaItems().size())/maxX;
                   
                    int currentMana = step;
                    while (maxX > 0)
                    {
                        ManaCollection baseCost = ManaCollection.getPlayCostBase(card);
                        ManaCollection rest = possibleMana.subMana(baseCost);

                        for (int m=0; m<currentMana; m++)
                        {
                            baseCost.addMana(rest.getManaItems().elementAt(m));
                        }
                        currentMana += step;
                        maxX--;
                        cam.addElement(new CardAndMana(CardAndMana.CAM_PLAY , card, new ManaCollection(baseCost) ) );
                    }
                }
            }
        //count x
        }

       
  /*     
        // For Activation cards
        if (mDoStacking)
        {
            // if we are in stack reaction
            if (vMatch.getStack().size() == 0)
            {
                // and there is nothing on stack
                // we assume, that all is right, and nothing instant to be done!

                // if not in block phase
                if (vMatch.getPhase() != MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS)
                {
                    for(int c=possibleActivateableCards.size()-1; c>=0; c--)
                    {
                        CardSim card = possibleActivateableCards.getCard(c);
                        possibleActivateableCards.remove(card);
                    }           
                }
            }
        }
*/       
        for(int c=0; c< possibleActivateableCards.size(); c++)
        {
            int kickMaxCount = 1;
            CardSim card = possibleActivateableCards.getCard(c);
            if (card.getCard().isKicker())
            {
                kickMaxCount = possibleMana.kickMax(card);
            }
            for (int k = 0; k<kickMaxCount; k++)
                cam.addElement(new CardAndMana(CardAndMana.CAM_ACTIVATE, possibleActivateableCards.getCard(c), ManaCollection.getActivateCost(possibleActivateableCards.getCard(c)) ) );
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

        Vector<String> ids = new Vector<String>();
        for (int i = 0; i < plan.size(); i++)
        {
            EAIAction eAIAction = plan.elementAt(i);
            CardSim card = eAIAction.getSCard();

            // should I take names in genral?
            if (card.isLand())
            {
                ids.addElement(card.getCard().getName());
            }
            else
            {
                ids.addElement(card.getCard().getId());
         
               
            }

        }
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

    CardSimList getSubListUndieable(CardSimList shorten, CardSimList possibleBlockers, int p)
    {
        CardSimList ret = shorten.copyList();
        for (int i=ret.size()-1; i>=0; i-- )
        {
            CardSim card = ret.getCard(i);
            if (isWeakling(card, possibleBlockers, p))
            {
                ret.remove(i);
            }
        }
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

    {
        CardSimList ret = possibleBlockers.copyList();

        for (int i=ret.size()-1; i>=0; i--)
        {
            CardSim card = ret.getCard(i);
            if (card.getCard().isActivatable())
            {
                ret.remove(i);
            }
        }
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

        if ((varAttackers != null) && (varAttackers.size() >0))
        {
           
            for (int i=0; i < varAttackers.size(); i++)
            {
                CardSim at = varAttackers.getCard(i);
                CardSimList shorter = varAttackers.copyList();
                shorter.remove(at);

                // add one without this attacker
                EAIPlanTree leaf  = new EAIPlanTree(this);
                leafs.addElement(leaf);
                leaf.buildAttackerLeafs(attackers, analyze, shorter, removedPossibleAttackers);

                CardAndMana cam = new CardAndMana(CardAndMana.CAM_ATTACK , at, ManaCollection.NO_COST );

                AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(at);
                Vector<Vector> sources = createSources(cam, hints); // at least one empty target! or null -> must targets not available!
                if (sources == null) { continue; }

                int sourceCount = sources.size();
                for (int s=0; s< sourceCount; s++)
                {
                    Vector<EAIAction> currentSource = sources.elementAt(s);

                    Vector<Vector> targets = createTargets(cam, hints, currentSource)// at least one empty target! or null -> must targets not available!
                    //            cunning giant should be in var list

                    if (targets == null) { break; }
                   
                    int targetCount = targets.size();

                    for (int t=0; t< targetCount; t++)
                    {
                        Vector<EAIAction> currentTargets = targets.elementAt(t);
                        Vector<EAIAction> target = joinSourceAndTarget(currentSource, currentTargets);

                        // add one WITH this attacker
                        leaf  = new EAIPlanTree(this);
                        leaf.leafExceuteOneAttackAction(at, target);
                        leafs.addElement(leaf);
                        leaf.buildAttackerLeafs(attackers, analyze, shorter, removedPossibleAttackers);
                    }
                }
            }
            return;
        }

        EAIPlanTree leaf = new EAIPlanTree(this, false);
        if (attackers.size() == 0)
        {
            // add branch without this one !
            leafs.addElement(leaf);
            // if no attackers - leave
            return;
        }
       
        // smallest first
        CardSimList shorten = (CardSimList) attackers.clone();
        CardSimList possibleBlockers = vMatch.getBattlefield((player+1)%2).getSubListByType("Creature");
        possibleBlockers = possibleBlockers.onlyTapstate(false);

        CardSimList undangeredAttackers = new CardSimList();
        CardSimList blockCheck = new CardSimList(shorten);
       
        if (possibleBlockers.size() != 0)
        {
            CardSimList unblockablAttackers = getSubListUnblockable(shorten, possibleBlockers, player);
            CardSimList undieAbleAttackers = getSubListUndieable(shorten, possibleBlockers, player);
            undangeredAttackers = CardSimList.merge(unblockablAttackers, undieAbleAttackers);
            shorten.removeListDirect(undangeredAttackers);
        }
        // search for undangered attackers, that
        // should attack (no different try outs)
        // since the rest of undangered attackers are
        // able to do all blockings by themselfs!

        //-> further todo reduce attackers to (local) top scorers

        CardSimList mustAttack = undangeredAttackers.copyList();
        possibleBlockers = vMatch.getBattlefield((player+1)%2).getSubListByType("Creature");
       // ? possibleBlockers = assumeNoBlockers(possibleBlockers);

        // returns the blocker that can be used to block
        // in block check remain the blockers that are not used.
        undangeredAttackers = removeBlockerTillAttackerDead(blockCheck, possibleBlockers, (player+1)%2);

        for (int i=0; i< mustAttack.size(); i++)
        {
            CardSim at = mustAttack.getCard(i);
            if (blockCheck.isInList(at))
            {
                leafExceuteOneAttackAction(at, null);
                undangeredAttackers.remove(at);
            }
View Full Code Here

Examples of csa.jportal.ai.enhancedAI.enhancedSim.CardSim

        for (int i=0; i< formation.singleFights.size(); i++)
        {
            SingleFight sf = formation.singleFights.elementAt(i);
            for(int b=0; b<sf.blocker.size(); b++)
            {
                CardSim bl = sf.blocker.getCard(b);
                allBlockers.moveCardTo(bl, blockersUsed);
            }
        }
        return blockersUsed;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.