/
Test.cs
73 lines (66 loc) · 1.81 KB
/
Test.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Server.Items;
namespace Server.Commands
{
public class Test
{
public static void Initialize()
{
CommandSystem.Register("Test", AccessLevel.GameMaster, new CommandEventHandler(Test_DoCommand));
}
private static void Test_DoCommand(CommandEventArgs e)
{
if (e.ArgString == "tmaps")
Test_Tmaps(e);
else if (e.ArgString == "tmapdrop")
Test_TmapDrop(e);
}
private static void Test_TmapDrop(CommandEventArgs e)
{
int count = 0;
int itters = 10000;
for(int i = 0; i < itters; ++i)
{
Mobiles.Ettin mob = new Mobiles.Ettin();
mob.NoKillAwards = false;
mob.OnBeforeDeath();
if (mob.Backpack.FindItemByType(typeof(TreasureMap)) != null)
++count;
}
double percent = ((double)count / (double)itters) * 100;
e.Mobile.SendMessage("Generated {0} Ettins, {1} ({2:0.00}%) dropped TMaps. Expected {3:0.00}%",
itters, count, percent, TreasureMap.LootChance * 100);
}
private static void Test_Tmaps(CommandEventArgs e)
{
Dictionary<UInt64, int> stats = new Dictionary<ulong, int>();
for(int i = 0; i < 10000; ++i)
{
TreasureMap tmap = new TreasureMap(
Utility.Random(7),
Map.Felucca
);
UInt64 key = (UInt64)(tmap.ChestLocation.X | (tmap.ChestLocation.Y << 32));
if (!stats.ContainsKey(key))
{
stats.Add(key, 1);
}
else
{
stats[key] = stats[key] + 1;
}
}
e.Mobile.SendMessage(String.Format("Total Locations: {0}", stats.Count));
int expectedAverage = 10000 / stats.Count;
int maxDeviation = 0;
foreach(int count in stats.Values)
{
maxDeviation = Math.Max(Math.Abs(expectedAverage - count), maxDeviation);
}
e.Mobile.SendMessage(String.Format("Max Deviation: {0}", maxDeviation));
}
}
}