Exemple #1
0
        private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase()
        {
            HRLog.Write("handle mulligan");
            if (HRMulligan.IsMulliganActive())
            {
                var list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);

                foreach (var item in list)
                {
                    if (item.GetEntity().GetCost() >= 4)
                    {
                        HRLog.Write("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it cost is >= 4.");
                        HRMulligan.ToggleCard(item);
                    }
                    if (item.GetEntity().GetCardId() == "EX1_308" || item.GetEntity().GetCardId() == "EX1_622" || item.GetEntity().GetCardId() == "EX1_005")
                    {
                        HRLog.Write("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it is soulfire or shadow word: death");
                        HRMulligan.ToggleCard(item);
                    }
                }

                sf.setnewLoggFile();
                return(null);
                //HRMulligan.EndMulligan();
            }
            return(null);
        }
 public Bot()
 {
     OnBattleStateUpdate = HandleOnBattleStateUpdate;
       OnMulliganStateUpdate = HandleBattleMulliganPhase;
       this.sf = new Silverfish();
       sf.setnewLoggFile();
       //Ai.Instance.autoTester(this);
 }
Exemple #3
0
 public Bot()
 {
     OnBattleStateUpdate   = HandleOnBattleStateUpdate;
     OnMulliganStateUpdate = HandleBattleMulliganPhase;
     this.sf = new Silverfish();
     sf.setnewLoggFile();
     //Ai.Instance.autoTester(this);
 }
Exemple #4
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();
        }
Exemple #5
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...");
        }
Exemple #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;
            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();
        }
Exemple #7
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...");
        }
Exemple #8
0
        private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase()
        {
            if (Settings.Instance.learnmode)
            {
                return(new HREngine.API.Actions.MakeNothingAction());
            }
            //Helpfunctions.Instance.ErrorLog("handle mulligan");


            if (HRMulligan.IsMulliganActive())
            {
                var      list        = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);
                HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();
                HRPlayer ownPlayer   = HRPlayer.GetLocalPlayer();
                string   enemName    = Hrtprozis.Instance.heroIDtoName(enemyPlayer.GetHeroCard().GetEntity().GetCardId());
                string   ownName     = Hrtprozis.Instance.heroIDtoName(ownPlayer.GetHeroCard().GetEntity().GetCardId());
                if (Mulligan.Instance.hasmulliganrules(ownName, enemName))
                {
                    List <Mulligan.CardIDEntity> celist = new List <Mulligan.CardIDEntity>();
                    foreach (var item in list)
                    {
                        if (item.GetEntity().GetCardId() != "GAME_005")// dont mulligan coin
                        {
                            celist.Add(new Mulligan.CardIDEntity(item.GetEntity().GetCardId(), item.GetEntity().GetEntityId()));
                        }
                    }
                    List <int> mullientitys = Mulligan.Instance.whatShouldIMulligan(celist, ownName, enemName);
                    foreach (var item in list)
                    {
                        if (mullientitys.Contains(item.GetEntity().GetEntityId()))
                        {
                            Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because of your rules");
                            HRMulligan.ToggleCard(item);
                        }
                    }
                }
                else
                {
                    foreach (var item in list)
                    {
                        if (item.GetEntity().GetCost() >= 4)
                        {
                            Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it cost is >= 4.");
                            HRMulligan.ToggleCard(item);
                        }
                        if (item.GetEntity().GetCardId() == "EX1_308" || item.GetEntity().GetCardId() == "EX1_622" || item.GetEntity().GetCardId() == "EX1_005")
                        {
                            Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it is soulfire or shadow word: death");
                            HRMulligan.ToggleCard(item);
                        }
                    }
                }


                sf.setnewLoggFile();

                //writeSettings();

                if (Mulligan.Instance.loserLoserLoser)
                {
                    if (!autoconcede())
                    {
                        concedeVSenemy(ownName, enemName);
                    }
                }

                return(null);
                //HRMulligan.EndMulligan();
            }
            return(null);
        }
Exemple #9
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();
       }
Exemple #10
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();
        }
Exemple #11
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();
        }
Exemple #12
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);
               }
        }