元编程参考文档

种子随机数

9 个节点

本页内容 9

种子随机数

函数

此节点没有文档说明。

签名
种子随机数(种子: 整数) -> Seeded Random
SeededRandom SeededRandom(int seed = 1)

参数

名称类型默认值说明
种子整数1Which stream. Any value is a valid seed, including zero and negative numbers - the output function scrambles the state thoroughly enough that neighbouring seeds give unrelated streams.

返回

种子随机数Seeded Random
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
种子随机数
所属包
Glaze 实时

已抽取次数

函数

How many numbers have been drawn since the last SeededRandom.Restart.

签名
已抽取次数(Seeded Random: Seeded Random) -> 大整数
long Draws(SeededRandom Seeded Random)

参数

名称类型默认值说明
Seeded RandomSeeded Random—

返回

结果大整数

备注

The position in the stream, and therefore the other half of its reproducibility: two runs that agree
on the seed and on this have drawn the same numbers. Worth asserting in a scripted run, because a
game that draws a different NUMBER of times is just as unreproducible as one that draws different
values.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
种子随机数
所属包
Glaze 实时

种子

函数

The seed this stream was made with.

签名
种子(Seeded Random: Seeded Random) -> 整数
int Seed(SeededRandom Seeded Random)

参数

名称类型默认值说明
Seeded RandomSeeded Random—

返回

结果整数
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
数据流 函数 事件 例程 蓝图 状态机状态
声明于
种子随机数
所属包
Glaze 实时

附近的下一个数

函数

One of two numbers, either side of a middle, by an even coin flip.

签名
附近的下一个数 -> 数字
    Seeded Random: Seeded Random
    中心: 数字
    分布范围: 数字
double NextAround(
    SeededRandom Seeded Random,
    double centre,
    double spread)

参数

名称类型默认值说明
Seeded RandomSeeded Random—
中心数字—
分布范围数字—

返回

结果数字

备注

The shape a spawner keeps needing: an obstacle's gap sits somewhere in a band around the centre of
the screen, and what varies is how far and which way. Saves a game writing the same two lines.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
种子随机数
所属包
Glaze 实时

区间内的下一个数

函数

A number between two bounds, including the lower and excluding the upper.

签名
区间内的下一个数 -> 数字
    Seeded Random: Seeded Random
    最小值: 数字
    最大值: 数字
double NextBetween(
    SeededRandom Seeded Random,
    double minimum,
    double maximum)

参数

名称类型默认值说明
Seeded RandomSeeded Random—
最小值数字—
最大值数字—

返回

结果数字

备注

Bounds the wrong way round are swapped rather than refused: a spawn range typed backwards is
a slip, and refusing it would take a game down mid-run for something with an obvious meaning.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
种子随机数
所属包
Glaze 实时

按概率判定

函数

Whether a thing with this probability happened.

签名
按概率判定(Seeded Random: Seeded Random, 概率: 数字) -> 真否
bool NextChance(
    SeededRandom Seeded Random,
    double probability = 0.5)

参数

名称类型默认值说明
Seeded RandomSeeded Random—
概率数字0.5From zero (never) to one (always).

返回

结果真否
所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
种子随机数
所属包
Glaze 实时

下一个 0 到 1 之间的数

函数

A number from zero up to but not including one.

签名
下一个 0 到 1 之间的数(Seeded Random: Seeded Random) -> 数字
double NextUnit(SeededRandom Seeded Random)

参数

名称类型默认值说明
Seeded RandomSeeded Random—

返回

结果数字

备注

Built from the top 53 bits, which is exactly what a double's mantissa holds - so every value is
representable and the distribution is even. Taking the low bits instead is the classic way to get a
generator that is subtly worse than the one it wraps.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
种子随机数
所属包
Glaze 实时

下一个整数

函数

A whole number from the lower bound up to but not including the upper.

签名
下一个整数 -> 整数
    Seeded Random: Seeded Random
    最小值(含): 整数
    最大值(不含): 整数
int NextWhole(
    SeededRandom Seeded Random,
    int minimumInclusive,
    int maximumExclusive)

参数

名称类型默认值说明
Seeded RandomSeeded Random—
最小值(含)整数—
最大值(不含)整数—

返回

结果整数

备注

An empty or backwards range answers the lower bound, and draws nothing - there is no number
to pick, and advancing the stream for a question with no answer would make the sequence depend on how
often a game asked an impossible one.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
种子随机数
所属包
Glaze 实时

重新开始

函数

Go back to the beginning of the stream.

签名
重新开始(Seeded Random: Seeded Random)
void Restart(SeededRandom Seeded Random)

参数

名称类型默认值说明
Seeded RandomSeeded Random—

备注

What restarting a run means for the spawner: the same seed gives the same world again.

所属发行版
元编程(教育版)元编程(专业版)
可用的图种类
事件 例程 状态机状态
声明于
种子随机数
所属包
Glaze 实时