Welcome to the TNT Directory. Here you will find complete games and examples contributed by the TNT Basic community, as well as useful links to other websites. Feel free to add links to complete shareware games - you don't have to include the source!

You are not logged in.
9th Apr 2020 09:32 GMT
Sort by: View:
Selected: 1 of 41 total examples

RPG Engine - Weighted Numbers

Version 0.0.1

Posted by Jae Rune Last Updated on 19th Dec 2005
The basic idea here it to show you how to set up a weighted random number generator, also known as a biased number generator. The point of this is to allow you to create it so that one result is more likely to appear than another. So it takes the randomness out of a random number generator. Consider this: rolling a die, you have a 1:1 chance of landing on any number. It's completely and utterly random. Same thing with a random number generator. Each number has a 1:1 chance (or 50/50) of being generated. This bit of code, however, allows you to define ranges that are more likely than other to appear. Let's say you want a user to be able to roll 2-5 on a six-sided die 90% more often than a 1 or a 6. You'd set this up for a 5:90:5 ratio for 1/2-5/6. Not sure if that makes sense, but if it does, you can see the applications immediately. Usually it's great for determining battle systems where you want the chances of misses and criticals to be lower than the chance of a regular hit.
RPG Engine - Weighted Numbers source code

Submit Example...