Package csa.jportal.ai.enhancedAI.enhancedSim

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


        String key = "";
        ManaCollection possibleMana = E.helper.getMaxAvailableMana(vMatch);
        // list of all cards, that can be played with mana available

        // HAND cards
        CardSimList hand = (CardSimList) vMatch.getHand(E.pNumber).clone();
        CardSimList possiblePlayableCards;
        possiblePlayableCards = hand;
        possiblePlayableCards = EAIHelper.onlyEnoughMana(possiblePlayableCards, possibleMana);

        // Field activations!
        CardSimList field = vMatch.getBattlefield(E.pNumber);
        field = field.onlyActivatable(); // possibly add land here
        field = field.removeSick();
        CardSimList possibleActivateableCards = field;
        possibleActivateableCards = EAIHelper.onlyEnoughManaActivate(possibleActivateableCards, possibleMana);
        possibleActivateableCards = EAIHelper.onlyUntappedToActivate(possibleActivateableCards);

        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


     * NOT checked if fitting targets are available for cards!
     */
    Vector<CardAndMana> generatePossibleActionsGeneral(boolean restrictMana, Vector<EAIAction> stack)
    {
        ManaCollection possibleMana = E.helper.getMaxAvailableMana(vMatch);
        CardSimList hand = (CardSimList) vMatch.getHand(E.pNumber).clone();
        // list of all cards, that can be played with mana available
        CardSimList possiblePlayableCards;


        // do different optimizations of "possible" playable cards

        // LAND Play
        // should be in phase 1
        // and only one land of a type
        boolean landPlay = true;
        boolean removeDebufs = false;
        if (isMyTurn())
        {
            if (E.aiPlayer.getEAIConfig().getLandForceMain1())
            {
                if (vMatch.getPhase() != MatchConstants.PHASE_MAIN1)
                {
                    landPlay = false;
                }
            }
            if (landPlay)
            {
                if (!decidePlayLand())
                {
                    landPlay = false;
                }
                else
                {
                }
            }
            // this one should ensure land play when a land was got in attacking phase
            // like tapping tales researcher...
            if (vMatch.getPhase() == MatchConstants.PHASE_MAIN2)
            {
                if (decidePlayLand())
                {
                    if (!(vMatch.isLandPlayed(E.pNumber)))
                    {
                        if (E.aiPlayer.getEAIConfig().getLandForceMain1())
                        {
                            landPlay = true;
                        }
                    }
                }
            }
        }
        else
        {
            landPlay = false;
        }
        boolean willPlayLand = false;
        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);
View Full Code Here

        if ((vMatch.getPhase() == MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS) && (!isMyTurn()))
        {
            return true;
        }

        CardSimList possibleBlockers = vMatch.getPossibleBlockers((p+1)%2);
        return isWeakling(card, possibleBlockers, p);
    }
View Full Code Here

    {
        boolean ret;

        int tough = card.getNowToughness();
        int damage = 0;
        E.cconfig.attackers = new CardSimList(card); // this is not correct -> but correct enough
        E.cconfig.attackerLands = vMatch.getLand(p);
        E.cconfig.blockerLands = vMatch.getLand((p+1)%2);

        // if null -> there is no possiblility for the blockers to kill the attacker
        ret = CombatSimNew.getLeastDeadKillers(card, possibleBlockers, 0, true, E.cconfig) != null;
View Full Code Here

        return ret;
    }
    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);
            }
        }
        return ret;
    }
View Full Code Here

        }
        return ret;
    }
    CardSimList assumeNoBlockers(CardSimList possibleBlockers)
    {
        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);
            }
        }

        return ret;
    }
