Exemplo n.º 1
0
 public void printcards()
 {
     help.logg("Own Handcards: ");
     foreach (Handmanager.Handcard c in this.handCards)
     {
         help.logg("pos " + c.position + " " + c.card.name + " " + c.manacost + " entity " + c.entity);
     }
 }
Exemplo n.º 2
0
 public void printcards()
 {
     help.logg("Own Handcards: ");
     foreach (Handmanager.Handcard hc in this.handCards)
     {
         help.logg("pos " + hc.position + " " + hc.card.name + " " + hc.manacost + " entity " + hc.entity + " " + hc.card.cardIDenum + " " + hc.addattack + " " + hc.addHp + " " + hc.elemPoweredUp);
     }
     help.logg("Enemy cards: " + this.enemyAnzCards);
 }
Exemplo n.º 3
0
        public void printcards()
        {
            help.logg("Own Handcards: ");
            foreach (Handmanager.Handcard c in this.handCards)
            {
                help.logg("pos " + c.position + " " + c.card.name + " " + c.manacost + " entity " + c.entity + " " + c.card.cardIDenum);
            }
            help.logg("Enemy cards: " + this.enemyAnzCards);
            if (Ai.Instance.playaround)
            {
                if (Hrtprozis.Instance.enemyHeroname == HeroEnum.mage)
                {
                    help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_032) + " " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_028));
                }

                if (Hrtprozis.Instance.enemyHeroname == HeroEnum.warrior)
                {
                    help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_400));
                }

                if (Hrtprozis.Instance.enemyHeroname == HeroEnum.hunter)
                {
                    help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_538));
                }

                if (Hrtprozis.Instance.enemyHeroname == HeroEnum.priest)
                {
                    help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS1_112));
                }

                if (Hrtprozis.Instance.enemyHeroname == HeroEnum.shaman)
                {
                    help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_259));
                }

                if (Hrtprozis.Instance.enemyHeroname == HeroEnum.pala)
                {
                    help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_093));
                }

                if (Hrtprozis.Instance.enemyHeroname == HeroEnum.druid)
                {
                    help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_012));
                }
            }
        }
Exemplo n.º 4
0
        public void printHero()
        {
            help.logg("player:");
            help.logg(this.currentMana + " " + this.ownMaxMana + " " + this.numMinionsPlayedThisTurn + " " + this.cardsPlayedThisTurn + " " + this.ueberladung);

            help.logg("ownhero:");
            help.logg(this.heroname + " " + heroHp + " " + heroDefence);
            help.logg("ready: " + this.ownheroisread + " alreadyattacked: " + this.ownheroAlreadyAttacked + " attack: " + heroAtk + " weapon attk: " + heroWeaponAttack);
            help.logg("enemyhero:");
            help.logg(this.enemyHeroname + " " + enemyHp + " " + heroAtk);
        }
Exemplo n.º 5
0
        public void printHero()
        {
            help.logg("player:");
            help.logg(this.numMinionsPlayedThisTurn + " " + this.cardsPlayedThisTurn + " " + this.ueberladung + " " + this.lockedMana + " " + this.ownPlayerController);

            help.logg("ownhero:");
            help.logg((this.heroname == HeroEnum.None ? this.heronameingame : this.heroname.ToString()) + " " + this.ownHero.Hp + " " + this.ownHero.maxHp + " " + this.ownHero.armor + " " + this.ownHero.immuneWhileAttacking + " " + this.ownHero.immune + " " + this.ownHero.entitiyID + " " + this.ownHero.Ready + " " + this.ownHero.numAttacksThisTurn + " " + this.ownHero.frozen + " " + this.ownHero.Angr + " " + this.ownHero.tempAttack);
            help.logg("weapon: " + heroWeaponAttack + " " + heroWeaponDurability + " " + this.ownWeaponCard.name + " " + this.ownWeaponCard.cardIDenum);
            help.logg("ability: " + this.ownAbilityisReady + " " + this.heroAbility.cardIDenum);
            string secs = "";

            foreach (CardDB.cardIDEnum sec in this.ownSecretList)
            {
                secs += sec + " ";
            }
            help.logg("osecrets: " + secs);
            help.logg("cthunbonus: " + this.anzOgOwnCThunAngrBonus + " " + this.anzOgOwnCThunHpBonus + " " + this.anzOgOwnCThunTaunt);
            help.logg("jadegolems: " + this.anzOwnJadeGolem + " " + this.anzEnemyJadeGolem);
            help.logg("enemyhero:");
            help.logg((this.enemyHeroname == HeroEnum.None ? this.enemyHeronameingame : this.enemyHeroname.ToString()) + " " + this.enemyHero.Hp + " " + this.enemyHero.maxHp + " " + this.enemyHero.armor + " " + this.enemyHero.frozen + " " + this.enemyHero.immune + " " + this.enemyHero.entitiyID);
            help.logg("weapon: " + this.enemyWeaponAttack + " " + this.enemyWeaponDurability + " " + this.enemyWeaponCard.name + " " + this.enemyWeaponCard.cardIDenum);
            help.logg("ability: " + "true" + " " + this.enemyAbility.cardIDenum);
            help.logg("fatigue: " + this.ownDeckSize + " " + this.ownHeroFatigue + " " + this.enemyDeckSize + " " + this.enemyHeroFatigue);
        }
