Godot Nature of Code  1.2.0
Nature of Code implemented in Godot Engine
Public Member Functions | Properties | List of all members
Automata.CellularAutomata1D Class Reference

Cellular automata 1D. More...

Inherits Node2D.

Public Member Functions

delegate void ScreenCompleted ()
 Sent when _rows generations have been created. More...
 
 CellularAutomata1D ()
 Create a default cellular automata with a cell scale of 10. More...
 
 CellularAutomata1D (int scale)
 Create a default cellular automata with a custom cell scale. More...
 
void RandomizeRuleSet ()
 Randomize rule set. More...
 
void RandomizeCurrentLine ()
 Randomize current line. More...
 
void ResetCurrentLine ()
 Reset current line. More...
 

Properties

float WaitTime [get, set]
 Wait time More...
 
Color CellColor = Colors.LightBlue [get, set]
 Cell color More...
 
bool ScrollLines [get, set]
 Scroll lines? More...
 
byte RuleNumber [get, set]
 Current rule number More...
 

Detailed Description

Cellular automata 1D.

Definition at line 15 of file CellularAutomata1D.cs.

Constructor & Destructor Documentation

◆ CellularAutomata1D() [1/2]

Automata.CellularAutomata1D.CellularAutomata1D ( )
inline

Create a default cellular automata with a cell scale of 10.

Definition at line 67 of file CellularAutomata1D.cs.

67 : this(10) { }

◆ CellularAutomata1D() [2/2]

Automata.CellularAutomata1D.CellularAutomata1D ( int  scale)
inline

Create a default cellular automata with a custom cell scale.

Parameters
scaleScale

Definition at line 73 of file CellularAutomata1D.cs.

74  {
75  _scale = scale;
76  _ruleSet = new int[RULESET_COUNT];
77  RuleNumber = 90;
78  }
byte RuleNumber
Current rule number

Member Function Documentation

◆ RandomizeCurrentLine()

void Automata.CellularAutomata1D.RandomizeCurrentLine ( )
inline

Randomize current line.

Definition at line 91 of file CellularAutomata1D.cs.

92  {
93  var currRow = GetCurrentRow();
94  for (int i = 0; i < _cols; ++i)
95  {
96  _lines[currRow][i] = MathUtils.RandRangei(0, 1);
97  }
98 
99  _generation = 0;
100  }
Math utility functions
Definition: MathUtils.cs:7
static int RandRangei(int min, int max)
Return an int RandRange.
Definition: MathUtils.cs:37

◆ RandomizeRuleSet()

void Automata.CellularAutomata1D.RandomizeRuleSet ( )
inline

Randomize rule set.

Definition at line 83 of file CellularAutomata1D.cs.

84  {
85  RuleNumber = (byte)MathUtils.RandRangei(0, 255);
86  }

◆ ResetCurrentLine()

void Automata.CellularAutomata1D.ResetCurrentLine ( )
inline

Reset current line.

Definition at line 105 of file CellularAutomata1D.cs.

106  {
107  var currRow = GetCurrentRow();
108  for (int i = 0; i < _cols; ++i)
109  {
110  _lines[currRow][i] = 0;
111  }
112  _lines[currRow][_cols / 2] = 1;
113 
114  _generation = 0;
115  }

◆ ScreenCompleted()

delegate void Automata.CellularAutomata1D.ScreenCompleted ( )

Sent when _rows generations have been created.

Property Documentation

◆ CellColor

Color Automata.CellularAutomata1D.CellColor = Colors.LightBlue
getset

Cell color

Definition at line 35 of file CellularAutomata1D.cs.

35 { get; set; } = Colors.LightBlue;

◆ RuleNumber

byte Automata.CellularAutomata1D.RuleNumber
getset

Current rule number

Definition at line 41 of file CellularAutomata1D.cs.

42  {
43  get => _ruleNumber;
44  set
45  {
46  _ruleNumber = value;
47  SetRuleSetFromRuleNumber(value);
48  }
49  }

◆ ScrollLines

bool Automata.CellularAutomata1D.ScrollLines
getset

Scroll lines?

Definition at line 38 of file CellularAutomata1D.cs.

38 { get; set; }

◆ WaitTime

float Automata.CellularAutomata1D.WaitTime
getset

Wait time

Definition at line 21 of file CellularAutomata1D.cs.

22  {
23  get => _waitTime;
24  set
25  {
26  _waitTime = value;
27  if (_timer != null)
28  {
29  _timer.WaitTime = value;
30  }
31  }
32  }

The documentation for this class was generated from the following file: