forked from devsam/core
기존의 Util 내의 함수는 mt_rand에 기반하고 있어서 일반적으론 충분하지만, 게임 내부에서 랜덤 값을 정교하게 제어하고 싶은 경우에는 적절하지 않았음. 따라서 직접 seed를 제어할 수 있는 난수생성기를 추가. SHA512(seed || blockIdx) 의 형태로 동작하는 DRBG이며, FIPS 표준을 따르는 RNG는 아니지만 암호학적으로 안전한 형태로 구현함. PHP, TS 두가지 형태로 구현. Reviewed-on: https://storage.hided.net/gitea/devsam/core/pulls/208 Co-authored-by: hide_d <hided62@gmail.com> Co-committed-by: hide_d <hided62@gmail.com>
13 lines
258 B
TypeScript
13 lines
258 B
TypeScript
export interface RNG {
|
|
|
|
/**
|
|
* nextInt()가 반환 가능한 최대값
|
|
*/
|
|
getMaxInt(): number;
|
|
|
|
nextBytes(bytes: number): Uint8Array;
|
|
nextBits(bits: number): Uint8Array;
|
|
|
|
nextInt(max?: number): number;
|
|
nextFloat1(): number;
|
|
} |