Examples of CardSim


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

           
            CardSimList currentList = undangeredAttackers_.copyList();
            // b) undangeredAttackers
            //for (int i=currentList.size()-1; i >=0 ; i--)
            {
                CardSim at = currentList.getCard(0);
                currentList.remove(at);

                EAIPlanTree leaf;
                if (shorten.size() >= 0)
                {
                    // add one without this attacker
                    leaf  = new EAIPlanTree(this);
                    leafs.addElement(leaf);
                    leaf.buildUndangeredAttackers(currentList, shorten);
                }

                // add one WITH this attacker
                leaf  = new EAIPlanTree(this);
               
                leaf.leafExceuteOneAttackAction(at, null);
                leafs.addElement(leaf);
                leaf.buildUndangeredAttackers(currentList, shorten);
            }
            return;
        }
       
        // c) all other attackers
        // now build attacker variations with shorten!
        E.cconfig.attackers = shorten; // this is not correct -> but correct enough
        E.cconfig.attackerLands = vMatch.getLand(player);
        E.cconfig.blockerLands = vMatch.getLand((player+1)%2);

//        String eKey = shorten.toUHString();
//        eKey += vMatch.getBattlefield((player+1)%2).toUHString();
   
        // power!
        // smallest first
        Vector<CardSimList> powerAsc = new Vector<CardSimList>();
        Vector<CardSimList> powerDesc = new Vector<CardSimList>();
        Vector<CardSimList> toughAsc = new Vector<CardSimList>();
        Vector<CardSimList> toughDesc = new Vector<CardSimList>();
        CardSimList evaluate = null;
        int max = MAX_ATTACK_STEP;
        if (max == 0) max = 1000000;
       
        if (ATTACK_BY_POWER)
        {
            evaluate = (CardSimList) shorten.sortListByPower().clone();
            int step = max;
            if (step > evaluate.size()-1) step = evaluate.size()-1;
            step = evaluate.size()-1-step;
   
            if (ATTACK_BY_INCREASE)
            {
                // none and all are left out!
                for (int i=step; i< evaluate.size()-1; i++)
                {
                    CardSimList currentList = new CardSimList();
                    for (int ii=0; ii<=i; ii++)
                    {
                        currentList.addCard(evaluate.getCard(ii));
                    }
                    powerAsc.addElement(currentList);
                    currentList.info = "powerAsc";
                }
            }
            if (ATTACK_BY_DECREASE)
            {
                // none and all are left out!
                for (int i=step; i< evaluate.size()-1; i++)
                {
                    CardSimList currentList = new CardSimList();
                    for (int ii=0; ii<=i; ii++)
                    {
                        currentList.addCard(evaluate.getCard(evaluate.size()-1-ii));
                    }
                    powerDesc.addElement(currentList);
                    currentList.info = "powerDesc";
                }
            }
        }

        if (ATTACK_BY_TOUGHNESS)
        {
            evaluate = (CardSimList) shorten.sortListByToughness().clone();
            int step = max;
            if (step > evaluate.size()-1) step = evaluate.size()-1;
            step = evaluate.size()-1-step;


            if (ATTACK_BY_INCREASE)
            {
                // none and all are left out!
                for (int i=step; i< evaluate.size()-1; i++)
                {
                    CardSimList currentList = new CardSimList();
                    for (int ii=0; ii<=i; ii++)
                    {
                        currentList.addCard(evaluate.getCard(ii));
                    }
                    toughAsc.addElement(currentList);
                    currentList.info = "toughAsc";
                }
            }
            if (ATTACK_BY_DECREASE)
            {
                // none and all are left out!
                for (int i=step; i< evaluate.size()-1; i++)
                {
                    CardSimList currentList = new CardSimList();
                    for (int ii=0; ii<=i; ii++)
                    {
                        currentList.addCard(evaluate.getCard(evaluate.size()-1-ii));
                    }
                    toughDesc.addElement(currentList);
                    currentList.info = "DescAsc";
                }
            }
        }
        removeDoubleCombos(powerDesc, powerAsc);
       
        removeDoubleCombos(toughAsc, powerAsc);
        removeDoubleCombos(toughAsc, powerDesc);
       
        removeDoubleCombos(toughDesc, powerAsc);
        removeDoubleCombos(toughDesc, powerDesc);
        removeDoubleCombos(toughDesc, toughAsc);
       
        CardSimList all = shorten.copyList();
        all.info = "all";
        CardSimList none = new CardSimList();
        none.info = "none";
       
        Vector<CardSimList> allVariants = new Vector<CardSimList>();
        if (all.size() != 0)
            allVariants.addElement(none);
        allVariants.addElement(all);
        allVariants.addAll(powerAsc);
        allVariants.addAll(powerDesc);
        allVariants.addAll(toughAsc);
        allVariants.addAll(toughDesc);
       
        // todo remove not good scored sorted variants
        for (int i=0; i<allVariants.size(); i++ )
        {
            EAIPlanTree leaf  = new EAIPlanTree(this);
            leafs.addElement(leaf);
            CardSimList attackers = allVariants.elementAt(i);
            for (int ii=0; ii< attackers.size(); ii++)
            {
                CardSim at = attackers.getCard(ii);
                leaf.leafExceuteOneAttackAction(at, null);
            }
            leaf.attackInfo = attackers.info;
        }       
    }
