Esempio n. 1
0
File: Ai.cs Progetto: shuyi3/AIPJ
        //private static Ai instance;

        //public static Ai Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new Ai());
        //    }
        //}

        public Ai(Silverfish sf)
        {
            this.sf = sf;
            this.nextMoveGuess = new Playfield(sf);
            PenalityManager penman = sf.PenalityManager;
            hp = sf.Hrtprozis;
            hm = sf.Handmanager;
            help = sf.Helpfunctions;

            this.nextMoveGuess = new Playfield (sf) { mana = -100 };

            this.mainTurnSimulator = new MiniSimulator(sf, maxdeep, maxwide, 0); // 0 for unlimited
            this.mainTurnSimulator.setPrintingstuff(true);

            /*this.nextTurnSimulator = new MiniSimulatorNextTurn();
            this.enemyTurnSim = new EnemyTurnSimulator();
            this.enemySecondTurnSim = new EnemyTurnSimulator();*/

            for (int i = 0; i < sf.Settings.numberOfThreads; i++)
            {
                this.nextTurnSimulator.Add(new MiniSimulatorNextTurn(sf));
                this.enemyTurnSim.Add(new EnemyTurnSimulator(sf));
                this.enemySecondTurnSim.Add(new EnemyTurnSimulator(sf));

                this.nextTurnSimulator[i].thread = i;
                this.enemyTurnSim[i].thread = i;
                this.enemySecondTurnSim[i].thread = i;
            }

        }
Esempio n. 2
0
 public BotBase()
 {
     OnBattleStateUpdate   = HandleOnBattleStateUpdate;
     OnMulliganStateUpdate = HandleBattleMulliganPhase;
     this.sf = new Silverfish();
     //Ai.Instance.simulatorTester(this);
 }
Esempio n. 3
0
 public Bot()
 {
     OnBattleStateUpdate = HandleOnBattleStateUpdate;
       OnMulliganStateUpdate = HandleBattleMulliganPhase;
       this.sf = new Silverfish();
       //Ai.Instance.autoTester(this);
 }
Esempio n. 4
0
 public Bot()
 {
     OnBattleStateUpdate   = HandleOnBattleStateUpdate;
     OnMulliganStateUpdate = HandleBattleMulliganPhase;
     this.sf = new Silverfish();
     sf.setnewLoggFile();
     //Ai.Instance.autoTester(this);
 }
Esempio n. 5
0
 public MiniSimulator(Silverfish sf, int deep, int wide, int ttlboards)
 {
     this.sf = sf;
     this.bestboard = new Playfield(sf);
     this.maxdeep = deep;
     this.maxwide = wide;
     this.totalboards = ttlboards;
 }
Esempio n. 6
0
        public Bot()
        {
            //crawler stuff-----------------
            OnVictory             = HandleWining;
            OnLost                = HandleLosing;
            OnBattleStateUpdate   = HandleOnBattleStateUpdate;
            OnMulliganStateUpdate = HandleBattleMulliganPhase;
            //-----------------------------------------
            starttime = DateTime.Now;


            Settings set = Settings.Instance;

            this.sf = Silverfish.Instance;
            set.setSettings();
            sf.setnewLoggFile();
            CardDB cdb = CardDB.Instance;

            if (cdb.installedWrong)
            {
                Helpfunctions.Instance.ErrorLog("cant find CardDB");
                return;
            }

            bool teststuff  = false; // set to true, to run a testfile (requires test.txt file in folder where _cardDB.txt file is located)
            bool printstuff = false; // if true, the best board of the tested file is printet stepp by stepp

            Helpfunctions.Instance.ErrorLog("----------------------------");
            Helpfunctions.Instance.ErrorLog("you are running uai V" + sf.versionnumber);
            Helpfunctions.Instance.ErrorLog("----------------------------");

            if (Settings.Instance.useExternalProcess)
            {
                Helpfunctions.Instance.ErrorLog("YOU USE SILVER.EXE FOR CALCULATION, MAKE SURE YOU STARTED IT!");
            }
            if (Settings.Instance.useExternalProcess)
            {
                Helpfunctions.Instance.ErrorLog("SILVER.EXE IS LOCATED IN: " + Settings.Instance.path);
            }



            if (teststuff)//run autotester for developpers
            {
                Ai.Instance.autoTester(printstuff);
            }
            writeSettings();
        }
Esempio n. 7
0
        public Bot()
        {
            starttime = DateTime.Now;
            Settings set = Settings.Instance;

            this.sf = Silverfish.Instance;
            set.setSettings();
            sf.setnewLoggFile();

            bool teststuff  = true;
            bool printstuff = true;

            if (teststuff)
            {
                Helpfunctions.Instance.logg("teststuff");
                Playfield p = new Playfield();
                Ai.Instance.autoTester(printstuff);
            }
            Helpfunctions.Instance.ErrorLog("wait for board...");
        }
Esempio n. 8
0
        public Bot()
        {
            //crawler stuff-----------------
            OnVictory = HandleWining;
            OnLost = HandleLosing;
            OnBattleStateUpdate = HandleOnBattleStateUpdate;
            OnMulliganStateUpdate = HandleBattleMulliganPhase;
            //-----------------------------------------
            starttime = DateTime.Now;


            Settings set = Settings.Instance;
            this.sf = Silverfish.Instance;
            behave = set.setSettings();
            sf.setnewLoggFile();
            CardDB cdb = CardDB.Instance;
            if (cdb.installedWrong)
            {
                Helpfunctions.Instance.ErrorLog("cant find CardDB");
                return;
            }

            bool teststuff = false; // set to true, to run a testfile (requires test.txt file in folder where _cardDB.txt file is located)
            bool printstuff = false; // if true, the best board of the tested file is printet stepp by stepp

            Helpfunctions.Instance.ErrorLog("----------------------------");
            Helpfunctions.Instance.ErrorLog("you are running uai V" + sf.versionnumber);
            Helpfunctions.Instance.ErrorLog("----------------------------");

            if (Settings.Instance.useExternalProcess) Helpfunctions.Instance.ErrorLog("YOU USE SILVER.EXE FOR CALCULATION, MAKE SURE YOU STARTED IT!");
            if (Settings.Instance.useExternalProcess) Helpfunctions.Instance.ErrorLog("SILVER.EXE IS LOCATED IN: " + Settings.Instance.path);



            if (teststuff)//run autotester for developpers
            {
                Ai.Instance.autoTester(printstuff);
            }
            writeSettings();
        }
Esempio n. 9
0
        public Bot()
        {
            starttime = DateTime.Now;
            this.sf   = Silverfish.Instance;
            sf.setnewLoggFile();

            bool teststuff  = true;
            bool printstuff = true;

            if (teststuff)
            {
                Helpfunctions.Instance.logg("teststuff");
                Playfield p = new Playfield();
                Ai.Instance.autoTester(printstuff);
            }

            if (System.IO.File.Exists(SilverFishBotPath.AssemblyDirectory + "crashtest.txt"))
            {
                testing(1);
            }

            Helpfunctions.Instance.ErrorLog("wait for board...");
        }
Esempio n. 10
0
 public MiniSimulatorNextTurn(Silverfish sf)
 {
     this.sf = sf;
     this.bestboard = new Playfield(sf);
 }
Esempio n. 11
0
        //private static Mulligan instance;

        //public static Mulligan Instance
        //{
        //    get
        //    {
        //        if (instance == null)
        //        {
        //            instance = new Mulligan();
        //        }
        //        return instance;
        //    }
        //}

        public Mulligan(Silverfish sf)
        {
            this.sf = sf;
            readCombos();
        }
