Created
August 11, 2012 09:03
-
-
Save anonymous/3322720 to your computer and use it in GitHub Desktop.
RandomNumber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class RandomNumber | |
{ | |
#region Initialization | |
private int generatedNumber = 10000, maxValue = 10000, minValue = 0; | |
private string memory = "10000", aid; | |
private bool minus = false; | |
#endregion | |
#region Functions | |
private void BuildNumber() | |
{ | |
aid = (((int)Math.Pow(2, int.Parse(memory)) * Environment.TickCount) - Environment.ProcessorCount).ToString(); | |
GenerateNumber(); | |
if (generatedNumber > maxValue) | |
generatedNumber = (int)(maxValue - ((maxValue - minValue) * Math.Abs(Math.Sin(generatedNumber)))); | |
else if (generatedNumber < minValue) | |
generatedNumber = (int)(minValue + ((maxValue - minValue) * Math.Abs(Math.Sin(generatedNumber)))); | |
} | |
private void GenerateNumber(int index = 0) | |
{ | |
if (aid.Length - 1 > index) | |
GenerateNumber(index + 1); | |
else if (minus == true) | |
{ | |
generatedNumber *= -1; | |
minus = false; | |
} | |
if (aid[index] == '-') | |
this.minus = true; | |
else | |
{ | |
if (Math.Sin(aid[index]) > 0.8) | |
generatedNumber -= int.Parse(aid[index].ToString()); | |
else if (Math.Sin(aid[index]) > 0.5 && Math.Sin(aid[index]) <= 0.8) | |
generatedNumber *= int.Parse(aid[index].ToString()); | |
else if (Math.Sin(aid[index]) > 0.3 && Math.Sin(aid[index]) <= 0.5) | |
generatedNumber *= int.Parse(aid[index].ToString()) / ((int)(Math.Sin(index) * 10) + 1); | |
else | |
generatedNumber += int.Parse(aid[index].ToString()); | |
} | |
memory = ("1" + Math.Abs(generatedNumber) + memory).Substring(0, 5); | |
} | |
#endregion | |
#region Output | |
public int Random | |
{ | |
get | |
{ | |
BuildNumber(); | |
return generatedNumber; | |
} | |
} | |
public int MaxValue | |
{ | |
get { return maxValue; } | |
set { maxValue = value; } | |
} | |
public int MinValue | |
{ | |
get { return minValue; } | |
set { minValue = value; } | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment