Package csa.jportal.ai.enhancedAI.enhancedSim

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


    public void setData(VirtualMatch vMatch, int playerNo)
    {
        this.vMatch = vMatch;
        this.playerNo = playerNo;
        CardSimList allLands = vMatch.getLand(playerNo);
        lands = new CardSimList();
       
        // only lands where we are owner of!
        for (int i=0; i<allLands.size(); i++)
        {
            if (allLands.getCard(i).getOwner()==playerNo)
            {
                lands.addCard(allLands.getCard(i));
            }
        }
       
       
    }
View Full Code Here


    public int computeScore()
    {
        int ret =0;

        CardSimList lands = vMatch.getLand(playerNo);
        CardSimList handLands = vMatch.getHand(playerNo).onlyWithTypes("Land");
       
        int blackLand = lands.getSubListBySubType("Swamp").size();
        int redLand = lands.getSubListBySubType("Mountain").size();
        int whiteLand = lands.getSubListBySubType("Plains").size();
        int blueLand = lands.getSubListBySubType("Island").size();
        int greenLand = lands.getSubListBySubType("Forest").size();
       
        int blackHand = handLands.getSubListBySubType("Swamp").size();
        int redHand = handLands.getSubListBySubType("Mountain").size();
        int whiteHand = handLands.getSubListBySubType("Plains").size();
        int blueHand = handLands.getSubListBySubType("Island").size();
        int greenHand = handLands.getSubListBySubType("Forest").size();

        ret += 2*getLandsScore(blackHand, blackLand)+blackHand*HAND_minor;
        ret += 2*getLandsScore(redHand, redLand)+redHand*HAND_minor;
        ret += 2*getLandsScore(whiteHand, whiteLand)+whiteHand*HAND_minor;
        ret += 2*getLandsScore(blueHand, blueLand)+blueHand*HAND_minor;
        ret += 2*getLandsScore(greenHand, greenLand)+greenHand*HAND_minor;
       
       
        Vector<CardSim> cards = hand.removeTypes("Land").getCards();
        for (int i = 0; i < cards.size(); i++)
        {
            CardSim card = cards.elementAt(i);
            int subScore=getBaseScore(card) + HAND_minor;

            ret += subScore;
        }

        // double cards that can be played
        CardSimList handwoLands = hand.removeTypes("Land");
        CardSimList playable = CardSimList.onlyEnoughManaGeneral(handwoLands, lands);
        for(int i=0; i< playable.size(); i++)
        {
            CardSim card = playable.getCard(i);
            int subScore=getBaseScore(card);
            ret += subScore;
        }

        score = ret;
View Full Code Here

    }

    public int computeScore()
    {
        int ret =0;
        CardSimList lands = vMatch.getLand(playerNo);
        int landsPlayed = lands.size();
        int landsNeeded = landsPlayed - 7;
        int landsOnHand = hand.getSubListByType("Land").size();
        int round = vMatch.getRound();
        ret = landsOnHand;
        if (landsNeeded<0)
        {
            if (round < 8)
            {
                if ((landsPlayed + landsOnHand - 1) >= round) // dann ok
                {
                    ret+=landsOnHand;
                }
            }
        }
        else
        {
            if ((landsOnHand >= 2) || (landsOnHand == hand.size()))
                ret-=landsOnHand/2;
        }
        CardSimList handwoLands = hand.removeTypes("Land");

        ret+=handwoLands.size();

        CardSimList playable = CardSimList.onlyEnoughManaGeneral(handwoLands, lands);
        for(int i=0; i< playable.size(); i++)
        {
            CardSim card = playable.getCard(i);
            ret += card.getManaCost();
        }
        score = ret;
        return ret;
    }
View Full Code Here

    public void setData(VirtualMatch vMatch, int playerNo)
    {
        this.vMatch = vMatch;
        this.playerNo = playerNo;
        CardSimList allLands = vMatch.getLand(playerNo);
        lands = new CardSimList();
       
        // only lands where we are owner of!
        for (int i=0; i<allLands.size(); i++)
        {
            if (allLands.getCard(i).getOwner()==playerNo)
            {
                lands.addCard(allLands.getCard(i));
            }
        }
       
       
    }
