gol

package
v0.0.0-...-2efb1be Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CPUS = -1

CPUS : if assigned to Gol.Processes a number of GO processes equal to the number of CPUs of the computer will be used when computing the next generation.

View Source
const DefaultThreadPoolSize = 10

DefaultThreadPoolSize : default number of threads used in the thread pool to compute next generation of a game of life instance.

View Source
const ExplosiveThreadPoolSize = -1

ExplosiveThreadPoolSize : the thread pool will use a thread for each cell do not use it unless you want to experiment with your memory limits.

View Source
const SERIAL = 1

SERIAL : if assigned to Gol.Processes, a serial algorithm (i.e. no concurrency) will be used when computing the next generation.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gol

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

Gol : game of life

func NewGol

func NewGol(name, description, rules, gridType, rowsLimitation, colsLimitation string, rows, cols, generation int) *Gol

NewGol : creates a game of life

func NewRandomGol

func NewRandomGol(name, description, rules, gridType, rowsLimitation, colsLimitation string, rows, cols int, randomSeed int64) *Gol

NewRandomGol : creates a new random game of life

func (*Gol) ChangeCells

func (g *Gol) ChangeCells(changes [][]int) base.GolInterface

ChangeCells : apply cell changes before a new generation This method is used by NextGeneration to allow input data on the Game of Life instance

func (*Gol) Clone

func (g *Gol) Clone() base.GolInterface

Clone : clone a game of life instance

func (*Gol) Cols

func (g *Gol) Cols() int

Cols : return the number of columns of the grid

func (*Gol) DbgStdout

func (g *Gol) DbgStdout()

DbgStdout : show a matrix to ease debugging

func (*Gol) Description

func (g *Gol) Description() string

Description : return the description of this Game of life instance

func (*Gol) Equals

func (g *Gol) Equals(o base.GolInterface) bool

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

func (*Gol) EqualsError

func (g *Gol) EqualsError(o base.GolInterface) error

EqualsError : inform if two game of life instances have the same data by returning an error if different, or nil otherwise.

func (*Gol) FastForward

func (g *Gol) FastForward(generations int) base.GolInterface

FastForward : move forward a number of generations

func (*Gol) Generation

func (g *Gol) Generation() int

Generation : return the number of generations passed

func (*Gol) Get

func (g *Gol) Get(i int, j int) int

Get : get the value of the cell (ALICE, DEAD) in the i, j coordinates

func (*Gol) GridEquals

func (g *Gol) GridEquals(o base.GolInterface, mode string) bool

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

ignoring the difference in generations value

func (*Gol) InitFromConf

func (g *Gol) InitFromConf(name, description string, rows, cols int, gconf *base.GolConf)

InitFromConf : initialize a Game of Life instance

func (*Gol) InitWithGrid

func (g *Gol) InitWithGrid(name, description, rules string, generation, neighborhoodType int, gr *grid.Grid)

InitWithGrid : initialize a Game of Life instance

func (*Gol) LimitCols

func (g *Gol) LimitCols() bool

LimitCols : return the number of columns of the grid

func (*Gol) LimitRows

func (g *Gol) LimitRows() bool

LimitRows : inform if rows are limited or isn't

func (*Gol) Name

func (g *Gol) Name() string

Name : return the name of this Game of life instance

func (*Gol) NeighborhoodType

func (g *Gol) NeighborhoodType() int

NeighborhoodType : return the neighborhood type

func (*Gol) NeighborhoodTypeString

func (g *Gol) NeighborhoodTypeString() string

NeighborhoodTypeString : return the neighborhood type (as string)

func (*Gol) NextGeneration

func (g *Gol) NextGeneration() base.GolInterface

NextGeneration : compute the next generation If no prior change to the generation of the next game of life instance, pass a nil in the place of changes parameter.

func (*Gol) Processes

func (g *Gol) Processes() int

Processes : return the number of GO processes used in the computing of the next generation. Take account the constants SERIAL and CPUS of this package.

func (*Gol) Rows

func (g *Gol) Rows() int

Rows : return the number of rows of the grid

func (*Gol) Rules

func (g *Gol) Rules() string

Rules : return the rules of the game of life as a string with the survival/birth format. See https://www.conwaylife.com/wiki/Life_1.05

func (*Gol) Set

func (g *Gol) Set(i int, j int, value int)

Set : set the value of the cell in the i, j coordinates

func (*Gol) SetAll

func (g *Gol) SetAll(value int)

SetAll : set the value to all cells

func (*Gol) SetGeneration

func (g *Gol) SetGeneration(generation int)

SetGeneration : set generation passed

func (*Gol) SetLimitCols

func (g *Gol) SetLimitCols(limitRows bool)

SetLimitCols : set if cols are limited or isn't

func (*Gol) SetLimitRows

func (g *Gol) SetLimitRows(limitRows bool)

SetLimitRows : set if rows are limited or isn't

func (*Gol) SetNeighborhoodType

func (g *Gol) SetNeighborhoodType(neighborhoodType int)

SetNeighborhoodType : return the neighborhood type

func (*Gol) SetNeighborhoodTypeString

func (g *Gol) SetNeighborhoodTypeString(neighborhoodType string)

SetNeighborhoodTypeString : return the neighborhood type (as string)

func (*Gol) SetProcesses

func (g *Gol) SetProcesses(processes int)

SetProcesses : set the number of GO processes used in the computing of the next generation. Take account the constants SERIAL and CPUS of this package.

func (*Gol) SetRules

func (g *Gol) SetRules(rules string)

SetRules : set rules according with the survival/birth format. See https://www.conwaylife.com/wiki/Life_1.05

func (*Gol) SetThreadPoolSize

func (g *Gol) SetThreadPoolSize(threadPoolSize int)

SetThreadPoolSize : set the number of threads that will be used when the parallel next generation algorithm is used.

func (*Gol) ThreadPoolSize

func (g *Gol) ThreadPoolSize() int

ThreadPoolSize : get the number of threads that will be used when the parallel next generation algorithm is used.

Jump to

Keyboard shortcuts

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