public void ControlTest() { CardDB.Initialize(); BoardTester bt = new BoardTester(); Control behave = new Control(); Cast bc = behave.GetBestCast(bt.btPlayfield); Assert.Equal(0, bc.Position.X); Assert.Equal(0, bc.Position.Y); }
public void ApolloTest() { CardDB.Initialize(); BoardTester bt = new BoardTester(); Apollo behave = new Apollo(); Apollo.FillSettings(); Cast bc = behave.GetBestCast(bt.btPlayfield); bt.btPlayfield.print(); //Assert.Equal(0, bc.Position.X); //Assert.Equal(0, bc.Position.Y); }
public void autoTester(bool printstuff, string data = "", bool logg = true) { help.logg("simulating board "); BoardTester bt = new BoardTester(data); if (!bt.datareaded) { return; } //calculate the stuff posmoves.Clear(); posmoves.Add(new Playfield()); posmoves[0].sEnemTurn = Settings.Instance.simulateEnemysTurn; if (logg) { help.logg("readed:"); help.logg(posmoves[0].getCompleteBoardForSimulating("", "", "")); } if (logg) { foreach (Playfield p in this.posmoves) { p.value = botBase.getPlayfieldValue(p); p.printBoard(); } } help.logg("ownminionscount " + posmoves[0].ownMinions.Count); help.logg("owncardscount " + posmoves[0].owncards.Count); foreach (var item in this.posmoves[0].owncards) { if (item.canplayCard(posmoves[0])) { help.logg("card " + item.card.name + " is playable :" + item.canplayCard(posmoves[0]) + " cost/mana: " + item.manacost + "/" + posmoves[0].mana); } } if (Playfield.Instance.ownAbilityReady) { if (posmoves[0].ownHeroAblility.card.canplayCard(posmoves[0], 2)) { help.logg("ability " + posmoves[0].ownHeroAblility.card.name + " is playable :" + posmoves[0].ownHeroAblility.card.canplayCard(posmoves[0], 2) + " cost/mana: " + posmoves[0].ownHeroAblility.card.getManaCost(posmoves[0], 2) + "/" + posmoves[0].mana); } } else { help.logg("ability is NOT READY"); } // lethalcheck + normal DateTime strt = DateTime.Now; doallmoves(false, true); help.logg("calculated " + (DateTime.Now - strt).TotalSeconds); double timeneeded = 0; if (bestmoveValue < 8500) { posmoves.Clear(); posmoves.Add(new Playfield()); posmoves[0].sEnemTurn = Settings.Instance.simulateEnemysTurn; strt = DateTime.Now; doallmoves(false, false); timeneeded = (DateTime.Now - strt).TotalSeconds; help.logg("calculated 2 " + (DateTime.Now - strt).TotalSeconds); } if (printstuff) { this.mainTurnSimulator.printPosmoves(); simmulateWholeTurn(this.mainTurnSimulator.bestboard); help.logg("Best Board Actions:"); this.mainTurnSimulator.bestboard.printActions(); help.logg(""); help.logg("calculated " + timeneeded); } if (bt.boardToSimulate >= 0) { int input = 0; while (input >= 0) { Console.WriteLine("write Index of board you want to simulate:"); String cnslrdl = Console.ReadLine(); try { input = Convert.ToInt32(cnslrdl); simmulateWholeTurn(this.mainTurnSimulator.getBoard(input)); } catch { Console.WriteLine("testmode ended..."); input = -1; } } } else { //Console.WriteLine("notestmode"); } }
public List <double> autoTester(bool printstuff, string data = "", int mode = 0) //-mode: 0-all, 1-lethalcheck, 2-normal { List <double> retval = new List <double>(); double calcTime = 0; LogHelper.WriteCombatLog("simulating board "); BoardTester bt = new BoardTester(data); if (!bt.datareaded) { return(retval); } hp.printHero(); hp.printOwnMinions(); hp.printEnemyMinions(); hm.printcards(); //calculate the stuff posmoves.Clear(); Playfield pMain = new Playfield(); //pMain.ownHeroPowerCostLessOnce -= ChuckHelper.GetOwnHeroPowerCost(); //pMain.ownHeroPowerCostLessOnce = -1; pMain.print = printstuff; posmoves.Add(pMain); LogHelper.WriteCombatLog("### Print current board state start ###"); foreach (Playfield p in this.posmoves) { p.printBoard(); } LogHelper.WriteCombatLog("ownminionscount " + posmoves[0].ownMinions.Count); LogHelper.WriteCombatLog("owncardscount " + posmoves[0].owncards.Count); foreach (var item in this.posmoves[0].owncards) { LogHelper.WriteCombatLog("card " + item.card.name + " is playable :" + item.canplayCard(posmoves[0], true) + " cost/mana: " + item.manacost + "/" + posmoves[0].mana); } var heroAbilityCard = posmoves[0].ownHeroAblility.card; LogHelper.WriteCombatLog("ability " + heroAbilityCard.name + " is playable :" + heroAbilityCard.canplayCard(posmoves[0], 2, true) + " cost/mana: " + heroAbilityCard.getManaCost(posmoves[0], 2) + "/" + posmoves[0].mana); LogHelper.WriteCombatLog($"### Print current board state end ###{Environment.NewLine}{Environment.NewLine}"); DateTime strt = DateTime.Now; // lethalcheck if (mode == 0 || mode == 1) { doallmoves(false, true); calcTime = (DateTime.Now - strt).TotalSeconds; LogHelper.WriteCombatLog("calculated " + calcTime); retval.Add(calcTime); } if (Settings.Instance.berserkIfCanFinishNextTour > 0 && bestmoveValue > 5000) { } else if (bestmoveValue < 10000) { // normal if (mode == 0 || mode == 2) { posmoves.Clear(); pMain = new Playfield(); pMain.print = printstuff; //pMain.ownHeroPowerCostLessOnce = -1; posmoves.Add(pMain); strt = DateTime.Now; doallmoves(false, false); calcTime = (DateTime.Now - strt).TotalSeconds; LogHelper.WriteCombatLog("calculated " + calcTime); retval.Add(calcTime); } } if (printstuff) { this.mainTurnSimulator.printPosmoves(); simmulateWholeTurn(); LogHelper.WriteCombatLog("calculated " + calcTime); } return(retval); }