malfunction
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

Malfunction Continuous Integration License Renovate enabled

Computes all possible states of a procedurally-generated finite state machine and performs simple optimizations to eliminate duplicate states.

Originally written to generate state machines for simple web browser games, but may have other uses.

Installation

Dependencies

This is a NPM package without any runtime NPM dependencies. It targets NodeJS 16.11.1 or newer on the following operating systems:

  • Ubuntu 20.04
  • Ubuntu 18.04
  • macOS 11 (Big Sur)
  • macOS 10.15 (Catalina)
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016

It is likely also possible to use this package as part of a web browser application through tools such as webpack. This has not been tested, however.

Install as a runtime dependency

If your application uses Malfunction as a runtime dependency, install it like any other NPM package:

npm install --save malfunction

Install as a development dependency

If Malfunction is used when building your application and not at runtime, install it as a development dependency:

npm install --save-dev malfunction

Usage

First, you must define a game source object which describes your finite state machine. This project provides some examples:

A game source object includes:

  • An initial game state from which to start.
  • A function which compares two game states to determine whether they represent the same game state.
  • A function which compares two game states to determine whether they would appear identical to the player(s).
  • A function which compares two links to determine whether they would appear identical to player(s).
  • A function which lists the links from a game state to other game states.

From this, the malfunction function will crawl the entire graph of possible choices and generate a list of the distinct game states which were identified:

import { malfunction } from "malfunction";

const gameArtifact = malfunction(gameSource);

console.log(gameArtifact);
{
  states: [
    {
      state: `Example Game State A`,
      links: [
        {
          link: `Example Link A`,
          stateIndex: 1234,
        },
        ...
      ],
    },
    ...
  ],
}

Readme

Keywords

none

Package Sidebar

Install

npm i malfunction

Weekly Downloads

0

Version

0.0.0

License

MIT

Unpacked Size

13.4 kB

Total Files

15

Last publish

Collaborators

  • jameswilddev