Class: Berlin::AI::Map
- Inherits:
-
Object
- Object
- Berlin::AI::Map
- Includes:
- Internal
- Defined in:
- lib/ai/map.rb,
lib/ai/map_internal.rb
Overview
Map keeps track of all the useful information needed to play, such as nodes, points, soldiers, etc. Game will then be able to pick any information it wants from map to decide what are the best moves to do.
Defined Under Namespace
Modules: Internal
Instance Attribute Summary collapse
-
#directed ⇒ Object
Returns the value of attribute directed.
-
#nodes_hash ⇒ Object
Returns the value of attribute nodes_hash.
-
#player_id ⇒ Object
Returns the value of attribute player_id.
Instance Method Summary collapse
-
#controlled_nodes ⇒ Object
We can now loop on our owned nodes in order to find our controlled nodes.
-
#directed? ⇒ Boolean
Is the map directed?.
-
#enemy_nodes ⇒ Object
Returns an array of all enemy nodes.
-
#foreign_nodes ⇒ Object
Returns an array of all nodes that we don’t owned.
-
#free_nodes ⇒ Object
Returns an array of all free nodes.
-
#nodes ⇒ Object
Returns an array of all nodes of the map.
-
#owned_nodes ⇒ Object
Returns an array of all owned nodes.
Methods included from Internal
included, #initialize, #update
Instance Attribute Details
#directed ⇒ Object
Returns the value of attribute directed.
9 10 11 |
# File 'lib/ai/map.rb', line 9 def directed @directed end |
#nodes_hash ⇒ Object
Returns the value of attribute nodes_hash.
9 10 11 |
# File 'lib/ai/map.rb', line 9 def nodes_hash @nodes_hash end |
#player_id ⇒ Object
Returns the value of attribute player_id.
9 10 11 |
# File 'lib/ai/map.rb', line 9 def player_id @player_id end |
Instance Method Details
#controlled_nodes ⇒ Object
We can now loop on our owned nodes in order to find our controlled nodes.
37 38 39 |
# File 'lib/ai/map.rb', line 37 def controlled_nodes owned_nodes.select{ |n| n.occupied? } end |
#directed? ⇒ Boolean
Is the map directed?
42 43 44 |
# File 'lib/ai/map.rb', line 42 def directed? @directed end |
#enemy_nodes ⇒ Object
Returns an array of all enemy nodes
22 23 24 |
# File 'lib/ai/map.rb', line 22 def enemy_nodes nodes.select{ |n| n.enemy? } end |
#foreign_nodes ⇒ Object
Returns an array of all nodes that we don’t owned
32 33 34 |
# File 'lib/ai/map.rb', line 32 def foreign_nodes nodes.select{ |n| n.foreign? } end |
#free_nodes ⇒ Object
Returns an array of all free nodes
27 28 29 |
# File 'lib/ai/map.rb', line 27 def free_nodes nodes.select{ |n| n.free? } end |
#nodes ⇒ Object
Returns an array of all nodes of the map
12 13 14 |
# File 'lib/ai/map.rb', line 12 def nodes @nodes_hash.values end |
#owned_nodes ⇒ Object
Returns an array of all owned nodes
17 18 19 |
# File 'lib/ai/map.rb', line 17 def owned_nodes nodes.select{ |n| n.mine? } end |