public void simmulateWholeTurn() { help.ErrorLog("########################################################################################################"); help.ErrorLog("simulate best board"); help.ErrorLog("########################################################################################################"); //this.bestboard.printActions(); Playfield tempbestboard = new Playfield(); tempbestboard.printBoard(); if (bestmove != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc! { bestmove.print(); tempbestboard.doAction(bestmove); } else { tempbestboard.mana = -100; } help.logg("-------------"); tempbestboard.printBoard(); foreach (Action bestmovee in this.bestActions) { help.logg("stepp"); if (bestmovee != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc! { bestmovee.print(); tempbestboard.doAction(bestmovee); } else { tempbestboard.mana = -100; } help.logg("-------------"); tempbestboard.printBoard(); } //help.logg("AFTER ENEMY TURN:" ); tempbestboard.sEnemTurn = true; tempbestboard.endTurn(false, this.playaround, false, Settings.Instance.playaroundprob, Settings.Instance.playaroundprob2); help.logg("ENEMY TURN:-----------------------------"); tempbestboard.value = int.MinValue; tempbestboard.prepareNextTurn(tempbestboard.isOwnTurn); Ai.Instance.enemyTurnSim[0].simulateEnemysTurn(tempbestboard, true, playaround, true, Settings.Instance.playaroundprob, Settings.Instance.playaroundprob2); }
public void simmulateWholeTurn() { help.ErrorLog("########################################################################################################"); help.ErrorLog("simulate best board"); help.ErrorLog("########################################################################################################"); //this.bestboard.printActions(); Playfield tempbestboard = new Playfield(); tempbestboard.printBoard(); if (bestmove != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc! { bestmove.print(); tempbestboard.doAction(bestmove); } else { tempbestboard.mana = -100; } help.logg("-------------"); tempbestboard.printBoard(); foreach (Action bestmovee in this.bestActions) { help.logg("stepp"); if (bestmovee != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc! { bestmovee.print(); tempbestboard.doAction(bestmovee); } else { tempbestboard.mana = -100; } help.logg("-------------"); tempbestboard.printBoard(); } //help.logg("AFTER ENEMY TURN:" ); }
public void sendCurrentBoardToClient() { //bool runEx = true; Helpfunctions hpf = Helpfunctions.Instance; player p = p2; player opponent = p1; if (this.currentplayer) { p = p1; opponent = p2; } //DO we need this? //hpf.resetBuffer(); //hpf.writeBufferToActionFile(p.client); hpf.resetBuffer(); string dtimes = DateTime.Now.ToString("HH:mm:ss:ffff"); /*int ownsecretcount = p.secrets.Count; * int enemySecretCount = opponent.secrets.Count; * * string enemysecretIds = ""; * enemysecretIds = Probabilitymaker.Instance.getEnemySecretData(); * * * hpf.writeToBuffer("#######################################################################"); * hpf.writeToBuffer("#######################################################################"); * hpf.writeToBuffer("start calculations, current time: " + dtimes + " V" + "115.55" + " " + p.settings); * hpf.writeToBuffer("#######################################################################"); * hpf.writeToBuffer("mana " + p.curMana + "/" + p.maxMana); * hpf.writeToBuffer("emana " + opponent.maxMana); * hpf.writeToBuffer("own secretsCount: " + ownsecretcount); * hpf.writeToBuffer("enemy secretsCount: " + enemySecretCount + " ;" + enemysecretIds); * * Hrtprozis.Instance.printHero(runEx); * Hrtprozis.Instance.printOwnMinions(runEx); * Hrtprozis.Instance.printEnemyMinions(runEx); * Handmanager.Instance.printcards(runEx); * Probabilitymaker.Instance.printTurnGraveYard(runEx); * Probabilitymaker.Instance.printGraveyards(runEx);*/ hpf.writeToBuffer(this.board.getCompleteBoardForSimulating(p.settings, "116.00", dtimes)); hpf.writeBufferToFile(p.client); hpf.ErrorLog("sended"); }
private void printError(List <Action> mainActList, List <Action> newActList, Action aError) { help.ErrorLog("Reordering actions error!"); LogHelper.WriteCombatLog("Reordering actions error!\r\nError in action:"); aError.print(); LogHelper.WriteCombatLog("Main order of actions:"); foreach (Action a in mainActList) { a.print(); } LogHelper.WriteCombatLog("New order of actions:"); foreach (Action a in newActList) { a.print(); } return; }
public void simmulateWholeTurnandPrint() { help.ErrorLog("###################################"); help.ErrorLog("what would silverfish do?---------"); help.ErrorLog("###################################"); if (this.bestmoveValue >= 10000) { help.ErrorLog("DETECTED LETHAL ###################################"); } //this.bestboard.printActions(); Playfield tempbestboard = new Playfield(); if (bestmove != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc! { tempbestboard.doAction(bestmove); tempbestboard.printActionforDummies(tempbestboard.playactions[tempbestboard.playactions.Count - 1]); if (this.bestActions.Count == 0) { help.ErrorLog("end turn"); } } else { tempbestboard.mana = -100; help.ErrorLog("end turn"); } foreach (Action bestmovee in this.bestActions) { if (bestmovee != null && bestmove.actionType != actionEnum.endturn) // save the guessed move, so we doesnt need to recalc! { //bestmovee.print(); tempbestboard.doAction(bestmovee); tempbestboard.printActionforDummies(tempbestboard.playactions[tempbestboard.playactions.Count - 1]); } else { tempbestboard.mana = -100; help.ErrorLog("end turn"); } } }
public void readCombos(string behavName) { if (!Silverfish.Instance.BehaviorPath.ContainsKey(behavName)) { help.ErrorLog(behavName + ": no special combos."); return; } string pathToCombo = Path.Combine(Silverfish.Instance.BehaviorPath[behavName], "_combo.txt"); if (!System.IO.File.Exists(pathToCombo)) { help.ErrorLog(behavName + ": no special combos."); return; } help.ErrorLog("[Combo] Load combos for " + behavName); string[] lines = new string[0] { }; combos.Clear(); playByValue.Clear(); try { lines = System.IO.File.ReadAllLines(pathToCombo); } catch { help.logg("cant find _combo.txt"); help.ErrorLog("cant find _combo.txt (if you dont created your own combos, ignore this message)"); return; } help.logg("read _combo.txt..."); help.ErrorLog("read _combo.txt..."); foreach (string line in lines) { if (line == "" || line == null) { continue; } if (line.StartsWith("//")) { continue; } if (line.Contains("weapon:")) { try { this.attackFaceHP = Convert.ToInt32(line.Replace("weapon:", "")); } catch { help.logg("combomaker cant read: " + line); help.ErrorLog("combomaker cant read: " + line); } } else { if (line.Contains("cardvalue:")) { try { string cardvalue = line.Replace("cardvalue:", ""); CardDB.cardIDEnum ce = cdb.cardIdstringToEnum(cardvalue.Split(',')[0]); int val = Convert.ToInt32(cardvalue.Split(',')[1]); if (this.playByValue.ContainsKey(ce)) { continue; } this.playByValue.Add(ce, val); //help.ErrorLog("adding: " + line); } catch { help.logg("combomaker cant read: " + line); help.ErrorLog("combomaker cant read: " + line); } } else { try { combo c = new combo(line); this.combos.Add(c); } catch { help.logg("combomaker cant read: " + line); help.ErrorLog("combomaker cant read: " + line); } } } } help.ErrorLog("[Combo] " + combos.Count + " combos loaded successfully, " + playByValue.Count + " values loaded successfully"); }
public void simmulateWholeTurnandPrint() { help.ErrorLog(""); help.ErrorLog("what would silverfish do?---------"); help.ErrorLog(""); //this.bestboard.printActions(); Playfield tempbestboard = new Playfield(); if (bestmove != null) // save the guessed move, so we doesnt need to recalc! { tempbestboard.printActionforDummies(bestmove); if (bestmove.cardplay) { //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality); Handmanager.Handcard hc = tempbestboard.owncards.Find(x => x.entity == bestmove.cardEntitiy); if (bestmove.owntarget >= 0 && bestmove.enemytarget >= 0 && bestmove.enemytarget <= 9 && bestmove.owntarget < bestmove.enemytarget) { tempbestboard.playCard(bestmove.handcard, hc.position - 1, hc.entity, bestmove.enemytarget - 1, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0); } else { tempbestboard.playCard(bestmove.handcard, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0); } } if (bestmove.minionplay) { //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality); Minion mm = tempbestboard.ownMinions.Find(x => x.entitiyID == bestmove.ownEntitiy); tempbestboard.attackWithMinion(mm, bestmove.enemytarget, bestmove.enemyEntitiy, 0); } if (bestmove.heroattack) { tempbestboard.attackWithWeapon(bestmove.enemytarget, bestmove.enemyEntitiy, 0); } if (bestmove.useability) { //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality); tempbestboard.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmove.enemytarget, bestmove.enemyEntitiy, 0); } } else { tempbestboard.mana = -1; help.ErrorLog("end turn"); } foreach (Action bestmovee in bestboard.playactions) { tempbestboard.printActionforDummies(bestmovee); if (bestmovee != null) // save the guessed move, so we doesnt need to recalc! { bestmovee.print(); if (bestmovee.cardplay) { //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality); Handmanager.Handcard hc = tempbestboard.owncards.Find(x => x.entity == bestmovee.cardEntitiy); if (bestmovee.owntarget >= 0 && bestmovee.enemytarget >= 0 && bestmovee.enemytarget <= 9 && bestmovee.owntarget < bestmovee.enemytarget) { tempbestboard.playCard(bestmovee.handcard, hc.position - 1, hc.entity, bestmovee.enemytarget - 1, bestmovee.enemyEntitiy, bestmovee.druidchoice, bestmovee.owntarget, 0); } else { tempbestboard.playCard(bestmovee.handcard, hc.position - 1, hc.entity, bestmovee.enemytarget, bestmovee.enemyEntitiy, bestmovee.druidchoice, bestmovee.owntarget, 0); } } if (bestmovee.minionplay) { //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality); Minion mm = tempbestboard.ownMinions.Find(x => x.entitiyID == bestmovee.ownEntitiy); tempbestboard.attackWithMinion(mm, bestmovee.enemytarget, bestmovee.enemyEntitiy, 0); } if (bestmovee.heroattack) { tempbestboard.attackWithWeapon(bestmovee.enemytarget, bestmovee.enemyEntitiy, 0); } if (bestmovee.useability) { //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality); tempbestboard.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmovee.enemytarget, bestmovee.enemyEntitiy, 0); } } else { tempbestboard.mana = -1; help.ErrorLog("end turn"); } } }
public void ReadCombos(string behavName, bool nameIsPath = false) { string pathToCombo = behavName; if (!nameIsPath) { if (!SilverFishBot.Instance.BehaviorPath.ContainsKey(behavName)) { help.ErrorLog(behavName + ": no special combos."); return; } pathToCombo = Path.Combine(SilverFishBot.Instance.BehaviorPath[behavName], "_combo.txt"); } if (!File.Exists(pathToCombo)) { help.InfoLog(behavName + ": no special combos."); return; } help.InfoLog($"[Combo] Load combos for {behavName}"); string[] lines = new string[0] { }; combos.Clear(); playByValue.Clear(); try { lines = File.ReadAllLines(pathToCombo); } catch (Exception ex) { LogHelper.WriteCombatLog("cant find _combo.txt"); help.ErrorLog(ex); help.ErrorLog("cant find _combo.txt (if you don't created your own combos, ignore this message)"); return; } help.InfoLog("read _combo.txt..."); foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } if (line.StartsWith("//")) { continue; } if (line.Contains("weapon:")) { try { this.attackFaceHP = Convert.ToInt32(line.Replace("weapon:", "")); } catch (Exception ex) { LogHelper.WriteCombatLog("combomaker cant read: " + line); help.ErrorLog(ex); help.ErrorLog("combomaker cant read: " + line); } } else { if (line.Contains("cardvalue:")) { try { string cardvalue = line.Replace("cardvalue:", ""); CardDB.cardIDEnum ce = cdb.cardIdstringToEnum(cardvalue.Split(',')[0]); int val = Convert.ToInt32(cardvalue.Split(',')[1]); if (this.playByValue.ContainsKey(ce)) { continue; } this.playByValue.Add(ce, val); //help.ErrorLog("adding: " + line); } catch (Exception ex) { LogHelper.WriteCombatLog("combomaker cant read: " + line); help.ErrorLog(ex); help.ErrorLog("combomaker cant read: " + line); } } else { try { combo c = new combo(line); this.combos.Add(c); } catch (Exception ex) { LogHelper.WriteCombatLog("combomaker cant read: " + line); help.ErrorLog(ex); help.ErrorLog("combomaker cant read: " + line); } } } } help.InfoLog("[Combo] " + combos.Count + " combos loaded successfully, " + playByValue.Count + " values loaded successfully"); }
public void readCombos(string behavName, bool nameIsPath = false) { string pathToCombo = behavName; if (!nameIsPath) { if (!Silverfish.Instance.BehaviorPath.ContainsKey(behavName)) { help.ErrorLog(behavName + ": 没有特定的“连招”."); return; } pathToCombo = Path.Combine(Silverfish.Instance.BehaviorPath[behavName], "_combo.txt"); } if (!System.IO.File.Exists(pathToCombo)) { help.ErrorLog(behavName + ": 没有特定的“连招”."); return; } help.ErrorLog("[连招功能] 成功加载“连招” " + behavName); string[] lines = new string[0] { }; combos.Clear(); playByValue.Clear(); try { lines = System.IO.File.ReadAllLines(pathToCombo); } catch { help.logg("没有发现“连招功能”文本 _combo.txt"); help.ErrorLog("“连招功能”文本 _combo.txt "); return; } help.logg("加载“连招功能”文本 _combo.txt..."); help.ErrorLog("加载“连招功能”文本 _combo.txt..."); foreach (string line in lines) { if (line == "" || line == null) { continue; } if (line.StartsWith("//")) { continue; } if (line.Contains("weapon:")) { try { this.attackFaceHP = Convert.ToInt32(line.Replace("weapon:", "")); } catch { help.logg("[连招功能]不能加载: " + line); help.ErrorLog("[连招功能]不能加载: " + line); } } else { if (line.Contains("cardvalue:")) { try { string cardvalue = line.Replace("cardvalue:", ""); CardDB.cardIDEnum ce = cdb.cardIdstringToEnum(cardvalue.Split(',')[0]); int val = Convert.ToInt32(cardvalue.Split(',')[1]); if (this.playByValue.ContainsKey(ce)) { continue; } this.playByValue.Add(ce, val); //help.ErrorLog("adding: " + line); } catch { help.logg("[连招功能]不能加载: " + line); help.ErrorLog("[连招功能]不能加载: " + line); } } else { try { combo c = new combo(line); this.combos.Add(c); } catch { help.logg("[连招功能]不能加载: " + line); help.ErrorLog("[连招功能]不能加载: " + line); } } } } help.ErrorLog("[连招功能] " + combos.Count + " “连招”功能激活成功, " + playByValue.Count + " 个权重值已加载"); }