c1_gonway_game_of_life

package
v0.0.0-...-63b2ac5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) Alive

func (f *Field) Alive(x, y int) bool

Alive reports whether the specified cell is alive. 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) bool

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

func (*Field) Set

func (f *Field) Set(x, y int, b bool)

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 NewLife

func NewLife(w, h int) *Life

NewLife 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.

func (*Life) String

func (l *Life) String() string

String returns the game board as a string.

Jump to

Keyboard shortcuts

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