Documentation ¶
Index ¶
- func EqualsGrid(a, b *Grid) bool
- type Cell
- type Cella2d
- func (c *Cella2d) CountCellsPerState()
- func (c *Cella2d) GetCellsPerState() []int
- func (c *Cella2d) GetGeneration() int
- func (c *Cella2d) GetInitGrid() *Grid
- func (c *Cella2d) GetNextGrid() *Grid
- func (c *Cella2d) GetRules() []*Rule2d
- func (c *Cella2d) GetStates() []Cell
- func (c *Cella2d) NextGeneration() error
- func (c *Cella2d) SetAuxBordersAsToroidal()
- func (c *Cella2d) SetCellsPerState(cps []int)
- func (c *Cella2d) SetGeneration(g int)
- func (c *Cella2d) SetInitGrid(g *Grid)
- func (c *Cella2d) SetNextGrid(g *Grid)
- func (c *Cella2d) SetRules(r []*Rule2d)
- func (c *Cella2d) SetStates(numStates int)
- type Grid
- func (g *Grid) GetAuxBorderDown() []Cell
- func (g *Grid) GetAuxBorderLeft() []Cell
- func (g *Grid) GetAuxBorderRight() []Cell
- func (g *Grid) GetAuxBorderUp() []Cell
- func (g *Grid) GetCell(x, y int) Cell
- func (g *Grid) GetNeighbourhood(x, y int, neighbours [][]Cell)
- func (g *Grid) SetAuxBorderDown(bd []Cell)
- func (g *Grid) SetAuxBorderLeft(bl []Cell)
- func (g *Grid) SetAuxBorderRight(br []Cell)
- func (g *Grid) SetAuxBorderUp(bu []Cell)
- func (g *Grid) SetCell(x, y int, c Cell)
- type Rule2d
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cella2d ¶
type Cella2d struct { InitGrid *Grid // Initial grid NextGrid *Grid // Next grid Width int // Width of the grid Height int // Height of the grid Rules []*Rule2d // Rules of the automaton NumStates int // Number of states of the automaton States []Cell // States of the automaton CellsPerState []int // Number of cells per state Generation int // Generation of the automaton }
Cellular Automaton 2D. Currently only supports 3x3 neighbourhoods.
func NewCella2d ¶
NewCella2d creates a new cellular automaton 2D
func (*Cella2d) CountCellsPerState ¶
func (c *Cella2d) CountCellsPerState()
CountCellsPerState counts the number of cells per state of the automaton using the initial grid
func (*Cella2d) GetCellsPerState ¶
GetCellsPerState gets the number of cells per state of the automaton
func (*Cella2d) GetGeneration ¶
GetGeneration gets the generation of the automaton
func (*Cella2d) GetInitGrid ¶
GetInitGrid gets the initial grid of the automaton
func (*Cella2d) GetNextGrid ¶
GetNextGrid gets the next grid of the automaton
func (*Cella2d) NextGeneration ¶
NextGeneration calculates the next generation of the automaton using the initial grid and the next grid
func (*Cella2d) SetAuxBordersAsToroidal ¶
func (c *Cella2d) SetAuxBordersAsToroidal()
SetAuxBordersAsToroidal sets auxiliar borders with values as if the Grid of cells had a toroidal shape
func (*Cella2d) SetCellsPerState ¶
SetCellsPerState sets the number of cells per state of the automaton
func (*Cella2d) SetGeneration ¶
SetGeneration sets the generation of the automaton
func (*Cella2d) SetInitGrid ¶
SetInitGrid sets the initial grid of the automaton
func (*Cella2d) SetNextGrid ¶
SetNextGrid sets the next grid of the automaton
type Grid ¶
type Grid struct { Width int // Width of the grid Height int // Height of the grid Cells [][]Cell // Cells of the grid WholeGrid [][]Cell // Cells of the grid with auxiliar borders }
Grid is a grid of cells
func (*Grid) GetAuxBorderDown ¶
GetAuxBorderDown gets a down auxiliar border of the grid used for the evaluation of the rules
func (*Grid) GetAuxBorderLeft ¶
GetAuxBorderLeft gets a left auxiliar border of the grid used for the evaluation of the rules
func (*Grid) GetAuxBorderRight ¶
GetAuxBorderRigth gets a rigth auxiliar border of the grid used for the evaluation of the rules
func (*Grid) GetAuxBorderUp ¶
GetAuxBorderUp gets a up auxiliar border of the grid used for the evaluation of the rules
func (*Grid) GetNeighbourhood ¶
GetNeighbours gets the neighbours of a cell and copies them to the neighbours grid
func (*Grid) SetAuxBorderDown ¶
SetAuxBorderDown sets a down auxiliar border of the grid used for the evaluation of the rules
func (*Grid) SetAuxBorderLeft ¶
SetAuxBorderLeft sets a left auxiliar border of the grid used for the evaluation of the rules
func (*Grid) SetAuxBorderRight ¶
SetAuxBorderRigth sets a rigth auxiliar border of the grid used for the evaluation of the rules
func (*Grid) SetAuxBorderUp ¶
SetAuxBorderUp sets a up auxiliar border of the grid used for the evaluation of the rules
type Rule2d ¶
type Rule2d struct {
// contains filtered or unexported fields
}
Rule2d conditions for a cell to change state. Only neighbourhoods of 3x3 are currently supported
func NewRule2d ¶
New creates a new rule by setting the condition and the state that the cell will change to if the condition is true
func (*Rule2d) CheckCondition ¶
CheckCondition checks if the condition is true
func (*Rule2d) GetCondition ¶
GetCondition returns the condition used to change the state
func (*Rule2d) GetState ¶
GetState returns the state that the cell will change to if the condition is true
func (*Rule2d) SetNeighbourhood ¶
SetNeighbourhood sets the neighbourhood used in the condition