Package csa.jportal.ai.enhancedAI.enhancedSim

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


    Vector<CardAndMana> futureMinusActions(Vector<CardAndMana> fp, Vector<CardAndMana> willBeActions)
    {
        Vector<CardAndMana> ret = new Vector<CardAndMana>();
        for (int i = 0; i < fp.size(); i++)
        {
            CardAndMana cam = fp.elementAt(i);
            if (!willBeActions.contains(cam))
            {
                ret.add(cam);
            }
        }
View Full Code Here


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

                // 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; }
View Full Code Here

        // TODO - apply the above settings do genration

        for (int i = 0; i < toDos.size(); i++)
        {
            CardAndMana c = toDos.elementAt(i);


            if (c.type == CardAndMana.CAM_PLAY)
            {
                if (c.card.isLand())
View Full Code Here

        // simple and straight forward
       
        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;
View Full Code Here

        {
            // if this is active, all lists below stage one
            // should NOT contain lands!
            for (int l=0; l < shorten.size(); l++)
            {
                CardAndMana lcam = shorten.elementAt(l);
                if (lcam.card.isLand())
                {
                    shorten.removeElement(lcam);
                    l--;
                }
View Full Code Here

       
       
       
        for (int i = 0; ((i < forced.size()) && (!changeBreak)); i++)
        {
            CardAndMana cam = forced.elementAt(i);

            // one WITH - no choice
            // all actions also to one leaf - since now choice!
            ManaCollection possibleMana = E.helper.getMaxAvailableMana(vMatch);
            if (!EAIHelper.hasEnoughMana(cam.cost, possibleMana))
View Full Code Here

        leafs.addElement(leaf);

        boolean changeBreak = false;
        for (int i = fixed.size()-1; ((i >=0 ) && (!changeBreak)); i--)
        {
            CardAndMana cam = fixed.elementAt(i);
//            if (cam.card.getId().equals("6523"))
//                System.out.println("Buh!");
            fixed.removeElement(cam);
            boolean isX = (cam.card.getCard().getManaCost() == -1);
            Vector<CardAndMana> newVariable = (Vector<CardAndMana>) variable.clone();
            Vector<CardAndMana> newFixed = (Vector<CardAndMana>) fixed.clone();

            // and (possibly) one WITH           
            AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
               
            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!

                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);
                    leaf = new EAIPlanTree(this);
                    leaf.maxDamageInTodo = maxDamageInTodo;

                    boolean successfull = leaf.leafExceuteOneAction(cam, target, player, camList(fixed,variable) );
                    if (doTestTwins)
                    {
                        String key =  EnhancedAI.generateCurrentVMatchKeyID(leaf.vMatch, player) + target.toString();
                        if (isX) key += cam.card.getCard().getUniqueID()+cam.cost.getAllManaCount();
                        String hintKey = "";
                        if (cam.type == CardAndMana.CAM_ACTIVATE)
                            hintKey = HintAll.HINT_SITUATION_ACTIVATION;
                        else if(cam.type == CardAndMana.CAM_PLAY)
                                if (cam.card.isInstant()) hintKey = HintAll.HINT_SITUATION_INSTANT;
                                else hintKey = HintAll.HINT_SITUATION_CARD_PLAYED;

                        // assumes ONE source
                        // assumes depends on source is player!
                        if (hints.hasHint(hintKey, HintAll.TR_TARGET_DEPENDS_ON_SOURCE)) // card has targets, but they are not to be selected
                        {
                            if (currentSource.size() > 0)
                            {
                                if (currentSource.elementAt(0).targetIsPlayer)
                                    key+=""+currentSource.elementAt(0).targetPlayerNumber;
                                else
                                    key+=""+currentSource.elementAt(0).getSCard();
                            }
                        }

                        String test = twinTest.get(key);
                        if (test == null)
                        {
                            test = twinTest.put(key, key);
                        }
                        else
                        {
                            successfull = false;
                        }
                    }
                    if (successfull)
                    {
                        leaf.maxDamageInTodo = adjustMaxDamage(cam, leaf.maxDamageInTodo);

                        // indicates whether the played out card had
                        // changed the preconditions for evaluating the current
                        // playable cards.

                        // Played out lands DO change things
                        boolean changesThings = cam.card.isLand();

                        int orgHandSize = vMatch.getHand(E.pNumber).size();
                        int newHandSize = leaf.vMatch.getHand(E.pNumber).size();
                        if (cam.type == CardAndMana.CAM_PLAY) orgHandSize--;
                        // if after playing out a card is the handsize different
                        // from befor -> that means that the hand changed and
                        // possibly something else can be played...
                        if (orgHandSize != newHandSize)
                            changesThings = true;

                        int orgLandSize = vMatch.getLand(E.pNumber).size();
                        int newLandSize = leaf.vMatch.getLand(E.pNumber).size();
                        if (cam.card.isLand()) orgLandSize++;
                        if (orgLandSize != newLandSize)
                            changesThings = true;
                        if (!changesThings)
                        {
                            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;
                            changesThings = EAIHelper.hasHandChanges(cam.card, key);
                        }

                        leafs.addElement(leaf);
                        if (changesThings)
                        {
                            Vector<CardAndMana> shorten;
                            shorten = new Vector<CardAndMana>();
                            shorten = leaf.generatePossibleActionsGeneral(true, null) ;
                            cleanLands(shorten);
                            leaf.buildLeafs(shorten);
                        }
                        else
                        {
                            newFixed = (Vector<CardAndMana>) fixed.clone();

                            // remove all instances of just played X card from CAM
                            // one card cannot be played twice per round!
                            if (isX)
                            {
                                String uid = cam.card.getCard().getUniqueID();
                                for (int r=newFixed.size()-1; r>=0; r--)
                                {
                                    CardAndMana icam = newFixed.elementAt(r);
                                    if (icam.card.getCard().getUniqueID().equals(uid))
                                        newFixed.remove(r);
                                }
                            }
                            newFixed = leaf.onlyEnoughMana(newFixed);
View Full Code Here

        leafs.addElement(leaf);

        boolean changeBreak = false;
        for (int i = 0; ((i < toDos.size()) && (!changeBreak)); i++)
        {
            CardAndMana cam = toDos.elementAt(i);
           
            if (cam.card.getId().equals("21068"))
            {
                if (vMatch.getLibrary(0).isDummy())
                    System.out.println("Buh!");
            }
           
            boolean isX = (cam.card.getCard().getManaCost() == -1);
           
            Vector<CardAndMana> newToDos = (Vector<CardAndMana>) toDos.clone();
            newToDos.remove(i);
           
            AIEnhancedCardHints hints = AIEnhancedCardHints.getHints(cam.card);
            if (cam.card.getCard().getUniqueID().equals("377"))
                System.out.println("Buh");
           
            if (UID == 169)
            {
                if (cam.card.getCard().getUniqueID().equals("353") )
                    System.out.println("Buh");
            }
            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);
                   
//                    if (cam.card.getName().equals("Forked Lightning"))
//                        System.out.println("Bla");
                   
                        if (cam.card.getId().equals("4341"))
                            System.out.println("Buh");
                   
                    Vector<Vector> targets = createTargets(cam, hints, currentSource)// at least one empty target! or null -> must targets not available!
                    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);
                        leaf = new EAIPlanTree(this);
                        leaf.maxDamageInTodo = maxDamageInTodo;

                       
                        if (cam.card.getId().equals("4341"))
                            System.out.println("Buh");
                       
                        boolean successfull = leaf.leafExceuteOneAction(cam, target, player, newToDos);

/* Test Twins in V disabled due to not wokring correctly
* Order of cards DO matter with Var cards!
* The implementented Twin Test does not respect order!
                        if (doTestTwins)
                        {
                            String key =  EnhancedAI.generateCurrentVMatchKeyID(leaf.vMatch, player) + target.toString();
                            if (isX) key += cam.card.getCard().getUniqueID()+cam.cost.getAllManaCount();

                            String test = twinTest.get(key);
                            if (test == null)
                            {
                                test = twinTest.put(key, key);
                            }
                            else
                            {
                                successfull = false;
                            }
                        }
*/
                       
                        if (successfull)
                        {
                            // indicates whether the played out card had
                            // changed the preconditions for evaluating the current
                            // playable cards.

                            // Played out lands DO change things
                            boolean changesThings = cam.card.isLand();

                            int orgHandSize = vMatch.getHand(E.pNumber).size();
                            int newHandSize = leaf.vMatch.getHand(E.pNumber).size();
                            if (cam.type == CardAndMana.CAM_PLAY) orgHandSize--;

                            // if after playing out a card is the handsize different
                            // from befor -> that means that the hand changed and
                            // possibly something else can be played...
                            if (orgHandSize != newHandSize)
                                changesThings = true;

                            int orgLandSize = vMatch.getLand(E.pNumber).size();
                            int newLandSize = leaf.vMatch.getLand(E.pNumber).size();
                            if (cam.card.isLand()) orgLandSize++;
                            if (orgLandSize != newLandSize)
                                changesThings = true;

                            if (!changesThings)
                            {
                                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;
                                changesThings = EAIHelper.hasHandChanges(cam.card, key);
                            }

                            leafs.addElement(leaf);
                            leaf.maxDamageInTodo = adjustMaxDamage(cam, leaf.maxDamageInTodo);
                            if ((changesThings) && (!mDoStacking))
                            {
                                Vector<CardAndMana> shorten;
                                shorten = new Vector<CardAndMana>();
                                shorten = leaf.generatePossibleActionsGeneral(true, null) ;
                                cleanLands(shorten);

                                leaf.buildLeafs(shorten);
                            }
                            else
                            {
                                Vector<CardAndMana> shorten;
                                shorten = leaf.onlyEnoughMana(toDos);
                                // remove all instances of just played X card from CAM
                                // one card cannot be played twice per round!
                                if (isX)
                                {
                                    String uid = cam.card.getCard().getUniqueID();
                                    for (int r=shorten.size()-1; r>=0; r--)
                                    {
                                        CardAndMana icam = shorten.elementAt(r);
                                        if (icam.card.getCard().getUniqueID().equals(uid))
                                            shorten.remove(r);
                                       
                                    }
                                }
View Full Code Here

    {
        Vector<CardAndMana> ret = new Vector<CardAndMana>();
        ManaCollection possibleMana = E.helper.getMaxAvailableMana(vMatch);
        for (int i=0; i< list.size(); i++)
        {
            CardAndMana cam = list.elementAt(i);
           
            if (EAIHelper. hasEnoughMana(cam.cost, possibleMana))
                ret.addElement(cam);
        }
        return ret;
View Full Code Here

TOP

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

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.