JSPM

@life2/format

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q25465F
  • License Apache-2.0

Textual representation format of a Life2 board state.

Package Exports

  • @life2/format
  • @life2/format/index.js

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 (@life2/format) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@life2/format

@life2/format is a JavaScript package to parse and load artifacts of Life2 games stored in the Life2 Text Format (L2TF) dynamically.

The Life2 Text Format serves as a simple and readable way of storing and sharing specific states of a board at any given time. We used it during the study to share states we considered important with everyone member of the team.

The file format itself is really simple:

  • Each line of a 2D board corresponds to a line in the file (with no regard to the line delimiter used, even tho we recommend using Linux LF only).
  • Empty cells are represented by dots (.), barrier cells are hash symbols (#), and cells from a team are represented by the team name in lowercase (a or b).

For instance, the following board in JavaScript

const board = [[3, 3, 3, 3, 3, 3, 3, 3, 3],
               [3, 0, 1, 0, 0, 0, 0, 2, 3],
               [3, 0, 1, 0, 1, 2, 2, 2, 3],
               [3, 0, 0, 1, 1, 2, 1, 1, 3],
               [3, 0, 0, 0, 2, 2, 2, 0, 3],
               [3, 3, 3, 3, 3, 3, 3, 3, 3]];  // 9x6

can be represented in L2TF as:

#########
#.a....b#
#.a.abbb#
#..aabaa#
#...bbb.#
#########

Installation

The @life2/format package is distributed via NPM. It can be installed using:

npm install @life2/format

@life2/format is part of the Life2 project and is governed by the Apache License, Version 2.0.