Quark
Post Demos
Posts: 14
|
|
« on: June 26, 2011, 11:04:58 am » |
|
[Wow, I just found out one shouldn't use the tab key much in posting here-- got kicked out of the editor]
Hi (again),
The Chance(n) function is obviously related to the RndRange() routine I posted before and, while I don't use it as often, it does have its uses. Here is something similar to some code I was playing with last night in which I caused increasing chances of a wandering character to change course:
Odds = 1 ' 100% chance DO ...some plain code... IF Chance(Odds) then ...some special code... Odds=20 'switch to happening only 5% of the time end if ...more plain code... Odds = Odds - 1 'Increase the chance of something special happening down toward 100% chance LOOP END '---------------------------------------- FUNCTION Chance%(n%) Chance% = (RND * n%) < 1 ' gives 1 chance of TRUE out of n possibilities END FUNCTION
--Quark
|
|
|
|
|
OlDosLover
Guest
|
|
« Reply #1 on: June 26, 2011, 11:28:39 am » |
|
Hi all, Tanks Quark , nice function. Will come in handy in games i think. OlDosLover.
|
|
|
|
|
|