public void InitialStateTest3() { WR.ReturnToInitialState(); int restWater = WR.GetRestWater(); int gap = 100; int someWater = WR.IGNORE_V + 10; //放上一个空杯子 WR.NewWaterDataInput(WR.MIN_V_IN_BOTTLE); Assert.IsTrue(restWater == WR.GetRestWater()); //空杯子拿起又放下 WR.NewWaterDataInput(WR.MIN_V_IN_BOTTLE); Assert.IsTrue(restWater == WR.GetRestWater()); //空杯子拿起又放下 WR.NewWaterDataInput(WR.MIN_V_IN_BOTTLE - WR.IGNORE_V); Assert.IsTrue(restWater == WR.GetRestWater()); //放上一杯不满的水,认为已经喝了几口 WR.NewWaterDataInput(WR.DEFAULT_V_OF_BOTTLE - gap); restWater = restWater - gap; Assert.IsTrue(restWater == WR.GetRestWater()); //拿起来又放下 WR.NewWaterDataInput(WR.DEFAULT_V_OF_BOTTLE - gap - WR.IGNORE_V); Assert.IsTrue(restWater == WR.GetRestWater()); //稍微喝几口,不喝完 WR.NewWaterDataInput(WR.DEFAULT_V_OF_BOTTLE - gap - someWater); restWater = restWater - someWater; Assert.IsTrue(restWater == WR.GetRestWater()); //再放上一杯不满的水,比上面那杯多一点 WR.NewWaterDataInput(WR.DEFAULT_V_OF_BOTTLE - gap); restWater = restWater - gap; Assert.IsTrue(restWater == WR.GetRestWater()); //再放上满满的一杯水,说明把上一杯喝完了 WR.NewWaterDataInput(WR.DEFAULT_V_OF_BOTTLE); restWater = restWater - (WR.DEFAULT_V_OF_BOTTLE - gap); Assert.IsTrue(WR.GetRestWater() == restWater); //拿起来又放下 WR.NewWaterDataInput(WR.DEFAULT_V_OF_BOTTLE - WR.IGNORE_V); Assert.IsTrue(restWater == WR.GetRestWater()); //喝完一杯水 WR.NewWaterDataInput(WR.MIN_V_IN_BOTTLE); restWater = restWater - WR.DEFAULT_V_OF_BOTTLE; Assert.IsTrue(restWater == WR.GetRestWater()); //空杯子拿起来又放下 WR.NewWaterDataInput(WR.MIN_V_IN_BOTTLE); Assert.IsTrue(restWater == WR.GetRestWater()); //再放上满满的一杯水,说明把上一杯喝完了 WR.NewWaterDataInput(WR.DEFAULT_V_OF_BOTTLE); Assert.IsTrue(WR.GetRestWater() == restWater); }
public JsonResult ListPending() { WR datosWE = new WR(); var datos = datosWE.ListaWR(); return(Json(datos, JsonRequestBehavior.AllowGet)); }
public void InitializeTest() { csvfileReader.WR component = new WR(); System.Collections.Hashtable args = new System.Collections.Hashtable(); args.Add("ConfigFile", "C:/research/code/HydroDesktopHG/Source/Plugins/HydroModeler/Components/wtmpReader/Source/config.xml"); args.Add("DataFolder", "C:/research/code/HydroDesktopHG/Source/Plugins/HydroModeler/Components/wtmpReader/data"); component.Initialize(args); }
public CClink_Variable() { _X = new X(MAX_X_COUNT); _Y = new Y(MAX_Y_COUNT); _SB = new SB(MAX_SB_COUNT); _SW = new SW(MAX_SW_COUNT); _RAB = new RAB(MAX_RAB_COUNT); _WW = new WW(MAX_WW_COUNT); _WR = new WR(MAX_WR_COUNT); _SPB = new SPB(MAX_SPB_COUNT); }
public void PerformTimeStepTest() { csvfileReader.WR component = new WR(); //Initialize Component System.Collections.Hashtable args = new System.Collections.Hashtable(); args.Add("ConfigFile", "C:/research/code/HydroDesktopHG/Source/Plugins/HydroModeler/Components/wtmpReader/Source/config.xml"); args.Add("DataFolder", "C:/research/code/HydroDesktopHG/Source/Plugins/HydroModeler/Components/wtmpReader/data"); component.Initialize(args); //Call perform timestep in the component class component.PerformTimeStep(); //retrieve values from the compenent class ScalarSet OutputValues = (ScalarSet)component.GetValues("Temperature", "Temp"); double[] T = OutputValues.data; }
private string GetHtml(string url) { foreach (var proxy in proxyList) { try { WebRequest WR; if (url.Contains("https://www.foxtrot.com.ua")) { WR = WebRequest.Create(url); } else { WR = WebRequest.Create("https://www.foxtrot.com.ua" + url); } WR.Method = "GET"; WR.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0"); string[] fulladress = proxy.Split(":"); var(adress, port) = (fulladress[0], int.Parse(fulladress[1])); WebProxy myproxy = new WebProxy(adress, port); myproxy.BypassProxyOnLocal = false; WR.Proxy = myproxy; WebResponse response = WR.GetResponse(); using (Stream stream = response.GetResponseStream()) { using (StreamReader reader = new StreamReader(stream)) { return(reader.ReadToEnd()); } } } catch (Exception ex) { } } return(null); }
public void TestApi(object sender, RoutedEventArgs e) { if (MReference.Config.SSLTrust) { ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; } if (ApiKey == string.Empty && MReference.Config.VenafiAPIURL != null && MReference.Config.Username != null && MReference.Config.Password != null) { Authenticate = true; } APITest = true; Byte[] PostData; HttpWebRequest WR; string responseString; HttpWebResponse response; if (MReference.Config.VenafiAPIURL != null && MReference.Config.Username != null && MReference.Config.Password != null) { StringBuilder RequestURL = new StringBuilder("https://" + MReference.Config.VenafiAPIURL + "/vedsdk"); string AuthData = JHelper.BuildNewObject(MReference.Config.GetAuthData(), false); if (Authenticate) { RequestURL.Append("/authorize"); PostData = Encoding.ASCII.GetBytes(AuthData); } else { PostData = Encoding.ASCII.GetBytes(TextData); RequestURL.Append(CallUrl); } WR = (HttpWebRequest)WebRequest.Create(RequestURL.ToString()); WR.Method = "Post"; WR.ContentType = "application/json"; WR.ContentLength = PostData.Length; if (ApiKey != null) { WR.Headers.Add("X-Venafi-Api-Key", ApiKey); } try { using (var stream = WR.GetRequestStream()) { stream.Write(PostData, 0, PostData.Length); } response = (HttpWebResponse)WR.GetResponse(); responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); if (Authenticate && !responseString.Contains("Unauthorized")) { JHelper.ParseString(responseString, false); Authenticate = false; TestApi(sender, e); } else { TestResults.Text = JHelper.ParseString(responseString); APITest = false; } } catch (WebException WRE) { ErrorM = WRE.Message; Console.WriteLine(WRE.Message); } } else { responseString = "Enter the Config Settings"; ErrorM = "Enter the Config settings"; } }
/*IEnumerator Example() * { * print(Time.time); * yield return new WaitForSeconds(5); * print(Time.time); * this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, -10)); * yield return new WaitForSeconds(5); * this.GetComponent<Rigidbody2D>().AddForce(new Vector2(0, -10)); * } */ void OnTriggerStay2D(Collider2D other) { if (other == WL.GetComponent <Collider2D>() || other == WR.GetComponent <Collider2D>()) { /* * out1 = true; * time0 = 0f; * time1 = 1.1f; * rmode = 0; * if ((D2 % 360f >= 180f && D2 % 360f < 360f) || (D2 % 360f >= -180f && D2 % 360f < 0f)) * D1 = 3f; * if ((D2 % 360f < 180f && D2 % 360f >= 0f) || (D2 % 360f < -180f && D2 % 360f >= -360f)) * D1 = -3f; */ D2 = 180f - D2; T1.Rotate(Vector3.forward * (2f * D2 - 180f)); } /* * if (other == WR.GetComponent<Collider2D>()) * { * out1 = true; * time0 = 0f; * time1 = 1.1f; * rmode = 0; * * if ((D2 % 360f >= 180f && D2 % 360f < 360f) || (D2 % 360f >= -180f && D2 % 360f < 0f)) * D1 = -3f; * if ((D2 % 360f < 180f && D2 % 360f >= 0f) || (D2 % 360f < -180f && D2 % 360f >= -360f)) * D1 = 3f; * * } */ if (other == WU.GetComponent <Collider2D>() || other == WD.GetComponent <Collider2D>()) { D2 = -D2; T1.Rotate(Vector3.forward * 2 * D2); /* * out1 = true; * time0 = 0f; * time1 = 1.1f; * rmode = 0; * if ((D2 % 360f >= 90f && D2 % 360f < 270f) || (D2 % 360f >= -270f && D2 % 360f < -90f)) * D1 = 3f; * if ((D2 % 360f < 90f && D2 % 360f >= 270f) || (D2 % 360f < -270f && D2 % 360f >= -90f)) * D1 = -3f; */ } /* * if (other == WD.GetComponent<Collider2D>()) * { * out1 = true; * time0 = 0f; * time1 = 1.1f; * rmode = 0; * if ((D2 % 360f >= 90f && D2 % 360f < 270f) || (D2 % 360f >= -270f && D2 % 360f < -90f)) * D1 = -3f; * if ((D2 % 360f < 90f && D2 % 360f >= 270f) || (D2 % 360f < -270f && D2 % 360f >= -90f)) * D1 = 3f; * * } */ if (other == Room.GetComponent <Collider2D>()) { Debug.Log(out1); } }
public static int Main() { int numTests = 0; int numPassed = 0; WR wr = ReturnWR(); wr = null; // this will resurrect wr GC.Collect(); GC.WaitForPendingFinalizers(); try { numTests++; Console.WriteLine("Get Target Test"); Console.WriteLine(Test.w.Target); Console.WriteLine("Passed"); numPassed++; } catch (Exception e) { Console.WriteLine(e); } try { numTests++; Console.WriteLine("IsAlive Test"); bool b = Test.w.IsAlive; Console.WriteLine(b); if (!b) { Console.WriteLine("Passed"); numPassed++; } } catch (Exception e) { Console.WriteLine(e); } try { numTests++; Console.WriteLine("Set Target Test"); Test.w.Target = new Object(); } catch (InvalidOperationException) { numPassed++; Console.WriteLine("Passed"); } catch (Exception e) { Console.WriteLine(e); } if (numTests == numPassed) { return(100); } return(1); }
public void Run() { for (int i = 0; i < trial_times; i++) { foreach (int WR in wingmanRange) { HexaPos startPos = this._mapForm.human.path[0]; TopologyGraphGenerator topologyGenerator = new TopologyGraphGenerator(this._mapForm.map); TopologyGraph tograph = topologyGenerator.GetTopologyGraph(); PlanningGraphGenerator planningGenerator = new PlanningGraphGenerator(tograph); PathPlanningGraph planGraph = planningGenerator.GetPathPlanningGraph(this._mapForm.HumanPath, WR); PlanningGraphPruner pruner = new PlanningGraphPruner(); PathPlanningGraph newPlanGraph = pruner.GetPlanningGraph(planGraph, startPos); PathPlanningGraph prunedPlanGraph = pruner.BackwardPrune(newPlanGraph); prunedPlanGraph = pruner.ForwardPrune(prunedPlanGraph); Robot robot = new Robot(this._mapForm.map); Human human = new Human(this._mapForm.map); foreach (int HR in humanRange) { this._mapForm.map.GetMapStateMgr().RandomizeValue(); human.SetObservationRange(HR); double[,] localEntropy = this._mapForm.map.GetMapStateMgr().CopyEntropy(); human.Update(this._mapForm.HumanPath, localEntropy); foreach (int RR in robotRange) { robot.SetObservationRange(RR); Console.WriteLine("Trial Time: " + i.ToString() + " WR: " + WR.ToString() + " RR: " + RR.ToString() + " HR: " + HR.ToString()); HexaPath maxPath = new HexaPath(); TreeExpandingWithIterativeTrackingPathPlanner planner = new TreeExpandingWithIterativeTrackingPathPlanner(this._mapForm.map, robot); planner._localEntropy = localEntropy; planner.iteratingOnce = false; maxPath = planner.FindPath(prunedPlanGraph, startPos); Console.WriteLine("PATH : " + maxPath.ToString()); // double[,] tempEntropy = (double[,])this._mapForm.map.GetMapStateMgr().CopyEntropy(); //double maxScore = robot.Score(maxPath, tempEntropy); double maxScore = planner.finalMaxScore; Console.WriteLine("SCORE: " + maxScore); Console.WriteLine(""); PerformanceParameter param = new PerformanceParameter(); param.maxScore = maxScore; param.problemSize = planner.problemSize; param.scoreAtFirstRun = planner.scoreAtFirstRun; param.exploredSize = planner.exploredSize; param.totalRunTime = planner.totalRunTime; param.hitOptimalRunTime = planner.hitOptimalRunTime; param.robotRange = RR; param.humanRange = HR; param.wingmanRange = WR; param.runIndex = i; this.performanceList.Add(param); } } } } save(prefix); }
public static void DestroyWR() { wr = null; }
public static void Combo() { if (MenuManager.ComboMenu["R"].GetValue <MenuBool>().Enabled&& SpellManager.R.IsReady()) { if (MenuManager.ComboMenu["QUpgradeHits"].GetValue <MenuSliderButton>().Enabled&& QR.IsReady()) { var target = TargetSelector.GetTarget(500); if (target != null) { if (target.IsValidTarget(QR.Range) && objPlayer.Position.CountEnemyHeroesInRange(550) >= MenuManager.ComboMenu["QUpgradeHits"].GetValue <MenuSliderButton>().Value&& objPlayer.HasBuff("HeimerdingerR")) { SpellManager.Q.Cast(objPlayer.Position.Extend(target.Position, +280)); } else if (!objPlayer.HasBuff("HeimerdingerR") && objPlayer.Position.CountEnemyHeroesInRange(550) <= MenuManager.ComboMenu["QUpgradeHits"].GetValue <MenuSliderButton>().Value) { SpellManager.R.Cast(); } } } switch (MenuManager.ComboMenu["RMode"].GetValue <MenuList>().SelectedValue) { case "E-R-W": var target = TargetSelector.GetTarget(WR.Range); if (target.Health < DamageManager.GetDamageByChampion(target)) { if (target.IsValidTarget(SpellManager.E.Range) && MenuManager.ComboMenu["E"].GetValue <MenuBool>().Enabled) { var getPrediction = SpellManager.E.GetPrediction(target); if (getPrediction.Hitchance >= HitChance.High) { SpellManager.E.Cast(getPrediction.CastPosition); } } if (target.IsValidTarget(WR.Range) && SpellManager.W.IsReady() && objPlayer.HasBuff("HeimerdingerR")) { var getPrediction = WR.GetPrediction(target); if (getPrediction.Hitchance >= HitChance.Immobile && Variables.TickCount - SpellManager.E.LastCastAttemptT > 500) { WR.Cast(getPrediction.CastPosition); } } else if (!objPlayer.HasBuff("HeimerdingerR") && !SpellManager.E.IsReady()) { if (SpellManager.E.IsReady() && !SpellManager.W.IsReady()) { return; } SpellManager.R.Cast(); } } break; case "W-R-E": target = TargetSelector.GetTarget(ER.Range); if (target.IsValidTarget(SpellManager.W.Range) && MenuManager.ComboMenu["W"].GetValue <MenuBool>().Enabled) { var getPrediction = SpellManager.W.GetPrediction(target); if (getPrediction.Hitchance >= HitChance.High) { SpellManager.W.Cast(getPrediction.CastPosition); } } if (target.IsValidTarget(ER.Range) && SpellManager.E.IsReady() && objPlayer.HasBuff("HeimerdingerR")) { var getPrediction = ER.GetPrediction(target); if (getPrediction.Hitchance >= HitChance.Immobile) { ER.Cast(getPrediction.CastPosition); } } else if (!objPlayer.HasBuff("HeimerdingerR") && !SpellManager.W.IsReady()) { SpellManager.R.Cast(); } break; } } if (MenuManager.ComboMenu["E"].GetValue <MenuBool>().Enabled&& SpellManager.E.IsReady() && !objPlayer.HasBuff("HeimerdingerR")) { var target = TargetSelector.GetTarget(SpellManager.E.Range); if (target.IsValidTarget(SpellManager.E.Range) && target != null) { var getPrediction = SpellManager.E.GetPrediction(target); SpellManager.E.Cast(getPrediction.CastPosition); } } if (MenuManager.ComboMenu["Q"].GetValue <MenuBool>().Enabled&& SpellManager.Q.IsReady() && !objPlayer.HasBuff("HeimerdingerR")) { var target = TargetSelector.GetTarget(SpellManager.Q.Range + 300); if (target.IsValidTarget(SpellManager.Q.Range + 300) && target != null) { SpellManager.Q.Cast(objPlayer.Position.Extend(target.Position, +300)); } } if (MenuManager.ComboMenu["W"].GetValue <MenuBool>().Enabled&& SpellManager.W.IsReady() && !objPlayer.HasBuff("HeimerdingerR") && !SpellManager.E.IsReady()) { var target = TargetSelector.GetTarget(SpellManager.W.Range); if (target.IsValidTarget(SpellManager.W.Range) && target != null) { var getPrediction = SpellManager.W.GetPrediction(target); SpellManager.W.Cast(getPrediction.CastPosition); } } }
private void Awake() { wR = new WR(); }
public static void CreateWR() { wr = new WR(new Object()); }
private void BallThrown(QB thrower, WR reciever, FootBall footBall, Vector3 impactPos, float arcType, float power, bool isComplete) { }
public void AverageVTest() { WR.AddTempV(0); Assert.IsTrue(0 == WR.GetAverageV()); }
public ActionResult HeadsTailsSingle(int?pokemon, string Coin) { Session["Quarter"] = 0; if (Session["TierCount"] == null && (string)Session["PlayType"] == "Tournament") { Session["TierCount"] = 1; } else if (Session["TierCount"] != null && (string)Session["PlayType"] == "Tournament") { int x = (int)Session["TierCount"]; x++; Session["TierCount"] = x; } if (Session["TierTrack"] == null && (string)Session["PlayType"] == "Tournament") { Session["TierTrack"] = 0; } Random random = new Random(); int flip = random.Next(1, 3); Session["Pokemon"] = pokemon; int PID; try { PID = (from p in db.PokeTiers where p.PokeID == pokemon select p.PokedexNumber).Single(); } catch (Exception) { return(RedirectToAction("Index", "Home")); } int compThreePoint = 0; int compFieldGoal = 0; int compPaint = 0; int compSteal = 0; int compBlock = 0; HttpWebRequest WR; try { WR = WebRequest.CreateHttp($"https://pokeapi.co/api/v2/pokemon/{PID}/"); WR.UserAgent = ".NET Framework Test Client"; } catch (Exception) { return(RedirectToAction("APIError", "Home")); } HttpWebResponse Response; try { Response = (HttpWebResponse)WR.GetResponse(); } catch (WebException e) { ViewBag.Error = "Exception"; ViewBag.ErrorDescription = e.Message; return(RedirectToAction("APIError", "Home")); } if (Response.StatusCode != HttpStatusCode.OK) { ViewBag.Error = Response.StatusCode; ViewBag.ErrorDescription = Response.StatusDescription; return(RedirectToAction("APIError", "Home")); } StreamReader reader = new StreamReader(Response.GetResponseStream()); string PokemonData = reader.ReadToEnd(); try { JObject JsonData = JObject.Parse(PokemonData); ViewBag.Name = JsonData["forms"][0]; string name = ViewBag.Name.name; ViewBag.NameProp = Methods.UppercaseFirst(name); Session["PokeName"] = Methods.UppercaseFirst(name); string specialAtt = (string)JsonData["stats"][2]["base_stat"]; string att = (string)JsonData["stats"][4]["base_stat"]; string speed = (string)JsonData["stats"][0]["base_stat"]; string specialDef = (string)JsonData["stats"][1]["base_stat"]; string def = (string)JsonData["stats"][3]["base_stat"]; compThreePoint = Methods.StatConverter(specialAtt); compFieldGoal = Methods.StatConverter(att) + 10; compPaint = Methods.StatConverter(speed) + 15; compSteal = Methods.StatConverter(specialDef) - 20; compBlock = Methods.StatConverter(def) - 15; } catch (Exception e) { ViewBag.Error = "JSON Issue"; ViewBag.ErrorDescription = e.Message; return(RedirectToAction("APIError", "Home")); } Session["compThreePoint"] = compThreePoint; Session["compFieldGoal"] = compFieldGoal; Session["compPaint"] = compPaint; Session["compSteal"] = compSteal; Session["compBlock"] = compBlock; if (flip == 1) { if (Coin == "Heads") { Session["Winner"] = "Player"; return(RedirectToAction("QuarterSelector", "GamePlay")); } else { Session["Winner"] = "Computer"; return(RedirectToAction("QuarterSelector", "GamePlay")); } } else if (flip == 2) { if (Coin == "Tails") { Session["Winner"] = "Player"; return(RedirectToAction("QuarterSelector")); } else { Session["Winner"] = "Computer"; return(RedirectToAction("QuarterSelector")); } } return(RedirectToAction("QuarterSelector")); }