Ejemplo n.º 1
0
        //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;
            }
        }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 public Helpfunctions(Silverfish sf)
 {
     //foreach (Window window in Application.Current.Windows)
     //{
     //    if (window.GetType() == typeof(HRSim.MainWindow))
     //    {
     //        this.window = (HRSim.MainWindow)window;
     //    }
     //}
     this.sf = sf;
     //System.IO.File.WriteAllText(sf.Settings.logpath + sf.Settings.logfile, "");
 }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
        public Bot(Silverfish sf)
        {
            //starttime = DateTime.Now;
            //Settings set = Settings.Instance;
            //this.sf = sf;
            //set.setSettings();
            //sf.setnewLoggFile();

            //bool teststuff = true;
            //bool printstuff = false;

            //if (teststuff)
            //{
            //    Helpfunctions.Instance.logg("teststuff");
            //    Playfield p = new Playfield();
            //    Ai.Instance.autoTester( printstuff);
            //}
            //Helpfunctions.Instance.ErrorLog("wait for board...");
        }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
0
 public BehaviorMana(Silverfish sf)
 {
     this.sf = sf;
     penman  = sf.PenalityManager;
 }
Ejemplo n.º 8
0
 public EnemyTurnSimulator(Silverfish sf)
 {
     this.sf = sf;
 }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
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();
        }
Ejemplo n.º 11
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;

            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;
                }
            }


            //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;
                }
            }


            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();
                }

                if (usedspell)
                {
                    si.usedTrigger_SpellIsPlayed(lastEffectedIsMinion == 2);
                }
            }
        }
Ejemplo n.º 12
0
        //private static Probabilitymaker instance;
        //public static Probabilitymaker Instance
        //{
        //    get
        //    {
        //        return instance ?? (instance = new Probabilitymaker());
        //    }
        //}

        public Probabilitymaker(Silverfish sf)
        {
            this.sf = sf;
        }
Ejemplo n.º 13
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);
            }
Ejemplo n.º 14
0
 public MiniSimulatorNextTurn(Silverfish sf)
 {
     this.sf        = sf;
     this.bestboard = new Playfield(sf);
 }
Ejemplo n.º 15
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;
        }