public void RandomBoolTest() { var random = new RandomBool(20); var randFalse = random.GetNext(); var randTrue = random.GetNext(); Assert.IsTrue(randTrue); Assert.IsFalse(randFalse); }
public static Vector3 GetPointOnPath(Vector3 from, Vector3 to, float atLength, float minNoise, float maxNoise) { Vector3 path = (to - from); Vector3 point = (path * atLength) + from; Vector3 direction = path.normalized; bool decalLeft = RandomBool.Next(); Vector3 decal = new Vector3(direction.y, direction.x, 0) * Random.Range(minNoise, maxNoise); if (decalLeft) { decal *= -1; } // Debug.Log ( "Decal " + decal + " " + decalLeft ); // Vector3 decal = Quaternion.Euler ( 0, 0, Random.Range ( 0, 360 ) ) * ( Vector3.right * distanceRadius ); point += decal; return(point); }
public Enemy(string alien, string imagePath, Coords coords, Speed speed, double moveAmount) : base(imagePath, coords) { this.AlienName = alien; _maxDeviation = moveAmount; switch (speed) { case Speed.Fast: this.Vy = _slowSpeed; break; case Speed.Medium: this.Vy = _mediumSpeed; break; case Speed.Slow: this.Vy = _fastSpeed; break; } this.MovesSideways = RandomBool.Get(); _movingLeft = RandomBool.Get(); _initialPosX = coords.X; }
static void Main(string[] args) { string keypress; do { // 0) // Display starting menu Console.Clear(); Console.WriteLine("Adapter Pattern -- Lending Context"); Console.WriteLine(); Console.WriteLine("1) Create Loan Application"); Console.ReadKey(); // 1) // Create application var application = new LoanApplication { FirstName = RandomString.Create(RandomNumber.Create(2, 8)), LastName = RandomString.Create(RandomNumber.Create(4, 10)), Employed = RandomBool.Create(), Income = RandomNumber.Create(15000, 55000), LoanAmount = RandomNumber.Create(500, 2500) }; // 2) // Display random application for confirmation Console.Clear(); Console.WriteLine(JsonSerializer.Serialize(application)); Console.WriteLine(); Console.WriteLine("Any key to submit..."); Console.ReadKey(); // 3) // Submit application to lender var lender = new Lender(); lender.SubmitApplication(application); // 4) - Handled in Lender object // Lender verifies customer // - New API <-> Legacy API // Adapter submits individual data points // 5) - Handled in Lender object // Lender retrieves customer score // - New API <-> Legacy API // Adapter retrieves individual data points // 6) // Get the decision from the Lender var decision = lender.MakeDecision(); // 7) // Display decision Spinner(); Console.WriteLine(JsonSerializer.Serialize(decision)); Console.WriteLine(); Console.WriteLine("Menu ( M )"); Console.WriteLine("Exit ( X )"); keypress = Console.ReadKey().Key.ToString(); } while (keypress.ToLower() != "x"); }
public static bool CheckApplication(LegacyCustomer customer) { return(RandomBool.Create()); }