github.com/dum-dum-genius/ggol

Inspired by Conway's Game of Life, built for more possibilities!


Keywords
conways-game-of-life, go, go118, golang
License
MIT
Install
go get github.com/dum-dum-genius/ggol

Documentation

Gonways Game of Life

Go Reference Go Report Card Build Status

Gonways Game of Life is a go package that provides fundamental functions for running Conway's Game of Life,

The goal is to help you build a Conway's Game of Life in the way you like.

Installed This Package

go get github.com/DumDumGeniuss/ggol

Initialize A New Game

package main

import {
    "fmt"
    
    "github.com/DumDumGeniuss/ggol"
)

main() {
    // This seed will bring cells in 2nd row back to life.
    seed := ggol.Seed{
        {Coordinate: ggol.Coordinate{X: 0, Y: 1}, Cell: true},
        {Coordinate: ggol.Coordinate{X: 1, Y: 1}, Cell: true},
        {Coordinate: ggol.Coordinate{X: 2, Y: 1}, Cell: true},
    }
    // Create a size
    size := ggol.Size{Height: 3, Width: 3}
    // Start a new game with given seed.
    game, _ := ggol.NewGame(&size)
    game.PlantSeed(&seed)
    // Generate next cellLiveMap.
    game.Evolve()
    // Get current cellLiveMap.
    newCellLiveStatusMap := *game.GetCellLiveStatusMap()
    // We digonally rotate the cellLiveMap so it's easier to read.
    rotatedNewCellLiveStatusMap := ggol.RotateCellLiveStatusMapInDigonalLine(newCellLiveStatusMap)
    fmt.Println(rotatedNewCellLiveStatusMap)
    // [
    //     [false true false]
    //     [false true false]
    //     [false true false]
    // ]
}

Demo

You can see a quick demo by cloning this repo to your local machine.

git clone https://github.com/DumDumGeniuss/ggol.git
cd ggol
go mod tidy
go run ./cmd/main.go
# [GIN-debug] Listening and serving HTTP on :8000

And you can open your browser and view the demo on http://localhost:8000/demo

demo

Document

NewGame

import "github.com/DumDumGeniuss/ggol"

game, _ := ggol.NewGame(&size, &seed)