/// <summary> /// Initiates the special shot to this player /// </summary> /// <param name="s">The pong script</param> public void getCoupSpecial(PongManagerScript s) { pms = s; coupSpecial = true; initTimer = Time.time; timer = Math.Abs((float)Laws.gauss() + 10) % 3; }
private double getDeltaPos() { double ret; switch (paramId) { case 0: ret = Laws.uniforme(-4, 4); break; case 1: ret = Laws.gauss(0, 4); break; case 2: ret = 0; break; default: ret = 0; break; } if (ret > 4) { ret = 4; } return(ret); }
/// <summary>Update the projectile's position and the player's scale..</summary> /// <returns>void</returns> void Update() { guiStyle.fontSize = Mathf.RoundToInt(Responsive.baseFontSize * Screen.width / Responsive.baseWidth); if (projectile_.activeSelf) { if (Vector3.Distance(transform.position, projectile_.transform.position) > projectileMaxDistance_) { recallProjectile(); } } if (Time.time - lastTimeChangeSize > changeSizeCooldown) { switch (paramId) { case 0: goalScale = (float)Laws.uniforme(1, 15); break; case 1: goalScale = (float)Laws.exponential(0.5f); break; case 2: goalScale = (float)Laws.gauss(8, 2); break; } cutScale(); lastTimeChangeSize = Time.time; //transform.localScale = new Vector3(goalScale, 1, 1); } transform.localScale -= new Vector3((transform.localScale.x - goalScale) / (transform.localScale.x + goalScale), 0, 0); }
public void TestPassingLaw2() { var behaviour = new FakeBehaviour { Type = BehaviourType.Order }; Assert.IsTrue(Laws.Check(behaviour)); }
public void TestPassingLaw3() { var behaviour = new FakeBehaviour { Type = BehaviourType.GeneratedBehaviour }; Assert.IsTrue(Laws.Check(behaviour)); }
public void TestCreation() { var behaviour = new FakeBehaviour { Type = BehaviourType.Order }; Assert.IsTrue(Laws.Check(behaviour)); }
public void TestCatchesBreakingLaw1() { var behaviour = new FakeBehaviour { Type = BehaviourType.Order }; ((FakeModel)behaviour.Model).InjuresHuman = true; Assert.IsFalse(Laws.Check(behaviour)); }
public void TestCatchesBreakingLaw3() { var behaviour = new FakeBehaviour { Type = BehaviourType.GeneratedBehaviour }; ((FakeModel)behaviour.Model).InjuresSelf = true; Assert.IsFalse(Laws.Check(behaviour)); }
/// <summary> /// Adds artificial sensor imprecision to a Position Vector according to R /// </summary> /// <param name="oldVector">Position Vector</param> /// <returns>Noised Vector</returns> private Vector addImprecision(Vector oldVector) { double t1 = Laws.gauss(); double t2 = Laws.gauss(); Vector imprecision = new DenseVector(new double[] { t1, t2, }); return((Vector)(oldVector + sqrtR * imprecision)); }
public ActionResult AddLaw(Laws law) { if (ModelState.IsValid) { if (FrozenCritters.Models.FrozenCrittersDb.AddLaw(law)) { return(RedirectToAction("Index", "Admin")); } } return(RedirectToAction("Index", "Admin")); }
/* Prends le vecteur réel et en retourne une version artificiellement bruitée */ /// <summary> /// Adds artificial noise to a Position+Speed Vector according to Q /// </summary> /// <param name="oldVector">Position+Speed Vector</param> /// <returns>Noised Vector</returns> private Vector addNoise(Vector oldVector) { double t1 = Laws.gauss(); double t2 = Laws.gauss(); double t3 = Laws.gauss(); double t4 = Laws.gauss(); Vector noise = new DenseVector(new double[] { t1, t2, t3, t4, }); return((Vector)(oldVector + sqrtQ * noise)); }
public void AddLaw(ILaw newLaw) { var alredyHas = Laws.FirstOrDefault(lw => lw.Name == newLaw.Name); if (alredyHas != null) { throw new KeyNotFoundException("Такой закон уже тут есть!"); } Laws.Add(newLaw); newLaw.Owner = this; }
/** * When the ball hits a Pallet and goes back * This is where the whole "random" collision has to be made **/ /// <summary> /// Called when the ball hits a pallet /// </summary> void OnTriggerEnter2D(Collider2D obstacle) { PongManagerScript managerScript = manager.GetComponent <PongManagerScript>(); if (((coupPlayer == -1 && transform.position.x < 0) || (coupPlayer == 1 && transform.position.x > 0)) && coupSpecial) { managerScript.activateCoupSpecial(speed); speed = new Vector2(0, 0); coupSpecial = false; } else { speed.x *= -1; float norm = Mathf.Sqrt(speed.x * speed.x + speed.y * speed.y); float Angle = 0; if (transform.position.x < 0) // côté joueur { Angle = Mathf.Atan2(speed.y, speed.x) * Mathf.Rad2Deg; } else { /* Here is the magic stuff ! */ if (managerScript.param.id == 0) { Angle = (float)Laws.uniforme(-80, 81); } else if (managerScript.param.id == 1) { Angle += -80 + 2 * (float)Laws.poisson(4); } else if (managerScript.param.id == 2) { Angle += ((float)Laws.binom(0.5, 10) - 5) * 16; } if (Angle > 80) { Angle = 80; } if (Angle < -80) { Angle = 80; } speed.x = Mathf.Cos(Angle * Mathf.Deg2Rad) * norm * ((transform.position.x > 0) ? -1 : 1); speed.y = Mathf.Sin(Angle * Mathf.Deg2Rad) * norm; } if (fireBall) { transform.localEulerAngles = new Vector3(0, 0, 90 + ((transform.position.x > 0) ? 0 : 180) + ((transform.position.x > 0) ? -1 : 1) * Angle); } } }
/// <summary> /// 添加法庭 /// </summary> /// <param name="law"></param> /// <returns></returns> public int Add(Laws law) { using (var db = new Entities()) { if (law.sLawPicture == null) { law.sLawPicture = string.Empty; } db.Laws.Add(law); return(db.SaveChanges()); } }
/// <summary> /// 编辑法庭 /// </summary> /// <param name="law"></param> /// <returns></returns> public int Edit(Laws law) { using (var db = new Entities()) { if (law.sLawPicture == null) { law.sLawPicture = string.Empty; } db.Entry <Laws>(law).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } }
/// <summary> /// 编辑法庭 /// </summary> /// <param name="law"></param> public void Update(Laws law) { if (!manage.checkUpdate(law.sLawName, law.ID)) { if (manage.Edit(law) > 0) { result.success = true; } } else { result.info = string.Format("{0}法庭已存在,请重新命名", law.sLawName); } }
/// <summary> /// 添加法庭 /// </summary> /// <param name="law"></param> public void Insert(Laws law) { if (!manage.check(law.sLawName)) { if (manage.Add(law) > 0) { result.success = true; } } else { result.info = string.Format("{0}法庭已存在,请重新命名", law.sLawName); } }
/// <summary> /// Returns two correlated randomly generated values according to a gauss(0,1) /// </summary> /// <param name="var">The stddev of the correlation</param> /// <returns>A vector2 made of two correlated randomly generated values</returns> public static Vector2 gaussCorrelated(double stddev = 1) { double t1 = Laws.gauss(); double t2 = Laws.gauss(); Vector vect = new DenseVector(new double[] { t1, t2, }); Matrix R = new DenseMatrix(2, 2); R.SetRow(0, new double[] { 1, 0, }); R.SetRow(1, new double[] { 0, 1, }); R = (Matrix)R.Multiply(Math.Pow(stddev, 2)); Matrix sqrtR = sqrtm(R); vect = (Vector)(sqrtR * vect); return(new Vector2((float)vect.At(0), (float)vect.At(1))); }
public virtual void Dispose() { DiffArr = null; Prms.Clear(); Prms = null; foreach (var ch in Children) { ch.Dispose(); } Children.Clear(); Children = null; AllParamsNames.Clear(); AllParamsNames = null; Laws.Clear(); SynchMeBefore = null; SynchMeAfter = null; RebuildStructureAction = null; FlagDict.Clear(); FlagDict = null; }
/// <summary> /// Create dots. /// </summary> void create() { GameObject dot = Instantiate(circle, transform.position, transform.rotation) as GameObject; dot.renderer.material.color = couleur; dot.transform.parent = transform; switch (paramId) { case 0: dot.transform.Translate(Random.Range(-10f, 10f), Random.Range(-5f, 5f), 1f, transform); break; case 1: dot.transform.Translate((float)Laws.gauss(0, 3f), (float)Laws.gauss(0, 3f), 1f, transform); break; case 2: Vector2 corr = Laws.gaussCorrelated(2); dot.transform.Translate(corr.x, corr.y, 1f, transform); break; } }
public ActionResult LawForm(Laws law, int id) { return(View()); }