Class: Lifelike::LifelikeCellularAutomaton

Inherits:
Object
  • Object
show all
Defined in:
lib/lifelike/lifelike_cellular_automaton.rb,
lib/lifelike/lifelike_cellular_automaton/cell.rb,
lib/lifelike/lifelike_cellular_automaton/rules.rb,
lib/lifelike/lifelike_cellular_automaton/world.rb,
lib/lifelike/lifelike_cellular_automaton/cell_serializer.rb,
lib/lifelike/lifelike_cellular_automaton/world_serializer.rb,
lib/lifelike/lifelike_cellular_automaton/world_string_analyzer.rb

Defined Under Namespace

Classes: Cell, CellSerializer, RuleString, Rules, World, WorldSerializer, WorldStringAnalyzer

Instance Method Summary collapse

Constructor Details

#initialize(initial_world_string, rule_string) ⇒ LifelikeCellularAutomaton

Returns a new instance of LifelikeCellularAutomaton.



9
10
11
12
# File 'lib/lifelike/lifelike_cellular_automaton.rb', line 9

def initialize(initial_world_string, rule_string)
  @initial_world_string = initial_world_string
  @rules = Rules.new(rule_string)
end

Instance Method Details

#tick(generations) ⇒ Object



14
15
16
# File 'lib/lifelike/lifelike_cellular_automaton.rb', line 14

def tick(generations)
  world_serializer.dump(initial_world.tick(generations))
end