life

package
v0.0.0-...-7db34b9 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

An implementation of Conway's Game of Life.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Animation

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

func NewAnimation

func NewAnimation(sz image.Point) *Animation

func (*Animation) Delay

func (*Animation) Delay() time.Duration

func (*Animation) Image

func (a *Animation) Image() image.Image

func (*Animation) Next

func (a *Animation) Next() error

type Field

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

Field represents a two-dimensional field of cells.

func NewField

func NewField(w, h int) *Field

NewField returns an empty field of the specified width and height.

func (*Field) At

func (f *Field) At(x, y int) color.Color

func (*Field) Bounds

func (f *Field) Bounds() image.Rectangle

Bounds return the topology of the Canvas

func (*Field) ColorModel

func (*Field) ColorModel() color.Model

ColorModel returns the canvas' color model, always color.RGBAModel

func (*Field) Get

func (f *Field) Get(x, y int) color.RGBA

Get returns the specified cell. If the x or y coordinates are outside the field boundaries they are wrapped toroidally. For instance, an x value of -1 is treated as width-1.

func (*Field) Next

func (f *Field) Next(x, y int) color.RGBA

Next returns the state of the specified cell at the next time step.

func (*Field) Set

func (f *Field) Set(x, y int, c color.RGBA)

Set sets the state of the specified cell to the given value.

type Life

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

Life stores the state of a round of Conway's Game of Life.

func New

func New(w, h int) *Life

New returns a new Life game state with a random initial state.

func (*Life) Step

func (l *Life) Step()

Step advances the game by one instant, recomputing and updating all cells.

Jump to

Keyboard shortcuts

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