//not updated anymore! public void printcards(bool writeTobuffer = false) { help.logg("Own Handcards: "); foreach (Handmanager.Handcard c in this.handCards) { help.logg("pos " + c.position + " " + c.card.name + " " + c.manacost + " entity " + c.entity + " " + c.card.cardIDenum + " " + c.addattack + " " + c.elemPoweredUp); } help.logg("Enemy cards: " + this.enemyAnzCards); //todo print died minions this turn! /*if(Ai.Instance.playaround) * { * if(Hrtprozis.Instance.enemyHeroname == HeroEnum.mage) * { * help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_032) + " " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_028)); * } * * if (Hrtprozis.Instance.enemyHeroname == HeroEnum.warrior) * { * help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_400)); * } * * if (Hrtprozis.Instance.enemyHeroname == HeroEnum.hunter) * { * help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_538)); * } * * if (Hrtprozis.Instance.enemyHeroname == HeroEnum.priest) * { * help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS1_112)); * } * * if (Hrtprozis.Instance.enemyHeroname == HeroEnum.shaman) * { * help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.EX1_259)); * } * * if (Hrtprozis.Instance.enemyHeroname == HeroEnum.pala) * { * help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_093)); * } * * if (Hrtprozis.Instance.enemyHeroname == HeroEnum.druid) * { * help.logg("probs: " + Probabilitymaker.Instance.anzCardsInDeck(CardDB.cardIDEnum.CS2_012)); * } * }*/ if (writeTobuffer) { help.writeToBuffer("Own Handcards: "); foreach (Handmanager.Handcard c in this.handCards) { help.writeToBuffer("pos " + c.position + " " + c.card.name + " " + c.manacost + " entity " + c.entity + " " + c.card.cardIDenum + " " + c.addattack); } help.writeToBuffer("Enemy cards: " + this.enemyAnzCards); //todo print died minions this turn! } }
public void Print(bool tobuffer = false) { Helpfunctions help = Helpfunctions.Instance; string discover = ""; if (this.tracking >= 1) { discover = " discover " + tracking; } if (tobuffer) { if (this.actionType == ActionType.PLAY_CARD) { string playaction = "play "; playaction += "id " + this.card.entity; if (this.target != null) { playaction += " target " + this.target.entityID; } if (this.place >= 0) { playaction += " pos " + this.place; } if (this.druidchoice >= 1) { playaction += " choice " + this.druidchoice; } help.writeToBuffer(playaction + discover); } if (this.actionType == ActionType.ATTACK_WITH_MINION && this.target != null) { help.writeToBuffer("attack " + this.own.entityID + " enemy " + this.target.entityID + discover); } if (this.actionType == ActionType.ATTACK_WITH_HERO && this.target != null) { help.writeToBuffer("heroattack " + this.target.entityID + discover); } if (this.actionType == ActionType.USE_HERO_POWER) { if (this.target != null) { help.writeToBuffer("useability on target " + this.target.entityID + discover); } else { help.writeToBuffer("useability" + discover); } } return; } //todo sepefeets - consider adding names into actions from the start instead of mapping them here string cardname = ""; string targetname = ""; Playfield tmpPf = new Playfield(); if (this.target != null) { foreach (Minion m in tmpPf.enemyMinions) { if (m.entityID == this.target.entityID) { targetname = "" + m.name; } } if (tmpPf.enemyHero.entityID == this.target.entityID) { targetname = "" + tmpPf.enemyHeroName; } } foreach (Minion m in tmpPf.ownMinions) { if (this.target != null && m.entityID == this.target.entityID) { targetname = "" + m.name; } if (this.card != null && m.entityID == this.card.entity) { cardname = "" + m.name; } if (this.own != null && m.entityID == this.own.entityID) { cardname = "" + m.name; } } if (this.target != null && tmpPf.ownHero.entityID == this.target.entityID) { targetname = "" + tmpPf.ownHeroName; } foreach (Handmanager.Handcard h in tmpPf.owncards) { if (this.card != null && h.entity == this.card.entity) { cardname = "" + h.card.name; } } if (this.actionType == ActionType.PLAY_CARD && this.card != null) { string playaction = "play "; playaction += cardname; playaction += " id " + this.card.entity; if (this.target != null) { playaction += ", target " + targetname + " id " + this.target.entityID; } if (this.place >= 0) { playaction += ", pos " + this.place; } if (this.druidchoice >= 1) { playaction += ", choice " + this.druidchoice; } help.logg(playaction + discover); } if (this.actionType == ActionType.ATTACK_WITH_MINION && this.target != null && this.own != null) { help.logg("attacker: " + cardname + " id " + this.own.entityID + ", enemy: " + targetname + " id " + this.target.entityID + discover); } if (this.actionType == ActionType.ATTACK_WITH_HERO && this.target != null) { help.logg("attack with hero, enemy: " + targetname + " id " + this.target.entityID + discover); } if (this.actionType == ActionType.USE_HERO_POWER) { help.logg("useability " + discover); if (this.target != null) { help.logg("on " + (target.own ? "own " : "enemy ") + targetname + " id " + this.target.entityID + discover); } } }
public void adjustActions(Playfield p, bool isLethalCheck) { if (p.enemySecretCount > 0) { return; } if (p.playactions.Count < 2) { return; } List <Action> reorderedActions = new List <Action>(); Dictionary <int, Dictionary <int, int> > rndActIdsDmg = new Dictionary <int, Dictionary <int, int> >(); Playfield tmpPlOld = new Playfield(); if (isLethalCheck) { if (Ai.Instance.botBase.getPlayfieldValue(p) < 10000) { return; } Playfield tmpPf = new Playfield(); if (tmpPf.anzEnemyTaunt > 0) { return; } Dictionary <Action, int> actDmgDict = new Dictionary <Action, int>(); tmpPf.enemyHero.Hp = 30; try { int useability = 0; foreach (Action a in p.playactions) { if (a.actionType == ActionType.USE_HERO_POWER) { useability = 1; } if (a.actionType == ActionType.ATTACK_WITH_HERO) { useability++; } int actDmd = tmpPf.enemyHero.Hp + tmpPf.enemyHero.armor; tmpPf.doAction(a); actDmd -= (tmpPf.enemyHero.Hp + tmpPf.enemyHero.armor); actDmgDict.Add(a, actDmd); } if (useability > 1) { return; } } catch { return; } foreach (var pair in actDmgDict.OrderByDescending(pair => pair.Value)) { reorderedActions.Add(pair.Key); } tmpPf = new Playfield(); foreach (Action a in reorderedActions) { if (!isActionPossible(tmpPf, a)) { return; } try { tmpPf.doAction(a); } catch { this.printError(p.playactions, reorderedActions, a); return; } } if (Ai.Instance.botBase.getPlayfieldValue(tmpPf) < 10000) { return; } } else { bool damageRandom = false; bool rndBeforeDamageAll = false; Action aa; for (int i = 0; i < p.playactions.Count; i++) { aa = p.playactions[i]; switch (aa.actionType) { case ActionType.PLAY_CARD: if (damageRandom && penman.DamageAllEnemysDatabase.ContainsKey(aa.card.card.name)) { rndBeforeDamageAll = true; } else if (penman.DamageRandomDatabase.ContainsKey(aa.card.card.name)) { damageRandom = true; } break; } } int aoeEnNum = 0; int outOfPlace = 0; bool totemiccall = false; List <Action> rndAct = new List <Action>(); List <Action> rndActTmp = new List <Action>(); for (int i = 0; i < p.playactions.Count; i++) { damageRandom = false; aa = p.playactions[i]; reorderedActions.Add(aa); switch (aa.actionType) { case ActionType.USE_HERO_POWER: if (aa.card.card.name == CardDB.cardName.totemiccall) { totemiccall = true; } break; case ActionType.PLAY_CARD: if (penman.DamageAllEnemysDatabase.ContainsKey(aa.card.card.name)) { if (i != aoeEnNum) { if (totemiccall && aa.card.card.type == CardDB.cardtype.SPELL) { return; } reorderedActions.RemoveAt(i); reorderedActions.Insert(aoeEnNum, aa); outOfPlace++; } aoeEnNum++; } else if (rndBeforeDamageAll && aa.card.card.type == CardDB.cardtype.SPELL && penman.DamageRandomDatabase.ContainsKey(aa.card.card.name)) { damageRandom = true; Playfield tmp = new Playfield(tmpPlOld); tmpPlOld.doAction(aa); Dictionary <int, int> actIdDmg = new Dictionary <int, int>(); if (tmp.enemyHero.Hp != tmpPlOld.enemyHero.Hp) { actIdDmg.Add(tmpPlOld.enemyHero.entityID, tmp.enemyHero.Hp - tmpPlOld.enemyHero.Hp); } if (tmp.ownHero.Hp != tmpPlOld.ownHero.Hp) { actIdDmg.Add(tmpPlOld.ownHero.entityID, tmp.ownHero.Hp - tmpPlOld.ownHero.Hp); } bool found = false; foreach (Minion m in tmp.enemyMinions) { found = false; foreach (Minion nm in tmpPlOld.enemyMinions) { if (m.entityID == nm.entityID) { found = true; if (m.Hp != nm.Hp) { actIdDmg.Add(m.entityID, m.Hp - nm.Hp); } break; } } if (!found) { actIdDmg.Add(m.entityID, m.Hp); } } foreach (Minion m in tmp.ownMinions) { found = false; foreach (Minion nm in tmpPlOld.ownMinions) { if (m.entityID == nm.entityID) { found = true; if (m.Hp != nm.Hp) { actIdDmg.Add(m.entityID, m.Hp - nm.Hp); } break; } } if (!found) { actIdDmg.Add(m.entityID, m.Hp); } } rndActIdsDmg.Add(aa.card.entity, actIdDmg); } break; } if (!damageRandom) { tmpPlOld.doAction(aa); } } if (outOfPlace == 0) { return; } Playfield tmpPf = new Playfield(); foreach (Action a in reorderedActions) { if (!isActionPossible(tmpPf, a)) { return; } try { if (!(a.actionType == ActionType.PLAY_CARD && rndActIdsDmg.ContainsKey(a.card.entity))) { tmpPf.doAction(a); } else { tmpPf.playactions.Add(a); Dictionary <int, int> actIdDmg = rndActIdsDmg[a.card.entity]; if (actIdDmg.ContainsKey(tmpPf.enemyHero.entityID)) { tmpPf.minionGetDamageOrHeal(tmpPf.enemyHero, actIdDmg[tmpPf.enemyHero.entityID]); } if (actIdDmg.ContainsKey(tmpPf.ownHero.entityID)) { tmpPf.minionGetDamageOrHeal(tmpPf.ownHero, actIdDmg[tmpPf.ownHero.entityID]); } foreach (Minion m in tmpPf.enemyMinions) { if (actIdDmg.ContainsKey(m.entityID)) { tmpPf.minionGetDamageOrHeal(m, actIdDmg[m.entityID]); } } foreach (Minion m in tmpPf.ownMinions) { if (actIdDmg.ContainsKey(m.entityID)) { tmpPf.minionGetDamageOrHeal(m, actIdDmg[m.entityID]); } } tmpPf.doDmgTriggers(); } } catch { printError(p.playactions, reorderedActions, a); return; } } tmpPf.lostDamage = tmpPlOld.lostDamage; float newval = Ai.Instance.botBase.getPlayfieldValue(tmpPf); float oldval = Ai.Instance.botBase.getPlayfieldValue(tmpPlOld); if (oldval > newval) { return; } } help.logg("Old order of actions:"); foreach (Action a in p.playactions) { a.Print(); } p.playactions.Clear(); p.playactions.AddRange(reorderedActions); help.logg("New order of actions:"); }
public void doallmoves(bool test, bool isLethalCheck) { //set maxwide to the value for the first-turn-sim. //foreach (EnemyTurnSimulator ets in enemyTurnSim) //{ // ets.setMaxwideFirstStep(true); //} //foreach (EnemyTurnSimulator ets in enemySecondTurnSim) //{ // ets.setMaxwideFirstStep(false); //} if (isLethalCheck) { this.posmoves[0].enemySecretList.Clear(); } this.mainTurnSimulator.doallmoves(this.posmoves[0], isLethalCheck); bestplay = this.mainTurnSimulator.bestboard; float bestval = this.mainTurnSimulator.bestmoveValue; help.loggonoff(true); help.logg("-------------------------------------"); help.logg("value of best board " + bestval); if (isLethalCheck) { this.lethalMissing = bestplay.enemyHero.armor + bestplay.enemyHero.Hp;//RR help.logg("missing dmg to lethal " + this.lethalMissing); } else { this.lethalMissing = 130; } //set best tracking this.bestTracking = 0; this.bestTrackingStatus = 0; if (Handmanager.Instance.getNumberChoices() >= 1) { selectBestTracking(); } //set best actions this.bestActions.Clear(); this.bestmove = null; foreach (Action a in bestplay.playactions) { this.bestActions.Add(new Action(a)); a.Print(); } //todo sepefeets - enable after implementing anzEnemyTaunt or finding alternative //if (isLethalCheck) reorderingActions(); if (this.bestActions.Count >= 1) { this.bestmove = this.bestActions[0]; this.bestActions.RemoveAt(0); } this.bestmoveValue = bestval; if (bestmove != null && bestmove.actionType != ActionType.END_TURN) // save the guessed move, so we doesnt need to recalc! { this.nextMoveGuess = new Playfield(); //TODO: add card if bestTracking was calculated! this.nextMoveGuess.doAction(bestmove); } else { nextMoveGuess.mana = -100; } }