Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random function
Author Message
WRWR
Journeyman
*

Posts: 212
Likes Given: 30
Likes Received: 1 in 1 posts
Joined: Mar 2012
Reputation: 1



Post: #21
RE: Random function
how to get random number from 1, 2, 6, 7, 13, 19, 22, 24 only, for example?
07-12-2012 06:56 PM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #22
RE: Random function
Hmm you can try this :

[DEFNAME rand_defs]
random_list 1,2,6,7,13,19,22,24

[FUNCTION calc_random ]//This function take as input <def.random_list>
local.result = <R<argv>> // argv holds the total number of random_list, 8 in our case,since argv is 0 based we will have a result from 0 to 8-1
return <argv[<dlocal.result>]>

In theory is correct, i cannot test it right now but i think it's fineShock

Maybe there are already some random functions that use intervals, or it's possible to use weighted random like
local.result = {{1}1{2}1{6}1{7}1{13}1{19}1{22}1{24}1} where 1 is the weight, so we have a chance of 1/8 to get 1 or 2 or 6 etc..
I think this one works too
(This post was last modified: 07-12-2012 08:08 PM by darksun84.)
07-12-2012 07:53 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)