Package csa.jportal.ai.enhancedAI.enhancedSim

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


        boolean didBlock = false;
        for (int f = 0; f < fights.size(); f++)
        {
            SingleFight singleFight = fights.elementAt(f);
            CardSim matchAttacker = vMatch.getAttacker(singleFight.attacker);
            CardSimList blockers = singleFight.blocker;
            int ta = 0;

            for (int b = 0; b < blockers.size(); b++)
            {
                EAIAction target = EAIAction.createTargetAction(ta, MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS, matchAttacker , -1);
                ta++;
                // using a blocker, even from a different vMatch does work,
                // since vMatch in "DeclareBlcoker" uses
                // mBattlefield[].getCard(blocker)
                // which compares the UId of the original card.
                // which in fact is allways the same!
                EAIAction block = EAIAction.createDeclareBlockerAction(no, blockers.getCard(b), target);
                boolean success = vMatch.executeAction(block, playerNo, false);
                if (success)
                {
                    addAction(currentPhaseExtended, block);
                    String key = EnhancedAI.generateCurrentVMatchKey(vMatch, playerNo);
View Full Code Here


        }
        return didBlock;
    }
    private CardSimList removeBlocking(CardSimList blockers)
    {
        CardSimList attackers = vMatch.getAttacker();
        CardSimList ret = new CardSimList();
        for (int b=0; b<blockers.size(); b++)
        {
            CardSim bl = blockers.getCard(b);
            boolean blocking = false;
            for (int a=0; ((a<attackers.size()) && (!blocking)); a++)
            {
                CardSim at = attackers.getCard(a);
                CardSimList atbl = vMatch.getBlocker(at);
                if (atbl.isInList(bl))
                {
                    blocking = true;
                }

            }
View Full Code Here

    void generatePlayerBlockerActionsLeaf(int strategy)
    {
        int opponentNo = (E.pNumber+1)%2;
        int playerNo = E.pNumber;
        CardSimList attacker = vMatch.getAttacker();
        CardSimList blocker = vMatch.getBattlefield(playerNo).getSubListByType("Creature");

        if (attacker.size() ==1)
            if (attacker.getCard(0).getCard().getUniqueID().equals("242"))
                System.out.println("ARGH!");
       
        blocker = blocker.removeTapped();
        blocker = removeBlocking(blocker);

        String blKey = generateBlockerKey(attacker, blocker);
        CombatFormation formation = blockerCache.get(blKey);
View Full Code Here

        flatten();
    }

    private CardSimList reduceSameToMax(CardSimList list, int maxSame)
    {
        CardSimList ret = new CardSimList();
       
        for (int i=0; i<list.size(); i++)
        {
            CardSim currentCard = list.getCard(i);

            if (ret.countSame(currentCard) <maxSame)
            {
                ret.addCard(currentCard);
            }
       
        }
        return ret;
    }
View Full Code Here

        }
        return ret;
    }
    private CardSimList reduceEqualIDsToMax(CardSimList list, int maxSame)
    {
        CardSimList ret = new CardSimList();
       
        for (int i=0; i<list.size(); i++)
        {
            CardSim currentCard = list.getCard(i);

            if (ret.countID(currentCard) <maxSame)
            {
                ret.addCard(currentCard);
            }
       
        }
        return ret;
    }
View Full Code Here

        return ret;
    }
    // player is no of attacker
    CardSimList getSubListUnblockable(CardSimList attackers, CardSimList blockers, int p)
    {
        CardSimList ret = new CardSimList();
        CombatSimConfig c = new CombatSimConfig(E.aiPlayer);
        c.attackerLands = vMatch.getLand(p);
        c.blockerLands = vMatch.getLand((p+1)%2);
        c.attackers = attackers;

        for (int a=0; a< attackers.size(); a++)
        {
            boolean blockPossible = false;
            CardSim attacker = attackers.getCard(a);
           
            for (int b=0; b<blockers.size(); b++)
            {
                CardSim blocker = blockers.getCard(b);
                blockPossible = SingleFight.canBlock(blocker, attacker, c, false);
                if (blockPossible) break;
            }           
            if (!blockPossible)
            {
                ret.addCard(attacker);
            }
        }
        return ret;
    }
View Full Code Here

        return possibleCardTargets;
    }

    public static Object getBestDamageTarget(VirtualMatch match, int damageToDo, int player, Communication c)
    {
        CardSimList enemies = match.getBattlefield((player+1)%2);
        enemies = enemies.sortListByCost();
        CardSim target = null;
        int targetScore = Integer.MIN_VALUE;
       
        int playerScore = -Weighting.DEFAULT.getPlayerDamageScore(damageToDo, match.getLife((player+1)%2));
        for (int i= enemies.size()-1; i>=0; i--)
        {
            if (enemies.getCard(i).getNowToughness()<= damageToDo)
            {
                target = enemies.getCard(i);
                targetScore = Weighting.DEFAULT.getCardBaseScore(target);
                break;
            }
        }
View Full Code Here

    }
   
    private int getNeedMana(String color)
    {
        int ret = 0;
        CardSimList hand = vMatch.getHand(E.pNumber);
        for (int i=0; i< hand.size(); i++)
        {
            CardSim card = hand.getCard(i);
            int now = card.getCard().getManaCost(color);
            if (now > ret) ret = now;
        }
        return ret;
    }
View Full Code Here

    {
        if (landsOnly.size() == 0) return null;
        if (landsOnly.size() == 1) return landsOnly.getCard(0);
       

        CardSimList hand = (CardSimList) vMatch.getHand(E.pNumber).clone();
//        hand.removeTypes("Land")
        ManaCollection possibleMana = E.helper.getMaxAvailableManaUnstated(vMatch);
        int preCount = EAIHelper.onlyEnoughMana(hand, possibleMana).size();
       
        int manaBlack = vMatch.getLand(E.pNumber).getSubListBySubType("Swamp").size();
View Full Code Here

        {
           
            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

TOP

Related Classes of csa.jportal.ai.enhancedAI.enhancedSim.CardSimList

Copyright © 2018 www.massapicom. 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.