Examples of CombatFormation


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

        c.attackers = allAttackers;
        c.attackerLands = vMatch.getLand(attacker);
        c.blockerLands = vMatch.getLand((attacker+1)%2);
        int blockerHealth = vMatch.getLife((attacker+1)%2);
        CombatSimNew csim = new CombatSimNew(allAttackers, allBlockers, c, false);
        CombatFormation formation = csim.computeBestBlock(blockerHealth, Weighting.DEFAULT,0);

        CardSimList blockersUsed = new CardSimList();
       
        for (int i=0; i< formation.singleFights.size(); i++)
        {
View Full Code Here

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

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

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

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

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

       
        blocker = blocker.removeTapped();
        blocker = removeBlocking(blocker);

        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(opponentNo);
            c.blockerLands = vMatch.getLand(playerNo);
            int blockerHealth = vMatch.getLife(playerNo);
           
            CombatSimNew csim = new CombatSimNew(attacker, blocker, c, false);

            // TEST new Blocking!
           
           
            int preventDamage = EAIHelper.getDamagePrevention(vMatch, (player+1)%2, vMatch.getBattlefield((player+1)%2));
           
           
            if (strategy == BLOCK_PLAYER_LEAST_CREATURE_DEAD)
                formation = csim.computeBestBlock(blockerHealth, Weighting.DEFAULT, preventDamage);
            else
                formation = csim.computeBestBlockHealth(blockerHealth, Weighting.DEFAULT, preventDamage);
            if (formation != null)
            {
                blockerCache.put(blKey, formation);
            }
            else
            {
                formation = new CombatFormation();
                blockerCache.put(blKey, formation);
            }
            cacheNotHit++;
        }
        else
View Full Code Here

