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

outdated

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 square grid.

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

Demo

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

Run tests

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.

Evolver #

A GridWorld accepts an Evolver to push it through discrete evolutionary steps.

A ConwayEvolver is an Evolver embodying Conway's GOL rules with wrap-around boundary conditions. This evolver 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
0
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

License

unknown (LICENSE)

Dependencies

test, tuple

More

Packages that depend on grid_world