conway

package
v0.0.0-...-6f04cdd Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

This package provides all means for creating the Conway's Game for arbitrary sizes and number of generations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EuclideanDistance

func EuclideanDistance(p1, p2 image.Point) float64

EuclideanDistance

Return the euclidean distance between two points

func NewGeneration

func NewGeneration(rectangle image.Rectangle,
	palette color.Palette,
	ratio AspectRatio,
	model string,
	nbgeneration, nbgenerations int) *generation

return a new generation which is initially empty. Since this implementation honours colors, the contents are stored as indexes to a color palette and a colour model has to be given. The new generation is given index nbgeneration among nbgenerations

Types

type AspectRatio

type AspectRatio struct {
	X, Y int
}

Frames can be generated with arbitrary aspect ratios, whose definition is given below. They represent a magnification of the underlying matrix by 1:X and 1:Y

type Conway

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

The Conway's Game consists of a slice with a number of generations each with a given width and height

func NewConway

func NewConway(width, height, generations int, contents *generation) Conway

Return a new Conway's Game. Note that it is necessary to specify the first generation

func (*Conway) GetGIF

func (game *Conway) GetGIF(delay0, delay, average int) gif.GIF

return a gif animation of the Conway's Game with the given delay in 100th of a second between frames, and an initial delay equal to delay0 100th of a second. If average has a value strictly greater than 1 then the color index of each cell (either alive of dead) is averaged over the last "average" generations

func (*Conway) Run

func (game *Conway) Run()

Run the entire game and generate all generations from the initial population in the given instance of the Conway's Game

Jump to

Keyboard shortcuts

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