|
||
|
|||||||
| General Discussion General discussion for the RunUO community, all off-topic posts will be deleted. This forum is NOT FOR SUPPORT! |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#2 (permalink) |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
|
Dice and Randoms are the same thing
4d6+5 is the same as random from 9 to 31 And actually there is a utility function for dice rolls.
__________________
Zippy, Razor Creator and RunUO Core Developer The RunUO Software Team "Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal." ~The Cryptonomicon |
|
|
|
|
|
#3 (permalink) |
|
Forum Expert
|
Wouldn't the numbers be distributed differently with dice then by using random numbers?
2d6+1 may be a random number between 3 and 13, but wouldn't 8 be a more common number then 13 this way? Choosing a purly random number between 3 and 13 the odds for all numbers are distributed evenly. |
|
|
|
|
|
#8 (permalink) | |
|
Join Date: Jan 2003
Posts: 22
|
Quote:
Consider this: 2d6 gives a range of 2-12. Roll 2d6 500 times and you'll get the same average as if you did a random 2-12 500 times. -But- the difference is obvious when rolling just once. 7 is the most common result with 2d6. How? Well, take a look at the dice. There are a total of 3 combinations that can give a total result of 7. 1 + 6 2 + 5 3 + 4 But! There's only one combination that gives 2, and the same thing applies for 12. 1 + 1 or 6 + 6 So, in conclusion, while it averages out over a large number of rolls, using a die system tends to give less extreme individual rolls, and more "average" rolls. [Edit for typos in the numbers] |
|
|
|
|
|
|
#9 (permalink) |
|
Forum Expert
|
I play plenty of Pen & Paper Dnd games. Rolling 2d10 is always much safer then rolling 1d20.
This is fairly easy to test. Write a short program that loops and chooses a random number bewteen 2 and 10, count the number of times each number shows up. Then do the same thing but choose 2 random numbers between 1 and 5, add them together and count the number of times each number shows up. If you loop enough times, say 1000 times, and graph the results on a line graph you will see the following. The [2-10] will be a straight horizontal line, the [1-5] + [1-5] will result in a Bell Curve. The average of the numbers will be preserved, but the chance of getting a 10 or a 2 is significantly less when choosing 2 random numbers and adding them. I'm really not trying to be annoying about this, but there is an important distinction in the results. It really helps to stop the occurance of getting a really high attack on 1 roll, and a really low on the next. there is still a chance it's going to happen, but it would pull the attach closer to a mid range, and make powerful, or pityful attacks more rare. |
|
|
|
|
|
#11 (permalink) |
|
Forum Expert
|
I whipped together a quick example program to show the results. Create a blank VB.Net project, add a module and paste in the following code, then point the program to use this sub as the entrypoint.
the 1st column will the the Result of the roll. the 2nd column is the count of times that number occured by choosing a random number between 2 and 12. the 3rd column is the count of times that number came up by choosing 2 random numbers between 1 and 6, and adding them. [code:1]Module Module1 Sub Main() Randomize() Dim Arr1(12) As Integer Dim Arr2(12) As Integer Dim I As Integer For I = 1 To 10000 Dim r1, r2, r3 As Integer r1 = Int(Rnd() * 11) + 2 'random between 2 and 12 r2 = Int(Rnd() * 6) + 1 'random between 1 and 6 r3 = Int(Rnd() * 6) + 1 'random between 1 and 6 Arr1(r1) += 1 Arr2(r2 + r3) += 1 Next Dim R As String For I = 2 To 12 R = R & I & " - " & vbTab & Arr1(I) & vbTab & Arr2(I) & vbNewLine Next MsgBox(R) End Sub End Module[/code:1] |
|
|
|
|
|
#12 (permalink) | |
|
Administrator
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
|
oh god I hate VB
Anyway, here's a C# comparison: Quote:
using System; namespace Dice { class Class1 { [STAThread] static void Main(string[] args) { int[] dice = new int[]{ 0, 0, 0, 0, 0 }; int[] rand = new int[]{ 0, 0, 0, 0, 0 }; for (int i=0;i<1000000;i++) { dice[Dice( 2, 3, 0 )-2] ++; rand[Random( 5 )] ++; } Console.WriteLine( "Dice: " ); for (int i=0;i<dice.Length;i++) { Console.WriteLine( "{0}: {1}", i+2, dice[i] ); } Console.WriteLine( "Rand: " ); for (int i=0;i<rand.Length;i++) { Console.WriteLine( "{0}: {1}", i+2, rand[i] ); } Console.ReadLine(); } private static Random m_Random = new Random(); //4d6+8 would be: Utility.Dice( 4, 6, 8 ) public static int Dice( int numDice, int numSides, int bonus ) { int total = 0; for (int i=0;i<numDice;++i) total += Random( numSides ) + 1; total += bonus; return total; } public static int Random( int count ) { return m_Random.Next( count ); } } } [/code:1]
__________________
Zippy, Razor Creator and RunUO Core Developer The RunUO Software Team "Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal." ~The Cryptonomicon |
|
|
|
|
|
|
#14 (permalink) |
|
Join Date: Nov 2002
Posts: 42
|
that's why I asked it here, weapons in osi have dice throws, like katana (3d8+2), and it's fairly better to use dice throws instead of random values, I've modified my baseweapons.cs to do it but would be better if it's in the same runuo release scripts
someone said there's an utility to make the dice throws, how do I use it? (I'm a bit noob with runuo script) |
|
|
|
|
|
#15 (permalink) |
|
Join Date: Dec 2002
Posts: 140
|
Law of big numbers.
The random function gives you an uniform probability. So all numbers have the same probability to appear. But when you add a lot of those random variables, the new result isn't uniform anymore. It's a gaussian curve. Check this link to clarify a bit what I said: http://www.willamette.edu/~mjaneba/h...rmalcurve.html As for the dice roll, this is his sintaxis (it's on Utility): int Dice(int numDice,int numSides,int bonus) I haven't use it never, but maybe a 3d8 + 1 will be: Utility.Dice(3,8,1); Edited: garlor, use the Sharpdevelop IDE. With him you can see the hardcoded functions that runuo.exe have inside, and has code completion. Really useful to program. |
|
|
|
|
|
#18 (permalink) |
|
Newbie
Join Date: Oct 2002
Posts: 77
|
FYI, Dougan_Ironfist has modified the weapons scripts to use dice rolls (and use the OSI specs for each weapon). He's hosting it for download on his site.
If the RunUO designers decide to convert to using a dice function for weapons, they should really take a look at his script. He does this cool thing with a Point3D to plug in the variables. If I remember correctly, he used: Point3D (X, Y, Z) So you can use (and easily change) XdY + Z |
|
|
|
|
|
#20 (permalink) |
|
Join Date: Dec 2002
Posts: 140
|
Where to download SharpDevelop
http://www.icsharpcode.net/OpenSource/SD/default.asp How to configure it to allow code completion: http://www.runuo.com/discussion/view...t=sharpdevelop In Spanish: Arrancas el runuo y cuando haya acabado de cargar lo cierras. Busca el archivo Script.dll y copialo a otro lado con otro nombre. Te bajas el sharpdevelop del primer link. Lo instalas y una vez dentro creas un nuevo proyecto vacio. Pon el sharpdevelop en español (ya que te dan la opción ^^) En la columna de proyectos vete a tu proyecto y dentro de él aparece la etiqueta 'Referencias'. Con el segundo botón eliges agregar referencia->Visor de Ensamblajes .NET->Browse. Te pedirá que elijas un archivo. Elige el runuo.exe y el script.dll renombrado que tenías. Con esto te saldrán las dos nuevas referencias, y puedes ver las clases que tienen dentro (y sus propiedades), además de que completa el código. Es muy muy útil. Ni intentes scriptear algo sin él, porque para "bucear" buscando ese método o variable que buscas no hay nada mejor. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|