Esempio n. 12
0
        //private static Hrtprozis instance;

        //public static Hrtprozis Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new Hrtprozis());
        //    }
        //}



        public Hrtprozis(Silverfish sf)
        {
            this.sf = sf;
            this.help = sf.Helpfunctions;
        }
Esempio n. 13
0
        public Bot()
        {
            OnBattleStateUpdate = HandleOnBattleStateUpdate;
               OnMulliganStateUpdate = HandleBattleMulliganPhase;
               bool concede = false;
               bool writeToSingleFile = false;
               try
               {
               concede = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.autoconcede") == "true") ? true : false;
               writeToSingleFile = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.singleLog") == "true") ? true : false;
               }
               catch
               {
               HRLog.Write("a wild error occurrs! cant read the settings...");
               }
               try
               {
               this.concedeLvl = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.concedelvl")));
               if (this.concedeLvl >= 20) this.concedeLvl = 20;
               if (concede)
               {
                   HRLog.Write("concede till rank " + concedeLvl);
               }
               }
               catch
               {
               HRLog.Write("cant read your concede-Lvl");
               }

               this.sf = new Silverfish(writeToSingleFile);

               Mulligan.Instance.setAutoConcede(concede);

               sf.setnewLoggFile();

               try
               {
               int enfacehp = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyfacehp")));
               HRLog.Write("set enemy-face-hp to: " + enfacehp);
               ComboBreaker.Instance.attackFaceHP = enfacehp;
               }
               catch
               {
               HRLog.Write("error in reading enemy-face-hp");
               }

               try
               {
               int mxwde = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.maxwide")));
               if (mxwde != 3000)
               {
                   Ai.Instance.setMaxWide(mxwde);
                   HRLog.Write("set maxwide to: " + mxwde);
               }
               }
               catch
               {
               HRLog.Write("error in reading Maxwide from settings, please recheck the entry");
               }

               try
               {
               bool twots = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.simulateTwoTurns") == "true") ? true : false;
               if (twots)
               {
                   Ai.Instance.setTwoTurnSimulation(twots);
                   HRLog.Write("activated two turn simulation");
               }

               }
               catch
               {
               HRLog.Write("error in reading two-turn-simulation from settings");
               }

               HRLog.Write("write to single log file is: " + writeToSingleFile);

               bool teststuff = false;
               bool printstuff = false;
               try
               {

               printstuff = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.longteststuff") == "true") ? true : false;
               teststuff = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.teststuff") == "true") ? true : false;
               }
               catch
               {
               HRLog.Write("something went wrong with simulating stuff!");
               }

               if (teststuff)
               {
               Ai.Instance.autoTester(this, printstuff);
               }
        }
Esempio n. 14
0
        //private static Handmanager instance;

        //public static Handmanager Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new Handmanager());
        //    }
        //}


        public Handmanager(Silverfish sf)
        {
            this.help =sf.Helpfunctions;
            this.sf = sf;
        }
Esempio n. 15
0
        public void updateSecretList(Playfield p, Playfield old)
        {
            if (p.enemySecretCount == 0)
            {
                return;
            }

            bool usedspell            = false;
            int  lastEffectedIsMinion = 0; //2 = minion, 1 = hero
            bool playedMob            = false;
            bool enemyMinionDied      = false;
            bool attackedWithMob      = false;
            bool attackedWithHero     = false;
            int  attackTargetIsMinion = 0;
            bool enemyHeroGotDmg      = false;
            int  minionsOnBoard       = old.enemyMinions.Count;
            bool endedTurn            = false;
            bool usedHeropower        = false;

            Handmanager.Handcard hcard = null;
            if (p.cardsPlayedThisTurn > old.cardsPlayedThisTurn)
            {
                for (int i = 0; i < old.owncards.Count - 1; i++)
                {
                    if (p.owncards.Count - 1 >= i)
                    {
                        if (old.owncards[i].entity != p.owncards[i].entity)
                        {
                            hcard = old.owncards[i];
                            break;
                        }
                    }
                    else
                    {
                        hcard = old.owncards[i];
                        break;
                    }
                }

                if (hcard != null && hcard.card.type == CardDB.cardtype.SPELL)
                {
                    if (hcard.card.type == CardDB.cardtype.SPELL)
                    {
                        usedspell = true;
                    }
                    int entityOfLastAffected = Silverfish.getCardTarget(hcard.entity);
                    if (entityOfLastAffected >= 1)
                    {
                        lastEffectedIsMinion = 2;
                    }
                    if (entityOfLastAffected == p.enemyHero.entitiyID)
                    {
                        lastEffectedIsMinion = 1;
                    }
                }

                if (hcard != null && hcard.card.type == CardDB.cardtype.MOB)
                {
                    int entityOfLastAffected = Silverfish.getLastAffected(hcard.entity);
                    if (entityOfLastAffected >= 1)
                    {
                        lastEffectedIsMinion = 2;
                    }
                    if (entityOfLastAffected == p.enemyHero.entitiyID && (p.enemyHero.Hp < old.enemyHero.Hp || p.enemyHero.immune))
                    {
                        lastEffectedIsMinion = 1;
                    }

                    entityOfLastAffected = Silverfish.getCardTarget(hcard.entity);
                    if (entityOfLastAffected >= 1)
                    {
                        lastEffectedIsMinion = 2;
                        if (entityOfLastAffected == p.enemyHero.entitiyID)
                        {
                            lastEffectedIsMinion = 1;
                        }
                    }
                }
            }

            if (p.mobsplayedThisTurn > old.mobsplayedThisTurn)
            {
                playedMob = true;
            }
            if (p.diedMinions != null && old.diedMinions != null)
            {
                int pcount = 0;
                int ocount = 0;
                foreach (GraveYardItem gyi in p.diedMinions)
                {
                    if (!gyi.own)
                    {
                        pcount++;
                    }
                }
                foreach (GraveYardItem gyi in old.diedMinions)
                {
                    if (!gyi.own)
                    {
                        ocount++;
                    }
                }
                if (pcount > ocount)
                {
                    enemyMinionDied = true;
                }
            }

            //used heropower?
            if (old.own_TIMES_HERO_POWER_USED_THIS_GAME < p.own_TIMES_HERO_POWER_USED_THIS_GAME)
            {
                usedHeropower = true;
            }

            //attacked with mob?

            int newAttackers = 0;
            int oldAttackers = 0;

            foreach (Minion m in p.ownMinions)
            {
                newAttackers += m.numAttacksThisTurn;
            }
            foreach (Minion m in old.ownMinions)
            {
                oldAttackers += m.numAttacksThisTurn;
            }

            if (newAttackers > oldAttackers)
            {
                attackedWithMob = true;
            }

            if (p.ownHero.numAttacksThisTurn > old.ownHero.numAttacksThisTurn)
            {
                attackedWithHero = true;
            }

            if (p.enemyHero.Hp < old.enemyHero.Hp)
            {
                enemyHeroGotDmg = true;
            }

            if (attackedWithHero || attackedWithMob)
            {
                //check hero first, so we can exclude deathrattles!
                if (p.enemyHero.Hp < old.enemyHero.Hp)
                {
                    attackTargetIsMinion = 1;
                }

                int newDefenders = 0; int oldDefenders = 0;

                foreach (Minion m in p.ownMinions)
                {
                    newDefenders += m.Hp;
                }
                foreach (Minion m in old.ownMinions)
                {
                    oldDefenders += m.Hp;
                }

                if (newDefenders < oldDefenders)
                {
                    attackTargetIsMinion = 2;
                }
            }

            if (old.optionsPlayedThisTurn >= 0 && p.optionsPlayedThisTurn == 0)
            {
                endedTurn = true;
            }

            foreach (SecretItem si in this.enemySecrets)
            {
                if (attackedWithHero || attackedWithMob)
                {
                    si.usedTrigger_CharIsAttacked(attackTargetIsMinion == 1, attackedWithHero);
                }

                if (enemyHeroGotDmg)
                {
                    si.usedTrigger_HeroGotDmg();
                }

                if (enemyMinionDied)
                {
                    si.usedTrigger_MinionDied();
                }

                if (playedMob)
                {
                    si.usedTrigger_MinionIsPlayed(minionsOnBoard);
                }

                if (usedspell)
                {
                    si.usedTrigger_SpellIsPlayed(lastEffectedIsMinion == 2);
                }

                if (endedTurn)
                {
                    si.usedTrigger_EndTurn();
                }

                if (usedHeropower)
                {
                    si.usedTrigger_HeroPower();
                }
            }
        }