Examples of csa.jportal.ai.standardAI.sim.CombatFormation

            aiPlayer.setObjectData(dblockerKey+"BLOCKER_LIST", myCreatures);
            blockerList = myCreatures;
        }

        int state = aiPlayer.getIntData(dblockerKey+"STATE");
        CombatFormation blockerFormation;
        if (state == 0)
        {
            int loop = aiPlayer.getIntData(dblockerKey+"TLOOP");

            E.D.addLog("EAI: state 0 enter, tapper size = "+ tapperList.size()+", loop = "+ loop,debugLevel);
            while ((loop < tapperList.size()) && (state == 0))
            {
              loop = aiPlayer.getIntData(dblockerKey+"TLOOP");
              boolean tappingDone = false;
              if (tapperList.size() != 0)
              {
                  E.D.addLog("EAI: tapper found enter: " +tapperList.size(),debugLevel);
                  E.D.addLog("EAI: tapper loop: " + loop,debugLevel);


                  Card card = tapperList.getCard(loop);
                  E.D.addLog("EAI: current tapper: " + card,debugLevel);

                  boolean sense = AIHelper.tapHintMakesSenseNow(E.player, E.match, card);

                  if ((!card.isTapped()) && (sense))
                  {
                      E.D.addLog("EAI: tapping in blocking possible: "+card,debugLevel);
                      boolean doTap=true;

                      if (AIHelper.hasHint(card, "OPPONENT_ATTACKER_NEED"))
                      {
                          doTap = E.match.getAttackerList().size()>0;
                      }
                      if (doTap)
                      {
                          E.D.addLog("EAI: tapping!: "+card,debugLevel);
                          E.match.playAbility(E.player, card);
                          tappingDone = true;
                      }
                      else
                      {
                          E.D.addLog("EAI: not tapping!: "+card,debugLevel);
                      }
                  }
              }
              loop++;
              if (loop >= tapperList.size())
              {
                  loop = 0;
                  aiPlayer.setIntData(dblockerKey+"TLOOP", 0);
                  state++;
                  aiPlayer.setIntData(dblockerKey+"STATE", state);
                  if ((tapperList.size() > 0) && (tappingDone))
                  {
                      E.D.addLog("EAI: Todo one tap - than come back to block " + loop,debugLevel);
                      return false;
                  }
              }
              if (loop != 0)
              {
                  E.D.addLog("EAI: Todo one tap - than come back to tap more " + loop,debugLevel);
                  aiPlayer.setIntData(dblockerKey+"TLOOP", loop);
                  if (tappingDone)
                  {
                        E.D.addLog("EAI: Tapping was done! " ,debugLevel);
                        return false;
                  }
              }

            }

            E.D.addLog("EAI: state 0 ends (state = "+state+")",debugLevel);
            state = 1;
            aiPlayer.setIntData(dblockerKey+"STATE", state);
        }

        // init declaration
        if (state == 1)
        {
            state++;
            aiPlayer.setIntData(dblockerKey+"STATE", state);

                int mood  = aiPlayer.mStrategie.getMood();
                int intelligence  = aiPlayer.mStrategie.getIntelligence();
                int majorMood = mood/3;
                if (majorMood>2) majorMood = 2;
                int minorMood = mood - (majorMood*3);

                if (majorMood==0)
                {
                    // defense
                    blockerFormation = AIHelper.getDefensiveBlocker(
                        blockerList,
                        E.match.getAttackerList(),
                        E.match.getLand(E.player),
                        E.match.getLand(E.opponent) , minorMood, intelligence);
                }
                else if (majorMood==1)
                {
                    // equal
                    blockerFormation = AIHelper.getMediumBlocker(
                        blockerList,
                        E.match.getAttackerList(),
                        E.match.getLand(E.player),
                        E.match.getLand(E.opponent) , minorMood, intelligence);
                }
                else // 2
                {
                    // offense
                    blockerFormation = AIHelper.getAgressiveBlocker(
                        blockerList,
                        E.match.getAttackerList(),
                        E.match.getLand(E.player),
                        E.match.getLand(E.opponent) , minorMood, intelligence);
                }

            aiPlayer.setObjectData(dblockerKey+"BlockerFormation", blockerFormation);
            E.D.addLog("EAI: Block formation:  "+blockerFormation ,debugLevel);
        }

        // blocker declaration
        if (state == 2)
        {
            blockerFormation = (CombatFormation) aiPlayer.getObjectData(dblockerKey+"BlockerFormation");
            int loopAttacker = aiPlayer.getIntData(dblockerKey+"ATTACKER_LOOP");
            int loopBlocker = aiPlayer.getIntData(dblockerKey+"BLOCKER_LOOP");

            while (loopAttacker < blockerFormation.getFormation().size())
            {
                E.D.addLog("EAI: entering loop, A counter = "+loopAttacker+" from "+(blockerFormation.getFormation().size()+1) ,debugLevel);
                E.D.addLog("EAI: B counter = "+loopBlocker+" from "+(blockerFormation.getFormation().elementAt(loopAttacker).blocker.size()+1) ,debugLevel);

                SingleFight sFight = blockerFormation.getFormation().elementAt(loopAttacker);
                E.D.addLog("EAI: SingleFight: "+sFight ,debugLevel);
                CardList blockers = sFight.blocker;
                Card attacker = sFight.attacker;

                while (loopBlocker < blockers.size())
View Full Code Here

Examples of csa.jportal.ai.standardAI.sim.CombatFormation

        String landKey="TMP_KEY_"+E.match.getRound()+"landPlayed";

        E.D.addLog("EAI: Computer entered main script.",debugLevel);

        CombatFormation sorceryAction = (CombatFormation) E.aiPlayer.getObjectData(baseKey+"SORCERY_COMBO");
        E.D.addLog("EAI: Enter Main: sorceryAction: "+sorceryAction,debugLevel);
        E.aiPlayer.removeObjectData(baseKey+"SORCERY_TARGET");
        if (sorceryAction != null)
        {
            E.D.addLog("EAI: Continue sorcery combo",debugLevel);
View Full Code Here

Examples of csa.jportal.ai.standardAI.sim.CombatFormation

                candidates.addCard(cc);
            }
        }
       
        SorcerySim ss = new SorcerySim(oCreatures, candidates, land.copyList(),  ownCreaturs);
        CombatFormation cf = ss.simSorceryKillCreature(intelligence);
        if (cf == null) return null;

        //     Vector <SingleFight> bla =  cf.getFormation()
        if (cf.attackerDead == 0) return null;
         if (cf.ownDead >cf.attackerDead) return null;
View Full Code Here

Examples of csa.jportal.ai.standardAI.sim.CombatFormation

    public static boolean hasEffectOnAttacker(Card instant, CardList attackers, CardList lands, int intelligence)
    {
        CardList tmp = new CardList();
        tmp.addCard(instant);
        CombatFormation r = simSorceries(tmp, lands, attackers, new CardList(), intelligence);
        return r != null;
    }
View Full Code Here

Examples of csa.jportal.ai.standardAI.sim.CombatFormation

                CardList defenderOpponent = opponentCreatures.copyList();

                CombatSim cs = new CombatSim(attackerPlayer, defenderOpponent);
                CombatSim.attackerLands = myLands ;
                CombatSim.blockerLands = opponentLands;
                CombatFormation as = cs.simDefensiveBlocker(10, 0);

                int opponentLife = Match.match.getLife(Match.match.getOpponent(Match.match.getOwner(myCreatures.getCard(0))));
                if (as != null)
                if (as.playerDamage > opponentLife)
                {
                    // GO for it, we kill him!
                    return myCreatures;
                }
            }
        }

        if (opponentCreatures.size() == 0)
        {
            CardList attackerPlayer = myCreatures.copyList();
            if (minorMood==0) if (myCreatures.size()<=2) return new CardList();
            if (minorMood==1) if (myCreatures.size()<=1) return new CardList();
            if (minorMood==0)
            {
                attackerPlayer = attackerPlayer.sortListByPower();
                attackerPlayer.removeCard(attackerPlayer.getCard(0));
                attackerPlayer.removeCard(attackerPlayer.getCard(0));
            }
            else if (minorMood==1)
            {
                attackerPlayer = attackerPlayer.sortListByPower();
                attackerPlayer.removeCard(attackerPlayer.getCard(0));
            }
            return myCreatures;
        }


        // first simulate an attack of the opponent to myself
        // the cards from myself that are NOT needed in defensive
        // action will be "left" over for attack by myself
        CardList attackerPlayer = myCreatures.copyList();
        CardList attackerOpponent = opponentCreatures.copyList();
        attackerOpponent = attackerOpponent.removeWithAbility("Defender");
        if (attackerOpponent.size() !=0)
        {
            CardList defenderPlayer = myCreatures.copyList();
            CombatSim cs = new CombatSim(attackerOpponent, defenderPlayer);
            // set globals as lands
            // needed to get Swampwalk etc right in simulation
            CombatSim.attackerLands = opponentLands;
            CombatSim.blockerLands = myLands;

            // as defensive player we think the worst of our opponent
            // he will certainly be aggressive :-)
            CombatFormation as = cs.simAgressiveBlocker(intellligence, 2);
            if (as==null)
            {
                D.addLog("as1 null",2);
//                return new CardList();
                attackerPlayer = new CardList();
            }
            else
                attackerPlayer = as.unUsedBlockerList;
            attackerPlayer = adjustVigilance(attackerPlayer, myCreatures);
        }
        attackerPlayer = attackerPlayer.removeWithAbility("Defender");
        attackerPlayer = attackerPlayer.getSubListBooleanState(Card.CARD_TAPPED, false);
        attackerPlayer = attackerPlayer.getSubListBooleanState(Card.CARD_SICKNESS, false);

        // System.out.println("Block´Formation: "+as);
        // all non blockers can attack!

        // idea - with attackers block opponent creatures,
        // the ones not needed for killing of blockers - can attack
        //System.out.println("Unused blocker: " + as.unUsedBlockerList);

        if (minorMood==0) if (attackerPlayer.size()<=2) return new CardList();
        if (minorMood==1) if (attackerPlayer.size()<=1) return new CardList();

        if (minorMood==0)
        {
            attackerPlayer = attackerPlayer.sortListByPower();
            attackerPlayer.removeCard(attackerPlayer.getCard(0));
            attackerPlayer.removeCard(attackerPlayer.getCard(0));
        }
        else if (minorMood==1)
        {
            attackerPlayer = attackerPlayer.sortListByPower();
            attackerPlayer.removeCard(attackerPlayer.getCard(0));
        }

        CardList defenderOpponent = opponentCreatures.copyList();
        CombatSim cs = new CombatSim(attackerPlayer, defenderOpponent);
        CombatSim.attackerLands = myLands ;
        CombatSim.blockerLands = opponentLands;
        CombatFormation as = cs.simDefensiveBlocker(10, 0);
        if (as==null)
        {
            D.addLog("as2 null",2);
            //System.out.println("as2 null");
            return attackerPlayer;
View Full Code Here

Examples of csa.jportal.ai.standardAI.sim.CombatFormation

                CardList defenderOpponent = opponentCreatures.copyList();

                CombatSim cs = new CombatSim(attackerPlayer, defenderOpponent);
                CombatSim.attackerLands = myLands ;
                CombatSim.blockerLands = opponentLands;
                CombatFormation as = cs.simDefensiveBlocker(10, 0);

                int opponentLife = Match.match.getLife(Match.match.getOpponent(Match.match.getOwner(myCreatures.getCard(0))));
                if (as != null)
                if (as.playerDamage > opponentLife)
                {
                    // GO for it, we kill him!
                    return myCreatures;
                }
            }
        }

        // first simulate an attack of the opponent to myself
        // the cards from myself that are NOT needed in defensive
        // action will be "left" over for attack by myself
        CardList attackerOpponent = opponentCreatures.copyList();
        attackerOpponent = attackerOpponent.removeWithAbility("Defender");
        CardList defenderPlayer = myCreatures.copyList();
        CardList attackerPlayer = myCreatures.copyList();
        if (attackerOpponent.size() !=0)
        {
            CombatSim cs = new CombatSim(attackerOpponent, defenderPlayer);
            // set globals as lands
            // needed to get Swampwalk etc right in simulation
            CombatSim.attackerLands = opponentLands;
            CombatSim.blockerLands = myLands;

            // as defensive player we think the worst of our opponent
            // he will certainly be aggressive :-)
            CombatFormation as = cs.simJustBlock(intellligence, 2);
            if (as==null)
            {
                D.addLog("as1 null",2);
//                return new CardList();
                attackerPlayer = new CardList();
            }
            else
                attackerPlayer = as.unUsedBlockerList;
            attackerPlayer = adjustVigilance(attackerPlayer, myCreatures);
        }
        attackerPlayer = attackerPlayer.removeWithAbility("Defender");
        attackerPlayer = attackerPlayer.getSubListBooleanState(Card.CARD_TAPPED, false);
        attackerPlayer = attackerPlayer.getSubListBooleanState(Card.CARD_SICKNESS, false);

        // idea - with attackers block opponent creatures,
        // the ones not needed for killing of blockers - can attack
        //System.out.println("Unused blocker: " + as.unUsedBlockerList);

        CardList defenderOpponent = opponentCreatures.copyList();
        CombatSim cs = new CombatSim(attackerPlayer, defenderOpponent);
        CombatSim.attackerLands = myLands ;
        CombatSim.blockerLands = opponentLands;
        CombatFormation as = cs.simDefensiveBlocker(10, 0);
        if (as==null)
        {
            D.addLog("as2 null",2);
            return attackerPlayer;
        }
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.