Class

GridWorldGame

GridWorldGame(sizeopt, randomSeednullable)

The grid world game

Constructor

# new GridWorldGame(sizeopt, randomSeednullable)

Parameters:
Name Type Attributes Default Description
size number <optional>
10

The dimensions of the grid.

randomSeed number <nullable>

The random seed.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 15

Members

Map.<GridWorldActionKeys, GridWorldAction>

# actionMapping

The action string to action mapping

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 45

boolean

# isTerminal

Get whether the environment has reached a terminal state.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 160

number

# iteration

Get the iteration

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 69

number

# return

Get the games current return

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 153

seedrandom.PRNG

# rng

Get the random number generator

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 188

number

# setRng

Set the games random seed

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 76

GridWorldState

# state

Get the current environment state

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 116

Map.<GridWorldActionKeys, GridWorldAction>

# static actionMapping

The action string to action mapping

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 209

# static getActionSpace

Get the action space.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 146

Methods

# getStartingPosition(size) → {Vec2}

Get a starting position.

Parameters:
Name Type Description
size

the size of the grid.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 126

The starting position.

Vec2

# grid() → {Grid}

Get the grid.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 217

Grid

# init() → {void}

Initialize the game.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 248

void

# isTerminal() → {boolean}

Get whether the environment has reached a terminal state.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 310

boolean

# iteration() → {number}

Get the iteration

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 233

number

# print() → {void}

Print the environment in the console.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 317

void

# reset() → {boolean}

Reset the game

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 287

Whether the reset was successful

boolean

# return() → {number}

Get the games current return

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 302

number

# rng() → {seedrandom.PRNG}

Get the random number generator

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 325

seedrandom.PRNG

# setRng(randomSeed)

Set the games random seed

Parameters:
Name Type Description
randomSeed number

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 241

# state() → {GridWorldState}

Get the current environment state

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 272

# step(actionString) → {StepResult.<GridWorldState>}

Play an environment step.

Parameters:
Name Type Description
actionString GridWorldActionKey

The action to take.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 264

The result of the action.

# static encodeStateToIndices(state) → {Array.<number>}

Encode a state to a numbers array

Parameters:
Name Type Description
state GridWorldState

The state to encode.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 256

The encoded numbers array.

Array.<number>

# static getActionSpace() → {Array.<string>}

Get the action space.

View Source core/src/Games/GridWorld/GridWorldGame.ts, line 294

Array.<string>