元編程參考文件

種子隨機數

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 即時