grid_world 2.0.0 copy "grid_world: ^2.0.0" to clipboard
grid_world: ^2.0.0 copied to clipboard

A cellular automaton library associated with a square grid. Includes Conway's Game of Life.

GridWorld #

GridWorld is a cellular automaton library associated with a rectangular grid.

It includes Conway's Game of Life evolution rules, and some classic Conway patterns ready for injection.

git clone git@github.com:monopole/grid_world.git
cd grid_world
dart run test
dart example/main.dart

Primary interfaces #

GridWorld #

A GridWorld is a grid of cells that can be dead or alive.

A GridWorld can be constructed from

  • a multi-line string, e.g.

    final blinker = GridWorld.fromString('''
    .....
    ..#..
    ..#..
    ..#..
    .....
    ''');
    

    where . means dead, and anything else means alive.

  • other worlds pasted into or appended to each other.

The cells have no builtin rules regarding their evolution. For that, see Evolver.

Evolver #

A GridWorld accepts, via its takeStep method, an Evolver.

An Evolver pushes a world forward in time per some set of evolutionary rules.

A ConwayEvolver is an Evolver embodying Conway's GOL rules with wrap-around boundary conditions. This evolver also defines some static instances of small GridWorlds containing famous Conway GOL patterns, e.g. the Gosper glider gun:

static final gosperGliderGun = GridWorld.fromString('''
......................................
.........................#............
.......................#.#............
.............##......##............##.
............#...#....##............##.
.##........#.....#...##...............
.##........#...#.##....#.#............
...........#.....#.......#............
............#...#.....................
.............##.......................
......................................
''');

GridWorldIterable #

Extending Iterable<GridWorld>, this object combines a GridWorld and an Evolver such that one may evolve a world in an iteration context, e.g.

for (var w in GridWorldIterable(initialWorld, limit: 1000)) {
  render(w);
}

GridStringer #

A GridWorld can be converted to a string using a GridStringer.

GridStringerAnsi is a GridStringer that converts a world to a string with embedded ANSI escape sequences for animation on a terminal.

1
likes
120
pub points
0%
popularity

Publisher

verified publisherorangebike.dev

A cellular automaton library associated with a square grid. Includes Conway's Game of Life.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

tuple

More

Packages that depend on grid_world