/ai/action.cs
C# | 7414 lines | 6158 code | 930 blank | 326 comment | 2351 complexity | 32ee997c99d71ff7390718b10a55e5f8 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- // the ai :D
- //please ask/write me if you use this in your project
- using System;
- using System.Collections.Generic;
- using System.Text;
- //TODO:
- //cardids of duplicate + avenge
- //tueftlermeisteroberfunks
- //verrückter bomber ( 3 damage to random chars)
- //nozdormu (for computing time :D)
- //faehrtenlesen
- // lehrensucher cho
- //scharmuetzel kills all :D
- //hoggersmash
- namespace HREngine.Bots
- {
- public class Action
- {
- public bool cardplay = false;
- public bool heroattack = false;
- public bool useability = false;
- public bool minionplay = false;
- public Handmanager.Handcard handcard;
- public int cardEntitiy = -1;
- public int owntarget = -1; //= target where card/minion is placed
- public int ownEntitiy = -1;
- public int enemytarget = -1; // target where red arrow is placed
- public int enemyEntitiy = -1;
- public int druidchoice = 0; // 1 left card, 2 right card
- public int numEnemysBeforePlayed = 0;
- public bool comboBeforePlayed = false;
- public void print()
- {
- Helpfunctions help = Helpfunctions.Instance;
- help.logg("current Action: ");
- if (this.cardplay)
- {
- help.logg("play " + this.handcard.card.name);
- if (this.druidchoice >= 1) help.logg("choose choise " + this.druidchoice);
- help.logg("with entityid " + this.cardEntitiy);
- if (this.owntarget >= 0)
- {
- help.logg("on position " + this.owntarget);
- }
- if (this.enemytarget >= 0)
- {
- help.logg("and target to " + this.enemytarget + " " + this.enemyEntitiy);
- }
- }
- if (this.minionplay)
- {
- help.logg("attacker: " + this.owntarget + " enemy: " + this.enemytarget);
- help.logg("targetplace " + this.enemyEntitiy);
- }
- if (this.heroattack)
- {
- help.logg("attack with hero, enemy: " + this.enemytarget);
- help.logg("targetplace " + this.enemyEntitiy);
- }
- if (this.useability)
- {
- help.logg("useability ");
- if (this.enemytarget >= 0)
- {
- help.logg("on enemy: " + this.enemytarget + "targetplace " + this.enemyEntitiy);
- }
- }
- help.logg("");
- }
- }
- public class Playfield
- {
- public bool logging = false;
- public bool sEnemTurn = false;
- public int attackFaceHP = 15;
- public int evaluatePenality = 0;
- public int ownController = 0;
- public int ownHeroEntity = -1;
- public int enemyHeroEntity = -1;
- public int value = Int32.MinValue;
- public int guessingHeroHP = 30;
- public int mana = 0;
- public int enemyHeroHp = 30;
- public HeroEnum ownHeroName = HeroEnum.druid;
- public HeroEnum enemyHeroName = HeroEnum.druid;
- public bool ownHeroReady = false;
- public bool enemyHeroReady = false;
- public int ownHeroNumAttackThisTurn = 0;
- public int enemyHeroNumAttackThisTurn = 0;
- public bool ownHeroWindfury = false;
- public bool enemyHeroWindfury = false;
- public List<string> ownSecretsIDList = new List<string>();
- public int enemySecretCount = 0;
- public int ownHeroHp = 30;
- public int ownheroAngr = 0;
- public int enemyheroAngr = 0;
- public bool ownHeroFrozen = false;
- public bool enemyHeroFrozen = false;
- public bool heroImmuneWhileAttacking = false;
- public bool enemyheroImmuneWhileAttacking = false;
- public bool heroImmune = false;
- public bool enemyHeroImmune = false;
- public int ownWeaponDurability = 0;
- public int ownWeaponAttack = 0;
- public string ownWeaponName = "";
- public string enemyWeaponName = "";
-
- public int enemyWeaponAttack = 0;
- public int enemyWeaponDurability = 0;
- public List<Minion> ownMinions = new List<Minion>();
- public List<Minion> enemyMinions = new List<Minion>();
- public List<Handmanager.Handcard> owncards = new List<Handmanager.Handcard>();
- public List<Action> playactions = new List<Action>();
- public bool complete = false;
- public int owncarddraw = 0;
- public int ownHeroDefence = 0;
- public int enemycarddraw = 0;
- public int enemyAnzCards = 0;
- public int enemyHeroDefence = 0;
-
- public int doublepriest = 0;
- public int spellpower = 0;
- public bool auchenaiseelenpriesterin = false;
- public bool ownBaronRivendare = false;
- public bool enemyBaronRivendare = false;
- public bool playedmagierinderkirintor = false;
- public bool playedPreparation = false;
- public int winzigebeschwoererin = 0;
- public int startedWithWinzigebeschwoererin = 0;
- public int zauberlehrling = 0;
- public int startedWithZauberlehrling = 0;
- public int managespenst = 0;
- public int startedWithManagespenst = 0;
- public int soeldnerDerVenture = 0;
- public int startedWithsoeldnerDerVenture = 0;
- public int beschwoerungsportal = 0;
- public int startedWithbeschwoerungsportal = 0;
- public int ownWeaponAttackStarted = 0;
- public int ownMobsCountStarted = 0;
- public int ownCardsCountStarted = 0;
- public int ownHeroHpStarted = 30;
- public int enemyHeroHpStarted = 30;
- public int mobsplayedThisTurn = 0;
- public int startedWithMobsPlayedThisTurn = 0;
- public int cardsPlayedThisTurn = 0;
- public int ueberladung = 0; //=recall
- public int ownMaxMana = 0;
- public int enemyMaxMana = 0;
- public int lostDamage = 0;
- public int lostHeal = 0;
- public int lostWeaponDamage = 0;
- public int ownDeckSize = 30;
- public int enemyDeckSize = 30;
- public int ownHeroFatigue = 0;
- public int enemyHeroFatigue = 0;
- public bool ownAbilityReady = false;
- public CardDB.Card ownHeroAblility;
- public bool enemyAbilityReady = false;
- public CardDB.Card enemyHeroAblility;
- //Helpfunctions help = Helpfunctions.Instance;
- private void addMinionsReal(List<Minion> source, List<Minion> trgt)
- {
- foreach (Minion m in source)
- {
- trgt.Add(new Minion(m));
- }
- }
- private void addCardsReal(List<Handmanager.Handcard> source)
- {
- foreach (Handmanager.Handcard m in source)
- {
- this.owncards.Add(new Handmanager.Handcard(m));
- }
- }
- public Playfield()
- {
- //this.simulateEnemyTurn = Ai.Instance.simulateEnemyTurn;
- this.ownController = Hrtprozis.Instance.getOwnController();
- this.ownHeroEntity = Hrtprozis.Instance.ownHeroEntity;
- this.enemyHeroEntity = Hrtprozis.Instance.enemyHeroEntitiy;
- this.mana = Hrtprozis.Instance.currentMana;
- this.ownMaxMana = Hrtprozis.Instance.ownMaxMana;
- this.enemyMaxMana = Hrtprozis.Instance.enemyMaxMana;
- this.evaluatePenality = 0;
- this.ownSecretsIDList = Hrtprozis.Instance.ownSecretList;
- this.enemySecretCount = Hrtprozis.Instance.enemySecretCount;
- this.heroImmune = Hrtprozis.Instance.heroImmune;
- this.enemyHeroImmune = Hrtprozis.Instance.enemyHeroImmune;
- this.attackFaceHP = Hrtprozis.Instance.attackFaceHp;
- addMinionsReal(Hrtprozis.Instance.ownMinions, ownMinions);
- addMinionsReal(Hrtprozis.Instance.enemyMinions, enemyMinions);
- addCardsReal(Handmanager.Instance.handCards);
- this.enemyHeroHp = Hrtprozis.Instance.enemyHp;
- this.ownHeroName = Hrtprozis.Instance.heroname;
- this.enemyHeroName = Hrtprozis.Instance.enemyHeroname;
- this.ownHeroHp = Hrtprozis.Instance.heroHp;
- this.complete = false;
- this.ownHeroReady = Hrtprozis.Instance.ownheroisread;
- this.ownHeroWindfury = Hrtprozis.Instance.ownHeroWindfury;
- this.ownHeroNumAttackThisTurn = Hrtprozis.Instance.ownHeroNumAttacksThisTurn;
- this.ownHeroFrozen = Hrtprozis.Instance.herofrozen;
- this.enemyHeroFrozen = Hrtprozis.Instance.enemyfrozen;
- this.ownheroAngr = Hrtprozis.Instance.heroAtk;
- this.heroImmuneWhileAttacking = Hrtprozis.Instance.heroImmuneToDamageWhileAttacking;
- this.ownWeaponDurability = Hrtprozis.Instance.heroWeaponDurability;
- this.ownWeaponAttack = Hrtprozis.Instance.heroWeaponAttack;
- this.ownWeaponName = Hrtprozis.Instance.ownHeroWeapon;
- this.owncarddraw = 0;
- this.ownHeroDefence = Hrtprozis.Instance.heroDefence;
- this.enemyHeroDefence = Hrtprozis.Instance.enemyDefence;
- this.enemyWeaponAttack = Hrtprozis.Instance.enemyWeaponAttack;//dont know jet
- this.enemyWeaponName = Hrtprozis.Instance.enemyHeroWeapon;
- this.enemyWeaponDurability = Hrtprozis.Instance.enemyWeaponDurability;
- this.enemycarddraw = 0;
- this.enemyAnzCards = Handmanager.Instance.enemyAnzCards;
- this.ownAbilityReady = Hrtprozis.Instance.ownAbilityisReady;
- this.ownHeroAblility = Hrtprozis.Instance.heroAbility;
- this.enemyHeroAblility = Hrtprozis.Instance.enemyAbility;
- this.doublepriest = 0;
- this.spellpower = 0;
- this.mobsplayedThisTurn = Hrtprozis.Instance.numMinionsPlayedThisTurn;
- this.startedWithMobsPlayedThisTurn = Hrtprozis.Instance.numMinionsPlayedThisTurn;// only change mobsplayedthisturm
- this.cardsPlayedThisTurn = Hrtprozis.Instance.cardsPlayedThisTurn;
- this.ueberladung = Hrtprozis.Instance.ueberladung;
- this.ownHeroFatigue = Hrtprozis.Instance.ownHeroFatigue;
- this.enemyHeroFatigue = Hrtprozis.Instance.enemyHeroFatigue;
- this.ownDeckSize = Hrtprozis.Instance.ownDeckSize;
- this.enemyDeckSize = Hrtprozis.Instance.enemyDeckSize;
- //need the following for manacost-calculation
- this.ownHeroHpStarted = this.ownHeroHp;
- this.enemyHeroHpStarted = this.enemyHeroHp;
- this.ownWeaponAttackStarted = this.ownWeaponAttack;
- this.ownCardsCountStarted = this.owncards.Count;
- this.ownMobsCountStarted = this.ownMinions.Count + this.enemyMinions.Count;
- this.playedmagierinderkirintor = false;
- this.playedPreparation = false;
- this.zauberlehrling = 0;
- this.winzigebeschwoererin = 0;
- this.managespenst = 0;
- this.soeldnerDerVenture = 0;
- this.beschwoerungsportal = 0;
- this.startedWithbeschwoerungsportal = 0;
- this.startedWithManagespenst = 0;
- this.startedWithWinzigebeschwoererin = 0;
- this.startedWithZauberlehrling = 0;
- this.startedWithsoeldnerDerVenture = 0;
- this.ownBaronRivendare = false;
- this.enemyBaronRivendare = false;
- foreach (Minion m in this.ownMinions)
- {
- if (m.silenced) continue;
- if (m.name == "prophetvelen") this.doublepriest++;
- spellpower = spellpower + m.handcard.card.spellpowervalue;
- if (m.name == "auchenaisoulpriest") this.auchenaiseelenpriesterin = true;
- if (m.name == "pint-sizedsummoner")
- {
- this.winzigebeschwoererin++;
- this.startedWithWinzigebeschwoererin++;
- }
- if (m.name == "sorcerersapprentice")
- {
- this.zauberlehrling++;
- this.startedWithZauberlehrling++;
- }
- if (m.name == "manawraith")
- {
- this.managespenst++;
- this.startedWithManagespenst++;
- }
- if (m.name == "venturecomercenary")
- {
- this.soeldnerDerVenture++;
- this.startedWithsoeldnerDerVenture++;
- }
- if (m.name == "summoningportal")
- {
- this.beschwoerungsportal++;
- this.startedWithbeschwoerungsportal++;
- }
- if (m.handcard.card.specialMin == CardDB.specialMinions.baronrivendare)
- {
- this.ownBaronRivendare = true;
- }
- foreach (Enchantment e in m.enchantments)// only at first init needed, after that its copied
- {
- if (e.CARDID == "NEW1_036e" || e.CARDID == "NEW1_036e2") m.cantLowerHPbelowONE = true;
- }
- }
- foreach (Minion m in this.enemyMinions)
- {
- if (m.silenced) continue;
- if (m.name == "manawraith")
- {
- this.managespenst++;
- this.startedWithManagespenst++;
- }
- if (m.handcard.card.specialMin == CardDB.specialMinions.baronrivendare)
- {
- this.enemyBaronRivendare = true;
- }
- }
- }
- public Playfield(Playfield p)
- {
- this.sEnemTurn = p.sEnemTurn;
- this.ownController = p.ownController;
- this.ownHeroEntity = p.ownHeroEntity;
- this.enemyHeroEntity = p.enemyHeroEntity;
- this.evaluatePenality = p.evaluatePenality;
- foreach(string s in p.ownSecretsIDList)
- { this.ownSecretsIDList.Add(s); }
- this.enemySecretCount = p.enemySecretCount;
- this.mana = p.mana;
- this.ownMaxMana = p.ownMaxMana;
- this.enemyMaxMana = p.enemyMaxMana;
- addMinionsReal(p.ownMinions, ownMinions);
- addMinionsReal(p.enemyMinions, enemyMinions);
- addCardsReal(p.owncards);
- this.enemyHeroHp = p.enemyHeroHp;
- this.ownHeroName = p.ownHeroName;
- this.enemyHeroName = p.enemyHeroName;
- this.ownHeroHp = p.ownHeroHp;
- this.playactions.AddRange(p.playactions);
- this.complete = false;
- this.ownHeroReady = p.ownHeroReady;
- this.enemyHeroReady = p.enemyHeroReady;
- this.ownHeroNumAttackThisTurn = p.ownHeroNumAttackThisTurn;
- this.enemyHeroNumAttackThisTurn = p.enemyHeroNumAttackThisTurn;
- this.ownHeroWindfury = p.ownHeroWindfury;
- this.attackFaceHP = p.attackFaceHP;
- this.heroImmune = p.heroImmune;
- this.enemyHeroImmune = p.enemyHeroImmune;
- this.ownheroAngr = p.ownheroAngr;
- this.enemyheroAngr = p.enemyheroAngr;
- this.ownHeroFrozen = p.ownHeroFrozen;
- this.enemyHeroFrozen = p.enemyHeroFrozen;
- this.heroImmuneWhileAttacking = p.heroImmuneWhileAttacking;
- this.enemyheroImmuneWhileAttacking = p.enemyheroImmuneWhileAttacking;
- this.owncarddraw = p.owncarddraw;
- this.ownHeroDefence = p.ownHeroDefence;
- this.enemyWeaponAttack = p.enemyWeaponAttack;
- this.enemyWeaponDurability = p.enemyWeaponDurability;
- this.enemyWeaponName = p.enemyWeaponName;
- this.enemycarddraw = p.enemycarddraw;
- this.enemyAnzCards = p.enemyAnzCards;
- this.enemyHeroDefence = p.enemyHeroDefence;
- this.ownWeaponDurability = p.ownWeaponDurability;
- this.ownWeaponAttack = p.ownWeaponAttack;
- this.ownWeaponName = p.ownWeaponName;
- this.lostDamage = p.lostDamage;
- this.lostWeaponDamage = p.lostWeaponDamage;
- this.lostHeal = p.lostHeal;
- this.ownAbilityReady = p.ownAbilityReady;
- this.enemyAbilityReady = p.enemyAbilityReady;
- this.ownHeroAblility = p.ownHeroAblility;
- this.enemyHeroAblility = p.enemyHeroAblility;
- this.doublepriest = 0;
- this.spellpower = 0;
- this.mobsplayedThisTurn = p.mobsplayedThisTurn;
- this.startedWithMobsPlayedThisTurn = p.startedWithMobsPlayedThisTurn;
- this.cardsPlayedThisTurn = p.cardsPlayedThisTurn;
- this.ueberladung = p.ueberladung;
- this.ownDeckSize = p.ownDeckSize;
- this.enemyDeckSize = p.enemyDeckSize;
- this.ownHeroFatigue = p.ownHeroFatigue;
- this.enemyHeroFatigue = p.enemyHeroFatigue;
- //need the following for manacost-calculation
- this.ownHeroHpStarted = p.ownHeroHpStarted;
- this.enemyHeroHp = p.enemyHeroHp;
- this.ownWeaponAttackStarted = p.ownWeaponAttackStarted;
- this.ownCardsCountStarted = p.ownCardsCountStarted;
- this.ownMobsCountStarted = p.ownMobsCountStarted;
- this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
- this.playedmagierinderkirintor = p.playedmagierinderkirintor;
- this.startedWithZauberlehrling = p.startedWithZauberlehrling;
- this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
- this.startedWithManagespenst = p.startedWithManagespenst;
- this.startedWithsoeldnerDerVenture = p.startedWithsoeldnerDerVenture;
- this.startedWithbeschwoerungsportal = p.startedWithbeschwoerungsportal;
- this.ownBaronRivendare = false;
- this.enemyBaronRivendare = false;
- this.zauberlehrling = 0;
- this.winzigebeschwoererin = 0;
- this.managespenst = 0;
- this.soeldnerDerVenture = 0;
- foreach (Minion m in this.ownMinions)
- {
- if (m.silenced) continue;
- if (m.handcard.card.specialMin == CardDB.specialMinions.prophetvelen) this.doublepriest++;
- spellpower = spellpower + m.handcard.card.spellpowervalue;
- if (m.handcard.card.specialMin == CardDB.specialMinions.auchenaisoulpriest) this.auchenaiseelenpriesterin = true;
- if (m.handcard.card.specialMin == CardDB.specialMinions.pintsizedsummoner) this.winzigebeschwoererin++;
- if (m.handcard.card.specialMin == CardDB.specialMinions.sorcerersapprentice) this.zauberlehrling++;
- if (m.handcard.card.specialMin == CardDB.specialMinions.manawraith) this.managespenst++;
- if (m.handcard.card.specialMin == CardDB.specialMinions.venturecomercenary) this.soeldnerDerVenture++;
- if (m.handcard.card.specialMin == CardDB.specialMinions.summoningportal) this.beschwoerungsportal++;
- if (m.handcard.card.specialMin == CardDB.specialMinions.baronrivendare)
- {
- this.ownBaronRivendare = true;
- }
- }
- foreach (Minion m in this.enemyMinions)
- {
- if (m.silenced) continue;
- if (m.handcard.card.specialMin == CardDB.specialMinions.manawraith) this.managespenst++;
- if (m.handcard.card.specialMin == CardDB.specialMinions.baronrivendare)
- {
- this.enemyBaronRivendare = true;
- }
- }
- }
- public bool isEqual(Playfield p, bool logg)
- {
- if (logg)
- {
- if (this.value != p.value) return false;
- }
- if (this.enemySecretCount != p.enemySecretCount)
- {
-
- if(logg) Helpfunctions.Instance.logg("enemy secrets changed ");
- return false;
- }
- if (this.mana != p.mana || this.enemyMaxMana != p.enemyMaxMana || this.ownMaxMana != p.ownMaxMana)
- {
- if (logg) Helpfunctions.Instance.logg("mana changed " + this.mana + " " + p.mana + " " + this.enemyMaxMana + " " + p.enemyMaxMana + " " + this.ownMaxMana + " " + p.ownMaxMana);
- return false;
- }
- if (this.ownDeckSize != p.ownDeckSize || this.enemyDeckSize != p.enemyDeckSize || this.ownHeroFatigue != p.ownHeroFatigue || this.enemyHeroFatigue != p.enemyHeroFatigue)
- {
- if (logg) Helpfunctions.Instance.logg("deck/fatigue changed " + this.ownDeckSize + " " + p.ownDeckSize + " " + this.enemyDeckSize + " " + p.enemyDeckSize + " " + this.ownHeroFatigue + " " + p.ownHeroFatigue + " " + this.enemyHeroFatigue + " " + p.enemyHeroFatigue);
- }
- if (this.cardsPlayedThisTurn != p.cardsPlayedThisTurn || this.mobsplayedThisTurn != p.mobsplayedThisTurn || this.ueberladung != p.ueberladung)
- {
- if (logg) Helpfunctions.Instance.logg("stuff changed " + this.cardsPlayedThisTurn + " " + p.cardsPlayedThisTurn + " " + this.mobsplayedThisTurn + " " + p.mobsplayedThisTurn + " " + this.ueberladung + " " + p.ueberladung);
- return false;
- }
-
- if (this.ownHeroName != p.ownHeroName || this.enemyHeroName != p.enemyHeroName)
- {
- if (logg) Helpfunctions.Instance.logg("hero name changed ");
- return false;
- }
- if (this.ownHeroHp != p.ownHeroHp || this.ownheroAngr != p.ownheroAngr || this.ownHeroDefence != p.ownHeroDefence || this.ownHeroFrozen != p.ownHeroFrozen || this.heroImmuneWhileAttacking != p.heroImmuneWhileAttacking || this.heroImmune!=p.heroImmune)
- {
- if (logg) Helpfunctions.Instance.logg("ownhero changed " + this.ownHeroHp + " " + p.ownHeroHp + " " + this.ownheroAngr + " " + p.ownheroAngr + " " + this.ownHeroDefence + " " + p.ownHeroDefence + " " + this.ownHeroFrozen + " " + p.ownHeroFrozen + " " + this.heroImmuneWhileAttacking + " " + p.heroImmuneWhileAttacking + " " + this.heroImmune + " " + p.heroImmune);
- return false;
- }
- if (this.ownHeroReady != p.ownHeroReady || this.ownWeaponAttack != p.ownWeaponAttack || this.ownWeaponDurability != p.ownWeaponDurability || this.ownHeroNumAttackThisTurn != p.ownHeroNumAttackThisTurn || this.ownHeroWindfury != p.ownHeroWindfury)
- {
- if (logg) Helpfunctions.Instance.logg("weapon changed " + this.ownHeroReady + " " + p.ownHeroReady + " " + this.ownWeaponAttack + " " + p.ownWeaponAttack + " " + this.ownWeaponDurability + " " + p.ownWeaponDurability + " " + this.ownHeroNumAttackThisTurn + " " + p.ownHeroNumAttackThisTurn + " " + this.ownHeroWindfury + " " + p.ownHeroWindfury);
- return false;
- }
- if (this.enemyHeroHp != p.enemyHeroHp || this.enemyWeaponAttack != p.enemyWeaponAttack || this.enemyHeroDefence != p.enemyHeroDefence || this.enemyWeaponDurability != p.enemyWeaponDurability || this.enemyHeroFrozen != p.enemyHeroFrozen || this.enemyHeroImmune != p.enemyHeroImmune)
- {
- if (logg) Helpfunctions.Instance.logg("enemyhero changed " + this.enemyHeroHp + " " + p.enemyHeroHp + " " + this.enemyWeaponAttack + " " + p.enemyWeaponAttack + " " + this.enemyHeroDefence + " " + p.enemyHeroDefence + " " + this.enemyWeaponDurability + " " + p.enemyWeaponDurability + " " + this.enemyHeroFrozen + " " + p.enemyHeroFrozen + " " + this.enemyHeroImmune + " " + p.enemyHeroImmune);
- return false;
- }
- /*if (this.auchenaiseelenpriesterin != p.auchenaiseelenpriesterin || this.winzigebeschwoererin != p.winzigebeschwoererin || this.zauberlehrling != p.zauberlehrling || this.managespenst != p.managespenst || this.soeldnerDerVenture != p.soeldnerDerVenture || this.beschwoerungsportal != p.beschwoerungsportal || this.doublepriest != p.doublepriest)
- {
- Helpfunctions.Instance.logg("special minions changed " + this.auchenaiseelenpriesterin + " " + p.auchenaiseelenpriesterin + " " + this.winzigebeschwoererin + " " + p.winzigebeschwoererin + " " + this.zauberlehrling + " " + p.zauberlehrling + " " + this.managespenst + " " + p.managespenst + " " + this.soeldnerDerVenture + " " + p.soeldnerDerVenture + " " + this.beschwoerungsportal + " " + p.beschwoerungsportal + " " + this.doublepriest + " " + p.doublepriest);
- return false;
- }*/
- if (this.ownHeroAblility.name != p.ownHeroAblility.name)
- {
- if (logg) Helpfunctions.Instance.logg("hero ability changed ");
- return false;
- }
-
- if (this.spellpower != p.spellpower)
- {
- if (logg) Helpfunctions.Instance.logg("spellpower changed");
- return false;
- }
-
- if (this.ownMinions.Count != p.ownMinions.Count || this.enemyMinions.Count != p.enemyMinions.Count || this.owncards.Count != p.owncards.Count)
- {
- if (logg) Helpfunctions.Instance.logg("minions count or hand changed");
- return false;
- }
- bool minionbool = true;
- for (int i = 0; i < this.ownMinions.Count; i++)
- {
- Minion dis = this.ownMinions[i]; Minion pis = p.ownMinions[i];
- //if (dis.entitiyID == 0) dis.entitiyID = pis.entitiyID;
- //if (pis.entitiyID == 0) pis.entitiyID = dis.entitiyID;
- if (dis.entitiyID != pis.entitiyID) minionbool= false;
- if (dis.Angr != pis.Angr || dis.Hp != pis.Hp || dis.maxHp != pis.maxHp || dis.numAttacksThisTurn != pis.numAttacksThisTurn) minionbool = false;
- if (dis.Ready != pis.Ready) minionbool = false; // includes frozen, exhaunted
- if (dis.playedThisTurn != pis.playedThisTurn || dis.numAttacksThisTurn != pis.numAttacksThisTurn) minionbool = false;
- if (dis.silenced != pis.silenced || dis.stealth != pis.stealth || dis.taunt != pis.taunt || dis.windfury != pis.windfury || dis.wounded != pis.wounded || dis.zonepos != pis.zonepos) minionbool = false;
- if (dis.divineshild != pis.divineshild || dis.cantLowerHPbelowONE != pis.cantLowerHPbelowONE || dis.immune != pis.immune) minionbool = false;
-
- }
- if (minionbool == false)
- {
- if (logg) Helpfunctions.Instance.logg("ownminions changed");
- return false;
- }
-
- for (int i = 0; i < this.enemyMinions.Count; i++)
- {
- Minion dis = this.enemyMinions[i]; Minion pis = p.enemyMinions[i];
- //if (dis.entitiyID == 0) dis.entitiyID = pis.entitiyID;
- //if (pis.entitiyID == 0) pis.entitiyID = dis.entitiyID;
- if (dis.entitiyID != pis.entitiyID) minionbool = false;
- if (dis.Angr != pis.Angr || dis.Hp != pis.Hp || dis.maxHp != pis.maxHp || dis.numAttacksThisTurn != pis.numAttacksThisTurn) minionbool = false;
- if (dis.Ready != pis.Ready) minionbool = false; // includes frozen, exhaunted
- if (dis.playedThisTurn != pis.playedThisTurn || dis.numAttacksThisTurn != pis.numAttacksThisTurn) minionbool = false;
- if (dis.silenced != pis.silenced || dis.stealth != pis.stealth || dis.taunt != pis.taunt || dis.windfury != pis.windfury || dis.wounded != pis.wounded || dis.zonepos != pis.zonepos) minionbool = false;
- if (dis.divineshild != pis.divineshild || dis.cantLowerHPbelowONE != pis.cantLowerHPbelowONE || dis.immune != pis.immune) minionbool = false;
- }
- if (minionbool == false)
- {
- if (logg) Helpfunctions.Instance.logg("enemyminions changed");
- return false;
- }
- for (int i = 0; i < this.owncards.Count; i++)
- {
- Handmanager.Handcard dishc = this.owncards[i]; Handmanager.Handcard pishc = p.owncards[i];
- if ( dishc.position != pishc.position || dishc.entity != pishc.entity || dishc.getManaCost(this) != pishc.getManaCost(p))
- {
- if (logg) Helpfunctions.Instance.logg("handcard changed: " + dishc.card.name);
- return false;
- }
- }
- return true;
- }
- public void simulateEnemysTurn()
- {
- int maxwide = 20;
- this.enemyAbilityReady = true;
- this.enemyHeroNumAttackThisTurn = 0;
- this.enemyHeroWindfury = false;
- if (this.enemyWeaponName == "doomhammer") this.enemyHeroWindfury = true;
- this.enemyheroImmuneWhileAttacking = false;
- if (this.enemyWeaponName == "gladiatorslongbow") this.enemyheroImmuneWhileAttacking = true;
- if (!this.enemyHeroFrozen && this.enemyWeaponDurability > 0) this.enemyHeroReady = true;
- this.enemyheroAngr = this.enemyWeaponAttack;
- bool havedonesomething = true;
- List<Playfield> posmoves = new List<Playfield>();
- posmoves.Add(new Playfield(this));
- List<Playfield> temp = new List<Playfield>();
- int deep = 0;
-
- while (havedonesomething)
- {
- temp.Clear();
- temp.AddRange(posmoves);
- havedonesomething = false;
- Playfield bestold = null;
- int bestoldval = 20000000;
- foreach (Playfield p in temp)
- {
- if (p.complete)
- {
- continue;
- }
- List<Minion> playedMinions = new List<Minion>(8);
- foreach (Minion m in p.enemyMinions)
- {
- if (m.Ready && m.Angr >= 1 && !m.frozen)
- {
- //BEGIN:cut (double/similar) attacking minions out#####################################
- // DONT LET SIMMILAR MINIONS ATTACK IN ONE TURN (example 3 unlesh the hounds-hounds doesnt need to simulated hole)
- List<Minion> tempoo = new List<Minion>(playedMinions);
- bool dontattacked = true;
- bool isSpecial = PenalityManager.Instance.specialMinions.ContainsKey(m.name);
- foreach (Minion mnn in tempoo)
- {
- // special minions are allowed to attack in silended and unsilenced state!
- //help.logg(mnn.silenced + " " + m.silenced + " " + mnn.name + " " + m.name + " " + penman.specialMinions.ContainsKey(m.name));
- bool otherisSpecial = PenalityManager.Instance.specialMinions.ContainsKey(mnn.name);
- if ((!isSpecial || (isSpecial && m.silenced)) && (!otherisSpecial || (otherisSpecial && mnn.silenced))) // both are not special, if they are the same, dont add
- {
- if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous) dontattacked = false;
- continue;
- }
- if (isSpecial == otherisSpecial && !m.silenced && !mnn.silenced) // same are special
- {
- if (m.name != mnn.name) // different name -> take it
- {
- continue;
- }
- // same name -> test whether they are equal
- if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous) dontattacked = false;
- continue;
- }
- }
- if (dontattacked)
- {
- playedMinions.Add(m);
- }
- else
- {
- //help.logg(m.name + " doesnt need to attack!");
- continue;
- }
- //END: cut (double/similar) attacking minions out#####################################
- //help.logg(m.name + " is going to attack!");
- List<targett> trgts = p.getAttackTargets(false);
- if (true)//(this.useCutingTargets)
- {
- trgts = Ai.Instance.cutAttackTargets(trgts, p, false);
- }
- foreach (targett trgt in trgts)
- {
- Playfield pf = new Playfield(p);
- havedonesomething = true;
- pf.ENEMYattackWithMinion(m, trgt.target, trgt.targetEntity);
- posmoves.Add(pf);
- }
- if (trgts.Count == 1 && trgts[0].target == 100)//only enemy hero is available als attack
- {
- break;
- }
- }
- }
- // attacked with minions done
- // attack with hero
- if (p.enemyHeroReady)
- {
- List<targett> trgts = p.getAttackTargets(false);
- havedonesomething = true;
- if (true)//(this.useCutingTargets)
- {
- trgts = Ai.Instance.cutAttackTargets(trgts, p, false);
- }
- foreach (targett trgt in trgts)
- {
- Playfield pf = new Playfield(p);
- pf.ENEMYattackWithWeapon(trgt.target, trgt.targetEntity, 0);
- posmoves.Add(pf);
- }
- }
- // use ability
- /// TODO check if ready after manaup
-
- if (p.enemyAbilityReady && p.enemyHeroAblility.canplayCard(p, 0))
- {
- int abilityPenality = 0;
- havedonesomething = true;
- // if we have mage or priest, we have to target something####################################################
- if (p.enemyHeroName == HeroEnum.mage || p.enemyHeroName == HeroEnum.priest)
- {
- List<targett> trgts = p.enemyHeroAblility.getTargetsForCard(p);
- foreach (targett trgt in trgts)
- {
- Playfield pf = new Playfield(p);
- havedonesomething = true;
- pf.ENEMYactivateAbility(p.enemyHeroAblility, trgt.target, trgt.targetEntity);
- posmoves.Add(pf);
- }
- }
- else
- {
- // the other classes dont have to target####################################################
- Playfield pf = new Playfield(p);
- havedonesomething = true;
- pf.ENEMYactivateAbility(p.enemyHeroAblility, -1, -1);
- posmoves.Add(pf);
- }
- }
- p.endEnemyTurn();
- if (Ai.Instance.botBase.getPlayfieldValue(p) < bestoldval) // want the best enemy-play-> worst for us
- {
- bestoldval = Ai.Instance.botBase.getPlayfieldValue(p);
- bestold = p;
- }
- posmoves.Remove(p);
- if (posmoves.Count >= maxwide) break;
- }
- if ( bestoldval <= 10000 && bestold != null)
- {
- posmoves.Add(bestold);
- }
- deep++;
- if (posmoves.Count >= maxwide) break;
- }
- foreach (Playfield p in posmoves)
- {
- if (!p.complete) p.endEnemyTurn();
- }
- int bestval = int.MaxValue;
- Playfield bestplay = posmoves[0];
- foreach (Playfield p in posmoves)
- {
- int val = Ai.Instance.botBase.getPlayfieldValue(p);
- if (bestval > val)// we search the worst value
- {
- bestplay = p;
- bestval = val;
- }
- }
- this.value = bestplay.value;
- }
- public void prepareNextTurn()
- {
- this.ownMaxMana = Math.Min(10, this.ownMaxMana + 1);
- this.mana = this.ownMaxMana - this.ueberladung;
- foreach (Minion m in ownMinions)
- {
- m.Ready = true;
- m.numAttacksThisTurn = 0;
- m.playedThisTurn = false;
- }
- if (this.ownWeaponName != "") this.ownHeroReady = true;
- this.ownheroAngr = this.ownWeaponAttack;
- this.ownHeroFrozen = false;
- this.ownAbilityReady = true;
- this.complete = false;
- this.sEnemTurn = false;
- this.value = int.MinValue;
- }
- public List<targett> getAttackTargets(bool own)
- {
- List<targett> trgts = new List<targett>();
- List<targett> trgts2 = new List<targett>();
- bool hastanks = false;
- if (own)
- {
- trgts2.Add(new targett(200, this.enemyHeroEntity));
- foreach (Minion m in this.enemyMinions)
- {
- if (m.stealth) continue; // cant target stealth
- if (m.taunt)
- {
- hastanks = true;
- trgts.Add(new targett(m.id + 10, m.entitiyID));
- }
- else
- {
- trgts2.Add(new targett(m.id + 10, m.entitiyID));
- }
- }
- }
- else
- {
-
- foreach (Minion m in this.ownMinions)
- {
- if (m.stealth) continue; // cant target stealth
- if (m.taunt)
- {
- hastanks = true;
- trgts.Add(new targett(m.id, m.entitiyID));
- }
- else
- {
- trgts2.Add(new targett(m.id, m.entitiyID));
- }
- }
- if (trgts2.Count == 0) trgts2.Add(new targett(100, this.ownHeroEntity));
- }
- if (hastanks) return trgts;
- return trgts2;
- }
- public int getBestPlace(CardDB.Card card, bool lethal)
- {
- if (card.type != CardDB.cardtype.MOB) return 0;
- if (this.ownMinions.Count == 0) return 0;
- if (this.ownMinions.Count == 1) return 1;
- int[] places = new int[this.ownMinions.Count];
- int i = 0;
- int tempval = 0;
- if (lethal && card.specialMin == CardDB.specialMinions.defenderofargus)
- {
- i = 0;
- foreach (Minion m in this.ownMinions)
- {
- places[i] = 0;
- tempval = 0;
- if (m.Ready)
- {
- tempval -= m.Angr -1;
- if(m.windfury) tempval-=m.Angr -1;
- }
- places[i] = tempval;
- i++;
- }
- i = 0;
- int bestpl = 7;
- int bestval = 10000;
- foreach (Minion m in this.ownMinions)
- {
- int prev = 0;
- int next = 0;
- if (i >= 1) prev = places[i - 1];
- next = places[i];
- if (bestval > prev + next)
- {
- bestval = prev + next;
- bestpl = i;
- }
- i++;
- }
- return bestpl;
- }
- if (card.specialMin == CardDB.specialMinions.sunfuryprotector || card.specialMin == CardDB.specialMinions.defenderofargus) // bestplace, if right and left minions have no taunt + lots of hp, dont make priority-minions to taunt
- {
- i = 0;
- foreach (Minion m in this.ownMinions)
- {
- places[i] = 0;
- tempval = 0;
- if (!m.taunt)
- {
- tempval -= m.Hp;
- }
- else
- {
- tempval -= m.Hp+2;
- }
- if (m.handcard.card.specialMin == CardDB.specialMinions.flametonguetotem) tempval += 50;
- if (m.handcard.card.specialMin == CardDB.specialMinions.raidleader) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.grimscaleoracle) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.direwolfalpha) tempval += 50;
- if (m.handcard.card.specialMin == CardDB.specialMinions.murlocwarleader) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.southseacaptain) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.stormwindchampion) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.timberwolf) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.leokk) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.northshirecleric) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.sorcerersapprentice) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.pintsizedsummoner) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.summoningportal) tempval += 10;
- if (m.handcard.card.specialMin == CardDB.specialMinions.scavenginghyena) tempval += 10;
- places[i] = tempval;
- i++;
- }
- i = 0;
- int bestpl = 7;
- int bestval = 10000;
- foreach (Minion m in this.ownMinions)
- {
- int prev = 0;
- int next = 0;
- if (i >= 1) prev = places[i - 1];
- next = places[i];
- if(bestval > prev + next)
- {
- bestval = prev + next;
- bestpl = i;
- }
- i++;
- }
- return bestpl;
- }
- int cardIsBuffer = 0;
- bool placebuff = false;
- if (card.specialMin == CardDB.specialMinions.flametonguetotem || card.specialMin == CardDB.specialMinions.direwolfalpha)
- {
- placebuff = true;
- if (card.specialMin == CardDB.specialMinions.flametonguetotem) cardIsBuffer = 2;
- if (card.specialMin == CardDB.specialMinions.direwolfalpha) cardIsBuffer = 1;
- }
- bool commander = false;
- foreach (Minion m in this.ownMinions)
- {
- if (m.handcard.card.specialMin == CardDB.specialMinions.warsongcommander) commander = true;
- }
- foreach (Minion m in this.ownMinions)
- {
- if (m.handcard.card.specialMin == CardDB.specialMinions.flametonguetotem || m.handcard.card.specialMin == CardDB.specialMinions.direwolfalpha) placebuff = true;
- }
- //attackmaxing :D
- if (placebuff)
- {
-
- int cval = 0;
- if (card.Charge || (card.Attack <= 3 && commander))
- {
- cval = card.Attack;
- if (card.windfury) cval = card.Attack;
- }
- i = 0;
- int[] buffplaces = new int[this.ownMinions.Count];
- int gesval = 0;
- foreach (Minion m in this.ownMinions)
- {
- buffplaces[i] = 0;
- places[i] = 0;
- if (m.Ready)
- {
- tempval = m.Angr;
- if (m.windfury && m.numAttacksThisTurn == 0) tempval += m.Angr;
-
- }
- if (m.handcard.card.specialMin == CardDB.specialMinions.flametonguetotem )
- {
- buffplaces[i] = 2;
- }
- if (m.handcard.card.specialMin == CardDB.specialMinions.direwolfalpha)
- {
- buffplaces[i] = 1;
- }
- places[i] = tempval;
- gesval += tempval;
- i++;
- }
- int bplace = 0;
- int bvale = 0;
- tempval = 0;
- i = 0;
- for (int j = 0; j <= this.ownMinions.Count; j++)
- {
- tempval = gesval;
- int current = cval;
- int prev = 0;
- int next = 0;
- if (i >= 1)
- {
- tempval -= places[i - 1];
- prev = places[i - 1];
- prev+=cardIsBuffer;
- current+=buffplaces[i-1];
- if (i < this.ownMinions.Count)
- {
- prev -= buffplaces[i];
- }
- }
- if (i < this.ownMinions.Count)
- {
- tempval -= places[i];
- next = places[i];
- next += cardIsBuffer;
- current += buffplaces[i];
- if (i >= 1)
- {
- next -= buffplaces[i-1];
- }
- }
- tempval += current + prev + next;
- if (tempval > bvale)
- {
- bplace = i;
- bvale = tempval;
- }
- i++;
- }
- return bplace;
- }
- // normal placement
- int cardvalue = card.Attack * 2 + card.Health;
- if (card.tank)
- {
- cardvalue += 5;
- cardvalue += card.Health;
- }
- if (card.specialMin == CardDB.specialMinions.flametonguetotem) cardvalue += 90;
- if (card.specialMin == CardDB.specialMinions.raidleader) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.grimscaleoracle) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.direwolfalpha) cardvalue += 90;
- if (card.specialMin == CardDB.specialMinions.murlocwarleader) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.southseacaptain) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.stormwindchampion) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.timberwolf) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.leokk) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.northshirecleric) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.sorcerersapprentice) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.pintsizedsummoner) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.summoningportal) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.scavenginghyena) cardvalue += 10;
- if (card.specialMin == CardDB.specialMinions.faeriedragon) cardvalue += 40;
- cardvalue += 1;
- i = 0;
- foreach(Minion m in this.ownMinions)
- {
- places[i] = 0;
- tempval = m.Angr * 2 + m.maxHp;
- if (m.taunt)
- {
- tempval += 6;
- tempval += m.maxHp;
- }
- if (!m.silenced)
- {
- if (m.handcard.card.specialMin == Car…
Large files files are truncated, but you can click here to view the full file