life

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package life implements Conway's Game of Life independently of the terminal UI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Grid

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

Grid is a rectangular collection of cells stored row-major.

func New

func New(width, height int) *Grid

New returns an empty grid. Width and height are clamped to at least one.

func (*Grid) Alive

func (g *Grid) Alive(x, y int) bool

func (*Grid) Clear

func (g *Grid) Clear()

func (*Grid) Height

func (g *Grid) Height() int

func (*Grid) Population

func (g *Grid) Population() int

func (*Grid) Randomize

func (g *Grid) Randomize(density float64, seed uint64)

func (*Grid) Set

func (g *Grid) Set(x, y int, alive bool)

func (*Grid) Step

func (g *Grid) Step(wrap bool)

Step advances the grid by one generation. With wrap enabled, opposite edges touch; otherwise cells outside the grid are always dead.

func (*Grid) Toggle

func (g *Grid) Toggle(x, y int)

func (*Grid) Width

func (g *Grid) Width() int

Jump to

Keyboard shortcuts

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