public void PointBasedVI(int cBeliefs, int cMaxIterations) { Random rand = new Random(); List <BeliefState> B = GenerateB(cBeliefs, rand); InitV(); m_dGCache = new Dictionary <AlphaVector, Dictionary <Action, Dictionary <Observation, AlphaVector> > >(); List <BeliefState> BTag; while (cMaxIterations > 0) { BTag = CopyB(B); List <AlphaVector> VTag = new List <AlphaVector>(); while (BTag.Count != 0) { //choose arbitrary point in BTag to improve BeliefState bCurr = RandomBeliefState(BTag, rand); AlphaVector newAV = Backup(bCurr); AlphaVector avBest = new AlphaVector(); double currValue = ValueOf(bCurr, m_lVectors, out avBest); double AlphaDotb = newAV.InnerProduct(bCurr); if (AlphaDotb > currValue) { //remove from B points whose value was improved by new newAV BTag.Where(b => newAV.InnerProduct(b) >= ValueOf(b, m_lVectors, out AlphaVector avTmp)).ToList(); avBest = newAV; } else { BTag.Remove(bCurr); avBest = ArgMax(m_lVectors, b: bCurr); } VTag.Add(avBest); } m_lVectors = VTag; cMaxIterations--; } }
public bool FetchRank() { if (!BattleNetSwitcherFuncs.ValidateBTag(BTag)) { return(false); } var split = BTag.Split("#"); var req = WebRequest.Create($"https://playoverwatch.com/en-us/career/pc/{split[0]}-{split[1]}/"); req.Method = "GET"; var doc = new HtmlDocument(); var responseStream = req.GetResponse().GetResponseStream(); if (responseStream == null) { _ = GeneralInvocableFuncs.ShowToast("error", Lang["Toast_BNet_StatsFail", new { BTag = BTag }], renderTo: "toastarea"); return(false); } using (var reader = new StreamReader(responseStream)) { doc.LoadHtml(reader.ReadToEnd()); } // If the PlayOverwatch site is overloaded if (doc.DocumentNode.SelectSingleNode("/html/body/section[1]/section/div/h1") != null) { _ = GeneralInvocableFuncs.ShowToast("error", Lang["Toast_BNet_StatsFail", new { BTag = BTag }], renderTo: "toastarea"); return(false); } // If the Profile is private if (doc.DocumentNode.SelectSingleNode( "/html/body/section[1]/div[1]/section/div/div/div/div/div[1]/p")?.InnerHtml == "Private Profile") { ImgUrl = doc.DocumentNode .SelectSingleNode("/html/body/section[1]/div[1]/section/div/div/div/div/div[2]/img") .Attributes["src"].Value; _ = GeneralInvocableFuncs.ShowToast("warning", Lang["Toast_BNet_Private", new { BTag = BTag }], renderTo: "toastarea"); _ = BattleNetSwitcherFuncs.DownloadImage(Email, ImgUrl); LastTimeChecked = DateTime.Now - TimeSpan.FromMinutes(1435); // 23 Hours 55 Minutes return(false); } // If BattleTag is invalid if (doc.DocumentNode.SelectSingleNode( "/html/body/section[1]/section/div/h1")?.InnerHtml == "PROFILE NOT FOUND") { _ = GeneralInvocableFuncs.ShowToast("error", Lang["Toast_ItemNotFound", new { item = BTag }], renderTo: "toastarea"); return(false); } LastTimeChecked = DateTime.Now; ImgUrl = doc.DocumentNode .SelectSingleNode("/html/body/section[1]/div[1]/section/div/div[2]/div/div/div[2]/img") .Attributes["src"].Value; _ = BattleNetSwitcherFuncs.DownloadImage(Email, ImgUrl); var ranks = doc.DocumentNode.SelectNodes( "/html/body/section[1]/div[1]/section/div/div[2]/div/div/div[2]/div/div[3]"); foreach (var node in ranks.Elements()) { if (!int.TryParse(node.LastChild.LastChild.InnerHtml, out var sr)) { continue; } switch (node.LastChild.FirstChild.Attributes["data-ow-tooltip-text"].Value.Split(" ").First()) { case "Tank": OwTankSr = sr; break; case "Damage": OwDpsSr = sr; break; case "Support": OwSupportSr = sr; break; default: continue; } } return(true); }