npm install markovjs-immutable
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.
This package exports the required
rater functions, alongside an
init one used for getting the initial value.
const m = memory
The initializer function has the following signature:
// A: action type// G: game state type// O: observation typetype Init = <A 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
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.
ImmutableJS, man. What an awesome package.