Table of Contents

Struct SeededRandom

Namespace
Framework.Common.Random
Assembly
Assembly-CSharp.dll

경량 Seed 기반 랜덤 struct. 독립된 로컬 랜덤 시퀀스 생성.

public struct SeededRandom

Examples

var rng = new SeededRandom(42);
int val = rng.Next(0, 10);
float f = rng.NextFloat(0f, 1f);

Remarks

전역 상태가 필요하면 RandomSystem(DI Singleton) 사용. struct이므로 복사 시 독립된 랜덤 시퀀스가 됨.

Constructors

SeededRandom(int)

public SeededRandom(int seed)

Parameters

seed int

재현 가능한 결과를 위한 시드 값.

Methods

Next(int, int)

min 이상 max 미만 정수 반환.

public int Next(int min, int max)

Parameters

min int

최솟값 (포함).

max int

최댓값 (미포함).

Returns

int

NextBool(float)

probability 확률로 true 반환.

public bool NextBool(float probability = 0.5)

Parameters

probability float

true 반환 확률 (0 ~ 1).

Returns

bool

NextFloat(float, float)

min ~ max 범위 float 반환.

public float NextFloat(float min = 0, float max = 1)

Parameters

min float

최솟값 (포함).

max float

최댓값 (포함).

Returns

float