Class: Abstracta::TerritoryDeveloper
Instance Method Summary
collapse
Methods inherited from Developer
#initialize, #step, #tick
Instance Method Details
#collection ⇒ Object
35
|
# File 'lib/abstracta/developer.rb', line 35
def collection; territory.occupants end
|
#develop(targets: adjacent) ⇒ Object
37
38
39
40
|
# File 'lib/abstracta/developer.rb', line 37
def develop(targets: adjacent)
grow(targets) if growth_indicated?
cull!
end
|
#grow(targets, n = growth) ⇒ Object
48
49
50
|
# File 'lib/abstracta/developer.rb', line 48
def grow(targets, n=growth)
targets.sample(n).map(&method(:occupy!))
end
|
#growth_indicated? ⇒ Boolean
42
43
44
45
46
|
# File 'lib/abstracta/developer.rb', line 42
def growth_indicated?
in_cycle = age % territory.period == 0
under_bound = size <= territory.limit
in_cycle && under_bound
end
|
#territory ⇒ Object
34
|
# File 'lib/abstracta/developer.rb', line 34
def territory; @entity end
|