View Full Code Here

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

       
        int ret = 0;
        for (int l=0; l < toDos.size(); l++)
        {
            CardAndMana cam = toDos.elementAt(l);
            CardSim card = cam.card;
            String key ="";
            if (cam.type == CardAndMana.CAM_ACTIVATE) key = HintAll.HINT_SITUATION_ACTIVATION;
            else if(cam.type == CardAndMana.CAM_PLAY)
                    if (cam.card.isInstant()) key = HintAll.HINT_SITUATION_INSTANT;
                    else key = HintAll.HINT_SITUATION_CARD_PLAYED;
View Full Code Here

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

    }

    int adjustMaxDamage(CardAndMana cam, int currentMax)
    {
        int ret = currentMax;
        CardSim card = cam.card;
        String key ="";
        if (cam.type == CardAndMana.CAM_ACTIVATE) key = HintAll.HINT_SITUATION_ACTIVATION;
        else if(cam.type == CardAndMana.CAM_PLAY)
                if (cam.card.isInstant()) key = HintAll.HINT_SITUATION_INSTANT;
                else key = HintAll.HINT_SITUATION_CARD_PLAYED;
View Full Code Here

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

                possibleActivateableCards = EAIHelper.onlyUntappedToActivate(possibleActivateableCards);

                Vector<CardAndMana> _cam = new Vector<CardAndMana>();
                for(int c=0; c< possibleActivateableCards.size(); c++)
                {
                    CardSim card = possibleActivateableCards.getCard(c);
                    ManaCollection cost = ManaCollection.getActivateCost(card);
                   
                    // TODO: hack for kicker prevention
                    //
                    if (!card.getCard().isKicker())
                        if (possibleMana.isCostFit(cost))
                        {
                            _cam.addElement(new CardAndMana(CardAndMana.CAM_ACTIVATE , card, cost));
                            possibleMana = possibleMana.subMana(cost);
                        }
                }

                // cams ready, now -> targets! (one)
                for (int i = _cam.size()-1; i >= 0; i--)
                {
                    CardAndMana cam = _cam.elementAt(i);
                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
                    Vector<EAIAction> sources = createOneOpponentSource(cam, hints); // at least one empty target! or null -> must targets not available!
                    if (sources == null)
                    {
                        continue;
                    }
                    Vector<EAIAction> targets = createOneOpponentTarget(cam, hints)// at least one empty target! or null -> must targets not available!
                    if (targets == null)
                    {
                        continue;
                    }
                    Vector<EAIAction> target = joinSourceAndTarget(sources, targets);
                    boolean successfull = leaf.leafExceuteOneAction(cam, target, opponent, camListBefor(_cam, i));
                }
            }
            else if(currentPhase == MatchConstants.PHASE_COMBAT_DECLARE_ATTACKERS)
            {
                if (mDoStacking)
                {
                    // in stack I dont estimate opponents attackers
                    EAIPlanTree leaf = new EAIPlanTree(this, false); // try out
                    leafs.addElement(leaf);
                    return;
                }

                // opponent: activate cards that are in battlefield

                // todo build best attacking opponent can do
                // which would be the worst case scenario
                // doing an ALL OUT attack :-)
                // therefor only that option is to be tested
                // "Phew" - no explosion of choices here!

//System.out.println("Try declaring attackers of other AI!");
                // generate instant, activations

                // generate instant, activations
                // after that create all possible attackers

                // create permutations
                // possibly reuse same in different leafs (not known from here,
                // other leafs are in parent - caching and cloning?

                // now for each leaf all attack possibilities

                // dummy as long as above is not implemented
                // allways add a empty leaf
                EAIPlanTree leaf = new EAIPlanTree(this, false);

                // opponent: activate cards that are in battlefield -> like kings assassin!
                ManaCollection possibleMana = EAIHelper.getMaxAvailableMana(vMatch, opponent);
                CardSimList possibleActivateableCards = vMatch.getBattlefield(opponent);
                possibleActivateableCards = EAIHelper.onlyAllowedToActivate(possibleActivateableCards, currentPhase, true, vMatch);
                possibleActivateableCards = EAIHelper.onlyUntappedToActivate(possibleActivateableCards);

                CardSimList activated = new CardSimList();
               
                Vector<CardAndMana> _cam = new Vector<CardAndMana>();
                for(int c=0; c< possibleActivateableCards.size(); c++)
                {
                    CardSim card = possibleActivateableCards.getCard(c);
                    ManaCollection cost = ManaCollection.getActivateCost(card);
                    if (possibleMana.isCostFit(cost))
                    {
                        _cam.addElement(new CardAndMana(CardAndMana.CAM_ACTIVATE , card, cost));
                        possibleMana = possibleMana.subMana(cost);
                    }
                }

                // cams ready, now -> targets! (one)
                for (int i = _cam.size()-1; i >= 0; i--)
                {
                    CardAndMana cam = _cam.elementAt(i);
                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
                    Vector<EAIAction> sources = createOneOpponentSource(cam, hints); // at least one empty target! or null -> must targets not available!
                    if (sources == null)
                    {
                        continue;
                    }
                    Vector<EAIAction> targets = createOneOpponentTarget(cam, hints)// at least one empty target! or null -> must targets not available!
                    if (targets == null)
                    {
                        continue;
                    }
                    Vector<EAIAction> target = joinSourceAndTarget(sources, targets);
                    boolean successfull = leaf.leafExceuteOneAction(cam, target, opponent, camListBefor(_cam, i));
                    activated.addCard(cam.card);
                }

                leafs.addElement(leaf);

                int no = 0;
                for (int i = 0; i < leafs.size(); i++)
                {
                    leaf = leafs.elementAt(i);
                    CardSimList possibleAttackers = leaf.vMatch.getPossibleAttackers();
                    possibleAttackers.removeListDirect(activated);
    //public CombatFormation computeBestAttack(Weighting weighting, int attackerHealth, int blockerHealth, CardSimList notHereEvaluatedAttackers, CardSimList externalRemovedAttackers, CardSimList allBlockers)

           
                    CombatSimConfig c = new CombatSimConfig(E.aiPlayer);
                    c.attackers = possibleAttackers;
                    c.attackerLands = vMatch.getLand(opponent);
                    c.blockerLands = vMatch.getLand(player);
                    CardSimList blocker = vMatch.getBattlefield(player).getSubListByType("Creature");
                    blocker = blocker.removeActivateable();
                    //blocker = vMatch.removeAllreadyBlocking(blocker);
                    blocker = blocker.onlyTapstate(false);

                    CombatSimNew csim = new CombatSimNew(possibleAttackers, blocker, c, false);
                    int blockerHealth = vMatch.getLife(player);

                    // TEST new Attacking!
                    CombatFormation attackFormation = csim.computeBestAttack(Weighting.DEFAULT, blockerHealth);

                    for (int a=0; a< attackFormation.singleFights.size(); a++)
                    {
                        CardSim at = attackFormation.singleFights.elementAt(a).attacker;
                        EAIAction attack = EAIAction.createDeclareAttackerAction(no++, at);

                        boolean success = leaf.vMatch.executeAction(attack, opponent, false);
                        if (success)
                        {
                            leaf.addAction(currentPhaseExtended, attack);
                            String key = EnhancedAI.generateCurrentVMatchKey(leaf.vMatch, player);
                            attack.setVMatchKeyAfter(key);
                        }
                    }

                    /*
                    // old -> all out attack
                    for (int a=0; a< possibleAttackers.size(); a++)
                    {
                        CardSim at = possibleAttackers.getCard(a);
                        EAIAction attack = EAIAction.createDeclareAttackerAction(no++, at);

                        boolean success = leaf.vMatch.executeAction(attack, opponent, false);
                        if (success)
                        {
                            leaf.addAction(currentPhaseExtended, attack);
                            String key = EnhancedAI.generateCurrentVMatchKey(leaf.vMatch, player);
                            attack.setVMatchKeyAfter(key);
                        }
                    }
                    *
                    */
                }
               
                flatten();

            }
            else if (currentPhase == MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS)
            {
                // todo build best blocking for ourselfs to block oppoents attack
//System.out.println("Try declaring blockers!");


                // do nothing if there is nothing to block!
                // stupid thing wants to play giant growth on no attacket!

                // here we come for each of our own attacker definitions
                // in order to simulate the game
                // here we get a best guess - of our opponents bloking actions

                // sets all corresponding actions!

                // generate instant, activations
                // after that create all possible attackers
                futurePrePlan.addAll(generatePossibleActionsGeneral(true, null));

                // rod of ruin
                buildLeafs(futurePrePlan);
                if (leafs.isEmpty())
                {
                    EAIPlanTree leaf = new EAIPlanTree(this, false); // try out
                    leafs.addElement(leaf);
                }
                flattenNoScore();
                // create permutations
                // possibly reuse same in different leafs (not known from here,
                // other leafs are in parent - caching and cloning?

                // now for each leaf all attack possibilities

                // Todo: for now opponent strategy!
                int opponentBlockStrategy = E.aiPlayer.getEAIConfig().getOpponentBlockStrategy();
                if (E.aiPlayer.getEAIConfig().getOpponentAdaptiveBlocking())
                {
                    int life = vMatch.getLife(player);
                    int maxDamage = EAIHelper.getPowerSum(vMatch.getAttacker());

                    if (life <= maxDamage+E.aiPlayer.getEAIConfig().getSavetyHealthThreshold())
                        opponentBlockStrategy = BLOCK_PLAYER_LEAST_DAMAGE;
                    else
                        opponentBlockStrategy = BLOCK_PLAYER_LEAST_CREATURE_DEAD;
                }
                generatePlayerBlockerActions(opponentBlockStrategy); // for now!
            }
            else if (currentPhase == MatchConstants.PHASE_COMBAT_END)
            {
                if (UID == 7325)
                    System.out.println("Buh!");
                vMatch.doCombat((player+1)%2);
            }

            if (leafs.isEmpty())
            {
                EAIPlanTree leaf = new EAIPlanTree(this, false); // try out
                leafs.addElement(leaf);
            }
            return;
        }
        if (currentPhase == MatchConstants.PHASE_BEGINNING_UNTAP)
        {
            CACHEHIT = false;
            int actionCounter = 0;
            Vector<CardAndMana> willBeActions = new Vector<CardAndMana>();
            Vector<CardAndMana> futurePlanWithoutActions = new Vector<CardAndMana>();

            CardSimList lands = vMatch.getLand(E.pNumber);
            CardSimList creatures = vMatch.getBattlefield(E.pNumber);
            Vector ls = lands.getCards();
            for (int i = 0; i < ls.size(); i++)
            {
                CardSim card = (CardSim) ls.elementAt(i);
                if (card.isTapped())
                {
                    CardAndMana untapLand = new CardAndMana(CardAndMana.CAM_UNTAP,card, null);
                    willBeActions.add(untapLand);
                }
            }
            Vector cs = creatures.getCards();
            for (int i = 0; i < cs.size(); i++)
            {
                CardSim card = (CardSim) cs.elementAt(i);
                if (card.isTapped())
                {
                    CardAndMana untapCreature = new CardAndMana(CardAndMana.CAM_UNTAP,card, null);
                    willBeActions.add(untapCreature);
                }
            }

            if (willBeActions.isEmpty())
            {
                // will allways be empty if nextRound() by match was played
                // sincew vmatch resets all tapped items on newRound()!
                EAIPlanTree leaf = new EAIPlanTree(this, false);
                leafs.addElement(leaf);
                return;
            }

            EAIPlanTree leaf = new EAIPlanTree(this);
            leaf.futurePrePlan = futurePlanWithoutActions;
            while (!willBeActions.isEmpty())
            {
                CardAndMana cam = willBeActions.elementAt(0);
                willBeActions.removeElement(cam);
                boolean reEvaluate = leaf.leafExceuteOneAction(cam, new Vector<EAIAction>(), player, null); // no targets (as of yet) for untapping
            }
            leaf.playerScore = Weighting.DEFAULT.buildScore(leaf.getMatch(), player, false);
            leaf.opponentScore = Weighting.DEFAULT.buildScore(leaf.getMatch(), (player+1)%2, false);
            leaf.difScore = leaf.playerScore-leaf.opponentScore;
            leafs.addElement(leaf);
        }
        if (currentPhase == MatchConstants.PHASE_BEGINNING_DRAW)
        {
            EAIPlanTree leaf = new EAIPlanTree(this);
            leaf.vMatch.drawLibCardToHand(player);
            leafs.addElement(leaf);
        }
        else if(currentPhase == MatchConstants.PHASE_MAIN1)
        {
            futurePrePlan.addAll(generatePossibleActionsGeneral(true, null));
            // in future plan all possible playing cards / actions are ilsted
            // permutation of these are done in build leafs...

            buildLeafs(futurePrePlan);
        }
        else if(currentPhase == MatchConstants.PHASE_MAIN2)
        {
            futurePrePlan.addAll(generatePossibleActionsGeneral(true, null));
            buildLeafs(futurePrePlan);
        }
        else if (currentPhase == MatchConstants.PHASE_COMBAT_DECLARE_ATTACKERS)
        {
            // generate instant, activations
            // after that create all possible attackers
            futurePrePlan.addAll(generatePossibleActionsGeneral(true, null));
           
// 10572          
            buildLeafs(futurePrePlan);
            if (leafs.isEmpty())
            {
                EAIPlanTree leaf = new EAIPlanTree(this, false); // try out
                leafs.addElement(leaf);
            }
            flatten();
            // create permutations
            // possibly reuse same in different leafs (not known from here,
            // other leafs are in parent - caching and cloning?

            // now for each leaf all attack possibilities
            for (int i = 0; i < leafs.size(); i++)
            {
                EAIPlanTree leaf = leafs.elementAt(i);
                // attackers in respect to allready activated cards -> therefor in respect to leaf!
                CardSimList possibleAttackers = new CardSimList();
                CardSimList removedPossibleAttackers = new CardSimList();

                // removed possible attackers are interesting for blocking a re attack! (Evaluation)
                leaf.generatePossibleAttackers(E.pNumber, possibleAttackers, removedPossibleAttackers);

                // NOTICE:
                // general Attacking Hints (SELF - ONLY!) are applied in
                // SingleFight:  applyAttackingHints(CardSim at)
                // targetting attacking hints are applied here!

                /*
                 * look for attackers which inherently do something upon attack
                  e.g. Seasoned marshal.
                  Than build leaves for attack / no attack

                 */
                CardSimList tryAttackerList = new CardSimList();
                for (int t=possibleAttackers.size()-1; t>=0; t--)
                {
                    CardSim card = possibleAttackers.getCard(t);
                    AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(card);
                    if (hints == null) continue;
                    if (hints.hasKey(HintAll.HINT_SITUATION_ATTACKER))
                    {
                        if (EAIHelper.isRemoveHand(card, HintAll.HINT_SITUATION_ATTACKER))
View Full Code Here

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

        // now create actions
        Vector<EAIAction> actions = new Vector<EAIAction>();
        for (int i = 0; i < possibleCardTargets.size(); i++)
        {
            CardSim card = possibleCardTargets.getCard(i);
            // if card is a damaging X card
            // only allow targets which will be destroyed by it exactly
            if (good != 1) // not good
            {
                if (EAIHelper.isCreatureDamageCardSource(cam.card, key))
                {
                    if (cam.card.getCard().getManaCost() == -1)
                    {
                        // damage X
                        int damage = cam.cost.getAllManaCount() - cam.card.getCard().getManaCostNonX();

                        if (card.getNowToughness() != damage) continue;
                    }

                    // reduce creature targets to only the ones we can actually kill
                    // we do not test only the damage this card can do
                    // but all possible damage we can do till the end of testing
                    // within this leaf
                    // compared to the "damage" allready taken (ToughnessNOW)
                    if (vMatch.getPhase() != MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS)
                        if ((card.getNowToughness() > maxDamageInTodo) && (onlyCreatureKillDamage))
                            continue;
              
                }
            }
View Full Code Here

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

        possibleCardTargets = reduceTargetToSensible(possibleCardTargets, minTargets, viewPlayer, vMatch, cam.card, good);

        // now create actions
        for (int i = 0; i < possibleCardTargets.size(); i++)
        {
            CardSim card = possibleCardTargets.getCard(i);
            // if card is a damaging X card
            // only allow targets which will be destroyed by it exactly
            if (good != 1) // not good
            {
                if (cam.card.getCard().getManaCost() == -1)
                {
                    // damage X
                    int damage = cam.cost.getAllManaCount() - cam.card.getCard().getManaCostNonX();

                    if (card.getNowToughness() != damage) continue;
                }
            }
            EAIAction action = EAIAction.createTargetAction(0, vMatch.getPhase(), card, -1);
            action.isSource = true;
            ret.addElement(action);
View Full Code Here

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

                {
                    // get cheapest till count ok
                    CardSimList temp = possibleCardTargets.removeOwner((player+1)%2).sortListByCost();
                    while ((possibleCardTargetsTest.size() < minTargets) && (temp.size()>0))
                    {
                        CardSim c = temp.getCard(0);
                        temp.remove(c);
                        possibleCardTargetsTest.addCard(c);
                       
                    }
                }
                possibleCardTargets = possibleCardTargetsTest;
               
                possibleCardTargetsTest = removeOpponentCardsWithNicePlayoutEffects(possibleCardTargets, player, vMatch);
                if (possibleCardTargetsTest.size() < minTargets)
                {
                    // get expansive till count ok
                    CardSimList temp = possibleCardTargets.removeOwner((player+1)%2).sortListByCost();
                    while ((possibleCardTargetsTest.size() < minTargets) && (temp.size()>0))
                    {
                        CardSim c = temp.getCard(temp.size()-1);
                        temp.remove(c);
                        possibleCardTargetsTest.addCard(c);
                       
                    }
                   
                }
                possibleCardTargets = possibleCardTargetsTest;
            }
            possibleCardTargets = reduceTargetToSensible(possibleCardTargets, SOME_SENSIBLE_CHOSING_SIZE, player, vMatch, cam.card, good);
        }

        // now create actions
        Vector<EAIAction> actions = new Vector<EAIAction>();

        if ((EAIHelper.hasHint(cam.card, key, new HintBundle(HintTargetTypes.TY_DIVIDE_AMOUNT))) && (creatureDamage))
        {
            int divided = 0;
            // e.g. forked lightning!
            for (int tt = 0; tt < maxTargets; tt++)
            {
                for (int i = 0; i < possibleCardTargets.size(); i++)
                {
                    CardSim card = possibleCardTargets.getCard(i);

                    // reduce creature targets to only the ones we can actually kill
                    // we do not test only the damage this card can do
                    // but all possible damage we can do till the end of testing
                    // within this leaf
                    // compared to the "damage" allready taken (ToughnessNOW)
                    if (vMatch.getPhase() != MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS)
                        if ((card.getNowToughness() > maxDamageInTodo) && (onlyCreatureKillDamage))
                            continue;
                    if (card.getNowToughness() <= card.helper)
                        continue; // creature is already dead!

                    EAIAction action = EAIAction.createTargetAction(0, vMatch.getPhase(), card, -1);
                    action.isTarget = true;
                    actions.addElement(action);
                   
                    // helper helps us to only add cards to divided damage
                    // as long as the divided damage for that card is
                    // not enough to kill it
                    card.helper++; // plus one damage
                    divided++; // only divide actions for max Targets!
                    if (divided>=maxTargets) break;
                }
                if (divided>=maxTargets) break;

            }
        }
        else
        {
            int currentChosenCount = 0;
            boolean choseCount = (EAIHelper.hasHint(cam.card, key, new HintBundle(HintTargetCount.CT_TARGET_COUNT_CHOSEN)));

            // for "Ransack" as it is implemented now!
            boolean actionsDone = false;
            if ((choseCount) && (possibleCardTargets.size() >0))
            {
                int sizeChosen = 1;
                if (maxTargets > 1)
                {
                    sizeChosen = maxTargets / 2;
                }
                CardSimList goodHalf = new CardSimList();
                CardSimList badHalf = possibleCardTargets.copyList();

                int cPlayer = 0;
                if (sourceDependened)
                    cPlayer =dependenedPlayer;
                else
                    cPlayer = badHalf.getCard(0).getOwner();
               
               
                // from cPlayer point of view
                for (int ii=badHalf.size()-1;ii >=0; ii--)
                {
                    CardSim g = EAIHelper.selectGoodCard(badHalf, true, cPlayer, vMatch, cam.card);
                    if (g == null) break;
                    goodHalf.addCard(g);
                    badHalf.remove(g);
                    if (goodHalf.size() >=sizeChosen) break;
                }
                if (EAIHelper.hasHint(cam.card, key, new HintBundle(HintTargetTypes.TY_CHOICE_LIBTOP_BOTTOM)));
                {
                    doPermutations = false;
                    if (player == cPlayer)
                    {
                        // put good cards on top of lib
                        actionsDone = true;
                        for (int i = 0; i < goodHalf.size(); i++)
                        {
                            CardSim card = goodHalf.getCard(i);
                            EAIAction action = EAIAction.createTargetAction(0, vMatch.getPhase(), card, -1);
                            action.isTarget = true;
                            actions.addElement(action);
                        }
                    }
                    else
                    {
                        // put good cards on top of lib
                        actionsDone = true;
                        for (int i = 0; i < badHalf.size(); i++)
                        {
                            CardSim card = badHalf.getCard(i);
                            EAIAction action = EAIAction.createTargetAction(0, vMatch.getPhase(), card, -1);
                            action.isTarget = true;
                            actions.addElement(action);
                        }
                    }

                    // do no permutation, since for now the
                    // above selection scheme of good/bad cards is
                    // a fixed algorithm and we do not make any further suggestions as of now
                    ret.addElement(actions);
                    return ret;
                }
            }
           
            if (!actionsDone)
            {
                for (int i = 0; i < possibleCardTargets.size(); i++)
                {
                    CardSim card = possibleCardTargets.getCard(i);

                    // if card is a damaging X card
                    // only allow targets which will be destroyed by it exactly
                    if (good != 1) // not good
                    {
                        if (creatureDamage)
                        {
                            if (cam.card.getCard().getManaCost() == -1)
                            {
                                // damage X
                                int damage = cam.cost.getAllManaCount() - cam.card.getCard().getManaCostNonX();

                                if (card.getNowToughness() != damage) continue;
                            }

                            // reduce creature targets to only the ones we can actually kill
                            // we do not test only the damage this card can do
                            // but all possible damage we can do till the end of testing
                            // within this leaf
                            // compared to the "damage" allready taken (ToughnessNOW)
                            else
                            {
                                if (card.getOwner() != player)
                                {
                                    if (vMatch.getPhase() != MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS)
                                        if ((card.getNowToughness() > maxDamageInTodo) && (onlyCreatureKillDamage))
                                            continue;
                                }
                            }
                        }
                    }
View Full Code Here

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

        String ret ="";
        Vector<String> v = new Vector<String>();
        for (int i = 0; i < actionList.size(); i++)
        {
            EAIAction eAIAction = actionList.elementAt(i);
            CardSim c = eAIAction.getSCard();
            if (c.getType().toUpperCase().indexOf("BASIC") != -1)
                v.add(c.getName());
            else
                v.add(c.getId());
        }
       
        Collections.sort(v, new Comparator<String>()
        {
           public final int compare(String s1, String s2)
View Full Code Here

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

        possibleCardTargets = reduceSameToMax(possibleCardTargets, maxTargets);
        // only ONE target
        possibleCardTargets = reduceTargetToSensible(possibleCardTargets, minTargets, viewPlayer, vMatch, cam.card, good);
        for (int i = 0; i < possibleCardTargets.size(); i++)
        {
            CardSim card = possibleCardTargets.getCard(i);

            // if card is a damaging X card
            // only allow targets which will be destroyed by it exactly
            if (good !=1 ) // not good
            {
                if (cam.card.getCard().getManaCost() == -1)
                {
                    // damage X
                    int damage = cam.cost.getAllManaCount() - cam.card.getCard().getManaCostNonX();
                    if (card.getNowToughness() != damage) continue;
                }
            }

            EAIAction action = EAIAction.createTargetAction(0, vMatch.getPhase(), card, -1);
            action.isTarget = true;
View Full Code Here

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

    String generateBlockerKey(CardSimList attacker, CardSimList blocker)
    {
        String aKey = "";
        for (int i=0; i< attacker.size(); i++)
        {
            CardSim at = attacker.getCard(i);
            aKey += at.getKey();
        }
        String bKey = "";
        for (int i=0; i< blocker.size(); i++)
        {
            CardSim bl = blocker.getCard(i);
            bKey += bl.getKey();
        }
        return aKey+"<->"+bKey;
    }
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.