View Full Code Here

        comboSelect = 0;

        jPanelvMatchPanel.removeAll();
        if (mVMatch ==null) return;
        if (!mVMatch.init) return;
        CardSimList simList=null;

        if(t.indexOf("Hand") != -1) simList = mVMatch.getHand(0);
        else if (t.indexOf("Grave") != -1) simList = mVMatch.getGraveyard(0);
        else if (t.indexOf("Land") != -1) simList = mVMatch.getLand(0);
        else if (t.indexOf("Atta") != -1)
        {
            simList = mVMatch.getAttacker(); // since usually the vmatch simulated is passed attacking phase
            if (simList == null)
            {
                simList = mVMatch.getOldAttacker(); // since usually the vmatch simulated is passed attacking phase
            }
            else
            {
                if (simList.size() == 0)
                    simList = mVMatch.getOldAttacker(); // since usually the vmatch simulated is passed attacking phase
            }

        }
        else if (t.indexOf("Bat") != -1) simList = mVMatch.getBattlefield(0);
        else if (t.indexOf("OLib") != -1)
        {
            mVMatch.initLibrary();
            simList = mVMatch.getLibrary(0);
        }
        else if (t.indexOf("Lib") != -1) simList = mVMatch.getLibrary(0);
        else if (t.indexOf("Bloc") != -1)
        {
            // todo
        }
        if (simList == null) return;
        jLabel30.setText(""+simList.size());
        final CardSimList simList2=simList;

        CardList list=new CardList();
        for (int i=0; i<simList.size(); i++)
        {
            list.addCard(simList.getCard(i).getCard());
        }

        final CardListPanel listDisplay = new csa.jportal.match.display.CardListPanel();

        listDisplay.addPlayerEventListener(new DisplayEventListener()
        {
            @Override
            public void displayEventOccurred(DisplayEvent e)
            {
                //  if rigth click, than show info of current card
                if (e.mMessageType == MOUSE_LEFTRELEASED_CARD)
                {
                    Card card = e.mCard;
                    for (int i=0; i < simList2.size(); i++)
                    {
                        if (card.getUniqueID().equals(simList2.getCard(i).getCard().getUniqueID()))
                        {
                            CardSim sim = simList2.getCard(i);
                            showSimCardInfo(sim);
                            break;
                        }
                    }
                }
View Full Code Here

        comboSelect = 1;
        jPanelvMatchPanel.removeAll();
        if (mVMatch == null) return;
        if (!mVMatch.init) return;

        CardSimList simList=null;

        if(t.indexOf("Hand") != -1) simList = mVMatch.getHand(1);
        else if (t.indexOf("Grave") != -1) simList = mVMatch.getGraveyard(1);
        else if (t.indexOf("Land") != -1) simList = mVMatch.getLand(1);
        else if (t.indexOf("Atta") != -1)
        {
            simList = mVMatch.getAttacker();
            if (simList == null)
            {
                simList = mVMatch.getOldAttacker(); // since usually the vmatch simulated is passed attacking phase
            }
            else
            {
                if (simList.size() == 0)
                    simList = mVMatch.getOldAttacker(); // since usually the vmatch simulated is passed attacking phase
            }
        }
        else if (t.indexOf("Bat") != -1) simList = mVMatch.getBattlefield(1);
        else if (t.indexOf("OLib") != -1)
        {
            mVMatch.initLibrary();
            simList = mVMatch.getLibrary(1);
        }
        else if (t.indexOf("Lib") != -1) simList = mVMatch.getLibrary(1);
        else if (t.indexOf("Bloc") != -1)
        {
            // todo
        }
        if (simList == null) return;
        jLabel31.setText(""+simList.size());
        CardList list=new CardList();
        for (int i=0; i<simList.size(); i++)
        {
            list.addCard(simList.getCard(i).getCard());
        }


        final CardListPanel listDisplay = new csa.jportal.match.display.CardListPanel();
        final CardSimList simList2=simList;

        listDisplay.addPlayerEventListener(new DisplayEventListener()
        {
            @Override
            public void displayEventOccurred(DisplayEvent e)
            {
                //  if rigth click, than show info of current card
                if (e.mMessageType == MOUSE_LEFTRELEASED_CARD)
                {
                    Card card = e.mCard;
                    for (int i=0; i < simList2.size(); i++)
                    {
                        if (card.getUniqueID().equals(simList2.getCard(i).getCard().getUniqueID()))
                        {
                            CardSim sim = simList2.getCard(i);
                            showSimCardInfo(sim);
                            break;
                        }
                    }
                }
View Full Code Here

                               
                                VirtualMatch vMatch = new VirtualMatch(c.E.mInitiatorMatch);
                                int damageToDo = initiator.getNowPower();
                               
                                CombatSimConfig configTMP = new CombatSimConfig();
                                configTMP.attackers = new CardSimList(initiator);
                                configTMP.blockerLands = vMatch.getLand((initiator.getOwner()+1)%2);
                                configTMP.attackerLands = vMatch.getLand(initiator.getOwner());
                               
                                csa.jportal.ai.enhancedAI.enhancedSim.SingleFight sFight = csa.jportal.ai.enhancedAI.enhancedSim.SingleFight.getFight(initiator, vMatch.getBlocker(initiator), configTMP, false);
                               
View Full Code Here

                    if (aHints.hasHint(key, HintTargetTypes.TY_DAMAGE_AS_BLOCKED))
                    {
                        VirtualMatch vMatch = new VirtualMatch(c.E.mInitiatorMatch);
                        int damageToDo = initiator.getNowPower();
                        vMatch.getAttacker().remove(initiator);
                        CardSimList attackersToRemove = new CardSimList( c.E.mInitiatorMatch.getAttacksDone());
                        vMatch.getAttacker().removeListDirect(attackersToRemove);

                        vMatch.doCombat(initiator.getOwner());
                        EAIPlanTree.getBestDamageTarget(vMatch, damageToDo, initiator.getOwner(), c);
                        return;
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.