1
0
mirror of https://git.disroot.org/80486DX2-66/polonium.git synced 2024-12-26 07:09:50 +05:30

WIP -> main post-merge editing

This commit is contained in:
Intel A80486DX2-66 2024-11-17 18:12:23 +03:00
parent 9ab507cf86
commit d69b3e8ea9
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -9,26 +9,6 @@ static bool is_line_ending(byte c);
/* function implementations */
static bool get_chance(uint16_t desired_chance) {
/* TODO: remove this multi-line comment before merging into main branch
// algorithm v1
// calculate the cumulative distribution function (CDF)
uint8_t cdf[UINT8_MAX_PLUS_1];
memset(cdf, 0, sizeof(cdf));
for (uint8_t i = 0; i < UINT8_MAX; i++)
cdf[i] = cdf[i] + ((i - 1) <= desired_chance);
// generate a random number in the range of 0 to the total weight
uint8_t random_number = mt_next() & UINT8_MAX;
// use the CDF to determine the outcome
for (uint8_t i = 0; i < UINT8_MAX; i++)
if (random_number < cdf[i])
return true;
return (random_number < cdf[UINT8_MAX] ||
random_number < cdf[UINT8_MAX_PLUS_1]);
*/
// algorithm v2
if (desired_chance == UINT16_MAX)
return true;