Пример #1
0
        internal static void LogRandTests()
        {
            StringBuilder stringBuilder = new StringBuilder();
            int           @int          = Rand.Int;

            stringBuilder.AppendLine("Repeating single ValueSeeded with seed " + @int + ". This should give the same result:");
            for (int i = 0; i < 4; i++)
            {
                stringBuilder.AppendLine("   " + Rand.ValueSeeded(@int));
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Long-term tests");
            for (int j = 0; j < 3; j++)
            {
                int num = 0;
                for (int k = 0; k < 5000000; k++)
                {
                    if (Rand.MTBEventOccurs(250f, 60000f, 60f))
                    {
                        num++;
                    }
                }
                string value = "MTB=" + 250 + " days, MTBUnit=" + 60000 + ", check duration=" + 60 + " Simulated " + 5000 + " days (" + 5000000 + " tests). Got " + num + " events.";
                stringBuilder.AppendLine(value);
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Short-term tests");
            for (int l = 0; l < 5; l++)
            {
                int num2 = 0;
                for (int m = 0; m < 10000; m++)
                {
                    if (Rand.MTBEventOccurs(1f, 24000f, 12000f))
                    {
                        num2++;
                    }
                }
                string value2 = "MTB=" + 1f + " days, MTBUnit=" + 24000f + ", check duration=" + 12000f + ", " + 10000 + " tests got " + num2 + " events.";
                stringBuilder.AppendLine(value2);
            }
            for (int n = 0; n < 5; n++)
            {
                int num3 = 0;
                for (int num4 = 0; num4 < 10000; num4++)
                {
                    if (Rand.MTBEventOccurs(2f, 24000f, 6000f))
                    {
                        num3++;
                    }
                }
                string value3 = "MTB=" + 2f + " days, MTBUnit=" + 24000f + ", check duration=" + 6000f + ", " + 10000 + " tests got " + num3 + " events.";
                stringBuilder.AppendLine(value3);
            }
            Log.Message(stringBuilder.ToString());
        }
Пример #2
0
 public void ResolveMissingPieces(string overrideLastName = null)
 {
     if (this.First.NullOrEmpty() && this.Nick.NullOrEmpty() && this.Last.NullOrEmpty())
     {
         Log.Error("Cannot resolve misssing pieces in PawnName: No name data.");
         this.firstInt = (this.nickInt = (this.lastInt = "Empty"));
     }
     else
     {
         if (this.First == null)
         {
             this.firstInt = string.Empty;
         }
         if (this.Last == null)
         {
             this.lastInt = string.Empty;
         }
         if (overrideLastName != null)
         {
             this.lastInt = overrideLastName;
         }
         if (this.Nick.NullOrEmpty())
         {
             if (this.Last == string.Empty)
             {
                 this.nickInt = this.First;
             }
             else
             {
                 if (Rand.ValueSeeded(Gen.HashCombine(this.First.GetHashCode(), this.Last)) < 0.5)
                 {
                     this.nickInt = this.First;
                 }
                 else
                 {
                     this.nickInt = this.Last;
                 }
                 this.CapitalizeNick();
             }
         }
     }
 }
Пример #3
0
 public void ResolveMissingPieces(string overrideLastName = null)
 {
     if (First.NullOrEmpty() && Nick.NullOrEmpty() && Last.NullOrEmpty())
     {
         Log.Error("Cannot resolve misssing pieces in PawnName: No name data.");
         firstInt = (nickInt = (lastInt = "Empty"));
     }
     else
     {
         if (First == null)
         {
             firstInt = string.Empty;
         }
         if (Last == null)
         {
             lastInt = string.Empty;
         }
         if (overrideLastName != null)
         {
             lastInt = overrideLastName;
         }
         if (Nick.NullOrEmpty())
         {
             if (Last == string.Empty)
             {
                 nickInt = First;
             }
             else
             {
                 if (Rand.ValueSeeded(Gen.HashCombine(First.GetHashCode(), Last)) < 0.5f)
                 {
                     nickInt = First;
                 }
                 else
                 {
                     nickInt = Last;
                 }
                 CapitalizeNick();
             }
         }
     }
 }
Пример #4
0
        internal static void RandTests()
        {
            StringBuilder stringBuilder = new StringBuilder();
            int           @int          = Rand.Int;

            stringBuilder.AppendLine("Repeating single ValueSeeded with seed " + @int + ". This should give the same result:");
            for (int i = 0; i < 4; i++)
            {
                stringBuilder.AppendLine("   " + Rand.ValueSeeded(@int));
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Long-term tests");
            for (int j = 0; j < 3; j++)
            {
                int num = 0;
                for (int k = 0; k < 5000000; k++)
                {
                    if (Rand.MTBEventOccurs(250f, 60000f, 60f))
                    {
                        num++;
                    }
                }
                string value = string.Concat(new object[]
                {
                    "MTB=",
                    250,
                    " days, MTBUnit=",
                    60000,
                    ", check duration=",
                    60,
                    " Simulated ",
                    5000,
                    " days (",
                    5000000,
                    " tests). Got ",
                    num,
                    " events."
                });
                stringBuilder.AppendLine(value);
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Short-term tests");
            for (int l = 0; l < 5; l++)
            {
                int num2 = 0;
                for (int m = 0; m < 10000; m++)
                {
                    if (Rand.MTBEventOccurs(1f, 24000f, 12000f))
                    {
                        num2++;
                    }
                }
                string value2 = string.Concat(new object[]
                {
                    "MTB=",
                    1f,
                    " days, MTBUnit=",
                    24000f,
                    ", check duration=",
                    12000f,
                    ", ",
                    10000,
                    " tests got ",
                    num2,
                    " events."
                });
                stringBuilder.AppendLine(value2);
            }
            for (int n = 0; n < 5; n++)
            {
                int num3 = 0;
                for (int num4 = 0; num4 < 10000; num4++)
                {
                    if (Rand.MTBEventOccurs(2f, 24000f, 6000f))
                    {
                        num3++;
                    }
                }
                string value3 = string.Concat(new object[]
                {
                    "MTB=",
                    2f,
                    " days, MTBUnit=",
                    24000f,
                    ", check duration=",
                    6000f,
                    ", ",
                    10000,
                    " tests got ",
                    num3,
                    " events."
                });
                stringBuilder.AppendLine(value3);
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine("Near seed tests");
            DebugHistogram debugHistogram = new DebugHistogram(new float[]
            {
                0f,
                0.1f,
                0.2f,
                0.3f,
                0.4f,
                0.5f,
                0.6f,
                0.7f,
                0.8f,
                0.9f,
                1f
            });

            Rand.PushState();
            for (int num5 = 0; num5 < 1000; num5++)
            {
                Rand.Seed = num5;
                debugHistogram.Add(Rand.Value);
            }
            Rand.PopState();
            debugHistogram.Display(stringBuilder);
            Log.Message(stringBuilder.ToString(), false);
        }