JSPM

markovjs-immutable

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q25315F
  • License MIT

immutable memory implementation for markovjs

Package Exports

  • markovjs-immutable

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (markovjs-immutable) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

markovjs-immutable

npm install markovjs-immutable

Release License

This is a memory implementation for markovjs based on immutablejs.

It provides an easier way to code the observation function while adding support for immutable data structures, enforcing great design patterns on your game model code.

Usage

This package exports the required update and rater functions, alongside an init one used for getting the initial value.

import markov from 'markovjs'
import * as memory from 'markovjs-immutable'

const m = memory.init(0.0, a => a)
markov().memory(memory, m)

The initializer function has the following signature:

// A: action type
// G: game state type
// O: observation type
type Init = <A, G, O>(number, G=> O) => MemoryState<A, G, O>

The first parameter is the initial value for all unset memory slots.

The second one is the observe function. It maps a game state type (G) to an observation type (O). It serves the same purpose as toString does in the default memory implementation, but expecting an immutable value as the return type instead of a string.

This is one of the great things this package provides: a way for you to code your state and agent observation in a higher level letting the package figure how to store the data.

It's important to note that while the observation value needs to be immutable, your game state value does not. That said, it's encouraged that you code it as an immutable value as well.

Thanks

ImmutableJS, man. What an awesome package.