Class: Astar::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/astar/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tile, destination, parent = nil) ⇒ Node

Returns a new instance of Node.



4
5
6
7
8
# File 'lib/astar/node.rb', line 4

def initialize(tile, destination, parent=nil)
  @tile = tile
  @parent = parent
  @destination = destination
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



3
4
5
# File 'lib/astar/node.rb', line 3

def destination
  @destination
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/astar/node.rb', line 3

def parent
  @parent
end

#tileObject (readonly)

Returns the value of attribute tile.



3
4
5
# File 'lib/astar/node.rb', line 3

def tile
  @tile
end

Instance Method Details

#walkable_neighboursObject



10
11
12
# File 'lib/astar/node.rb', line 10

def walkable_neighbours
  @tile.walkable_neighbours
end

#xObject



14
15
16
# File 'lib/astar/node.rb', line 14

def x
  @tile.x
end

#yObject



18
19
20
# File 'lib/astar/node.rb', line 18

def y
  @tile.y
end