-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New randomization opcodes #236
base: master
Are you sure you want to change the base?
Conversation
8acadfa
to
37acf5b
Compare
3dbdbe8
to
39ce37c
Compare
This needs more discussion. CLEO+ already provides this functionality (RANDOM_PERCENT, GENERATE_RANDOM_INT_IN_RANGE_WITH_SEED), also can be easily implemented as a cleo function. |
39ce37c
to
dc64466
Compare
@@ -434,4 +446,96 @@ class Math | |||
OPCODE_CONDITION_RESULT(value != 0); | |||
return OR_CONTINUE; | |||
} | |||
} Math; | |||
|
|||
//2705=-1,pick_random_int values %d% store_to %d% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
picking random array element is called sampling
please rename these it sample_int
, sample_float
, sample_string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm not sure about that. I would never guess it takes random element from set.
"Sample - get a representative experience of". Especially in software development it is already used for totally different meanings (like texture sampling).
Originally I considered also "select". Does some programming language have similar function?
draw_int would also make sense if not suggesting crating picture.
I see some php libraries provide Array.Sample(), but it makes way more sense than Float.Sample()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pick (noun) · picks (plural noun)
an act or the right of selecting something from a number of alternatives
I was baffling about name already and this seem to be the best one. Other options sounds like fancy ways to not say "pick".
random_pick_int maybe? Current choice is more in line with already existing generate_random_float_in_range.
In class syntax it is called Math.RandomPick(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sample is a verb too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, like sampling input sensor by averaging signal over sampling window time, or sampling audio to fill given time by repeating small portion.
I think all randomization opcodes should have word "random" in name. Then searching in SBL actually provides user with options to select from.
Math.Sample(1, 2, 3) looks meaningless.
added pick_random_int
added pick_random_float
added pick_random_text
added random_chance