public void Init(IHaveLog ctx, string imgName, string[] files, int top = 1, decimal threadHoldScala = (decimal)0.09) { _imgName = imgName; context = ctx; topX = top; foreach (var f in files) { if (f.EndsWith(".png")) { clicks.Add(new ImgChecksAndTags(f, threadHoldScala)); } } }
public static NameLevel GetStructureName(ccPoint loc, List <CommandInfo> results, IHaveLog context) { string[] tags = new string[] { GoldMine, ElixirCollector, TownHall, GoldStorage, ElixirStorage, Barracks, ArmyCamp, Laboratory, ClanCastle, }; var bottom = results.FirstOrDefault(r => r.command == "RecoResult_INFO_Bottom"); string best = ""; string bestTag = ""; if (bottom != null) { foreach (var tag in tags) { var res = LCS.LongestCommonSubsequence(tag.ToLower(), bottom.Text.ToLower()); if (res.Length > best.Length) { best = res; bestTag = tag; } } int bestDiff = bestTag.Length - best.Length; context.InfoLog($" at {loc.x},{loc.y} got {bottom.command}:{bottom.Text} diff {bestDiff}"); if (bestDiff < 3) { { var fullTxt = bottom.Text; if (fullTxt == null) { context.InfoLog("BESTTAG====> Can't find"); return(null); } context.InfoLog("BESTTAG====> " + bestTag + " " + best); int levelInd = fullTxt.IndexOf("level") + 5; if (levelInd < 0) { context.InfoLog("BESTTAG====> Can't find level"); return(null); } int endInd = fullTxt.IndexOf(")", levelInd); string level = ""; if (levelInd > 0 && endInd > levelInd) { level = fullTxt.Substring(levelInd, endInd - levelInd); } return(new NameLevel { name = bestTag, level = level, }); } } } return(null); }
public AutoResourceLoader(IHaveLog ctx, string imgName, string dataDir, int top = 1, decimal threadHoldScala = (decimal)0.09) { var files = Directory.GetFiles(dataDir); Init(ctx, imgName, files, top, threadHoldScala); }
public AutoResourceLoader(IHaveLog ctx, string imgName, string[] files, int top = 1, decimal threadHoldScala = (decimal)0.09) { Init(ctx, imgName, files, top, threadHoldScala); }
public static List <CommandInfo> GetAppInfo(string arguments, IHaveLog context) { var res = new List <CommandInfo>(); context.DebugLog($"GetAppInfo.Running command {arguments}"); var unparsedArg = Utils.runApp(arguments); context.DebugLog($"GetAppInfo: Above command got {unparsedArg}"); foreach (var cmd in unparsedArg.Split(new char[] { '\r', '\n' })) { if (cmd.Length < 2) { continue; } if (cmd.StartsWith("ERR:")) { context.DebugLog($"{cmd.Trim()} arg={arguments}"); continue; } if (cmd.StartsWith("*")) { continue; } context.DebugLog($" ***{cmd}"); try { if (cmd.StartsWith("RecoResult_")) { int sp = cmd.IndexOf(" "); res.Add(new CommandInfo { command = cmd.Substring(0, sp), Text = cmd.Substring(sp + 1).Trim() }); continue; } var cmds = cmd.Split(' '); var command = cmds[0]; int x = 0, y = 0; decimal cmpRes = decimal.MaxValue; if (cmds.Length > 2) { x = Convert.ToInt32(cmds[1]); y = Convert.ToInt32(cmds[2]); } if (cmds.Length > 3) { cmpRes = Convert.ToDecimal(cmds[3]); } string decision = null; if (cmds.Length > 4) { decision = cmds[4]; } string extraInfo = null; if (cmds.Length > 5) { extraInfo = cmds[5]; } res.Add(new CommandInfo { command = command, cmpRes = cmpRes, x = x, y = y, decision = decision, extraInfo = extraInfo }); } catch (Exception exc) { context.InfoLog("failed " + exc.Message + " " + cmd); context.InfoLog("StackTrace:" + exc.ToString()); throw exc; } } return(res); }