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