Class RandomSystem
Seed 기반 재현 가능한 전역 랜덤 관리. DI Singleton.
public class RandomSystem
- Inheritance
-
objectRandomSystem
Examples
_randomSystem.SetSeed(12345);
int val = _randomSystem.Next(0, 100);
var enemy = _randomSystem.Pick(enemyList);
Remarks
로컬 독립 랜덤 시퀀스가 필요하면 SeededRandom(struct, Common) 사용. SetSeed 호출 후 동일 Seed → 동일 결과 시퀀스가 재현된다.
Constructors
RandomSystem(ILogSystem)
public RandomSystem(ILogSystem log)
Parameters
logILogSystem
Methods
Next(int, int)
min 이상 max 미만 정수 반환.
public int Next(int min, int max)
Parameters
minint최솟값 (포함).
maxint최댓값 (미포함).
Returns
- int
NextFloat(float, float)
min ~ max 범위 float 반환.
public float NextFloat(float min = 0, float max = 1)
Parameters
minfloatmaxfloat
Returns
- float
Pick<T>(IList<T>)
리스트에서 무작위 요소 반환.
public T Pick<T>(IList<T> list)
Parameters
listIList<T>대상 리스트.
Returns
- T
무작위 요소. null 또는 빈 리스트면 default.
Type Parameters
T요소 타입.
SetSeed(int)
Seed 설정. 동일 Seed → 동일 시퀀스 재현.
public void SetSeed(int seed)
Parameters
seedint재현에 사용할 시드 값.