Skip to content
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

Merged
merged 1 commit into from
Dec 11, 2024
Merged

New randomization opcodes #236

merged 1 commit into from
Dec 11, 2024

Conversation

MiranDMC
Copy link
Collaborator

@MiranDMC MiranDMC commented Nov 24, 2024

added pick_random_int
added pick_random_float
added pick_random_text
added random_chance

@MiranDMC MiranDMC changed the title Get random from list opcodes New/fixed radomization opcodes Nov 27, 2024
@MiranDMC MiranDMC changed the title New/fixed radomization opcodes New and fixed radomization opcodes Nov 27, 2024
@MiranDMC MiranDMC force-pushed the get_random_from_list_opcodes branch 3 times, most recently from 8acadfa to 37acf5b Compare November 29, 2024 16:46
@MiranDMC MiranDMC requested a review from x87 November 29, 2024 16:46
@MiranDMC MiranDMC marked this pull request as ready for review November 29, 2024 16:46
@MiranDMC MiranDMC changed the title New and fixed radomization opcodes New radomization opcodes Nov 29, 2024
@MiranDMC MiranDMC force-pushed the get_random_from_list_opcodes branch 2 times, most recently from 3dbdbe8 to 39ce37c Compare November 30, 2024 00:29
@MiranDMC MiranDMC changed the title New radomization opcodes New randomization opcodes Nov 30, 2024
@x87
Copy link

x87 commented Dec 2, 2024

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.

@MiranDMC MiranDMC force-pushed the get_random_from_list_opcodes branch from 39ce37c to dc64466 Compare December 3, 2024 02:26
@@ -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%
Copy link

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

Copy link
Collaborator Author

@MiranDMC MiranDMC Dec 4, 2024

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()

Copy link
Collaborator Author

@MiranDMC MiranDMC Dec 4, 2024

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(...)

Copy link

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

@MiranDMC MiranDMC Dec 4, 2024

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.

@MiranDMC MiranDMC merged commit 67c6152 into master Dec 11, 2024
1 check passed
@MiranDMC MiranDMC deleted the get_random_from_list_opcodes branch December 11, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants