Class: Demiurge::Zone
- Inherits:
-
Container
- Object
- StateItem
- ActionItem
- Container
- Demiurge::Zone
- Defined in:
- lib/demiurge/zone.rb
Overview
A simplistic engine may contain only a small number of top-level areas, each a zone in itself. A complex engine may have a small number of areas, but each does extensive managing of its sub-locations.
Constant Summary
Constants inherited from ActionItem
Instance Attribute Summary
Attributes inherited from StateItem
Instance Method Summary collapse
-
#adjacent_positions(pos, options = {}) ⇒ Array<String>
Returns an array of position strings for positions adjacent to the one given.
-
#intentions_for_next_step ⇒ Array<Demiurge::Intention>
By default, a zone just passes control to all its non-agent items, gathering up their intentions into a list.
-
#location ⇒ Demiurge::StateItem
A Zone isn't located "inside" somewhere else.
-
#location_name ⇒ String
A Zone isn't located "inside" somewhere else.
-
#position ⇒ String
Similarly, a Zone has no position beyond itself.
-
#zone ⇒ Demiurge::StateItem
A Zone's zone is itself.
-
#zone? ⇒ Boolean
A Zone is, indeed, a Zone.
-
#zone_name ⇒ String
A Zone's zone is itself.
Methods inherited from Container
#can_accomodate_agent?, #contents_names, #ensure_contains, #ensure_does_not_contain, #finished_init, #initialize, #item_change_location, #item_change_position, #move_item_inside, #receive_offer
Methods inherited from ActionItem
#__state_internal, #finished_init, #get_action, #get_actions_with_tags, #initialize, #register_actions, #run_action
Methods inherited from StateItem
#agent?, from_name_type, #get_structure, #initialize, #state, #state_type
Constructor Details
This class inherits a constructor from Demiurge::Container
Instance Method Details
#adjacent_positions(pos, options = {}) ⇒ Array<String>
Returns an array of position strings for positions adjacent to the one given. In some Zones this won't be meaningful. But for most "plain" zones, this gives possibilities of where is moveable for simple AIs.
85 86 87 |
# File 'lib/demiurge/zone.rb', line 85 def adjacent_positions(pos, = {}) [] end |
#intentions_for_next_step ⇒ Array<Demiurge::Intention>
By default, a zone just passes control to all its non-agent items, gathering up their intentions into a list. It doesn't ask agents since agents located directly in zones are usually only for instantiation.
70 71 72 73 74 75 76 |
# File 'lib/demiurge/zone.rb', line 70 def intentions_for_next_step intentions = @state["contents"].flat_map do |item_name| item = @engine.item_by_name(item_name) item.agent? ? [] : item.intentions_for_next_step end intentions end |
#location ⇒ Demiurge::StateItem
A Zone isn't located "inside" somewhere else. It is located in/at itself.
19 20 21 |
# File 'lib/demiurge/zone.rb', line 19 def location self end |
#location_name ⇒ String
A Zone isn't located "inside" somewhere else. It is located in/at itself.
27 28 29 |
# File 'lib/demiurge/zone.rb', line 27 def location_name @name end |
#position ⇒ String
Similarly, a Zone has no position beyond itself.
35 36 37 |
# File 'lib/demiurge/zone.rb', line 35 def position @name end |
#zone ⇒ Demiurge::StateItem
A Zone's zone is itself.
43 44 45 |
# File 'lib/demiurge/zone.rb', line 43 def zone self end |
#zone? ⇒ Boolean
A Zone is, indeed, a Zone.
59 60 61 |
# File 'lib/demiurge/zone.rb', line 59 def zone? true end |
#zone_name ⇒ String
A Zone's zone is itself.
51 52 53 |
# File 'lib/demiurge/zone.rb', line 51 def zone_name @name end |