module Berlin::AI::Node::Internal
Public Class Methods
included(base)
click to toggle source
# File lib/ai/node_internal.rb, line 19 def self.included(base) base.extend(ClassMethods) end
new(options={})
click to toggle source
# File lib/ai/node_internal.rb, line 23 def initialize(options={}) @number_of_soldiers = 0 @player_id = nil @links = [] options.each do |k,v| self.send("#{k}=", v) end end
Public Instance Methods
==(other)
click to toggle source
Used to compare if two nodes are the same
# File lib/ai/node_internal.rb, line 51 def ==(other) other.id == @id end
link_to(other_node)
click to toggle source
Registers a given node as an adjacent one.
# File lib/ai/node_internal.rb, line 56 def link_to(other_node) @links << other_node end
reset!()
click to toggle source
Reset information for new turn
# File lib/ai/node_internal.rb, line 40 def reset! self.incoming_soldiers = 0 self.available_soldiers = self.number_of_soldiers end
to_i()
click to toggle source
Somewhat useful
# File lib/ai/node_internal.rb, line 46 def to_i @id.to_i end
to_s(options={})
click to toggle source
# File lib/ai/node_internal.rb, line 33 def to_s(options={}) str = "<Berlin::AI::Node @id=#{@id} @player_id='#{@player_id}' @type='#{@type}' @points=#{@points} @soldiers_per_turn=#{@soldiers_per_turn} @number_of_soldiers=#{@number_of_soldiers} @incoming_soldiers=#{@incoming_soldiers} @available_soldiers=#{@available_soldiers} @adjacent_nodes=#{adjacent_nodes.map(&:id)}" options.each { |key, val| str << " @#{key}=#{val}"} str << ">" end