PRNG Utilities #183

Parent #72Owner #29Flags readSource hellcore/hellcore.db

Aliases: PRNG Utilities

4 verbs · 12 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
randomthis none thisrxd#1837
nextthis none thisrxd#1836
clipthis none thisrxd#1832
randomlistthis none thisrxd#18312

Properties

PropertyDefinerFlagsOwnerValue
seed#183rc#29-1626935562
help_msg#72rc#29
list of 6{"Can use $prng_util instead of the objnum (#43383).", "", "A set of functions for generating pseudorandom numbers.", "", ":random([seed]) - Returns a list, [1] is the pseudorandom number, [2] is the new seed.", ":randomlist(count[, seed]) - Returns a list of pseudorandom numbers, [1..count] are the pseudorandom numbers, [count+1] is the new seed."}
aliases#1rc#29{"PRNG Utilities"}
description#1rc#29"Utilities for pseudorandom number generation."
object_size#1r#29{2330, 1298434029}
hidden_verbs#1rc#29<clear>
phelp_msg#1rc#29<clear>
weight#1rc#29<clear>
owner_verbs#1rc#29<clear>
plural_name#1rc#29<clear>
client_image#1rc#29<clear>
listening#1rc#29<clear>

Ancestry

Ancestors (nearest first): #72 Generic Utilities Package#1 root

Children: none

Call graph

calls n183_0 #183:random n183_1 #183:next n183_0->n183_1 n183_2 #183:clip n183_0->n183_2 n18_23 #18:IntFromBL n183_2->n18_23 n18_22 #18:BLFromInt n183_2->n18_22 n183_3 #183:randomlist n183_3->n183_0

Source

random

Spec this none thisFlags rxdOwner #29Definer #183

Referenced by

Source

1if (length(args) == 0)
2seed = this:next();
3this.seed = seed;
4else
5seed = this:next(@args);
6endif
7return {this:clip(seed), seed};

next

Spec this none thisFlags rxdOwner #29Definer #183

Referenced by

Source

1if (length(args) == 0)
2value = this.seed;
3else
4value = args[1];
5endif
6return (value * 214013) + 2531011;

clip

Spec this none thisFlags rxdOwner #29Definer #183

Referenced by

Source

1"Equivilent of ((args[1] >> 16) & 0x7FFF)";
2return $math_utils:IntFromBL($math_utils:BLFromInt(args[1])[2..16]);

randomlist

Spec this none thisFlags rxdOwner #29Definer #183

Referenced by

none

Source

1count = args[1];
2values = {};
3while (count > 0)
4result = this:random(@args[2..$]);
5if (length(args) > 1)
6args[2] = result[2];
7endif
8values = listappend(values, result[1]);
9count = count - 1;
10endwhile
11values = listappend(values, result[2]);
12return values;