go-l

A Go module implementation of Conway's Game of Life.

Stars
0

go-l

A Go module implementation of Conway's Game of Life.

A demo can be found at https://vergol.vercel.app.

How to use

1. First you need to create a new instance of the GameOfLife structure and put a Size into it to describe the dimensions of the game:

gol "github.com/stefma/go-l"

func main() {
  gameOfLife := gol.NewGameOfLife(gol.Size(10))
}

1.1 Additionally, you can use a custom generator function to create the game Cells yourself:

gameOfLife := gol.NewGameOfLifeWithGenerator(
		gol.Size(10),
		func(x, y int) gol.Cell { /* Custom logic here */ },
)

2.0 Get the current game board by calling gameOfLife.GameBoard and render it somewhere:

var gameBoard [][]Cell = gameOfLife.GameBoard

3.0 To update the Cells to the next evolution call Next():

gameOfLife.Next()

4.0 Repeat steps 2 and 3 🙃

Example: Vergol

One consumer of this module is Vergol, also part of this repository.

Package Rankings
Top 8.29% on Proxy.golang.org