[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / [command/host/randomSequences](https://jsprismarine.dev/api/@jsprismarine/prismarine/command/host/randomSequences/index.md) / RandomSequences

# Class: RandomSequences

Defined in: [packages/prismarine/src/command/host/randomSequences.ts:35](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/host/randomSequences.ts#L35)

One stream per sequence id, plus the unkeyed one a draw without an id uses.

## Constructors

### Constructor

> **new RandomSequences**(`worldSeed`): `RandomSequences`

Defined in: [packages/prismarine/src/command/host/randomSequences.ts:44](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/host/randomSequences.ts#L44)

#### Parameters

##### worldSeed

() => `bigint`

Read rather than held, because the default world is
  loaded after the host is built.

#### Returns

`RandomSequences`

## Methods

### draw()

> **draw**(`min`, `max`, `sequence?`): `number`

Defined in: [packages/prismarine/src/command/host/randomSequences.ts:52](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/host/randomSequences.ts#L52)

Draws one value, inclusive of both ends.

#### Parameters

##### min

`number`

##### max

`number`

##### sequence?

`string`

#### Returns

`number`

A value in `[min, max]`, or `min` when the range is empty,
  which is how `/random value 5..1` answers rather than throwing.

***

### reset()

> **reset**(`sequence`, `seed?`): `boolean`

Defined in: [packages/prismarine/src/command/host/randomSequences.ts:68](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/host/randomSequences.ts#L68)

Drops a sequence so its next draw starts over.

#### Parameters

##### sequence

`string`

One id, or `*` for every sequence at once.

##### seed?

`number`

Replaces the world seed the stream is keyed from, which is
  what makes a draw reproducible across worlds.

#### Returns

`boolean`

Whether anything was reset. Resetting a sequence nobody has
  drawn from yet still counts, because the next draw does start over.

***

### restoreState()

> **restoreState**(`state`): `void`

Defined in: [packages/prismarine/src/command/host/randomSequences.ts:99](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/host/randomSequences.ts#L99)

Restores command streams only when they belong to the same default world seed.

#### Parameters

##### state

`unknown`

#### Returns

`void`

***

### saveState()

> **saveState**(): [`RandomSequencesState`](https://jsprismarine.dev/api/@jsprismarine/prismarine/command/host/randomSequences/index.md#randomsequencesstate)

Defined in: [packages/prismarine/src/command/host/randomSequences.ts:86](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/command/host/randomSequences.ts#L86)

Captures the streams that have advanced, along with any explicit reset seeds.

#### Returns

[`RandomSequencesState`](https://jsprismarine.dev/api/@jsprismarine/prismarine/command/host/randomSequences/index.md#randomsequencesstate)
