コード例 #1
0
ファイル: SilverFishBot.cs プロジェクト: shuyi3/AIPJ
        public bool updateEverything(HRSim.Playfield mp, bool own)
        {
            //HRSim.Helpfunctions.Instance.startTimer();
            HRSim.Player mPlayer, ePlayer;
            if (own)
            {
                mPlayer = mp.playerFirst;
                ePlayer = mp.playerSecond;
            }
            else
            {
                mPlayer = mp.playerSecond;
                ePlayer = mp.playerFirst;
            }

            this.updateBehaveString(botbase);

            updateHeroStuff(mp, own);
            updateMinions(mp, own);
            updateHandcards(mp, own);
            updateDecks(mp, own);

            // send ai the data:
            Hrtprozis.clearAll();
            Handmanager.clearAll();

            Hrtprozis.setOwnPlayer(mPlayer.ownController);
            Handmanager.setOwnPlayer(mPlayer.ownController);

            this.numOptionPlayedThisTurn  = 0;
            this.numOptionPlayedThisTurn += this.cardsPlayedThisTurn + this.ownHero.numAttacksThisTurn;
            foreach (Minion m in this.ownMinions)
            {
                if (m.Hp >= 1)
                {
                    this.numOptionPlayedThisTurn += m.numAttacksThisTurn;
                }
            }

            Hrtprozis.updatePlayer(this.ownMaxMana, this.currentMana, this.cardsPlayedThisTurn,
                                   this.numMinionsPlayedThisTurn, this.numOptionPlayedThisTurn, this.ueberladung, mPlayer.ownHero.entitiyID,
                                   mp.playerSecond.ownHero.entitiyID);
            Hrtprozis.updateSecretStuff(this.ownSecretList, this.enemySecretCount);

            Hrtprozis.updateOwnHero(this.ownHeroWeapon, this.heroWeaponAttack, this.heroWeaponDurability,
                                    this.heroname, this.heroAbility, this.ownAbilityisReady, this.ownHero);
            Hrtprozis.updateEnemyHero(this.enemyHeroWeapon, this.enemyWeaponAttack, this.enemyWeaponDurability,
                                      this.enemyHeroname, this.enemyMaxMana, this.enemyAbility, this.enemyHero);

            Hrtprozis.updateMinions(this.ownMinions, this.enemyMinions);
            Handmanager.setHandcards(this.handCards, this.anzcards, this.enemyAnzCards);

            Hrtprozis.updateFatigueStats(this.ownDecksize, this.ownHeroFatigue, this.enemyDecksize,
                                         this.enemyHeroFatigue);

            Hrtprozis.updateMaxEntity(mp.getNextEntity()); //change here!!

            Probabilitymaker.getEnemySecretGuesses(this.enemySecretList,
                                                   Hrtprozis.enemyHeroStartClass);
            //learnmode :D
            //HRSim.Helpfunctions.Instance.logTime("start to finish update");

            Playfield p = new Playfield(this);

            if (lastpf != null)
            {
                if (lastpf.isEqualf(p))
                {
                    return(false);
                }

                //board changed we update secrets!
                //if(Ai.nextMoveGuess!=null) Probabilitymaker.Instance.updateSecretList(Ai.nextMoveGuess.enemySecretList);
                Probabilitymaker.updateSecretList(p, lastpf);
                lastpf = p;
            }
            else
            {
                lastpf = p;
            }

            p = new Playfield(this); //secrets have updated :D

            p.printBoard();

            // calculate stuff
            HRSim.Helpfunctions.Instance.ErrorLog("calculating stuff... " + DateTime.Now.ToString("HH:mm:ss.ffff"));
            //if (runExtern)
            //{
            //    HRSim.Helpfunctions.Instance.logg("recalc-check###########");
            //    if (p.isEqual(Ai.nextMoveGuess, true))
            //    {
            //        //printstuff(false);
            //        Debug.WriteLine("equal");
            //        Ai.doNextCalcedMove();
            //    }
            //    else
            //    {
            //        //printstuff(true);
            //        Debug.WriteLine("not equal");
            //        //readActionFile(passiveWait);
            //    }
            //}
            //else
            //{
            // Drew: This prevents the freeze during AI updates, but no API functions may be called
            // during this time!
            //using (TritonHs.Memory.ReleaseFrame(true))
            //{
            //    printstuff(false);
            Ai.dosomethingclever(botbase);
            //}
            //}
            //HRSim.Helpfunctions.Instance.logTime("end of do sth clever");

            //Ai.bestmove = Movegenerator.getRandomMove(new Playfield(p), true, false, true);

            HRSim.Helpfunctions.Instance.ErrorLog("calculating ended! " + DateTime.Now.ToString("HH:mm:ss.ffff"));
            return(true);
        }
