Class: Lifelike::LifelikeCellularAutomaton::Cell

Inherits:
Object
  • Object
show all
Defined in:
lib/lifelike/lifelike_cellular_automaton/cell.rb

Instance Method Summary collapse

Constructor Details

#initialize(alive, rules) ⇒ Cell

Returns a new instance of Cell.



4
5
6
7
# File 'lib/lifelike/lifelike_cellular_automaton/cell.rb', line 4

def initialize(alive, rules)
  @alive = alive
  @rules = rules
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


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

def alive?
  @alive
end

#tick(neighbors) ⇒ Object



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

def tick(neighbors)
  @neighbors = neighbors
  self.class.new(alive_next?, @rules)
end