Esempio n. 16
0
       public Bot()
       {
           behave = this.getBotBehave();
           OnVictory = HandleWining;
            OnLost = HandleLosing;
            OnBattleStateUpdate = HandleOnBattleStateUpdate;
            OnMulliganStateUpdate = HandleBattleMulliganPhase;
            starttime = DateTime.Now;
            bool concede = false;
            bool writeToSingleFile = false;

           

            try
            {
                this.learnmode = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.wwuaid") == "true") ? true : false;
                if (this.learnmode)
                {
                    Helpfunctions.Instance.ErrorLog("Learn mode is ON");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("a wild error occurrs! cant read the settings...");
            }
            try
            {
                concede = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.autoconcede") == "true") ? true : false;
                writeToSingleFile = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.singleLog") == "true") ? true : false;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("a wild error occurrs! cant read the settings...");
            }
            try
            {
                this.concedeLvl = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.concedelvl")));
                if (this.concedeLvl >= 20) this.concedeLvl = 20;
                if (concede)
                {
                    Helpfunctions.Instance.ErrorLog("concede till rank " + concedeLvl);
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read your concede-Lvl");
            }

            /*try
            {
                this.stopAfterWins = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.stopwin")));
                if (this.stopAfterWins <= 0) this.stopAfterWins = 10000;
                Helpfunctions.Instance.ErrorLog("stop after " + stopAfterWins + " wins");
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read stop after # of wins");
            }*/

            try
            {
                this.enemyConcede = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyconcede") == "true") ? true : false;
                if (this.enemyConcede) Helpfunctions.Instance.ErrorLog("concede whether enemy has lethal");
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read enemy concede");
            }

            this.sf = new Silverfish(writeToSingleFile);


            CardDB cdb = CardDB.Instance;
            if (cdb.installedWrong) return;


            Mulligan.Instance.setAutoConcede(concede);

            sf.setnewLoggFile();

            try
            {
                int enfacehp = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyfacehp")));
                Helpfunctions.Instance.ErrorLog("set enemy-face-hp to: " + enfacehp);
                ComboBreaker.Instance.attackFaceHP = enfacehp;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading enemy-face-hp");
            }

            try
            {
                int mxwde = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.maxwide")));
                if (mxwde != 3000)
                {
                    Ai.Instance.setMaxWide(mxwde);
                    Helpfunctions.Instance.ErrorLog("set maxwide to: " + mxwde);
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading Maxwide from settings, please recheck the entry");
            }

           int twotsamount =0;
            try
            {
                //bool twots = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.simulateTwoTurns") == "true") ? true : false;
                twotsamount = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.simulateTwoTurnCounter")));
                if (twotsamount < 0) twotsamount = 0;
                Ai.Instance.setTwoTurnSimulation(false, twotsamount);
                Helpfunctions.Instance.ErrorLog("calculate the second turn of the " + twotsamount + " best boards");


            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading two-turn-simulation from settings");
            }

            if (twotsamount >= 1)
            {
                try
                {
                    bool enemySecondTurnSim = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.simulateEnemyOnSecondTurn") == "true") ? true : false;
                    Ai.Instance.nextTurnSimulator.setEnemyTurnsim(enemySecondTurnSim);
                    if(enemySecondTurnSim) Helpfunctions.Instance.ErrorLog("simulates the enemy turn on your second turn");


                }
                catch
                {
                    Helpfunctions.Instance.ErrorLog("error in reading enemys-two-turn-simulation from settings");
                }
            }

            try
            {
                bool playaround = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAround") == "true") ? true : false;
                int playaroundprob = Convert.ToInt32(HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAroundProb"));
                if (playaroundprob > 100) playaroundprob = 100;
                if (playaroundprob < 0) playaroundprob = 0;

                int playaroundprob2 = Convert.ToInt32(HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAroundProb2"));
                if (playaroundprob2 < playaroundprob) playaroundprob2 = playaroundprob;
                if (playaroundprob2 > 100) playaroundprob2 = 100;
                if (playaroundprob2 < 0) playaroundprob2 = 0;
                if (playaround)
                {
                    Ai.Instance.setPlayAround(playaround, playaroundprob, playaroundprob2);
                    Helpfunctions.Instance.ErrorLog("activated playaround");
                }

            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading play around settings");
            }

            Helpfunctions.Instance.ErrorLog("write to single log file is: " + writeToSingleFile);

            bool teststuff = false;
            bool printstuff = false;
            try
            {

                printstuff = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.longteststuff") == "true") ? true : false;
                teststuff = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.teststuff") == "true") ? true : false;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("something went wrong with simulating stuff!");
            }
            Helpfunctions.Instance.ErrorLog("----------------------------");
            Helpfunctions.Instance.ErrorLog("you are running uai V" + sf.versionnumber);
            Helpfunctions.Instance.ErrorLog("----------------------------");

            try
            {
                this.useExternalProcess = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.extern") == "true") ? true : false;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("rand read the external-process setting!");
            }

            if (this.useExternalProcess) Helpfunctions.Instance.ErrorLog("YOU USE SILVER.EXE FOR CALCULATION, MAKE SURE YOU STARTED IT!");
            if (this.useExternalProcess) Helpfunctions.Instance.ErrorLog("SILVER.EXE IS LOCATED IN: " + Settings.Instance.path);

            if (teststuff)
            {
                Ai.Instance.autoTester(printstuff);
            }
            writeSettings();
        }
Esempio n. 17
0
            public combo(string s, Silverfish sf)
            {
                int i = 0;
                this.neededMana = 0;
                requiredWeapon = CardDB.cardName.unknown;
                this.type = combotype.combo;
                this.twoTurnCombo = false;
                bool fixmana = false;
                if (s.Contains("nxttrn")) this.twoTurnCombo = true;
                if (s.Contains("mana:")) fixmana = true;

                /*foreach (string ding in s.Split(':'))
                {
                    if (i == 0)
                    {
                        if (ding == "c") this.type = combotype.combo;
                        if (ding == "t") this.type = combotype.target;
                        if (ding == "w") this.type = combotype.weaponuse;
                    }
                    if (ding == "" || ding == string.Empty) continue;

                    if (i == 1 && type == combotype.combo)
                    {
                        int m = Convert.ToInt32(ding);
                        neededMana = -1;
                        if (m >= 1) neededMana = m;
                    }
                */
                if (type == combotype.combo)
                {
                    this.combolength = 0;
                    this.combot0len = 0;
                    this.combot1len = 0;
                    this.combot0lenAll = 0;
                    int manat0 = 0;
                    int manat1 = -1;
                    bool t1 = false;
                    foreach (string crdl in s.Split(';')) //ding.Split
                    {
                        if (crdl == "" || crdl == string.Empty) continue;
                        if (crdl == "nxttrn")
                        {
                            t1 = true;
                            continue;
                        }
                        if (crdl.StartsWith("mana:"))
                        {
                            this.neededMana = Convert.ToInt32(crdl.Replace("mana:", ""));
                            continue;
                        }
                        if (crdl.StartsWith("hero:"))
                        {
                            this.oHero = sf.Hrtprozis.heroNametoEnum(crdl.Replace("hero:", ""));
                            continue;
                        }
                        if (crdl.StartsWith("bonus:"))
                        {
                            this.bonusForPlaying = Convert.ToInt32(crdl.Replace("bonus:", ""));
                            continue;
                        }
                        if (crdl.StartsWith("bonusfirst:"))
                        {
                            this.bonusForPlayingT0 = Convert.ToInt32(crdl.Replace("bonusfirst:", ""));
                            continue;
                        }
                        if (crdl.StartsWith("bonussecond:"))
                        {
                            this.bonusForPlayingT1 = Convert.ToInt32(crdl.Replace("bonussecond:", ""));
                            continue;
                        }
                        string crd = crdl.Split(',')[0];
                        if (t1)
                        {
                            manat1 += CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(crd)).cost;
                        }
                        else
                        {
                            manat0 += CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(crd)).cost;
                        }
                        this.combolength++;

                        if (combocards.ContainsKey(CardDB.Instance.cardIdstringToEnum(crd)))
                        {
                            combocards[CardDB.Instance.cardIdstringToEnum(crd)]++;
                        }
                        else
                        {
                            combocards.Add(CardDB.Instance.cardIdstringToEnum(crd), 1);
                            cardspen.Add(CardDB.Instance.cardIdstringToEnum(crd), Convert.ToInt32(crdl.Split(',')[1]));
                        }

                        if (this.twoTurnCombo)
                        {

                            if (t1)
                            {
                                if (this.combocardsTurn1.ContainsKey(CardDB.Instance.cardIdstringToEnum(crd)))
                                {
                                    combocardsTurn1[CardDB.Instance.cardIdstringToEnum(crd)]++;
                                }
                                else
                                {
                                    combocardsTurn1.Add(CardDB.Instance.cardIdstringToEnum(crd), 1);
                                }
                                this.combot1len++;
                            }
                            else
                            {
                                CardDB.Card lolcrd = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(crd));
                                if (lolcrd.type == CardDB.cardtype.MOB)
                                {
                                    if (this.combocardsTurn0Mobs.ContainsKey(CardDB.Instance.cardIdstringToEnum(crd)))
                                    {
                                        combocardsTurn0Mobs[CardDB.Instance.cardIdstringToEnum(crd)]++;
                                    }
                                    else
                                    {
                                        combocardsTurn0Mobs.Add(CardDB.Instance.cardIdstringToEnum(crd), 1);
                                    }
                                    this.combot0len++;
                                }
                                if (lolcrd.type == CardDB.cardtype.WEAPON)
                                {
                                    this.requiredWeapon = lolcrd.name;
                                }
                                if (this.combocardsTurn0All.ContainsKey(CardDB.Instance.cardIdstringToEnum(crd)))
                                {
                                    combocardsTurn0All[CardDB.Instance.cardIdstringToEnum(crd)]++;
                                }
                                else
                                {
                                    combocardsTurn0All.Add(CardDB.Instance.cardIdstringToEnum(crd), 1);
                                }
                                this.combot0lenAll++;
                            }
                        }


                    }
                    if (!fixmana)
                    {
                        this.neededMana = Math.Max(manat1, manat0);
                    }
                }

                /*if (i == 2 && type == combotype.combo)
                {
                    int m = Convert.ToInt32(ding);
                    penality = 0;
                    if (m >= 1) penality = m;
                }

                i++;
            }*/
                this.bonusForPlaying = Math.Max(bonusForPlaying, 1);
                this.bonusForPlayingT0 = Math.Max(bonusForPlayingT0, 1);
                this.bonusForPlayingT1 = Math.Max(bonusForPlayingT1, 1);
            }
Esempio n. 18
0
        //private static Movegenerator instance;

        //public static Movegenerator Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new Movegenerator());
        //    }
        //}

        public Movegenerator(Silverfish sf)
        {
            this.sf = sf;
            pen = sf.PenalityManager;
        }
Esempio n. 19
0
 public EnemyTurnSimulator(Silverfish sf) {
     this.sf = sf;
 }
Esempio n. 20
0
        public Bot()
        {
            behave                = this.getBotBehave();
            OnVictory             = HandleWining;
            OnLost                = HandleLosing;
            OnBattleStateUpdate   = HandleOnBattleStateUpdate;
            OnMulliganStateUpdate = HandleBattleMulliganPhase;
            starttime             = DateTime.Now;
            bool concede           = false;
            bool writeToSingleFile = false;

            try
            {
                this.learnmode = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.wwuaid") == "true") ? true : false;
                if (this.learnmode)
                {
                    Helpfunctions.Instance.ErrorLog("Learn mode is ON");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("a wild error occurrs! cant read the settings...");
            }
            try
            {
                concede           = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.autoconcede") == "true") ? true : false;
                writeToSingleFile = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.singleLog") == "true") ? true : false;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("a wild error occurrs! cant read the settings...");
            }
            try
            {
                this.concedeLvl = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.concedelvl")));
                if (this.concedeLvl >= 20)
                {
                    this.concedeLvl = 20;
                }
                if (concede)
                {
                    Helpfunctions.Instance.ErrorLog("concede till rank " + concedeLvl);
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read your concede-Lvl");
            }

            try
            {
                this.stopAfterWins = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.stopwin")));
                if (this.stopAfterWins <= 0)
                {
                    this.stopAfterWins = 10000;
                }
                Helpfunctions.Instance.ErrorLog("stop after " + stopAfterWins + " wins");
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read stop after # of wins");
            }

            try
            {
                this.enemyConcede = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyconcede") == "true") ? true : false;
                if (this.enemyConcede)
                {
                    Helpfunctions.Instance.ErrorLog("concede whether enemy has lethal");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("cant read enemy concede");
            }

            this.sf = new Silverfish(writeToSingleFile);


            CardDB cdb = CardDB.Instance;

            if (cdb.installedWrong)
            {
                return;
            }


            Mulligan.Instance.setAutoConcede(concede);

            sf.setnewLoggFile();

            try
            {
                int enfacehp = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyfacehp")));
                Helpfunctions.Instance.ErrorLog("set enemy-face-hp to: " + enfacehp);
                ComboBreaker.Instance.attackFaceHP = enfacehp;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading enemy-face-hp");
            }

            try
            {
                int mxwde = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.maxwide")));
                Ai.Instance.setMaxWide(mxwde);
                if (mxwde != 3000)
                {
                    Ai.Instance.setMaxWide(mxwde);
                    Helpfunctions.Instance.ErrorLog("set maxwide to: " + mxwde);
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading Maxwide from settings, please recheck the entry");
            }

            try
            {
                bool twots = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.simulateTwoTurns") == "true") ? true : false;
                Ai.Instance.setTwoTurnSimulation(twots);
                if (twots)
                {
                    Ai.Instance.setTwoTurnSimulation(twots);
                    Helpfunctions.Instance.ErrorLog("activated two turn simulation");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading two-turn-simulation from settings");
            }

            try
            {
                bool playaround     = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAround") == "true") ? true : false;
                int  playaroundprob = Convert.ToInt32(HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAroundProb"));
                if (playaroundprob > 100)
                {
                    playaroundprob = 100;
                }
                if (playaroundprob < 0)
                {
                    playaroundprob = 0;
                }

                int playaroundprob2 = Convert.ToInt32(HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAroundProb2"));
                if (playaroundprob2 < playaroundprob)
                {
                    playaroundprob2 = playaroundprob;
                }
                if (playaroundprob2 > 100)
                {
                    playaroundprob2 = 100;
                }
                if (playaroundprob2 < 0)
                {
                    playaroundprob2 = 0;
                }
                if (playaround)
                {
                    Ai.Instance.setPlayAround(playaround, playaroundprob, playaroundprob2);
                    Helpfunctions.Instance.ErrorLog("activated playaround");
                }
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("error in reading play around settings");
            }

            Helpfunctions.Instance.ErrorLog("write to single log file is: " + writeToSingleFile);

            bool teststuff  = false;
            bool printstuff = false;

            try
            {
                printstuff = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.longteststuff") == "true") ? true : false;
                teststuff  = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.teststuff") == "true") ? true : false;
            }
            catch
            {
                Helpfunctions.Instance.ErrorLog("something went wrong with simulating stuff!");
            }
            Helpfunctions.Instance.ErrorLog("----------------------------");
            Helpfunctions.Instance.ErrorLog("you are running uai V" + sf.versionnumber);
            Helpfunctions.Instance.ErrorLog("----------------------------");

            if (teststuff)
            {
                Ai.Instance.autoTester(behave, printstuff);
            }
            writeSettings();
        }
Esempio n. 21
0
        public Playfield(Playfield p)
        {
            sf = p.sf;

            this.nextEntity = p.nextEntity;

            this.isOwnTurn = p.isOwnTurn;
            this.turnCounter = p.turnCounter;

            this.attacked = p.attacked;
            this.sEnemTurn = p.sEnemTurn;
            this.ownController = p.ownController;
            //this.ownHeroEntity = p.ownHeroEntity;
            //this.enemyHeroEntity = p.enemyHeroEntity;

            this.evaluatePenality = p.evaluatePenality;
            this.ownSecretsIDList.AddRange(p.ownSecretsIDList);

            this.enemySecretCount = p.enemySecretCount;

            this.enemySecretList.Clear();

            if (sf.Settings.useSecretsPlayArround)
            {
                foreach (SecretItem si in p.enemySecretList)
                {
                    this.enemySecretList.Add(new SecretItem(si));
                }
            }

            this.mana = p.mana;
            this.manaTurnEnd = p.manaTurnEnd;
            this.ownMaxMana = p.ownMaxMana;
            this.enemyMaxMana = p.enemyMaxMana;
            addMinionsReal(p.ownMinions, ownMinions);
            addMinionsReal(p.enemyMinions, enemyMinions);
            this.ownHero = new Minion(p.ownHero);
            this.enemyHero = new Minion(p.enemyHero);
            addCardsReal(p.owncards);

            this.ownHeroName = p.ownHeroName;
            this.enemyHeroName = p.enemyHeroName;

            this.playactions.AddRange(p.playactions);
            this.complete = false;

            this.attackFaceHP = p.attackFaceHP;

            this.owncarddraw = p.owncarddraw;

            this.enemyWeaponAttack = p.enemyWeaponAttack;
            this.enemyWeaponDurability = p.enemyWeaponDurability;
            this.enemyWeaponName = p.enemyWeaponName;
            this.enemycarddraw = p.enemycarddraw;
            this.enemyAnzCards = p.enemyAnzCards;

            this.ownWeaponDurability = p.ownWeaponDurability;
            this.ownWeaponAttack = p.ownWeaponAttack;
            this.ownWeaponName = p.ownWeaponName;

            this.lostDamage = p.lostDamage;
            this.lostWeaponDamage = p.lostWeaponDamage;
            this.lostHeal = p.lostHeal;

            this.ownAbilityReady = p.ownAbilityReady;
            this.enemyAbilityReady = p.enemyAbilityReady;
            this.ownHeroAblility = new Handmanager.Handcard(p.ownHeroAblility);
            this.enemyHeroAblility = new Handmanager.Handcard(p.enemyHeroAblility);

            this.spellpower = 0;
            this.mobsplayedThisTurn = p.mobsplayedThisTurn;
            this.startedWithMobsPlayedThisTurn = p.startedWithMobsPlayedThisTurn;
            this.optionsPlayedThisTurn = p.optionsPlayedThisTurn;
            this.cardsPlayedThisTurn = p.cardsPlayedThisTurn;
            this.ueberladung = p.ueberladung;

            this.ownDeckSize = p.ownDeckSize;
            this.enemyDeckSize = p.enemyDeckSize;
            this.ownHeroFatigue = p.ownHeroFatigue;
            this.enemyHeroFatigue = p.enemyHeroFatigue;

            //need the following for manacost-calculation
            this.ownHeroHpStarted = p.ownHeroHpStarted;
            this.ownWeaponAttackStarted = p.ownWeaponAttackStarted;
            this.ownCardsCountStarted = p.ownCardsCountStarted;
            this.enemyCardsCountStarted = p.enemyCardsCountStarted;
            this.ownMobsCountStarted = p.ownMobsCountStarted;

            this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
            this.playedmagierinderkirintor = p.playedmagierinderkirintor;

            this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
            this.startedWithManagespenst = p.startedWithManagespenst;
            this.startedWithsoeldnerDerVenture = p.startedWithsoeldnerDerVenture;
            this.startedWithbeschwoerungsportal = p.startedWithbeschwoerungsportal;
            this.startedWithnerubarweblord = p.startedWithnerubarweblord;

            this.startedWithDamagedMinions = p.startedWithDamagedMinions;

            this.nerubarweblord = p.nerubarweblord;
            this.winzigebeschwoererin = p.winzigebeschwoererin;
            this.managespenst = p.managespenst;
            this.soeldnerDerVenture = p.soeldnerDerVenture;
            this.loatheb = p.loatheb;

            this.spellpower = p.spellpower;
            this.enemyspellpower = p.enemyspellpower;

            this.needGraveyard = p.needGraveyard;
            if (p.needGraveyard) this.diedMinions = new List<GraveYardItem>(p.diedMinions);
            this.OwnLastDiedMinion = p.OwnLastDiedMinion;

            //####buffs#############################

            this.anzOwnRaidleader = p.anzOwnRaidleader;
            this.anzEnemyRaidleader = p.anzEnemyRaidleader;
            this.anzOwnMalGanis = p.anzOwnMalGanis;
            this.anzEnemyMalGanis = p.anzEnemyMalGanis;
            this.anzOwnStormwindChamps = p.anzOwnStormwindChamps;
            this.anzEnemyStormwindChamps = p.anzEnemyStormwindChamps;
            this.anzOwnTundrarhino = p.anzOwnTundrarhino;
            this.anzEnemyTundrarhino = p.anzEnemyTundrarhino;
            this.anzOwnTimberWolfs = p.anzOwnTimberWolfs;
            this.anzEnemyTimberWolfs = p.anzEnemyTimberWolfs;
            this.anzMurlocWarleader = p.anzMurlocWarleader;
            this.anzGrimscaleOracle = p.anzGrimscaleOracle;
            this.anzOwnAuchenaiSoulpriest = p.anzOwnAuchenaiSoulpriest;
            this.anzEnemyAuchenaiSoulpriest = p.anzEnemyAuchenaiSoulpriest;
            this.anzOwnsorcerersapprentice = p.anzOwnsorcerersapprentice;
            this.anzOwnsorcerersapprenticeStarted = p.anzOwnsorcerersapprenticeStarted;
            this.anzEnemysorcerersapprentice = p.anzEnemysorcerersapprentice;
            this.anzEnemysorcerersapprenticeStarted = p.anzEnemysorcerersapprenticeStarted;
            this.anzOwnSouthseacaptain = p.anzOwnSouthseacaptain;
            this.anzEnemySouthseacaptain = p.anzEnemySouthseacaptain;
            this.anzOwnMechwarper = p.anzOwnMechwarper;
            this.anzOwnMechwarperStarted = p.anzOwnMechwarperStarted;
            this.anzEnemyMechwarper = p.anzEnemyMechwarper;
            this.anzEnemyMechwarperStarted = p.anzEnemyMechwarperStarted;
            this.anzOwnChromaggus = p.anzOwnChromaggus;
            this.anzEnemyChromaggus = p.anzEnemyChromaggus;
            this.anzOwnDragonConsort = p.anzOwnDragonConsort;
            this.anzOwnDragonConsortStarted = p.anzOwnDragonConsortStarted;

            this.anzEnemyTaunt = p.anzEnemyTaunt;
            this.ownMinionsDiedTurn = p.ownMinionsDiedTurn;
            this.enemyMinionsDiedTurn = p.enemyMinionsDiedTurn;

            this.feugenDead = p.feugenDead;
            this.stalaggDead = p.stalaggDead;

            this.weHavePlayedMillhouseManastorm = p.weHavePlayedMillhouseManastorm;

            this.doublepriest = p.doublepriest;
            this.enemydoublepriest = p.enemydoublepriest;

            this.ownBaronRivendare = p.ownBaronRivendare;
            this.enemyBaronRivendare = p.enemyBaronRivendare;

            this.weHaveSteamwheedleSniper = p.weHaveSteamwheedleSniper;
            this.enemyHaveSteamwheedleSniper = p.enemyHaveSteamwheedleSniper;
            //#########################################


            this.tempanzOwnCards = this.owncards.Count;
            this.tempanzEnemyCards = this.enemyAnzCards;

        }
Esempio n. 22
0
        public Playfield(Silverfish sf)
        {
            this.sf = sf;

            this.nextEntity = sf.hrtprozis.getMaxEntity();
            //this.simulateEnemyTurn = sf.Ai.simulateEnemyTurn;
            this.ownController = sf.Hrtprozis.getOwnController();

            //this.ownHeroEntity = sf.Hrtprozis.ownHeroEntity;
            //this.enemyHeroEntity = sf.Hrtprozis.enemyHeroEntitiy;

            this.mana = sf.Hrtprozis.currentMana;
            this.manaTurnEnd = this.mana;
            this.ownMaxMana = sf.Hrtprozis.ownMaxMana;
            this.enemyMaxMana = sf.Hrtprozis.enemyMaxMana;
            this.evaluatePenality = 0;
            this.ownSecretsIDList.AddRange(sf.Hrtprozis.ownSecretList);
            this.enemySecretCount = sf.Hrtprozis.enemySecretCount;


            this.attackFaceHP = sf.Hrtprozis.attackFaceHp;

            this.complete = false;

            addMinionsReal(sf.Hrtprozis.ownMinions, ownMinions);
            addMinionsReal(sf.Hrtprozis.enemyMinions, enemyMinions);
            this.ownHero = new Minion(sf.Hrtprozis.ownHero);
            this.enemyHero = new Minion(sf.Hrtprozis.enemyHero);
            addCardsReal(sf.Handmanager.handCards);

            this.enemySecretList.Clear();
            if (sf.Settings.useSecretsPlayArround)
            {
                foreach (SecretItem si in sf.Probabilitymaker.enemySecrets)
                {
                    this.enemySecretList.Add(new SecretItem(si));
                }
            }

            this.ownHeroName = sf.Hrtprozis.heroname;
            this.enemyHeroName = sf.Hrtprozis.enemyHeroname;
            this.ownHeroStartClass = sf.Hrtprozis.ownHeroStartClass;
            this.enemyHeroStartClass = sf.Hrtprozis.enemyHeroStartClass;

            /*
            this.enemyHeroHp = sf.Hrtprozis.enemyHp;
            this.ownHeroHp = sf.Hrtprozis.heroHp;
            this.ownHeroReady = sf.Hrtprozis.ownheroisread;
            this.ownHeroWindfury = sf.Hrtprozis.ownHeroWindfury;
            this.ownHeroNumAttackThisTurn = sf.Hrtprozis.ownHeroNumAttacksThisTurn;
            this.ownHeroFrozen = sf.Hrtprozis.herofrozen;
            this.enemyHeroFrozen = sf.Hrtprozis.enemyfrozen;
            this.ownheroAngr = sf.Hrtprozis.heroAtk;
            this.heroImmuneWhileAttacking = sf.Hrtprozis.heroImmuneToDamageWhileAttacking;
            this.ownHeroDefence = sf.Hrtprozis.heroDefence;
            this.enemyHeroDefence = sf.Hrtprozis.enemyDefence;
             */

            //####buffs#############################

            this.anzOwnRaidleader = 0;
            this.anzEnemyRaidleader = 0;
            this.anzOwnStormwindChamps = 0;
            this.anzEnemyStormwindChamps = 0;
            this.anzOwnTundrarhino = 0;
            this.anzEnemyTundrarhino = 0;
            this.anzOwnTimberWolfs = 0;
            this.anzEnemyTimberWolfs = 0;
            this.anzMurlocWarleader = 0;
            this.anzGrimscaleOracle = 0;
            this.anzOwnAuchenaiSoulpriest = 0;
            this.anzEnemyAuchenaiSoulpriest = 0;
            this.anzOwnsorcerersapprentice = 0;
            this.anzOwnsorcerersapprenticeStarted = 0;
            this.anzEnemysorcerersapprentice = 0;
            this.anzEnemysorcerersapprenticeStarted = 0;
            this.anzOwnSouthseacaptain = 0;
            this.anzEnemySouthseacaptain = 0;
            this.anzOwnDragonConsortStarted = 0;
            
            this.anzEnemyTaunt = 0;
            this.ownMinionsDiedTurn = 0;
            this.enemyMinionsDiedTurn = 0;

            this.feugenDead = sf.Probabilitymaker.feugenDead;
            this.stalaggDead = sf.Probabilitymaker.stalaggDead;

            this.weHavePlayedMillhouseManastorm = false;

            this.doublepriest = 0;
            this.enemydoublepriest = 0;

            this.ownBaronRivendare = 0;
            this.enemyBaronRivendare = 0;
            //#########################################

            this.ownWeaponDurability = sf.Hrtprozis.heroWeaponDurability;
            this.ownWeaponAttack = sf.Hrtprozis.heroWeaponAttack;
            this.ownWeaponName = sf.Hrtprozis.ownHeroWeapon;
            this.owncarddraw = 0;


            this.enemyWeaponAttack = sf.Hrtprozis.enemyWeaponAttack;//dont know jet
            this.enemyWeaponName = sf.Hrtprozis.enemyHeroWeapon;
            this.enemyWeaponDurability = sf.Hrtprozis.enemyWeaponDurability;
            this.enemycarddraw = 0;

            this.enemyAnzCards = sf.Handmanager.enemyAnzCards;

            this.ownAbilityReady = sf.Hrtprozis.ownAbilityisReady;
            this.ownHeroAblility = new Handmanager.Handcard(sf.Hrtprozis.heroAbility);
            this.enemyHeroAblility = new Handmanager.Handcard(sf.Hrtprozis.enemyAbility);
            this.enemyAbilityReady = false;


            this.mobsplayedThisTurn = sf.Hrtprozis.numMinionsPlayedThisTurn;
            this.startedWithMobsPlayedThisTurn = sf.Hrtprozis.numMinionsPlayedThisTurn;// only change mobsplayedthisturm
            this.cardsPlayedThisTurn = sf.Hrtprozis.cardsPlayedThisTurn;
            //todo:
            this.optionsPlayedThisTurn = sf.Hrtprozis.numOptionsPlayedThisTurn;

            this.ueberladung = sf.Hrtprozis.ueberladung;

            this.ownHeroFatigue = sf.Hrtprozis.ownHeroFatigue;
            this.enemyHeroFatigue = sf.Hrtprozis.enemyHeroFatigue;
            this.ownDeckSize = sf.Hrtprozis.ownDeckSize;
            this.enemyDeckSize = sf.Hrtprozis.enemyDeckSize;

            //need the following for manacost-calculation
            this.ownHeroHpStarted = this.ownHero.Hp;
            this.enemyHeroHpStarted = this.enemyHero.Hp;
            this.ownWeaponAttackStarted = this.ownWeaponAttack;
            this.ownCardsCountStarted = this.owncards.Count;
            this.enemyCardsCountStarted = this.enemyAnzCards;
            this.ownMobsCountStarted = this.ownMinions.Count + this.enemyMinions.Count;

            this.playedmagierinderkirintor = false;
            this.playedPreparation = false;

            this.winzigebeschwoererin = 0;
            this.managespenst = 0;
            this.soeldnerDerVenture = 0;
            this.beschwoerungsportal = 0;
            this.nerubarweblord = 0;

            this.startedWithnerubarweblord = 0;
            this.startedWithbeschwoerungsportal = 0;
            this.startedWithManagespenst = 0;
            this.startedWithWinzigebeschwoererin = 0;
            this.startedWithsoeldnerDerVenture = 0;

            this.ownBaronRivendare = 0;
            this.enemyBaronRivendare = 0;

            needGraveyard = false;
            this.loatheb = false;
            this.spellpower = 0;
            this.enemyspellpower = 0;

            this.startedWithDamagedMinions = false;

            foreach (Minion m in this.ownMinions)
            {
                if (m.Hp < m.maxHp && m.Hp >= 1) this.startedWithDamagedMinions = true;
                if (m.playedThisTurn && m.name == CardDB.cardName.loatheb) this.loatheb = true;

                spellpower = spellpower + m.spellpower;
                if (m.silenced) continue;
                spellpower += m.handcard.card.spellpowervalue;
                if (m.name == CardDB.cardName.prophetvelen) this.doublepriest++;


                if (m.name == CardDB.cardName.pintsizedsummoner)
                {
                    this.winzigebeschwoererin++;
                    this.startedWithWinzigebeschwoererin++;
                }

                if (m.name == CardDB.cardName.manawraith)
                {
                    this.managespenst++;
                    this.startedWithManagespenst++;
                }
                if (m.name == CardDB.cardName.nerubarweblord)
                {
                    this.nerubarweblord++;
                    this.startedWithnerubarweblord++;
                }
                if (m.name == CardDB.cardName.venturecomercenary)
                {
                    this.soeldnerDerVenture++;
                    this.startedWithsoeldnerDerVenture++;
                }
                if (m.name == CardDB.cardName.summoningportal)
                {
                    this.beschwoerungsportal++;
                    this.startedWithbeschwoerungsportal++;
                }

                if (m.handcard.card.name == CardDB.cardName.baronrivendare)
                {
                    this.ownBaronRivendare++;
                }
                if (m.handcard.card.name == CardDB.cardName.kelthuzad)
                {
                    this.needGraveyard = true;
                }

                if (m.name == CardDB.cardName.raidleader) this.anzOwnRaidleader++;
                if (m.name == CardDB.cardName.malganis) this.anzOwnMalGanis++;
                if (m.name == CardDB.cardName.stormwindchampion) this.anzOwnStormwindChamps++;
                if (m.name == CardDB.cardName.tundrarhino) this.anzOwnTundrarhino++;
                if (m.name == CardDB.cardName.timberwolf) this.anzOwnTimberWolfs++;
                if (m.name == CardDB.cardName.murlocwarleader) this.anzMurlocWarleader++;
                if (m.name == CardDB.cardName.grimscaleoracle) this.anzGrimscaleOracle++;
                if (m.name == CardDB.cardName.auchenaisoulpriest) this.anzOwnAuchenaiSoulpriest++;
                if (m.name == CardDB.cardName.sorcerersapprentice)
                {
                    this.anzOwnsorcerersapprentice++;
                    this.anzOwnsorcerersapprenticeStarted++;
                }
                if (m.name == CardDB.cardName.southseacaptain) this.anzOwnSouthseacaptain++;
                if (m.name == CardDB.cardName.chromaggus) this.anzOwnChromaggus++;
                if (m.name == CardDB.cardName.dragonconsort && anzOwnDragonConsort > 0) this.anzOwnDragonConsortStarted++;
                if (m.name == CardDB.cardName.mechwarper)
                {
                    this.anzOwnMechwarper++;
                    this.anzOwnMechwarperStarted++;
                }
                if (m.name == CardDB.cardName.steamwheedlesniper && this.ownHeroName == HeroEnum.hunter)
                {
                    this.weHaveSteamwheedleSniper = true;
                }

            }

            foreach (Handmanager.Handcard hc in this.owncards)
            {

                if (hc.card.name == CardDB.cardName.kelthuzad)
                {
                    this.needGraveyard = true;
                }
            }

            foreach (Minion m in this.enemyMinions)
            {
                this.enemyspellpower = this.enemyspellpower + m.spellpower;
                enemyspellpower += m.handcard.card.spellpowervalue;
                if (m.silenced) continue;
                if (m.taunt) anzEnemyTaunt++;
                if (m.name == CardDB.cardName.prophetvelen) this.enemydoublepriest++;
                if (m.name == CardDB.cardName.manawraith)
                {
                    this.managespenst++;
                    this.startedWithManagespenst++;
                }
                if (m.name == CardDB.cardName.nerubarweblord)
                {
                    this.nerubarweblord++;
                    this.startedWithnerubarweblord++;
                }
                if (m.handcard.card.name == CardDB.cardName.baronrivendare)
                {
                    this.enemyBaronRivendare++;
                }
                if (m.handcard.card.name == CardDB.cardName.kelthuzad)
                {
                    this.needGraveyard = true;
                }

                if (m.name == CardDB.cardName.raidleader) this.anzEnemyRaidleader++;
                if (m.name == CardDB.cardName.malganis) this.anzEnemyMalGanis++;
                if (m.name == CardDB.cardName.stormwindchampion) this.anzEnemyStormwindChamps++;
                if (m.name == CardDB.cardName.tundrarhino) this.anzEnemyTundrarhino++;
                if (m.name == CardDB.cardName.timberwolf) this.anzEnemyTimberWolfs++;
                if (m.name == CardDB.cardName.murlocwarleader) this.anzMurlocWarleader++;
                if (m.name == CardDB.cardName.grimscaleoracle) this.anzGrimscaleOracle++;
                if (m.name == CardDB.cardName.auchenaisoulpriest) this.anzEnemyAuchenaiSoulpriest++;
                if (m.name == CardDB.cardName.sorcerersapprentice)
                {
                    this.anzEnemysorcerersapprentice++;
                    this.anzEnemysorcerersapprenticeStarted++;
                }
                if (m.name == CardDB.cardName.southseacaptain) this.anzEnemySouthseacaptain++;
                if (m.name == CardDB.cardName.chromaggus) this.anzEnemyChromaggus++;
                if (m.name == CardDB.cardName.mechwarper)
                {
                    this.anzEnemyMechwarper++;
                    this.anzEnemyMechwarperStarted++;
                }
                if (m.name == CardDB.cardName.steamwheedlesniper && this.enemyHeroName == HeroEnum.hunter)
                {
                    this.enemyHaveSteamwheedleSniper = true;
                }
            }
            if (this.enemySecretCount >= 1) this.needGraveyard = true;
            if (this.needGraveyard) this.diedMinions = new List<GraveYardItem>(sf.Probabilitymaker.turngraveyard);

            this.tempanzOwnCards = this.owncards.Count;
            this.tempanzEnemyCards = this.enemyAnzCards;


        }
Esempio n. 23
0
        //private static PenalityManager instance;

        //public static PenalityManager Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new PenalityManager());
        //    }
        //}

        public PenalityManager(Silverfish sf)
        {
            this.sf = sf;
        }
Esempio n. 24
0
       public Bot()
       {
           
           behave = this.getBotBehave();
           OnVictory = HandleWining;
           OnLost = HandleLosing;
           OnBattleStateUpdate = HandleOnBattleStateUpdate;
           OnMulliganStateUpdate = HandleBattleMulliganPhase;
           starttime = DateTime.Now;
           bool concede = false;
           bool writeToSingleFile = false;

           try
           {
               this.learnmode = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.wwuaid") == "true") ? true : false;
               if (this.learnmode)
               {
                   Helpfunctions.Instance.ErrorLog("Learn mode is ON");
               }
           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("a wild error occurrs! cant read the settings...");
           }
           try
           {
               concede = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.autoconcede") == "true") ? true : false;
               writeToSingleFile = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.singleLog") == "true") ? true : false;
           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("a wild error occurrs! cant read the settings...");
           }
           try
           {
               this.concedeLvl = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.concedelvl")));
               if (this.concedeLvl >= 20) this.concedeLvl = 20;
               if (concede)
               {
                   Helpfunctions.Instance.ErrorLog("concede till rank " + concedeLvl);
               }
           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("cant read your concede-Lvl");
           }

           try
           {
               this.stopAfterWins = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.stopwin")));
               if (this.stopAfterWins <= 0) this.stopAfterWins = 10000;
               Helpfunctions.Instance.ErrorLog("stop after " + stopAfterWins + " wins");
           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("cant read stop after # of wins");
           }

           try
           {
               this.enemyConcede = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyconcede") == "true") ? true : false;
               if (this.enemyConcede) Helpfunctions.Instance.ErrorLog("concede whether enemy has lethal");
           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("cant read enemy concede");
           }

           this.sf = new Silverfish(writeToSingleFile);


           CardDB cdb = CardDB.Instance;
           if (cdb.installedWrong) return;


           Mulligan.Instance.setAutoConcede(concede);

           sf.setnewLoggFile();

           try
           {
               int enfacehp = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.enemyfacehp")));
               Helpfunctions.Instance.ErrorLog("set enemy-face-hp to: " + enfacehp);
               ComboBreaker.Instance.attackFaceHP = enfacehp;
           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("error in reading enemy-face-hp");
           }

           try
           {
               int mxwde = Convert.ToInt32((HRSettings.Get.ReadSetting("silverfish.xml", "uai.maxwide")));
               Ai.Instance.setMaxWide(mxwde);
               if (mxwde != 3000)
               {
                   Ai.Instance.setMaxWide(mxwde);
                   Helpfunctions.Instance.ErrorLog("set maxwide to: " + mxwde);
               }
           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("error in reading Maxwide from settings, please recheck the entry");
           }

           try
           {
               bool twots = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.simulateTwoTurns") == "true") ? true : false;
               Ai.Instance.setTwoTurnSimulation(twots);
               if (twots)
               {
                   Ai.Instance.setTwoTurnSimulation(twots);
                   Helpfunctions.Instance.ErrorLog("activated two turn simulation");
               }

           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("error in reading two-turn-simulation from settings");
           }

           try
           {
               bool playaround = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAround") == "true") ? true : false;
               int playaroundprob = Convert.ToInt32(HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAroundProb"));
               if (playaroundprob > 100) playaroundprob = 100;
               if (playaroundprob < 0) playaroundprob = 0;

               int playaroundprob2 = Convert.ToInt32(HRSettings.Get.ReadSetting("silverfish.xml", "uai.playAroundProb2"));
               if (playaroundprob2 < playaroundprob) playaroundprob2 = playaroundprob;
               if (playaroundprob2 > 100) playaroundprob2 = 100;
               if (playaroundprob2 < 0) playaroundprob2 = 0;
               if (playaround)
               {
                   Ai.Instance.setPlayAround(playaround,playaroundprob, playaroundprob2);
                   Helpfunctions.Instance.ErrorLog("activated playaround");
               }

           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("error in reading play around settings");
           }

           Helpfunctions.Instance.ErrorLog("write to single log file is: " + writeToSingleFile);

           bool teststuff = false;
           bool printstuff = false;
           try
           {

               printstuff = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.longteststuff") == "true") ? true : false;
               teststuff = (HRSettings.Get.ReadSetting("silverfish.xml", "uai.teststuff") == "true") ? true : false;
           }
           catch
           {
               Helpfunctions.Instance.ErrorLog("something went wrong with simulating stuff!");
           }
           Helpfunctions.Instance.ErrorLog("----------------------------");
           Helpfunctions.Instance.ErrorLog("you are running uai V"+sf.versionnumber);
           Helpfunctions.Instance.ErrorLog("----------------------------");

           if (teststuff)
           {
               Ai.Instance.autoTester(behave, printstuff);
           }
           writeSettings();
       }
Esempio n. 25
0
 public BehaviorMana(Silverfish sf)
 {
     this.sf = sf;
     penman = sf.PenalityManager;
 }
Esempio n. 26
0
        //public static ComboBreaker Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new ComboBreaker());
        //    }
        //}

        public ComboBreaker(Silverfish sf)
        {
            this.sf = sf;
            hm = sf.Handmanager;
            hp = sf.Hrtprozis;

            readCombos();
            if (attackFaceHP != -1)
            {
                hp.setAttackFaceHP(attackFaceHP);
            }
        }