public List <Action> doAllChoices(Playfield p, Handmanager.Handcard hc, bool lethalcheck, bool usePenalityManager) { List <Action> returnlist = new List <Action>(); if (hc.card.type == CardDB.cardtype.MOB && p.ownMinions.Count >= 7) { return(returnlist); } for (int i = 1; i < 3; i++) { CardDB.Card c = hc.card; if (c.name == CardDB.cardName.darkwispers) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.GVG_041a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.GVG_041b); } } if (c.name == CardDB.cardName.keeperofthegrove) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166b); } } if (c.name == CardDB.cardName.starfall) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_007b); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_007a); } } if (c.name == CardDB.cardName.ancientoflore) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_008a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_008b); } } if (c.name == CardDB.cardName.powerofthewild) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_160b); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_160a); } } if (c.name == CardDB.cardName.ancientofwar) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_178a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_178b); } } if (c.name == CardDB.cardName.druidoftheclaw) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_165t1); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_165t2); } } if (c.name == CardDB.cardName.druidoftheflame) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.BRM_010t); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.BRM_010t2); } } //cenarius dont need if (c.name == CardDB.cardName.keeperofthegrove)//keeper of the grove { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166b); } } if (c.name == CardDB.cardName.markofnature) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_155a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_155b); } } if (c.name == CardDB.cardName.nourish) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_164a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_164b); } } if (c.name == CardDB.cardName.wrath) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_154a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_154b); } } if (c.canplayCard(p, hc.manacost)) { int bestplace = p.getBestPlace(c, lethalcheck); List <Minion> trgts = c.getTargetsForCard(p); int cardplayPenality = 0; if (trgts.Count == 0) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(hc.card, null, p, i, lethalcheck); if (cardplayPenality <= 499) { //help.logg(hc.card.name + " is played"); //pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, i, bestplace, cardplayPenality); // i is the choice Action a = new Action(actionEnum.playcard, hc, null, bestplace, null, cardplayPenality, i); //pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, 0, bestplace, cardplayPenality); returnlist.Add(a); } } else { //pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, i, bestplace, cardplayPenality); Action a = new Action(actionEnum.playcard, hc, null, bestplace, null, cardplayPenality, i); returnlist.Add(a); } } else { foreach (Minion trgt in trgts) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(hc.card, trgt, p, i, lethalcheck); if (cardplayPenality <= 499) { //help.logg(hc.card.name + " is played"); //pf.playCard(hc, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i, bestplace, cardplayPenality); Action a = new Action(actionEnum.playcard, hc, null, bestplace, trgt, cardplayPenality, i); //i is the choice returnlist.Add(a); } } else { //pf.playCard(hc, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i, bestplace, cardplayPenality); Action a = new Action(actionEnum.playcard, hc, null, bestplace, trgt, cardplayPenality, i); //i is the choice returnlist.Add(a); } } } } } return(returnlist); }
private bool doAllChoices(Playfield p, Handmanager.Handcard hc, bool lethalcheck) { bool havedonesomething = false; for (int i = 1; i < 3; i++) { CardDB.Card c = hc.card; if (c.name == CardDB.cardName.keeperofthegrove) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166b); } } if (c.name == CardDB.cardName.starfall) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_007b); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_007a); } } if (c.name == CardDB.cardName.ancientoflore) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_008a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_008b); } } if (c.name == CardDB.cardName.powerofthewild) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_160b); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_160a); } } if (c.name == CardDB.cardName.ancientofwar) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_178a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_178b); } } if (c.name == CardDB.cardName.druidoftheclaw) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_165t1); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_165t2); } } //cenarius dont need if (c.name == CardDB.cardName.keeperofthegrove)//keeper of the grove { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166b); } } if (c.name == CardDB.cardName.markofnature) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_155a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_155b); } } if (c.name == CardDB.cardName.nourish) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_164a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_164b); } } if (c.name == CardDB.cardName.wrath) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_154a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_154b); } } if (c.canplayCard(p, hc.manacost)) { havedonesomething = true; int bestplace = p.getBestPlace(c, lethalcheck); List <targett> trgts = c.getTargetsForCard(p); int cardplayPenality = 0; if (trgts.Count == 0) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(hc.card, -1, p, i, lethalcheck); if (cardplayPenality <= 499) { //help.logg(hc.card.name + " is played"); Playfield pf = new Playfield(p); pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, i, bestplace, cardplayPenality); addToPosmoves(pf); } } else { Playfield pf = new Playfield(p); pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, i, bestplace, cardplayPenality); addToPosmoves(pf); } } else { foreach (targett trgt in trgts) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(hc.card, trgt.target, p, 0, lethalcheck); if (cardplayPenality <= 499) { //help.logg(hc.card.name + " is played"); Playfield pf = new Playfield(p); pf.playCard(hc, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i, bestplace, cardplayPenality); addToPosmoves(pf); } } else { Playfield pf = new Playfield(p); pf.playCard(hc, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i, bestplace, cardplayPenality); addToPosmoves(pf); } } } } } return(havedonesomething); }
private void doallmoves(bool test, BotBase botBase) { bool havedonesomething = true; List <Playfield> temp = new List <Playfield>(); int deep = 0; while (havedonesomething) { help.logg("ailoop"); temp.Clear(); temp.AddRange(this.posmoves); havedonesomething = false; Playfield bestold = null; int bestoldval = -20000000; foreach (Playfield p in temp) { if (p.complete) { continue; } //take a card and play it List <string> playedcards = new List <string>(); foreach (Handmanager.Handcard hc in p.owncards) { CardDB.Card c = hc.card; //help.logg("try play crd" + c.name + " " + c.getManaCost(p) + " " + c.canplayCard(p)); if (playedcards.Contains(c.name)) { continue; // dont play the same card in one loop } playedcards.Add(c.name); if (c.choice) { if (doAllChoices(c, p, hc)) { havedonesomething = true; } } else { if (c.canplayCard(p)) { havedonesomething = true; List <targett> trgts = c.getTargetsForCard(p); if (trgts.Count == 0) { Playfield pf = new Playfield(p); pf.playCard(c, hc.position - 1, hc.entity, -1, -1, 0); this.posmoves.Add(pf); } else { foreach (targett trgt in trgts) { Playfield pf = new Playfield(p); pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0); this.posmoves.Add(pf); } } } } } //attack with a minion foreach (Minion m in p.ownMinions) { if (m.Ready && m.Angr >= 1 && !m.frozen) { List <targett> trgts = p.getAttackTargets(); havedonesomething = true; foreach (targett trgt in trgts) { Playfield pf = new Playfield(p); pf.attackWithMinion(m, trgt.target, trgt.targetEntity); this.posmoves.Add(pf); } } } // attack with hero if (p.ownHeroReady) { List <targett> trgts = p.getAttackTargets(); havedonesomething = true; foreach (targett trgt in trgts) { Playfield pf = new Playfield(p); pf.attackWithWeapon(trgt.target, trgt.targetEntity); this.posmoves.Add(pf); } } // use ability /// TODO check if ready after manaup if (p.ownAbilityReady && p.mana >= 2) { havedonesomething = true; if (this.hp.heroname == "mage" || this.hp.heroname == "priest") { List <targett> trgts = p.ownHeroAblility.getTargetsForCard(p); foreach (targett trgt in trgts) { //if (this.hp.heroname == "priest" && trgt == 200) continue; havedonesomething = true; Playfield pf = new Playfield(p); pf.activateAbility(p.ownHeroAblility, this.hp.heroname, trgt.target, trgt.targetEntity); this.posmoves.Add(pf); } } else { havedonesomething = true; Playfield pf = new Playfield(p); pf.activateAbility(p.ownHeroAblility, this.hp.heroname, -1, -1); this.posmoves.Add(pf); } } p.complete = true; //sort stupid stuff ouf if (botBase.getPlayfieldValue(p) > bestoldval) { bestoldval = botBase.getPlayfieldValue(p); bestold = p; } if (!test) { posmoves.Remove(p); } } if (!test && bestoldval >= -10000 && bestold != null) { this.posmoves.Add(bestold); } help.loggonoff(true); int donec = 0; foreach (Playfield p in posmoves) { if (p.complete) { donec++; } } help.logg("deep " + deep + " len " + this.posmoves.Count + " dones " + donec); if (!test) { cuttingposibilities(botBase); } /*if ((deep + 1) % 4 == 0) * { * help.logg("cut"); * }*/ help.loggonoff(false); deep++; if (deep >= 20) { break; //remove this? } } int bestval = -10; int bestanzactions = 1000; Playfield bestplay = temp[0]; foreach (Playfield p in temp) { int val = botBase.getPlayfieldValue(p); if (bestval <= val) { if (bestval == val && bestanzactions < p.playactions.Count) { continue; } bestplay = p; bestval = val; bestanzactions = p.playactions.Count; } } help.loggonoff(true); help.logg("############################################"); help.logg("bestPlayvalue " + bestval); if (!test) { bestplay.doAction(); } bestplay.printActions(); this.bestmove = bestplay.getNextAction(); }
public List <Action> doAllChoices(Playfield p, Handmanager.Handcard hcc, bool lethalcheck, bool usePenalityManager, int tracing = 0) { int tracking = tracing; List <Action> returnlist = new List <Action>(); Handmanager.Handcard hc = hcc; if (hc.card.type == CardDB.cardtype.MOB && p.ownMinions.Count >= 7) { return(returnlist); } int max = 3; if (hc.card.cardIDenum == CardDB.cardIDEnum.AT_132_SHAMAN) { max = 5; } if (hc.isChoiceTemp) { max = Handmanager.Instance.getNumberChoices() + 1; } for (int j = 1; j < max; j++) { int i = j; CardDB.Card c = hc.card; int basemana = hc.manacost; if (c.cardIDenum == CardDB.cardIDEnum.AT_132_SHAMAN) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.AT_132_SHAMANa); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.AT_132_SHAMANb); } if (i == 3) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.AT_132_SHAMANc); } if (i == 4) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.AT_132_SHAMANd); } } if (c.name == CardDB.cardName.darkwispers) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.GVG_041a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.GVG_041b); } } if (c.name == CardDB.cardName.keeperofthegrove) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166b); } } if (c.name == CardDB.cardName.starfall) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_007b); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_007a); } } if (c.name == CardDB.cardName.ancientoflore) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_008a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.NEW1_008b); } } if (c.name == CardDB.cardName.powerofthewild) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_160b); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_160a); } } if (c.name == CardDB.cardName.ancientofwar) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_178b); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_178a); } } if (c.name == CardDB.cardName.druidoftheclaw) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_165t1); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_165t2); } } if (c.name == CardDB.cardName.druidoftheflame) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.BRM_010t); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.BRM_010t2); } } //cenarius dont need if (c.name == CardDB.cardName.keeperofthegrove)//keeper of the grove { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_166b); } } if (c.name == CardDB.cardName.markofnature) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_155a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_155b); } } if (c.name == CardDB.cardName.nourish) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_164a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_164b); } } if (c.name == CardDB.cardName.wrath) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_154a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.EX1_154b); } } if (c.name == CardDB.cardName.livingroots) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.AT_037a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.AT_037b); } } if (c.name == CardDB.cardName.druidofthesaber) { if (i == 1) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.AT_042a); } if (i == 2) { c = CardDB.Instance.getCardDataFromID(CardDB.cardIDEnum.AT_042b); } } if (hcc.isChoiceTemp) { i = 0;//its not a druid-choice tracking = j; hc = Handmanager.Instance.getCardChoice(tracking - 1); c = hc.card; //the tracking/discover card is a druid-choice-card himself :D if (c.choice) { //Helpfunctions.Instance.ErrorLog("choice tracking " + c.name); Handmanager.Handcard hccc = Handmanager.Instance.getCardChoice(tracking - 1); returnlist.AddRange(doAllChoices(p, hccc, lethalcheck, usePenalityManager, tracking)); continue; } basemana = c.cost; } if (c.canplayCard(p, basemana)) { int bestplace = p.getBestPlace(c, lethalcheck); List <Minion> trgts = c.getTargetsForCard(p); int cardplayPenality = 0; if (trgts.Count == 0) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(hc, null, p, i, lethalcheck); if (cardplayPenality <= 499) { //help.logg(hc.card.name + " is played"); //pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, i, bestplace, cardplayPenality); // i is the choice Action a = new Action(actionEnum.playcard, hc, null, bestplace, null, cardplayPenality, i, tracking); //pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, 0, bestplace, cardplayPenality); returnlist.Add(a); } } else { //pf.playCard(hc, hc.position - 1, hc.entity, -1, -1, i, bestplace, cardplayPenality); Action a = new Action(actionEnum.playcard, hc, null, bestplace, null, cardplayPenality, i, tracking); returnlist.Add(a); } } else { foreach (Minion trgt in trgts) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(hc, trgt, p, i, lethalcheck); if (cardplayPenality <= 499) { //help.logg(hc.card.name + " is played"); //pf.playCard(hc, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i, bestplace, cardplayPenality); Action a = new Action(actionEnum.playcard, hc, null, bestplace, trgt, cardplayPenality, i, tracking); //i is the choice returnlist.Add(a); } } else { //pf.playCard(hc, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i, bestplace, cardplayPenality); Action a = new Action(actionEnum.playcard, hc, null, bestplace, trgt, cardplayPenality, i, tracking); //i is the choice returnlist.Add(a); } } } } } return(returnlist); }
private bool doAllChoices(CardDB.Card card, Playfield p, Handmanager.Handcard hc) { bool havedonesomething = false; for (int i = 1; i < 3; i++) { CardDB.Card c = card; if (card.name == "sternenregen") { if (i == 1) { c = CardDB.Instance.getCardDataFromID("NEW1_007b"); } if (i == 2) { c = CardDB.Instance.getCardDataFromID("NEW1_007a"); } } if (card.name == "urtumderlehren") { if (i == 1) { c = CardDB.Instance.getCardDataFromID("NEW1_008a"); } if (i == 2) { c = CardDB.Instance.getCardDataFromID("NEW1_008b"); } } if (c.canplayCard(p)) { havedonesomething = true; List <targett> trgts = c.getTargetsForCard(p); if (trgts.Count == 0) { Playfield pf = new Playfield(p); pf.playCard(card, hc.position - 1, hc.entity, -1, -1, i); this.posmoves.Add(pf); } else { foreach (targett trgt in trgts) { Playfield pf = new Playfield(p); pf.playCard(card, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i); this.posmoves.Add(pf); } } } } return(havedonesomething); }