Pontus Posted April 3, 2003 Posted April 3, 2003 I am doing a character generator for a roleplaying game in FM6, mainly for testing the randomizing features. Using the Int(Random*6) I am able to simulate a normal 1d6 (one sixsided dice) roll with the mean value 3.5. But I also want to be able to do the unlimited rolls (Un1d6 has the mean value 3.75). Unlimited throws works like when you roll a number 6, that dice + a new dice should be rolled again and the result should be added to the other dices. I.e if you roll a Un3d6 and rolls 3.6.2 you take the middle dice (the 6) and rolls that one together with a new dice again and rolls (3.2.)3.4. The numbers inside the paranthese are the old dices, the very result will then be 12. Any ideas on how to calculate this? Thanks in advance!
Pontus Posted April 22, 2003 Author Posted April 22, 2003 I'll give you the C++ function for it then. int Un(int n) //UnNt6 - t.ex. Un(3) = Un3t6 { //Error handling! If you get a negative value anywhere, you'll know that //something is wrong! if (n < 0) return(-1); //The very function int temp; if (n == 0) { return(0); } else { temp = rand() % 6 + 1; if (temp == 6) { temp = Ob(2); } return (temp + Ob(n - 1)); } } Anyone knowing how to script/calculate this or even - make a plugin that works as an external function for even easier scripting. Suggestions?
Recommended Posts
This topic is 7914 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now