Package csa.jportal.ai.standardAI.sim

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


        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

                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

    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

                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

                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

        CombatSim cs = new CombatSim(attackerPlayer, defenderOpponent);
        CombatSim.attackerLands = myLands ;
        CombatSim.blockerLands = opponentLands;

        // we think our opponent is VERY smart - > 10 (out of 10)
        CombatFormation as = cs.simDefensiveBlocker(10, 0);
        if (intellligence == 10)
        {
            int opponentLife = Match.match.getLife(Match.match.getOpponent(Match.match.getOwner(myCreatures.getCard(0))));

            if (as != null)
View Full Code Here

    /** Defensive Blocker means, little damage to player as possible, and not much blocker die during attack
     * -> but also not much attackers will die
     */
    public static CombatFormation getDefensiveBlocker(CardList myCreatures, CardList attackerOpponent, CardList myLands, CardList opponentLands, int minorMood, int intellligence)
    {
        CombatFormation result = new CombatFormation();
        if (myCreatures.size()==0) return result;
        if (attackerOpponent.size() == 0)
        {
            //System.out.println("Unused blocker: " +myCreatures);
            return result;
        }

        CardList defenderPlayer = myCreatures.getSubListTapState(false);
        if (intellligence > 7) defenderPlayer = removeWithHint(defenderPlayer, "CAN_BE_TAPPED_INSTEAD_ATTACK");

        CombatSim cs = new CombatSim(attackerOpponent, defenderPlayer);
        CombatSim.attackerLands = opponentLands;
        CombatSim.blockerLands = myLands;

        result = cs.simDefensiveBlocker(intellligence, minorMood);
        if (result==null)
            return new CombatFormation();;
        return result;
    }
View Full Code Here

            return new CombatFormation();;
        return result;
    }
    public static CombatFormation getMediumBlocker(CardList myCreatures, CardList attackerOpponent, CardList myLands, CardList opponentLands, int minorMood, int intellligence)
    {
        CombatFormation result = new CombatFormation();
        if (myCreatures.size()==0) return result;
        if (attackerOpponent.size() == 0)
        {
            //System.out.println("Unused blocker: " +myCreatures);
            return result;
        }
        CardList defenderPlayer = myCreatures.getSubListTapState(false);
        if (intellligence > 5) defenderPlayer = removeWithHint(defenderPlayer, "CAN_BE_TAPPED_INSTEAD_ATTACK");

        CombatSim cs = new CombatSim(attackerOpponent, defenderPlayer);
        CombatSim.attackerLands = opponentLands;
        CombatSim.blockerLands = myLands;

        result = cs.simMediumBlocker(intellligence, minorMood);
        int myLife = Match.match.getLife(Match.match.getOwner(myCreatures.getCard(0)));

        if (result != null)
        if (result.attackerDead == 0)
        {
            if (result.blockerDead > 0)
            if (result.blockerManaDead / result.blockerDead >4 )
            {
                if (myLife - result.getAllAttackerDamage() >0)
                result = null;
            }
        }

        if (result != null)
        if (result.playerDamage > myLife)
        {
            return getDefensiveBlocker(myCreatures, attackerOpponent, myLands, opponentLands, minorMood, intellligence);
        }
        if (result==null)
            return new CombatFormation();;
        return result;
    }
View Full Code Here

     */
     // opponent creatures should only be attackers to make sense!
    public static CombatFormation getAgressiveBlocker(CardList myCreatures, CardList attackerOpponent, CardList myLands, CardList opponentLands, int minorMood, int intellligence)
    {
        Logable D = Configuration.getConfiguration().getDebugEntity();
        CombatFormation result = new CombatFormation();
        if (myCreatures.size()==0) return result;
        if (attackerOpponent.size() == 0)
        {
            //System.out.println("Unused blocker: " +myCreatures);
            return result;
        }
        CardList defenderPlayer = myCreatures.getSubListTapState(false);
        if (intellligence > 3) defenderPlayer = removeWithHint(defenderPlayer, "CAN_BE_TAPPED_INSTEAD_ATTACK");

        CombatSim cs = new CombatSim(attackerOpponent, defenderPlayer);
        CombatSim.attackerLands = opponentLands;
        CombatSim.blockerLands = myLands;

        result = cs.simAgressiveBlocker(intellligence, minorMood);
        int myLife = Match.match.getLife(Match.match.getOwner(myCreatures.getCard(0)));

        if (result != null)
        if (result.attackerDead == 0)
        {
            D.addLog("No attacker dead!",3);
            if (result.blockerDead > 0)
            {
                D.addLog("But blocker dead!",3);
                if (result.blockerManaDead / result.blockerDead >4 )
                {
                    D.addLog("Attacker will damage player for: "+result.getAllAttackerDamage(),3);
                    D.addLog("Attacker will damage player for2: "+result.playerDamage,3);
                    D.addLog("player Life: "+myLife,3);
                    if (myLife - result.getAllAttackerDamage() >0)
                    {
                        D.addLog("Player damage accepted",3);
                        result = null;
                    }
                }
            }
        }

        if (result != null)
        if (result.playerDamage > myLife)
        {
            return getMediumBlocker(myCreatures, attackerOpponent, myLands, opponentLands, minorMood, intellligence);
        }

        if (result==null)
            return new CombatFormation();
        return result;
   }
View Full Code Here

TOP

Related Classes of csa.jportal.ai.standardAI.sim.CombatFormation

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.