gol

package
v0.0.0-...-9996730 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALIVE = 1
	DEAD  = 0
	A     = 1 // ALIVE alias
	D     = 0 // DEAD alias
	VOID  = -1
)

Status of cells in the Game of Life grid

Variables

This section is empty.

Functions

func MakeGifAnimation

func MakeGifAnimation(g *Gol, outputFilepath string, generations int, delay int) error

MakeGifAnimation : make a gif animation for some generations

Types

type Gol

type Gol struct {
	// contains filtered or unexported fields
}

Gol : game of life

func NewGol

func NewGol(rows int, cols int) *Gol

NewGol : creates a game of life

func NewRandomGol

func NewRandomGol(rows int, cols int, randomSeed int64) *Gol

NewRandomGol : creates a new random game of life

func ReadGolFromTextFile

func ReadGolFromTextFile(filename string) (*Gol, error)

ReadGolFromTextFile : create a new Game of life from a text file

func (*Gol) Clone

func (g *Gol) Clone() *Gol

Clone : clone a game of life instance

func (*Gol) Equals

func (g *Gol) Equals(other *Gol) bool

Equals : inform if two game of life instances have the same data

func (*Gol) GridEquals

func (g *Gol) GridEquals(other *Gol) bool

GridEquals : inform if two game of life instances have the same data,

ignoring the difference in generations value

func (*Gol) NextGeneration

func (g *Gol) NextGeneration() *Gol

NextGeneration : compute the next generation

func (*Gol) SaveToFile

func (g *Gol) SaveToFile(filename string) error

SaveToFile : prints on stdout the current state of the grid

func (*Gol) Stdout

func (g *Gol) Stdout()

Stdout : prints on stdout the current state of the grid

type Grid

type Grid struct {
	// contains filtered or unexported fields
}

Grid : a grid where the cells develop

func NewGrid

func NewGrid(rows int, cols int) *Grid

NewGrid : creates a grid

func NewRandomGrid

func NewRandomGrid(rows int, cols int, ramdomSeed int64) *Grid

NewRandomGrid : creates a grid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL