ThirstConsideration(ThirstConsideration other) : base(other) { var ptA = new Pointf(0.8f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); _ev = new SigmoidEvaluator(ptA, ptB, 0.5f); }
void Initialize() { var ptA = new Pointf(0f, 1f); var ptB = new Pointf(40f, 0f); Evaluator = new PowerEvaluator(ptA, ptB, 4f); }
/// <summary> /// called for getting a player position /// </summary> /// <returns></returns> private Vector3 GetPosSpawn() { Pointf point = new Pointf(0.0f, 0.0f); bool isInside = false; int randomList = UnityEngine.Random.Range(0, 100); float actualPertentage = 0; for (int i = 0; i < spawnPoint.Count; i++) { if (randomList >= actualPertentage && randomList <= actualPertentage + spawnPoint[i].percentage) { //ici ok point.x = spawnPoint[i].spawn.position.x + (UnityEngine.Random.Range(0.0f, rangeSpawn) * ExtRandom.RandomNegative()); point.y = spawnPoint[i].spawn.position.z + (UnityEngine.Random.Range(0.0f, rangeSpawn) * ExtRandom.RandomNegative()); isInside = true; break; } actualPertentage += spawnPoint[i].percentage; } if (!isInside) { point.x = spawnPoint[0].spawn.position.x + (UnityEngine.Random.Range(0.0f, rangeSpawn) * ExtRandom.RandomNegative()); point.y = spawnPoint[0].spawn.position.z + (UnityEngine.Random.Range(0.0f, rangeSpawn) * ExtRandom.RandomNegative()); } return(new Vector3(point.x, 0, point.y)); }
public ThirstConsideration() { var ptA = new Pointf(0.8f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); _ev = new SigmoidEvaluator(ptA, ptB, 0.5f); }
void Initialize() { var ptA1 = new Pointf(0f, 1f); var ptB1 = new Pointf(30f, 0f); Evaluator = new PowerEvaluator(ptA1, ptB1, 2f); }
public HungerConsideration() { var ptA = new Pointf(0.0f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); _ev = new SigmoidEvaluator(ptA, ptB, -0.5f); }
void Initialize() { var ptA = new Pointf(0.0f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); _ev = new LinearEvaluator(ptA, ptB); }
public void AddEvaluatorTest() { var cev = new CompositeEvaluator(); var ptA1 = new Pointf(0.0f, 0.0f); var ptB1 = new Pointf(0.2f, 0.3f); var ev1 = new LinearEvaluator(ptA1, ptB1); var ptA2 = new Pointf(0.22f, 0.32f); var ptB2 = new Pointf(0.3f, 0.4f); var ev2 = new PowerEvaluator(ptA2, ptB2, 3.0f); var ptA3 = new Pointf(0.35f, 0.34f); var ptB3 = new Pointf(0.55f, 0.55f); var ev3 = new SigmoidEvaluator(ptA3, ptB3, -0.4f); var ptA4 = new Pointf(0.55f, 0.55f); var ptB4 = new Pointf(1.0f, 1.0f); var ev4 = new SigmoidEvaluator(ptA4, ptB4, 0.6f); var minXmaxX = new Pointf(0.0f, 1.0f); cev.Add(ev1); Assert.AreEqual(ptA1, cev.PtA); Assert.AreEqual(ptB1, cev.PtB); cev.Add(ev2); cev.Add(ev3); cev.Add(ev4); Console.WriteLine(cev.Evaluators.Count); Assert.AreEqual(4, cev.Evaluators.Count); Assert.AreEqual(cev.MinX, minXmaxX.X); Assert.AreEqual(cev.MaxX, minXmaxX.Y); }
public void PointEqualityTests(float p1x, float p1y, float p2x, float p2y, bool expected) { var pt1 = new Pointf(p1x, p1y); var pt2 = new Pointf(p2x, p2y); Assert.That(pt1.Equals(pt2), Is.EqualTo(expected)); }
BehaviourConsideration(BehaviourConsideration other) : base(other) { var ptA = new Pointf(0.0f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); _ev = new LinearEvaluator(ptA, ptB); }
public void DefaultConstructorTest() { var p = new Pointf(); Assert.That(p.X, Is.EqualTo(0f)); Assert.That(p.Y, Is.EqualTo(0f)); }
public void TwoArgConstructorTest() { var p = new Pointf(1f, 2f); Assert.That(p.X, Is.EqualTo(1f)); Assert.That(p.Y, Is.EqualTo(2f)); }
void Initialize() { var ptA = new Pointf(85f, 0f); var ptB = new Pointf(100f, 1f); Evaluator = new SigmoidEvaluator(ptA, ptB, 0.7f); }
public void EvaluateTest(float xA, float yA, float xB, float yB, float power) { var ptA = new Pointf(xA, yA); var ptB = new Pointf(xB, yB); var ev = new PowerEvaluator(ptA, ptB, power); var yAn = yA.Clamp01(); var yBn = yB.Clamp01(); var xqArray = CrMath.LinearSpaced(_evN, xA - 0.001f * xA, xB + 0.001f * xB); for (int i = 0; i < _evN - 1; i++) { var dy = yBn - yAn; var dx = xB - xA; var cVal = dy * (float)Math.Pow((xqArray[i].Clamp <float>(xA, xB) - xA) / dx, power) + yAn; Utility cResult = cVal; var aResult = ev.Evaluate(xqArray[i]); Assert.That(aResult, Is.EqualTo(cResult.Value).Within(Tolerance)); Assert.That(aResult <= 1.0f); Assert.That(aResult >= 0.0f); } // Check the end points var utilA = ev.Evaluate(xA); var utilB = ev.Evaluate(xB); Assert.That(utilA, Is.EqualTo(yAn).Within(Tolerance)); Assert.That(utilB, Is.EqualTo(yBn).Within(Tolerance)); }
void Initialize() { var ptA = new Pointf(0f, 1f); var ptB = new Pointf(20f, 0f); Evaluator = new SigmoidEvaluator(ptA, ptB, 0.5f); }
public BehaviourConsideration() { var ptA = new Pointf(0.0f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); _ev = new LinearEvaluator(ptA, ptB); }
public void XaGreaterThanXbThrowsTest() { var ptA = new Pointf(11f, 0f); var ptB = new Pointf(10f, 1f); Assert.Throws <EvaluatorBase.EvaluatorXaGreaterThanXbException>(() => new TestEvaluator(ptA, ptB)); }
void Initialize() { var ptA = new Pointf(0.0f, 1.0f); var ptB = new Pointf(10.0f, 0.0f); _ev = new SigmoidEvaluator(ptA, ptB, -0.5f); }
public void DxZeroThrowsTest() { var ptA = new Pointf(10f, 0f); var ptB = new Pointf(10f, 1f); Assert.Throws <EvaluatorBase.EvaluatorDxZeroException>(() => new TestEvaluator(ptA, ptB)); }
private Pointf Rotate(Pointf pnt, Pointf ctr, float angle) { return(new Pointf( (float)(pnt.X + ctr.X * Math.Cos(angle) - ctr.Y * Math.Sin(angle)), (float)(pnt.Y + ctr.X * Math.Sin(angle) + ctr.Y * Math.Cos(angle)) )); }
void Initialize() { var ptA = new Pointf(0.0f, 1.0f); var ptB = new Pointf(10.0f, 0.0f); _ev = new PowerEvaluator(ptA, ptB, .5f); }
public void EvaluateTest(float xA, float yA, float xB, float yB) { var pt1 = new Pointf(xA, yA); var pt2 = new Pointf(xB, yB); IEvaluator ev = new LinearEvaluator(pt1, pt2); var yAn = yA.Clamp01(); var yBn = yB.Clamp01(); var xdf = xB - xA; var ydf = yBn - yAn; var alpha = ydf / xdf; var beta = yBn - alpha * xB; var xqArray = CrMath.LinearSpaced(_evN, xA - 10.0f, xB + 10.0f); for (int i = 0; i < _evN - 1; i++) { var cVal = LinearClamped(xqArray[i], alpha, beta); var aVal = ev.Evaluate(xqArray[i]); Assert.That(aVal, Is.EqualTo(cVal).Within(Tolerance)); Assert.That(aVal, Is.EqualTo(cVal).Within(Tolerance)); Assert.That(aVal <= 1.0f); Assert.That(aVal >= 0.0f); } // Check the end points var utilA = ev.Evaluate(xA); var utilB = ev.Evaluate(xB); Assert.That(utilA, Is.EqualTo(yA.Clamp01()).Within(Tolerance)); Assert.That(utilB, Is.EqualTo(yB.Clamp01()).Within(Tolerance)); }
BladderConsideration(BladderConsideration other) : base(other) { var ptA = new Pointf(0.8f, 0f); var ptB = new Pointf(1f, 1f); _ev = new PowerEvaluator(ptA, ptB, 3.0f); }
public BladderConsideration() { var ptA = new Pointf(0.8f, 0f); var ptB = new Pointf(1f, 1f); _ev = new PowerEvaluator(ptA, ptB, 3.0f); }
public void EvaluateTest( float xA1, float yA1, float xB1, float yB1, float xA2, float yA2, float xB2, float yB2, float xA3, float yA3, float xB3, float yB3, float xA4, float yA4, float xB4, float yB4) { var ptA1 = new Pointf(xA1, yA1); var ptB1 = new Pointf(xB1, yB1); var ev1 = new LinearEvaluator(ptA1, ptB1); var ptA2 = new Pointf(xA2, yA2); var ptB2 = new Pointf(xB2, yB2); var ev2 = new PowerEvaluator(ptA2, ptB2, 3.0f); var ptA3 = new Pointf(xA3, yA3); var ptB3 = new Pointf(xB3, yB3); var ev3 = new SigmoidEvaluator(ptA3, ptB3, -0.4f); var ptA4 = new Pointf(xA4, yA4); var ptB4 = new Pointf(xB4, yB4); var ev4 = new SigmoidEvaluator(ptA4, ptB4, 0.6f); var minX = Math.Min(Math.Min(xA1, xA2), Math.Min(xA3, xA4)); var maxX = Math.Max(Math.Max(xB1, xB2), Math.Max(xB3, xB4)); var compositeXInterval = new Interval <float>(minX, maxX); var cev = new CompositeEvaluator(); // AddConsideration them out of order to ensure the ordering works. cev.Add(ev2); cev.Add(ev4); cev.Add(ev3); cev.Add(ev1); Assert.That(cev.Evaluators.Count == 4); var xqArray = CrMath.LinearSpaced(_evN, minX * 0.999f, 1.001f * maxX); for (int i = 0; i < _evN - 1; i++) { var cVal = CombinedEvaluatorEvaluate(xqArray[i], ev1, ev2, ev3, ev4); Utility cResult = cVal; var aResult = cev.Evaluate(xqArray[i]); Assert.That(aResult, Is.EqualTo(cResult.Value).Within(Tolerance)); Assert.That(aResult <= 1.0f); Assert.That(aResult >= 0.0f); } // Check the end points var utilA = cev.Evaluate(compositeXInterval.LowerBound); var utilB = cev.Evaluate(compositeXInterval.UpperBound); Assert.That(utilA, Is.EqualTo(ev1.PtA.Y).Within(Tolerance)); Assert.That(utilB, Is.EqualTo(ev4.PtB.Y).Within(Tolerance)); }
public void ThreeParamConstructorTest() { var ptA = new Pointf(0.0f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); var ev = new PowerEvaluator(ptA, ptB, 2.0f); Assert.IsNotNull(ev); }
public static Pointf ClampMagnitude(Pointf vector, double maxLength) { if (vector.sqrMagnitude > maxLength * maxLength) { return(vector.normalized * maxLength); } return(vector); }
public void TwoParamConstructorTest() { var ptA = new Pointf(0.0f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); var ev = new LinearEvaluator(ptA, ptB); Assert.IsNotNull(ev); }
public void ThreeParamVector2ConstructorTest() { var ptA = new Pointf(0.0f, 0.0f); var ptB = new Pointf(1.0f, 1.0f); var ev = new SigmoidEvaluator(ptA, ptB, -0.5f); Assert.IsNotNull(ev); }
void Initialize() { var xa = Pcg.Default.NextFloat(20f, 30f); var ptA = new Pointf(xa, 0f); var xb = Pcg.Default.NextFloat(40f, 100f); var ptB = new Pointf(xb, 1f); Evaluator = new SigmoidEvaluator(ptA, ptB, 0.3f); }