コード例 #2
0
ファイル: SilverFishBot.cs プロジェクト: shuyi3/AIPJ
        private void updateDecks(HRSim.Playfield p, bool own)
        {
            HRSim.Player mPlayer, ePlayer;
            if (own)
            {
                mPlayer = p.playerFirst;
                ePlayer = p.playerSecond;
            }
            else
            {
                mPlayer = p.playerSecond;
                ePlayer = p.playerFirst;
            }

            List <CardDB.cardIDEnum> ownCards   = new List <CardDB.cardIDEnum>();
            List <CardDB.cardIDEnum> enemyCards = new List <CardDB.cardIDEnum>();
            List <GraveYardItem>     graveYard  = new List <GraveYardItem>();

            //own hands
            foreach (HRSim.Handmanager.Handcard c in mPlayer.owncards)
            {
                CardDB.cardIDEnum mCardID = (CardDB.cardIDEnum)Enum.Parse(typeof(CardDB.cardIDEnum), c.card.cardIDenum.ToString());
                ownCards.Add(mCardID);
            }
            //own minions
            foreach (HRSim.Minion m in mPlayer.ownMinions)
            {
                CardDB.cardIDEnum mCardID = (CardDB.cardIDEnum)Enum.Parse(typeof(CardDB.cardIDEnum), m.handcard.card.cardIDenum.ToString());
                ownCards.Add(mCardID);
            }
            //own secret
            foreach (HRSim.CardDB.cardIDEnum c in mPlayer.ownSecretsIDList)
            {
                CardDB.cardIDEnum mCardID = (CardDB.cardIDEnum)Enum.Parse(typeof(CardDB.cardIDEnum), c.ToString());
                ownCards.Add(mCardID);
            }
            //own weapon
            CardDB.cardName weaponName = (CardDB.cardName)Enum.Parse(typeof(CardDB.cardName), mPlayer.ownWeaponName.ToString());
            ownCards.Add(CardDB.Instance.getCardData(weaponName).cardIDenum);

            //playerSecond.own minions
            foreach (HRSim.Minion m in p.playerSecond.ownMinions)
            {
                Minion mMinion = new Minion(m);
                ownCards.Add(mMinion.handcard.card.cardIDenum);
            }
            //playerSecond.own weapon
            weaponName = (CardDB.cardName)Enum.Parse(typeof(CardDB.cardName), p.playerSecond.ownWeaponName.ToString());
            ownCards.Add(CardDB.Instance.getCardData(weaponName).cardIDenum);

            //grave yard
            foreach (HRSim.GraveYardItem g in p.graveYard)
            {
                CardDB.cardIDEnum graveCardID = (CardDB.cardIDEnum)Enum.Parse(typeof(CardDB.cardIDEnum), g.cardid.ToString());
                GraveYardItem     mGraveItem  = new GraveYardItem(graveCardID, g.entity, g.own);
                graveYard.Add(mGraveItem);
            }

            Probabilitymaker.setOwnCards(ownCards);
            Probabilitymaker.setEnemyCards(enemyCards);
            bool isTurnStart = false;

            if (Ai.nextMoveGuess.mana == -100)
            {
                isTurnStart = true;
                Ai.updateTwoTurnSim();
            }
            Probabilitymaker.setGraveYard(graveYard, isTurnStart);
        }