Exemplo n.º 6
0
        private void doallmoves(bool test, bool isLethalCheck)
        {
            //set maxwide to the value for the first-turn-sim.
            foreach (EnemyTurnSimulator ets in enemyTurnSim)
            {
                ets.setMaxwide(true);
            }
            foreach (EnemyTurnSimulator ets in enemySecondTurnSim)
            {
                ets.setMaxwide(true);
            }

            //if (isLethalCheck) this.posmoves[0].enemySecretList.Clear();
            this.posmoves[0].isLethalCheck = isLethalCheck;
            this.mainTurnSimulator.doallmoves(this.posmoves[0]);

            bestplay = this.mainTurnSimulator.bestboard;
            float bestval = this.mainTurnSimulator.bestmoveValue;

            help.loggonoff(true);
            help.logg("-------------------------------------");
            if (bestplay.ruleWeight != 0)
            {
                help.logg("ruleWeight " + bestplay.ruleWeight * -1);
            }
            if (settings.printRules > 0)
            {
                String[] rulesStr = bestplay.rulesUsed.Split('@');
                foreach (string rs in rulesStr)
                {
                    if (rs == "")
                    {
                        continue;
                    }
                    help.logg("rule: " + rs);
                }
            }
            help.logg("value of best board " + bestval);

            this.bestActions.Clear();
            this.bestmove = null;
            ActionNormalizer an = new ActionNormalizer();

            //an.checkLostActions(bestplay, isLethalCheck);
            if (settings.adjustActions > 0)
            {
                an.adjustActions(bestplay, isLethalCheck);
            }
            foreach (Action a in bestplay.playactions)
            {
                this.bestActions.Add(new Action(a));
                a.print();
            }

            if (this.bestActions.Count >= 1)
            {
                this.bestmove = this.bestActions[0];
                this.bestActions.RemoveAt(0);
            }
            this.bestmoveValue = bestval;

            if (bestmove != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc!
            {
                this.nextMoveGuess = new Playfield();

                this.nextMoveGuess.doAction(bestmove);
            }
            else
            {
                nextMoveGuess.mana = -100;
            }

            if (isLethalCheck)
            {
                this.lethalMissing = bestplay.enemyHero.armor + bestplay.enemyHero.Hp;//RR
                help.logg("missing dmg to lethal " + this.lethalMissing);
            }
        }
Exemplo n.º 7
0
        public void print(bool tobuffer = false)
        {
            Helpfunctions help     = Helpfunctions.Instance;
            string        discover = "";

            if (this.tracking >= 1)
            {
                discover = " discover " + tracking;
            }
            if (tobuffer)
            {
                if (this.actionType == actionEnum.playcard)
                {
                    string playaction = "play ";

                    playaction += "id " + this.card.entity;
                    if (this.target != null)
                    {
                        playaction += " target " + this.target.entityID;
                    }

                    if (this.place >= 0)
                    {
                        playaction += " pos " + this.place;
                    }

                    if (this.druidchoice >= 1)
                    {
                        playaction += " choice " + this.druidchoice;
                    }

                    help.writeToBuffer(playaction + discover);
                }
                if (this.actionType == actionEnum.attackWithMinion && this.target != null)
                {
                    help.writeToBuffer("attack " + this.own.entityID + " enemy " + this.target.entityID + discover);
                }
                if (this.actionType == actionEnum.attackWithHero && this.target != null)
                {
                    help.writeToBuffer("heroattack " + this.target.entityID + discover);
                }
                if (this.actionType == actionEnum.useHeroPower)
                {
                    if (this.target != null)
                    {
                        help.writeToBuffer("useability on target " + this.target.entityID + discover);
                    }
                    else
                    {
                        help.writeToBuffer("useability" + discover);
                    }
                }
                return;
            }

            //todo sepefeets - consider adding names into actions from the start instead of mapping them here
            string    cardname   = "";
            string    targetname = "";
            Playfield tmpPf      = new Playfield();

            if (this.target != null)
            {
                foreach (Minion m in tmpPf.enemyMinions)
                {
                    if (m.entityID == this.target.entityID)
                    {
                        targetname = "" + m.name;
                    }
                }
                if (tmpPf.enemyHero.entityID == this.target.entityID)
                {
                    targetname = "" + tmpPf.enemyHeroName;
                }
            }
            foreach (Minion m in tmpPf.ownMinions)
            {
                if (this.target != null && m.entityID == this.target.entityID)
                {
                    targetname = "" + m.name;
                }
                if (this.card != null && m.entityID == this.card.entity)
                {
                    cardname = "" + m.name;
                }
                if (this.own != null && m.entityID == this.own.entityID)
                {
                    cardname = "" + m.name;
                }
            }
            if (this.target != null && tmpPf.ownHero.entityID == this.target.entityID)
            {
                targetname = "" + tmpPf.ownHeroName;
            }
            foreach (Handmanager.Handcard h in tmpPf.owncards)
            {
                if (this.card != null && h.entity == this.card.entity)
                {
                    cardname = "" + h.card.name;
                }
            }


            if (this.actionType == actionEnum.playcard && this.card != null)
            {
                string playaction = "play ";
                playaction += cardname;
                playaction += " id " + this.card.entity;

                if (this.target != null)
                {
                    playaction += ", target " + targetname + " id " + this.target.entityID;
                }

                if (this.place >= 0)
                {
                    playaction += ", pos " + this.place;
                }

                if (this.druidchoice >= 1)
                {
                    playaction += ", choice " + this.druidchoice;
                }

                help.logg(playaction + discover);
            }
            if (this.actionType == actionEnum.attackWithMinion && this.target != null && this.own != null)
            {
                help.logg("attacker: " + cardname + " id " + this.own.entityID + ", enemy: " + targetname + " id " + this.target.entityID + discover);
            }
            if (this.actionType == actionEnum.attackWithHero && this.target != null)
            {
                help.logg("attack with hero, enemy: " + targetname + " id " + this.target.entityID + discover);
            }
            if (this.actionType == actionEnum.useHeroPower)
            {
                help.logg("useability " + discover);
                if (this.target != null)
                {
                    help.logg("on " + (target.own ? "own " : "enemy ") + targetname + " id " + this.target.entityID + discover);
                }
            }
        }
Exemplo n.º 8
0
        private void doallmoves(bool test, bool isLethalCheck)
        {
            //set maxwide to the value for the first-turn-sim.
            foreach (EnemyTurnSimulator ets in enemyTurnSim)
            {
                ets.setMaxwideFirstStep(true);
            }

            foreach (EnemyTurnSimulator ets in enemySecondTurnSim)
            {
                ets.setMaxwideFirstStep(false);
            }

            if (isLethalCheck)
            {
                this.posmoves[0].enemySecretList.Clear();
            }
            this.mainTurnSimulator.doallmoves(this.posmoves[0], isLethalCheck);

            bestplay = this.mainTurnSimulator.bestboard;
            float bestval = this.mainTurnSimulator.bestmoveValue;

            help.loggonoff(true);
            help.logg("-------------------------------------");
            help.logg("value of best board " + bestval);

            if (isLethalCheck)
            {
                this.lethalMissing = bestplay.enemyHero.armor + bestplay.enemyHero.Hp;//RR
                help.logg("missing dmg to lethal " + this.lethalMissing);
            }
            else
            {
                this.lethalMissing = 130;
            }

            //set best tracking
            this.bestTracking       = 0;
            this.bestTrackingStatus = 0;
            if (Handmanager.Instance.getNumberChoices() >= 1)
            {
                selectBestTracking();
            }

            //set best actions
            this.bestActions.Clear();
            this.bestmove = null;
            foreach (Action a in bestplay.playactions)
            {
                this.bestActions.Add(new Action(a));
                a.print();
            }
            //todo sepefeets - enable after implementing anzEnemyTaunt or finding alternative            //if (isLethalCheck) reorderingActions();

            if (this.bestActions.Count >= 1)
            {
                this.bestmove = this.bestActions[0];
                this.bestActions.RemoveAt(0);
            }
            this.bestmoveValue = bestval;

            if (bestmove != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc!
            {
                this.nextMoveGuess = new Playfield();

                //TODO: add card if bestTracking was calculated!

                this.nextMoveGuess.doAction(bestmove);
            }
            else
            {
                nextMoveGuess.mana = -100;
            }
        }
Exemplo n.º 9
0
        public void printHero()
        {
            help.logg("player:");
            help.logg(this.numMinionsPlayedThisTurn + " " + this.cardsPlayedThisTurn + " " + this.ueberladung + " " + this.ownPlayerController);

            help.logg("ownhero:");
            help.logg(this.heroname + " " + heroHp + " " + heroDefence + " immn " + this.heroImmuneToDamageWhileAttacking);
            help.logg("ready: " + this.ownheroisread + " alreadyattacked: " + this.ownHeroNumAttacksThisTurn + " frzn: " + this.herofrozen + " attack: " + heroAtk + " " + heroWeaponAttack + " " + heroWeaponDurability + " " + ownHeroWeapon);
            help.logg("ability: " + this.ownAbilityisReady + " " + this.heroAbility.CardID);
            string secs = "";

            foreach (string sec in this.ownSecretList)
            {
                secs += sec + " ";
            }
            help.logg("osecrets: " + secs);
            help.logg("enemyhero:");
            help.logg(this.enemyHeroname + " " + enemyHp + " " + enemyDefence + " " + this.enemyfrozen);
            help.logg(this.enemyWeaponAttack + " " + this.enemyWeaponDurability + " " + this.enemyHeroWeapon);
            help.logg("fatigue: " + this.ownDeckSize + " " + this.ownHeroFatigue + " " + this.enemyDeckSize + " " + this.enemyHeroFatigue);
        }
Exemplo n.º 10
0
        public void printHero()
        {
            help.logg("player:");
            help.logg(this.numMinionsPlayedThisTurn + " " + this.cardsPlayedThisTurn + " " + this.ueberladung + " " + this.lockedMana + " " + this.ownPlayerController);

            help.logg("ownhero:");
            help.logg((this.heroname == HeroEnum.None ? this.heronameingame : this.heroname.ToString()) + " " + this.ownHero.Hp + " " + this.ownHero.maxHp + " " + this.ownHero.armor + " " + this.ownHero.immuneWhileAttacking + " " + this.ownHero.immune + " " + this.ownHero.entitiyID + " " + this.ownHero.Ready + " " + this.ownHero.numAttacksThisTurn + " " + this.ownHero.frozen + " " + this.ownHero.Angr + " " + this.ownHero.tempAttack + " " + this.enemyHero.stealth);
            help.logg("weapon: " + ownWeapon.Angr + " " + ownWeapon.Durability + " " + this.ownWeapon.name + " " + this.ownWeapon.card.cardIDenum + " " + (this.ownWeapon.poisonous ? 1 : 0) + " " + (this.ownWeapon.lifesteal ? 1 : 0));
            help.logg("ability: " + this.ownAbilityisReady + " " + this.heroAbility.cardIDenum);
            string secs = "";

            foreach (CardDB.cardIDEnum sec in this.ownSecretList)
            {
                secs += sec + " ";
            }
            help.logg("osecrets: " + secs);
            help.logg("cthunbonus: " + this.anzOgOwnCThunAngrBonus + " " + this.anzOgOwnCThunHpBonus + " " + this.anzOgOwnCThunTaunt);
            help.logg("jadegolems: " + this.anzOwnJadeGolem + " " + this.anzEnemyJadeGolem);
            help.logg("elementals: " + this.anzOwnElementalsThisTurn + " " + this.anzOwnElementalsLastTurn + " " + this.ownElementalsHaveLifesteal);
            help.logg(Questmanager.Instance.getQuestsString());
            help.logg("advanced: " + this.ownCrystalCore + " " + (this.ownMinionsInDeckCost0 ? 1: 0));
            help.logg("enemyhero:");
            help.logg((this.enemyHeroname == HeroEnum.None ? this.enemyHeronameingame : this.enemyHeroname.ToString()) + " " + this.enemyHero.Hp + " " + this.enemyHero.maxHp + " " + this.enemyHero.armor + " " + this.enemyHero.frozen + " " + this.enemyHero.immune + " " + this.enemyHero.entitiyID + " " + this.enemyHero.stealth);
            help.logg("weapon: " + this.enemyWeapon.Angr + " " + this.enemyWeapon.Durability + " " + this.enemyWeapon.name + " " + this.enemyWeapon.card.cardIDenum + " " + (this.enemyWeapon.poisonous ? 1 : 0) + " " + (this.enemyWeapon.lifesteal ? 1 : 0));
            help.logg("ability: " + "True" + " " + this.enemyAbility.cardIDenum);
            help.logg("fatigue: " + this.ownDeckSize + " " + this.ownHeroFatigue + " " + this.enemyDeckSize + " " + this.enemyHeroFatigue);
        }
Exemplo n.º 11
0
        private void doallmoves(bool test, bool isLethalCheck)
        {
            //set maxwide to the value for the first-turn-sim.
            foreach (EnemyTurnSimulator ets in enemyTurnSim)
            {
                ets.setMaxwideFirstStep(true);
            }

            foreach (EnemyTurnSimulator ets in enemySecondTurnSim)
            {
                ets.setMaxwideFirstStep(false);
            }

            if (isLethalCheck)
            {
                this.posmoves[0].enemySecretList.Clear();
            }
            this.mainTurnSimulator.doallmoves(this.posmoves[0], isLethalCheck);

            Playfield bestplay = this.mainTurnSimulator.bestboard;
            float     bestval  = this.mainTurnSimulator.bestmoveValue;

            help.loggonoff(true);
            help.logg("-------------------------------------");
            help.logg("value of best board " + bestval);

            if (isLethalCheck)
            {
                this.lethalMissing = bestplay.enemyHero.armor + bestplay.enemyHero.Hp;//RR
                help.logg("missing dmg to lethal " + this.lethalMissing);
            }
            else
            {
                this.lethalMissing = 130;
            }

            this.bestActions.Clear();
            this.bestmove = null;
            foreach (Action a in bestplay.playactions)
            {
                this.bestActions.Add(new Action(a));
                a.print();
            }
            //this.bestActions.Add(new Action(actionEnum.endturn, null, null, 0, null, 0, 0));

            if (this.bestActions.Count >= 1)
            {
                this.bestmove = this.bestActions[0];
                this.bestActions.RemoveAt(0);
            }
            this.bestmoveValue = bestval;

            if (bestmove != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc!
            {
                this.nextMoveGuess = new Playfield();

                this.nextMoveGuess.doAction(bestmove);
            }
            else
            {
                nextMoveGuess.mana = -100;
            }
        }
Exemplo n.º 12
0
        private void doallmoves(bool test, bool isLethalCheck)
        {
            this.mainTurnSimulator.doallmoves(this.posmoves[0], isLethalCheck);

            Playfield bestplay = this.mainTurnSimulator.bestboard;
            int       bestval  = this.mainTurnSimulator.bestmoveValue;

            help.loggonoff(true);
            help.logg("-------------------------------------");
            help.logg("bestPlayvalue " + bestval);

            bestplay.printActions();
            this.bestmove      = bestplay.getNextAction();
            this.bestmoveValue = bestval;
            this.bestb         = new Playfield(bestplay);
            this.bestboard     = new Playfield(bestplay);

            if (bestmove != null) // save the guessed move, so we doesnt need to recalc!
            {
                this.nextMoveGuess = new Playfield();
                if (bestmove.cardplay)
                {
                    //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
                    Handmanager.Handcard hc = this.nextMoveGuess.owncards.Find(x => x.entity == bestmove.cardEntitiy);

                    if (bestmove.owntarget >= 0 && bestmove.enemytarget >= 0 && bestmove.enemytarget <= 9 && bestmove.owntarget < bestmove.enemytarget)
                    {
                        this.nextMoveGuess.playCard(bestmove.handcard, hc.position - 1, hc.entity, bestmove.enemytarget - 1, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
                    }
                    else
                    {
                        this.nextMoveGuess.playCard(bestmove.handcard, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
                    }
                    //this.nextMoveGuess.playCard(bestmove.card, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
                }

                if (bestmove.minionplay)
                {
                    //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
                    Minion m = this.nextMoveGuess.ownMinions.Find(x => x.entitiyID == bestmove.ownEntitiy);
                    this.nextMoveGuess.attackWithMinion(m, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
                }

                if (bestmove.heroattack)
                {
                    this.nextMoveGuess.attackWithWeapon(bestmove.enemytarget, bestmove.enemyEntitiy, 0);
                }

                if (bestmove.useability)
                {
                    //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
                    this.nextMoveGuess.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
                }

                this.bestboard.playactions.RemoveAt(0);
            }
            else
            {
                nextMoveGuess.mana = -1;
            }
        }
Exemplo n.º 13
0
        public void readCombos(string behavName, bool nameIsPath = false)
        {
            string pathToCombo = behavName;

            if (!nameIsPath)
            {
                if (!Silverfish.Instance.BehaviorPath.ContainsKey(behavName))
                {
                    help.ErrorLog(behavName + ": 没有特定的“连招”.");
                    return;
                }
                pathToCombo = Path.Combine(Silverfish.Instance.BehaviorPath[behavName], "_combo.txt");
            }

            if (!System.IO.File.Exists(pathToCombo))
            {
                help.ErrorLog(behavName + ": 没有特定的“连招”.");
                return;
            }

            help.ErrorLog("[连招功能] 成功加载“连招” " + behavName);
            string[] lines = new string[0] {
            };
            combos.Clear();
            playByValue.Clear();
            try
            {
                lines = System.IO.File.ReadAllLines(pathToCombo);
            }
            catch
            {
                help.logg("没有发现“连招功能”文本 _combo.txt");
                help.ErrorLog("“连招功能”文本 _combo.txt ");
                return;
            }
            help.logg("加载“连招功能”文本 _combo.txt...");
            help.ErrorLog("加载“连招功能”文本 _combo.txt...");
            foreach (string line in lines)
            {
                if (line == "" || line == null)
                {
                    continue;
                }
                if (line.StartsWith("//"))
                {
                    continue;
                }
                if (line.Contains("weapon:"))
                {
                    try
                    {
                        this.attackFaceHP = Convert.ToInt32(line.Replace("weapon:", ""));
                    }
                    catch
                    {
                        help.logg("[连招功能]不能加载: " + line);
                        help.ErrorLog("[连招功能]不能加载: " + line);
                    }
                }
                else
                {
                    if (line.Contains("cardvalue:"))
                    {
                        try
                        {
                            string            cardvalue = line.Replace("cardvalue:", "");
                            CardDB.cardIDEnum ce        = cdb.cardIdstringToEnum(cardvalue.Split(',')[0]);
                            int val = Convert.ToInt32(cardvalue.Split(',')[1]);
                            if (this.playByValue.ContainsKey(ce))
                            {
                                continue;
                            }
                            this.playByValue.Add(ce, val);
                            //help.ErrorLog("adding: " + line);
                        }
                        catch
                        {
                            help.logg("[连招功能]不能加载: " + line);
                            help.ErrorLog("[连招功能]不能加载: " + line);
                        }
                    }
                    else
                    {
                        try
                        {
                            combo c = new combo(line);
                            this.combos.Add(c);
                        }
                        catch
                        {
                            help.logg("[连招功能]不能加载: " + line);
                            help.ErrorLog("[连招功能]不能加载: " + line);
                        }
                    }
                }
            }
            help.ErrorLog("[连招功能] " + combos.Count + " “连招”功能激活成功, " + playByValue.Count + " 个权重值已加载");
        }
Exemplo n.º 14
0
        private void doallmoves(bool test, Bot botBase, bool isLethalCheck)
        {
            bool             havedonesomething = true;
            List <Playfield> temp = new List <Playfield>();
            int deep = 0;

            while (havedonesomething)
            {
                help.logg("ailoop");
                GC.Collect();
                temp.Clear();
                temp.AddRange(this.posmoves);
                havedonesomething = false;
                Playfield bestold    = null;
                int       bestoldval = -20000000;
                foreach (Playfield p in temp)
                {
                    if (p.complete)
                    {
                        continue;
                    }

                    //take a card and play it
                    List <string> playedcards = new List <string>();

                    foreach (Handmanager.Handcard hc in p.owncards)
                    {
                        CardDB.Card c = hc.card;
                        //help.logg("try play crd" + c.name + " " + c.getManaCost(p) + " " + c.canplayCard(p));
                        if (playedcards.Contains(c.name))
                        {
                            continue;                               // dont play the same card in one loop
                        }
                        playedcards.Add(c.name);
                        if (c.choice)
                        {
                            if (doAllChoices(p, hc, isLethalCheck))
                            {
                                havedonesomething = true;
                            }
                        }
                        else
                        {
                            int bestplace = p.getBestPlace(c);
                            if (hc.canplayCard(p))
                            {
                                havedonesomething = true;
                                List <targett> trgts = c.getTargetsForCard(p);

                                if (isLethalCheck && (penman.DamageTargetDatabase.ContainsKey(c.name) || penman.DamageTargetSpecialDatabase.ContainsKey(c.name)))// only target enemy hero during Lethal check!
                                {
                                    targett trg = trgts.Find(x => x.target == 200);
                                    if (trg != null)
                                    {
                                        trgts.Clear();
                                        trgts.Add(trg);
                                    }
                                    else
                                    {
                                        // no enemy hero -> enemy have taunts ->kill the taunts from left to right
                                        if (trgts.Count >= 1)
                                        {
                                            trg = trgts[0];
                                            trgts.Clear();
                                            trgts.Add(trg);
                                        }
                                    }
                                }


                                int cardplayPenality = 0;

                                if (trgts.Count == 0)
                                {
                                    if (usePenalityManager)
                                    {
                                        cardplayPenality = penman.getPlayCardPenality(c, -1, p, 0, isLethalCheck);
                                        if (cardplayPenality <= 499)
                                        {
                                            Playfield pf = new Playfield(p);
                                            havedonesomething = true;
                                            pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, 0, bestplace, cardplayPenality);
                                            this.posmoves.Add(pf);
                                        }
                                    }
                                    else
                                    {
                                        Playfield pf = new Playfield(p);
                                        havedonesomething = true;
                                        pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, 0, bestplace, cardplayPenality);
                                        this.posmoves.Add(pf);
                                    }
                                }
                                else
                                {
                                    if (isLethalCheck)// only target enemy hero during Lethal check!
                                    {
                                        targett trg = trgts.Find(x => x.target == 200);
                                        if (trg != null)
                                        {
                                            trgts.Clear();
                                            trgts.Add(trg);
                                        }
                                    }

                                    foreach (targett trgt in trgts)
                                    {
                                        if (usePenalityManager)
                                        {
                                            cardplayPenality = penman.getPlayCardPenality(c, trgt.target, p, 0, isLethalCheck);
                                            if (cardplayPenality <= 499)
                                            {
                                                Playfield pf = new Playfield(p);
                                                havedonesomething = true;
                                                pf.playCard(hc, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
                                                this.posmoves.Add(pf);
                                            }
                                        }
                                        else
                                        {
                                            Playfield pf = new Playfield(p);
                                            havedonesomething = true;
                                            pf.playCard(hc, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
                                            this.posmoves.Add(pf);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    //attack with a minion

                    List <Minion> playedMinions = new List <Minion>(8);

                    foreach (Minion m in p.ownMinions)
                    {
                        if (m.Ready && m.Angr >= 1 && !m.frozen)
                        {
                            //BEGIN:cut (double/similar) attacking minions out#####################################
                            // DONT LET SIMMILAR MINIONS ATTACK IN ONE TURN (example 3 unlesh the hounds-hounds doesnt need to simulated hole)
                            List <Minion> tempoo       = new List <Minion>(playedMinions);
                            bool          dontattacked = true;
                            bool          isSpecial    = penman.specialMinions.ContainsKey(m.name);
                            foreach (Minion mnn in tempoo)
                            {
                                // special minions are allowed to attack in silended and unsilenced state!
                                //help.logg(mnn.silenced + " " + m.silenced + " " + mnn.name + " " + m.name + " " + penman.specialMinions.ContainsKey(m.name));

                                bool otherisSpecial = penman.specialMinions.ContainsKey(mnn.name);

                                if ((!isSpecial || (isSpecial && m.silenced)) && (!otherisSpecial || (otherisSpecial && mnn.silenced))) // both are not special, if they are the same, dont add
                                {
                                    if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous)
                                    {
                                        dontattacked = false;
                                    }
                                    continue;
                                }

                                if (isSpecial == otherisSpecial && !m.silenced && !mnn.silenced) // same are special
                                {
                                    if (m.name != mnn.name)                                      // different name -> take it
                                    {
                                        continue;
                                    }
                                    // same name -> test whether they are equal
                                    if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous)
                                    {
                                        dontattacked = false;
                                    }
                                    continue;
                                }
                            }

                            if (dontattacked)
                            {
                                playedMinions.Add(m);
                            }
                            else
                            {
                                //help.logg(m.name + " doesnt need to attack!");
                                continue;
                            }
                            //END: cut (double/similar) attacking minions out#####################################

                            //help.logg(m.name + " is going to attack!");
                            List <targett> trgts = p.getAttackTargets();


                            if (isLethalCheck)// only target enemy hero during Lethal check!
                            {
                                targett trg = trgts.Find(x => x.target == 200);
                                if (trg != null)
                                {
                                    trgts.Clear();
                                    trgts.Add(trg);
                                }
                                else
                                {
                                    // no enemy hero -> enemy have taunts ->kill the taunts from left to right
                                    if (trgts.Count >= 1)
                                    {
                                        trg = trgts[0];
                                        trgts.Clear();
                                        trgts.Add(trg);
                                    }
                                }
                            }
                            else
                            {
                                if (this.useCutingTargets)
                                {
                                    trgts = this.cutAttackTargets(trgts, p);
                                }
                            }

                            foreach (targett trgt in trgts)
                            {
                                int attackPenality = 0;

                                if (usePenalityManager)
                                {
                                    attackPenality = penman.getAttackWithMininonPenality(m, p, trgt.target, isLethalCheck);
                                    if (attackPenality <= 499)
                                    {
                                        Playfield pf = new Playfield(p);
                                        havedonesomething = true;
                                        pf.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
                                        this.posmoves.Add(pf);
                                    }
                                }
                                else
                                {
                                    Playfield pf = new Playfield(p);
                                    havedonesomething = true;
                                    pf.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
                                    this.posmoves.Add(pf);
                                }
                            }
                            if (trgts.Count == 1 && trgts[0].target == 200)//only enemy hero is available als attack
                            {
                                break;
                            }
                        }
                    }

                    // attack with hero
                    if (p.ownHeroReady)
                    {
                        List <targett> trgts = p.getAttackTargets();

                        havedonesomething = true;

                        if (isLethalCheck)// only target enemy hero during Lethal check!
                        {
                            targett trg = trgts.Find(x => x.target == 200);
                            if (trg != null)
                            {
                                trgts.Clear();
                                trgts.Add(trg);
                            }
                            else
                            {
                                // no enemy hero -> enemy have taunts ->kill the taunts from left to right
                                if (trgts.Count >= 1)
                                {
                                    trg = trgts[0];
                                    trgts.Clear();
                                    trgts.Add(trg);
                                }
                            }
                        }
                        else
                        {
                            if (this.useCutingTargets)
                            {
                                trgts = this.cutAttackTargets(trgts, p);
                            }
                        }

                        foreach (targett trgt in trgts)
                        {
                            Playfield pf            = new Playfield(p);
                            int       heroAttackPen = 0;
                            if (usePenalityManager)
                            {
                                heroAttackPen = penman.getAttackWithHeroPenality(trgt.target, p);
                            }
                            pf.attackWithWeapon(trgt.target, trgt.targetEntity, heroAttackPen);
                            this.posmoves.Add(pf);
                        }
                    }

                    // use ability
                    /// TODO check if ready after manaup
                    if (p.ownAbilityReady && p.mana >= 2 && p.ownHeroAblility.canplayCard(p, 2))
                    {
                        int abilityPenality = 0;

                        havedonesomething = true;
                        // if we have mage or priest, we have to target something####################################################
                        if (this.hp.heroname == "mage" || this.hp.heroname == "priest")
                        {
                            List <targett> trgts = p.ownHeroAblility.getTargetsForCard(p);

                            if (isLethalCheck && (this.hp.heroname == "mage" || (this.hp.heroname == "priest" && p.ownHeroAblility.name != "lesserheal")))// only target enemy hero during Lethal check!
                            {
                                targett trg = trgts.Find(x => x.target == 200);
                                if (trg != null)
                                {
                                    trgts.Clear();
                                    trgts.Add(trg);
                                }
                                else
                                {
                                    // no enemy hero -> enemy have taunts ->kill the taunts from left to right
                                    if (trgts.Count >= 1)
                                    {
                                        trg = trgts[0];
                                        trgts.Clear();
                                        trgts.Add(trg);
                                    }
                                }
                            }

                            foreach (targett trgt in trgts)
                            {
                                if (usePenalityManager)
                                {
                                    abilityPenality = penman.getPlayCardPenality(p.ownHeroAblility, trgt.target, p, 0, isLethalCheck);
                                    if (abilityPenality <= 499)
                                    {
                                        Playfield pf = new Playfield(p);
                                        havedonesomething = true;
                                        pf.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
                                        this.posmoves.Add(pf);
                                    }
                                }
                                else
                                {
                                    Playfield pf = new Playfield(p);
                                    havedonesomething = true;
                                    pf.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
                                    this.posmoves.Add(pf);
                                }
                            }
                        }
                        else
                        {
                            // the other classes dont have to target####################################################
                            Playfield pf = new Playfield(p);

                            if (usePenalityManager)
                            {
                                abilityPenality = penman.getPlayCardPenality(p.ownHeroAblility, -1, pf, 0, isLethalCheck);
                                if (abilityPenality <= 499)
                                {
                                    havedonesomething = true;
                                    pf.activateAbility(p.ownHeroAblility, -1, -1, abilityPenality);
                                    this.posmoves.Add(pf);
                                }
                            }
                            else
                            {
                                havedonesomething = true;
                                pf.activateAbility(p.ownHeroAblility, -1, -1, abilityPenality);
                                this.posmoves.Add(pf);
                            }
                        }
                    }


                    p.endTurn();

                    //sort stupid stuff ouf

                    if (botBase.getPlayfieldValue(p) > bestoldval)
                    {
                        bestoldval = botBase.getPlayfieldValue(p);
                        bestold    = p;
                    }
                    if (!test)
                    {
                        posmoves.Remove(p);
                    }
                }

                if (!test && bestoldval >= -10000 && bestold != null)
                {
                    this.posmoves.Add(bestold);
                }

                help.loggonoff(true);
                int donec = 0;
                foreach (Playfield p in posmoves)
                {
                    if (p.complete)
                    {
                        donec++;
                    }
                }
                help.logg("deep " + deep + " len " + this.posmoves.Count + " dones " + donec);

                if (!test)
                {
                    cuttingposibilities(botBase);
                }
                help.logg("cut to len " + this.posmoves.Count);
                help.loggonoff(false);
                deep++;

                if (deep >= this.maxdeep)
                {
                    break;                      //remove this?
                }
            }

            int       bestval        = int.MinValue;
            int       bestanzactions = 1000;
            Playfield bestplay       = temp[0];

            foreach (Playfield p in temp)
            {
                int val = botBase.getPlayfieldValue(p);
                if (bestval <= val)
                {
                    if (bestval == val && bestanzactions < p.playactions.Count)
                    {
                        continue;
                    }
                    bestplay       = p;
                    bestval        = val;
                    bestanzactions = p.playactions.Count;
                }
            }
            help.loggonoff(true);
            help.logg("-------------------------------------");
            help.logg("bestPlayvalue " + bestval);

            bestplay.printActions();
            this.bestmove      = bestplay.getNextAction();
            this.bestmoveValue = bestval;
            this.bestboard     = new Playfield(bestplay);

            /*if (bestmove != null && bestmove.cardplay && bestmove.handcard.card.type == CardDB.cardtype.MOB)
             * {
             *  Playfield pf = new Playfield();
             *  help.logg("bestplaces:");
             *  pf.getBestPlacePrint(bestmove.card);
             * }*/

            if (bestmove != null) // save the guessed move, so we doesnt need to recalc!
            {
                this.nextMoveGuess = new Playfield();
                if (bestmove.cardplay)
                {
                    //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
                    Handmanager.Handcard hc = this.nextMoveGuess.owncards.Find(x => x.entity == bestmove.cardEntitiy);

                    if (bestmove.owntarget >= 0 && bestmove.enemytarget >= 0 && bestmove.enemytarget <= 9 && bestmove.owntarget < bestmove.enemytarget)
                    {
                        this.nextMoveGuess.playCard(bestmove.handcard, hc.position - 1, hc.entity, bestmove.enemytarget - 1, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
                    }
                    else
                    {
                        this.nextMoveGuess.playCard(bestmove.handcard, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
                    }
                    //this.nextMoveGuess.playCard(bestmove.card, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
                }

                if (bestmove.minionplay)
                {
                    //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
                    Minion m = this.nextMoveGuess.ownMinions.Find(x => x.entitiyID == bestmove.ownEntitiy);
                    this.nextMoveGuess.attackWithMinion(m, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
                }

                if (bestmove.heroattack)
                {
                    this.nextMoveGuess.attackWithWeapon(bestmove.enemytarget, bestmove.enemyEntitiy, 0);
                }

                if (bestmove.useability)
                {
                    //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
                    this.nextMoveGuess.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
                }

                this.bestboard.playactions.RemoveAt(0);
            }
            else
            {
                nextMoveGuess.mana = -1;
            }
        }
Exemplo n.º 15
0
Arquivo: Hrtprozis.cs Projeto: tnd34/e
        public void printHero(bool writetobuffer = false)
        {
            help.logg("player:");
            help.logg(this.numMinionsPlayedThisTurn + " " + this.cardsPlayedThisTurn + " " + this.ueberladung + " " + this.ownPlayerController);

            help.logg("ownhero:");
            help.logg(this.heroname + " " + this.ownHero.Hp + " " + this.ownHero.maxHp + " " + this.ownHero.armor + " " + this.ownHero.immuneWhileAttacking + " " + this.ownHero.immune + " " + this.ownHero.entitiyID + " " + this.ownHero.Ready + " " + this.ownHero.numAttacksThisTurn + " " + this.ownHero.frozen + " " + this.ownHero.Angr + " " + this.ownHero.tempAttack);
            help.logg("weapon: " + heroWeaponAttack + " " + heroWeaponDurability + " " + ownHeroWeapon);
            help.logg("ability: " + this.ownAbilityisReady + " " + this.heroAbility.cardIDenum);
            string secs = "";
            foreach (CardDB.cardIDEnum sec in this.ownSecretList)
            {
                secs += sec + " ";
            }
            help.logg("osecrets: " + secs);
            help.logg("enemyhero:");
            help.logg(this.enemyHeroname + " " + this.enemyHero.Hp + " " + this.enemyHero.maxHp + " " + this.enemyHero.armor + " " + this.enemyHero.frozen + " " + this.enemyHero.immune + " " + this.enemyHero.entitiyID);
            help.logg("weapon: " + this.enemyWeaponAttack + " " + this.enemyWeaponDurability + " " + this.enemyHeroWeapon);
            help.logg("ability: " + "true" + " " + this.enemyAbility.cardIDenum);
            help.logg("fatigue: " + this.ownDeckSize + " " + this.ownHeroFatigue + " " + this.enemyDeckSize + " " + this.enemyHeroFatigue);

            if (writetobuffer)
            {
                help.writeToBuffer("player:");
                help.writeToBuffer(this.numMinionsPlayedThisTurn + " " + this.cardsPlayedThisTurn + " " + this.ueberladung + " " + this.ownPlayerController);

                help.writeToBuffer("ownhero:");
                help.writeToBuffer(this.heroname + " " + this.ownHero.Hp + " " + this.ownHero.maxHp + " " + this.ownHero.armor + " " + this.ownHero.immuneWhileAttacking + " " + this.ownHero.immune + " " + this.ownHero.entitiyID + " " + this.ownHero.Ready + " " + this.ownHero.numAttacksThisTurn + " " + this.ownHero.frozen + " " + this.ownHero.Angr + " " + this.ownHero.tempAttack);
                help.writeToBuffer("weapon: " + heroWeaponAttack + " " + heroWeaponDurability + " " + ownHeroWeapon);
                help.writeToBuffer("ability: " + this.ownAbilityisReady + " " + this.heroAbility.cardIDenum);
                secs = "";
                foreach (CardDB.cardIDEnum sec in this.ownSecretList)
                {
                    secs += sec + " ";
                }
                help.writeToBuffer("osecrets: " + secs);
                help.writeToBuffer("enemyhero:");
                help.writeToBuffer(this.enemyHeroname + " " + this.enemyHero.Hp + " " + this.enemyHero.maxHp + " " + this.enemyHero.armor + " " + this.enemyHero.frozen + " " + this.enemyHero.immune + " " + this.enemyHero.entitiyID);
                help.writeToBuffer("weapon: " + this.enemyWeaponAttack + " " + this.enemyWeaponDurability + " " + this.enemyHeroWeapon);
                help.writeToBuffer("ability: " + "true" + " " + this.enemyAbility.cardIDenum);
                help.writeToBuffer("fatigue: " + this.ownDeckSize + " " + this.ownHeroFatigue + " " + this.enemyDeckSize + " " + this.enemyHeroFatigue);
            }
        }
Exemplo n.º 16
0
        public void adjustActions(Playfield p, bool isLethalCheck)
        {
            if (p.enemySecretCount > 0)
            {
                return;
            }
            if (p.playactions.Count < 2)
            {
                return;
            }

            List <Action> reorderedActions = new List <Action>();
            Dictionary <int, Dictionary <int, int> > rndActIdsDmg = new Dictionary <int, Dictionary <int, int> >();
            Playfield tmpPlOld = new Playfield();

            if (isLethalCheck)
            {
                if (Ai.Instance.botBase.getPlayfieldValue(p) < 10000)
                {
                    return;
                }
                Playfield tmpPf = new Playfield();
                if (tmpPf.anzEnemyTaunt > 0)
                {
                    return;
                }

                Dictionary <Action, int> actDmgDict = new Dictionary <Action, int>();
                tmpPf.enemyHero.Hp = 30;
                try
                {
                    int useability = 0;
                    foreach (Action a in p.playactions)
                    {
                        if (a.actionType == actionEnum.useHeroPower)
                        {
                            useability = 1;
                        }
                        if (a.actionType == actionEnum.attackWithHero)
                        {
                            useability++;
                        }
                        int actDmd = tmpPf.enemyHero.Hp + tmpPf.enemyHero.armor;
                        tmpPf.doAction(a);
                        actDmd -= (tmpPf.enemyHero.Hp + tmpPf.enemyHero.armor);
                        actDmgDict.Add(a, actDmd);
                    }
                    if (useability > 1)
                    {
                        return;
                    }
                }
                catch { return; }

                foreach (var pair in actDmgDict.OrderByDescending(pair => pair.Value))
                {
                    reorderedActions.Add(pair.Key);
                }

                tmpPf = new Playfield();
                foreach (Action a in reorderedActions)
                {
                    if (!isActionPossible(tmpPf, a))
                    {
                        return;
                    }
                    try
                    {
                        tmpPf.doAction(a);
                    }
                    catch
                    {
                        this.printError(p.playactions, reorderedActions, a);
                        return;
                    }
                }

                if (Ai.Instance.botBase.getPlayfieldValue(tmpPf) < 10000)
                {
                    return;
                }
            }
            else
            {
                bool   damageRandom       = false;
                bool   rndBeforeDamageAll = false;
                Action aa;
                for (int i = 0; i < p.playactions.Count; i++)
                {
                    aa = p.playactions[i];
                    switch (aa.actionType)
                    {
                    case actionEnum.playcard:
                        if (damageRandom && penman.DamageAllEnemysDatabase.ContainsKey(aa.card.card.name))
                        {
                            rndBeforeDamageAll = true;
                        }
                        else if (penman.DamageRandomDatabase.ContainsKey(aa.card.card.name))
                        {
                            damageRandom = true;
                        }
                        break;
                    }
                }

                int           aoeEnNum    = 0;
                int           outOfPlace  = 0;
                bool          totemiccall = false;
                List <Action> rndAct      = new List <Action>();
                List <Action> rndActTmp   = new List <Action>();
                for (int i = 0; i < p.playactions.Count; i++)
                {
                    damageRandom = false;
                    aa           = p.playactions[i];
                    reorderedActions.Add(aa);
                    switch (aa.actionType)
                    {
                    case actionEnum.useHeroPower:
                        if (aa.card.card.name == CardDB.cardName.totemiccall)
                        {
                            totemiccall = true;
                        }
                        break;

                    case actionEnum.playcard:
                        if (penman.DamageAllEnemysDatabase.ContainsKey(aa.card.card.name))
                        {
                            if (i != aoeEnNum)
                            {
                                if (totemiccall && aa.card.card.type == CardDB.cardtype.SPELL)
                                {
                                    return;
                                }
                                reorderedActions.RemoveAt(i);
                                reorderedActions.Insert(aoeEnNum, aa);
                                outOfPlace++;
                            }
                            aoeEnNum++;
                        }
                        else if (rndBeforeDamageAll && aa.card.card.type == CardDB.cardtype.SPELL && penman.DamageRandomDatabase.ContainsKey(aa.card.card.name))
                        {
                            damageRandom = true;
                            Playfield tmp = new Playfield(tmpPlOld);
                            tmpPlOld.doAction(aa);

                            Dictionary <int, int> actIdDmg = new Dictionary <int, int>();
                            if (tmp.enemyHero.Hp != tmpPlOld.enemyHero.Hp)
                            {
                                actIdDmg.Add(tmpPlOld.enemyHero.entitiyID, tmp.enemyHero.Hp - tmpPlOld.enemyHero.Hp);
                            }
                            if (tmp.ownHero.Hp != tmpPlOld.ownHero.Hp)
                            {
                                actIdDmg.Add(tmpPlOld.ownHero.entitiyID, tmp.ownHero.Hp - tmpPlOld.ownHero.Hp);
                            }
                            bool found = false;
                            foreach (Minion m in tmp.enemyMinions)
                            {
                                found = false;
                                foreach (Minion nm in tmpPlOld.enemyMinions)
                                {
                                    if (m.entitiyID == nm.entitiyID)
                                    {
                                        found = true;
                                        if (m.Hp != nm.Hp)
                                        {
                                            actIdDmg.Add(m.entitiyID, m.Hp - nm.Hp);
                                        }
                                        break;
                                    }
                                }
                                if (!found)
                                {
                                    actIdDmg.Add(m.entitiyID, m.Hp);
                                }
                            }
                            foreach (Minion m in tmp.ownMinions)
                            {
                                found = false;
                                foreach (Minion nm in tmpPlOld.ownMinions)
                                {
                                    if (m.entitiyID == nm.entitiyID)
                                    {
                                        found = true;
                                        if (m.Hp != nm.Hp)
                                        {
                                            actIdDmg.Add(m.entitiyID, m.Hp - nm.Hp);
                                        }
                                        break;
                                    }
                                }
                                if (!found)
                                {
                                    actIdDmg.Add(m.entitiyID, m.Hp);
                                }
                            }
                            rndActIdsDmg.Add(aa.card.entity, actIdDmg);
                        }
                        break;
                    }
                    if (!damageRandom)
                    {
                        tmpPlOld.doAction(aa);
                    }
                }

                if (outOfPlace == 0)
                {
                    return;
                }

                Playfield tmpPf = new Playfield();
                foreach (Action a in reorderedActions)
                {
                    if (!isActionPossible(tmpPf, a))
                    {
                        return;
                    }
                    try
                    {
                        if (!(a.actionType == actionEnum.playcard && rndActIdsDmg.ContainsKey(a.card.entity)))
                        {
                            tmpPf.doAction(a);
                        }
                        else
                        {
                            tmpPf.playactions.Add(a);
                            Dictionary <int, int> actIdDmg = rndActIdsDmg[a.card.entity];
                            if (actIdDmg.ContainsKey(tmpPf.enemyHero.entitiyID))
                            {
                                tmpPf.minionGetDamageOrHeal(tmpPf.enemyHero, actIdDmg[tmpPf.enemyHero.entitiyID]);
                            }
                            if (actIdDmg.ContainsKey(tmpPf.ownHero.entitiyID))
                            {
                                tmpPf.minionGetDamageOrHeal(tmpPf.ownHero, actIdDmg[tmpPf.ownHero.entitiyID]);
                            }
                            foreach (Minion m in tmpPf.enemyMinions)
                            {
                                if (actIdDmg.ContainsKey(m.entitiyID))
                                {
                                    tmpPf.minionGetDamageOrHeal(m, actIdDmg[m.entitiyID]);
                                }
                            }
                            foreach (Minion m in tmpPf.ownMinions)
                            {
                                if (actIdDmg.ContainsKey(m.entitiyID))
                                {
                                    tmpPf.minionGetDamageOrHeal(m, actIdDmg[m.entitiyID]);
                                }
                            }
                            tmpPf.doDmgTriggers();
                        }
                    }
                    catch
                    {
                        printError(p.playactions, reorderedActions, a);
                        return;
                    }
                }

                tmpPf.lostDamage = tmpPlOld.lostDamage;
                float newval = Ai.Instance.botBase.getPlayfieldValue(tmpPf);
                float oldval = Ai.Instance.botBase.getPlayfieldValue(tmpPlOld);

                if (oldval > newval)
                {
                    return;
                }
            }
            help.logg("Old order of actions:");
            foreach (Action a in p.playactions)
            {
                a.print();
            }

            p.playactions.Clear();
            p.playactions.AddRange(reorderedActions);

            help.logg("New order of actions:");
        }
Exemplo n.º 17
0
        public void print(bool tobuffer = false)
        {
            Helpfunctions help = Helpfunctions.Instance;

            if (tobuffer)
            {
                if (this.actionType == actionEnum.playcard)
                {
                    string playaction = "play ";

                    playaction += "id " + this.card.entity;
                    if (this.target != null)
                    {
                        playaction += " target " + this.target.entitiyID;
                    }

                    if (this.place >= 0)
                    {
                        playaction += " pos " + this.place;
                    }

                    if (this.druidchoice >= 1)
                    {
                        playaction += " choice " + this.druidchoice;
                    }

                    help.writeToBuffer(playaction);
                }
                if (this.actionType == actionEnum.attackWithMinion)
                {
                    help.writeToBuffer("attack " + this.own.entitiyID + " enemy " + this.target.entitiyID);
                }
                if (this.actionType == actionEnum.attackWithHero)
                {
                    help.writeToBuffer("heroattack " + this.target.entitiyID);
                }
                if (this.actionType == actionEnum.useHeroPower)
                {
                    if (this.target != null)
                    {
                        help.writeToBuffer("useability on target " + this.target.entitiyID);
                    }
                    else
                    {
                        help.writeToBuffer("useability");
                    }
                }
                return;
            }
            if (this.actionType == actionEnum.playcard)
            {
                string playaction = "play ";

                playaction += "id " + this.card.entity;
                if (this.target != null)
                {
                    playaction += " target " + this.target.entitiyID;
                }

                if (this.place >= 0)
                {
                    playaction += " pos " + this.place;
                }

                if (this.druidchoice >= 1)
                {
                    playaction += " choice " + this.druidchoice;
                }

                help.logg(playaction);
            }
            if (this.actionType == actionEnum.attackWithMinion)
            {
                help.logg("attacker: " + this.own.entitiyID + " enemy: " + this.target.entitiyID);
            }
            if (this.actionType == actionEnum.attackWithHero)
            {
                help.logg("attack with hero, enemy: " + this.target.entitiyID);
            }
            if (this.actionType == actionEnum.useHeroPower)
            {
                help.logg("useability ");
                if (this.target != null)
                {
                    help.logg("on enemy: " + this.target.entitiyID);
                }
            }
            help.logg("");
        }
Exemplo n.º 18
0
        //not updated anymore!
        public void printcards(bool writeTobuffer = false)
        {
            help.logg("Own Handcards: ");
            foreach (Handmanager.Handcard c in this.handCards)
            {
                help.logg("pos " + c.position + " " + c.card.name + " " + c.manacost + " entity " + c.entity + " " + c.card.cardIDenum + " " + c.addattack);
            }
            help.logg("Enemy cards: " + this.enemyAnzCards);

            //todo print died minions this turn!

            /*if(Ai.Instance.playaround)
             * {
             *  if(Hrtprozis.Instance.enemyHeroname == HeroEnum.mage)
             *  {
             *      help.logg("probs: "  + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_032) + " " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_028));
             *  }
             *
             *  if (Hrtprozis.Instance.enemyHeroname == HeroEnum.warrior)
             *  {
             *      help.logg("probs: "  + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_400));
             *  }
             *
             *  if (Hrtprozis.Instance.enemyHeroname == HeroEnum.hunter)
             *  {
             *      help.logg("probs: "  + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_538));
             *  }
             *
             *  if (Hrtprozis.Instance.enemyHeroname == HeroEnum.priest)
             *  {
             *      help.logg("probs: "  + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS1_112));
             *  }
             *
             *  if (Hrtprozis.Instance.enemyHeroname == HeroEnum.shaman)
             *  {
             *      help.logg("probs: "  + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_259));
             *  }
             *
             *  if (Hrtprozis.Instance.enemyHeroname == HeroEnum.pala)
             *  {
             *      help.logg("probs: "  + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_093));
             *  }
             *
             *  if (Hrtprozis.Instance.enemyHeroname == HeroEnum.druid)
             *  {
             *      help.logg("probs: "  + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_012));
             *  }
             * }*/

            if (writeTobuffer)
            {
                help.writeToBuffer("Own Handcards: ");
                foreach (Handmanager.Handcard c in this.handCards)
                {
                    help.writeToBuffer("pos " + c.position + " " + c.card.name + " " + c.manacost + " entity " + c.entity + " " + c.card.cardIDenum + " " + c.addattack);
                }
                help.writeToBuffer("Enemy cards: " + this.enemyAnzCards);

                //todo print died minions this turn!
            }
        }
Exemplo n.º 19
0
        public void readCombos(string behavName)
        {
            if (!Silverfish.Instance.BehaviorPath.ContainsKey(behavName))
            {
                help.ErrorLog(behavName + ": no special combos.");
                return;
            }

            string pathToCombo = Path.Combine(Silverfish.Instance.BehaviorPath[behavName], "_combo.txt");

            if (!System.IO.File.Exists(pathToCombo))
            {
                help.ErrorLog(behavName + ": no special combos.");
                return;
            }

            help.ErrorLog("[Combo] Load combos for " + behavName);
            string[] lines = new string[0] {
            };
            combos.Clear();
            playByValue.Clear();
            try
            {
                lines = System.IO.File.ReadAllLines(pathToCombo);
            }
            catch
            {
                help.logg("cant find _combo.txt");
                help.ErrorLog("cant find _combo.txt (if you dont created your own combos, ignore this message)");
                return;
            }
            help.logg("read _combo.txt...");
            help.ErrorLog("read _combo.txt...");
            foreach (string line in lines)
            {
                if (line == "" || line == null)
                {
                    continue;
                }
                if (line.StartsWith("//"))
                {
                    continue;
                }
                if (line.Contains("weapon:"))
                {
                    try
                    {
                        this.attackFaceHP = Convert.ToInt32(line.Replace("weapon:", ""));
                    }
                    catch
                    {
                        help.logg("combomaker cant read: " + line);
                        help.ErrorLog("combomaker cant read: " + line);
                    }
                }
                else
                {
                    if (line.Contains("cardvalue:"))
                    {
                        try
                        {
                            string            cardvalue = line.Replace("cardvalue:", "");
                            CardDB.cardIDEnum ce        = cdb.cardIdstringToEnum(cardvalue.Split(',')[0]);
                            int val = Convert.ToInt32(cardvalue.Split(',')[1]);
                            if (this.playByValue.ContainsKey(ce))
                            {
                                continue;
                            }
                            this.playByValue.Add(ce, val);
                            //help.ErrorLog("adding: " + line);
                        }
                        catch
                        {
                            help.logg("combomaker cant read: " + line);
                            help.ErrorLog("combomaker cant read: " + line);
                        }
                    }
                    else
                    {
                        try
                        {
                            combo c = new combo(line);
                            this.combos.Add(c);
                        }
                        catch
                        {
                            help.logg("combomaker cant read: " + line);
                            help.ErrorLog("combomaker cant read: " + line);
                        }
                    }
                }
            }
            help.ErrorLog("[Combo] " + combos.Count + " combos loaded successfully, " + playByValue.Count + " values loaded successfully");
        }
Exemplo n.º 20
0
        private void doallmoves(bool test, BotBase botBase)
        {
            bool             havedonesomething = true;
            List <Playfield> temp = new List <Playfield>();
            int deep = 0;

            while (havedonesomething)
            {
                help.logg("ailoop");
                temp.Clear();
                temp.AddRange(this.posmoves);
                havedonesomething = false;
                Playfield bestold    = null;
                int       bestoldval = -20000000;
                foreach (Playfield p in temp)
                {
                    if (p.complete)
                    {
                        continue;
                    }

                    //take a card and play it
                    List <string> playedcards = new List <string>();
                    foreach (Handmanager.Handcard hc in p.owncards)
                    {
                        CardDB.Card c = hc.card;
                        //help.logg("try play crd" + c.name + " " + c.getManaCost(p) + " " + c.canplayCard(p));
                        if (playedcards.Contains(c.name))
                        {
                            continue;                               // dont play the same card in one loop
                        }
                        playedcards.Add(c.name);
                        if (c.choice)
                        {
                            if (doAllChoices(c, p, hc))
                            {
                                havedonesomething = true;
                            }
                        }
                        else
                        {
                            if (c.canplayCard(p))
                            {
                                havedonesomething = true;
                                List <targett> trgts = c.getTargetsForCard(p);

                                if (trgts.Count == 0)
                                {
                                    Playfield pf = new Playfield(p);
                                    pf.playCard(c, hc.position - 1, hc.entity, -1, -1, 0);
                                    this.posmoves.Add(pf);
                                }
                                else
                                {
                                    foreach (targett trgt in trgts)
                                    {
                                        Playfield pf = new Playfield(p);
                                        pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0);
                                        this.posmoves.Add(pf);
                                    }
                                }
                            }
                        }
                    }

                    //attack with a minion
                    foreach (Minion m in p.ownMinions)
                    {
                        if (m.Ready && m.Angr >= 1 && !m.frozen)
                        {
                            List <targett> trgts = p.getAttackTargets();
                            havedonesomething = true;
                            foreach (targett trgt in trgts)
                            {
                                Playfield pf = new Playfield(p);
                                pf.attackWithMinion(m, trgt.target, trgt.targetEntity);
                                this.posmoves.Add(pf);
                            }
                        }
                    }

                    // attack with hero
                    if (p.ownHeroReady)
                    {
                        List <targett> trgts = p.getAttackTargets();
                        havedonesomething = true;
                        foreach (targett trgt in trgts)
                        {
                            Playfield pf = new Playfield(p);
                            pf.attackWithWeapon(trgt.target, trgt.targetEntity);
                            this.posmoves.Add(pf);
                        }
                    }

                    // use ability
                    /// TODO check if ready after manaup
                    if (p.ownAbilityReady && p.mana >= 2)
                    {
                        havedonesomething = true;
                        if (this.hp.heroname == "mage" || this.hp.heroname == "priest")
                        {
                            List <targett> trgts = p.ownHeroAblility.getTargetsForCard(p);
                            foreach (targett trgt in trgts)
                            {
                                //if (this.hp.heroname == "priest" && trgt == 200) continue;
                                havedonesomething = true;
                                Playfield pf = new Playfield(p);
                                pf.activateAbility(p.ownHeroAblility, this.hp.heroname, trgt.target, trgt.targetEntity);
                                this.posmoves.Add(pf);
                            }
                        }
                        else
                        {
                            havedonesomething = true;
                            Playfield pf = new Playfield(p);
                            pf.activateAbility(p.ownHeroAblility, this.hp.heroname, -1, -1);
                            this.posmoves.Add(pf);
                        }
                    }


                    p.complete = true;

                    //sort stupid stuff ouf

                    if (botBase.getPlayfieldValue(p) > bestoldval)
                    {
                        bestoldval = botBase.getPlayfieldValue(p);
                        bestold    = p;
                    }
                    if (!test)
                    {
                        posmoves.Remove(p);
                    }
                }

                if (!test && bestoldval >= -10000 && bestold != null)
                {
                    this.posmoves.Add(bestold);
                }

                help.loggonoff(true);
                int donec = 0;
                foreach (Playfield p in posmoves)
                {
                    if (p.complete)
                    {
                        donec++;
                    }
                }
                help.logg("deep " + deep + " len " + this.posmoves.Count + " dones " + donec);

                if (!test)
                {
                    cuttingposibilities(botBase);
                }

                /*if ((deep + 1) % 4 == 0)
                 * {
                 *  help.logg("cut");
                 * }*/
                help.loggonoff(false);
                deep++;

                if (deep >= 20)
                {
                    break;            //remove this?
                }
            }

            int       bestval        = -10;
            int       bestanzactions = 1000;
            Playfield bestplay       = temp[0];

            foreach (Playfield p in temp)
            {
                int val = botBase.getPlayfieldValue(p);
                if (bestval <= val)
                {
                    if (bestval == val && bestanzactions < p.playactions.Count)
                    {
                        continue;
                    }
                    bestplay       = p;
                    bestval        = val;
                    bestanzactions = p.playactions.Count;
                }
            }
            help.loggonoff(true);
            help.logg("############################################");
            help.logg("bestPlayvalue " + bestval);

            if (!test)
            {
                bestplay.doAction();
            }
            bestplay.printActions();
            this.bestmove = bestplay.getNextAction();
        }