View Full Code Here

        int ret =0;
        ret =  lib.size();
        if (lib.size() > 15) ret =  15;
        if (lib.size() <=0) ret = -10000;
   
        CardSimList lands = vMatch.getLand(playerNo);
        CardSimList handLands = vMatch.getHand(playerNo).onlyWithTypes("Land");
       
        blackLand = lands.getSubListBySubType("Swamp").size();
        redLand = lands.getSubListBySubType("Mountain").size();
        whiteLand = lands.getSubListBySubType("Plains").size();
        blueLand = lands.getSubListBySubType("Island").size();
        greenLand = lands.getSubListBySubType("Forest").size();
       
        blackHand = handLands.getSubListBySubType("Swamp").size();
        redHand = handLands.getSubListBySubType("Mountain").size();
        whiteHand = handLands.getSubListBySubType("Plains").size();
        blueHand = handLands.getSubListBySubType("Island").size();
        greenHand = handLands.getSubListBySubType("Forest").size();
       
        black = blackLand + blackHand;
        red = redLand + redHand;
        white = whiteLand + whiteHand;
        blue = blueLand + blueHand;
View Full Code Here

        // and than create all permutations of all actions and return them
        int minTargets = EAIHelper.getMinTargetCount(cam.card, hints, key);
        int maxTargets = EAIHelper.getMaxTargetCount(cam.card, hints, key);

        // now generate possible "targets"
        CardSimList possibleCardTargets = vMatch.getTargetEffectedList(key, cam.card, viewPlayer, hints, null);
        int good = EAIHelper.isGoodEffectCardTarget(cam.card, key);
        if (E.aiPlayer.getEAIConfig().getDontDamageOwn())
        {
             if (good == -1) // bad
             {
                int countOpponent = EAIHelper.countOwnerCards(possibleCardTargets, (viewPlayer+1)%2);
                if (countOpponent >= minTargets)
                {
                    possibleCardTargets = EAIHelper.removeOwnerCards(possibleCardTargets, viewPlayer);
                }
             }
             else if (good == 1) // good
             {
                int playerCards = EAIHelper.countOwnerCards(possibleCardTargets, viewPlayer);
                if (playerCards >= minTargets)
                {
                    possibleCardTargets = EAIHelper.removeOwnerCards(possibleCardTargets, (viewPlayer+1)%2);
                }
             }
        }

        Vector<Integer> possiblePlayerTargets = vMatch.getPlayerTargetEffectedList(key, cam.card, viewPlayer, hints);

        if (possibleCardTargets.hasRealCards())
            possibleCardTargets = possibleCardTargets.removeDummies();
        if (good==1) // good
        {
            for (int i=0; i < possiblePlayerTargets.size(); i++)
            {
                int tt = possiblePlayerTargets.elementAt(i);
                if (tt == ((viewPlayer+1)%2) )
                {
                    possiblePlayerTargets.remove(i);
                    break;
                }
            }
        }
        if (good ==-1) // bad
        {
            for (int i=0; i < possiblePlayerTargets.size(); i++)
            {
                int tt = possiblePlayerTargets.elementAt(i);
                if (tt == viewPlayer )
                {
                    possiblePlayerTargets.remove(i);
                    break;
                }
            }
        }

        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
            {
View Full Code Here

    // blocking that is assumed in the scoring process of the current attack.
    // therefor only ONE blocker strategy is the result
    void generateOpponentBlockerActions(int strategy)
    {
        int opponentNo = (E.pNumber+1)%2;
        CardSimList attacker = vMatch.getAttacker();
        CardSimList blocker = vMatch.getBattlefield(opponentNo).getSubListByType("Creature");



        // remove creatures with activation ability
        blocker = blocker.removeActivateable();
        blocker = vMatch.removeAllreadyBlocking(blocker);
        blocker = blocker.onlyTapstate(false);


        String blKey = generateBlockerKey(attacker, blocker);
        CombatFormation formation = blockerCache.get(blKey);

        if (formation == null)
        {
            CombatSimConfig c = new CombatSimConfig(E.aiPlayer);
            c.attackers = attacker;
            c.attackerLands = vMatch.getLand(E.pNumber);
            c.blockerLands = vMatch.getLand(opponentNo);

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

            int preventDamage = EAIHelper.getDamagePrevention(vMatch, player, vMatch.getBattlefield((player)));
            // TEST new Blocking!
            formation = csim.computeBestBlock(blockerHealth, Weighting.DEFAULT, preventDamage);
           
            if (formation != null)
            {
                blockerCache.put(blKey, formation);
            }
            else
            {
                formation = new CombatFormation();
                blockerCache.put(blKey, formation);
            }
            cacheNotHit++;
        }
        else
        {
            cacheHit++;
        }

        Vector <SingleFight> fights = formation.getFormation();
        int no=0;
        for (int f = 0; f < fights.size(); f++)
        {
            SingleFight singleFight = fights.elementAt(f);
            CardSim matchAttacker = vMatch.getAttacker(singleFight.attacker);
            CardSimList blockers = singleFight.blocker;

            if (blockers.size() > 0)
            {
                EAIAction target = EAIAction.createTargetAction(0, MatchConstants.PHASE_COMBAT_DECLARE_BLOCKERS, matchAttacker , -1);
                for (int b = 0; b < blockers.size(); b++)
                {
                    // 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, opponentNo,false);
                    if (success)
                    {
View Full Code Here

        }
    }

    CardSimList removePlayerCardsWithNotNicePlayoutEffects(CardSimList possibleCardTargets, int player, VirtualMatch vMatch)
    {
        CardSimList ret = new CardSimList();
        for (int i=0; i< possibleCardTargets.size(); i++)
        {
            CardSim card = possibleCardTargets.getCard(i);
            if (card.getOwner() != player)
            {
                ret.addCard(card);
                continue;
            }
            if (EAIHelper.isNicePlayoutCard(card))
            {
                ret.addCard(card);
                continue;
            }
        }
        return ret;
    }
View Full Code Here

        }
        return ret;
    }
    CardSimList removeOpponentCardsWithNicePlayoutEffects(CardSimList possibleCardTargets, int player, VirtualMatch vMatch)
    {
        CardSimList ret = new CardSimList();
        for (int i=0; i< possibleCardTargets.size(); i++)
        {
            CardSim card = possibleCardTargets.getCard(i);
            if (card.getOwner() == player)
            {
                ret.addCard(card);
                continue;
            }
            if (!EAIHelper.isNicePlayoutCard(card))
            {
                ret.addCard(card);
                continue;
            }
        }
        return ret;
    }
View Full Code Here

        return ret;
    }

    CardSimList reduceTargetToSensible(CardSimList possibleCardTargets, int maxSize, int playerNo, VirtualMatch vMatch, CardSim initiatorCard, int isGoodEffect)
    {
        CardSimList ret = new CardSimList();
        CardSimList clone = possibleCardTargets.copyList();

        if (isGoodEffect == 1)
        {
            for (int i=0; i<=maxSize; i++)
            {
                // use scoring like in old AI
                CardSim chosen = EAIHelper.selectGoodCard(clone, playerNo==player, playerNo, vMatch, initiatorCard );

                if (chosen == null) break;
                clone.remove(chosen);
                ret.addCard(chosen);
            }
        }
        else
        {
            while (clone.size() > maxSize)
            {
                // use scoring like in old AI
                CardSim chosen = EAIHelper.selectGoodCard(clone, playerNo==player, playerNo, vMatch, initiatorCard );

                if (chosen == null) break;
                clone.remove(chosen);
            }
            ret = clone;
        }
        return ret;
    }
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.