Class: ChessVwong::Rook
Instance Attribute Summary
Attributes inherited from Piece
#color, #current_space, #neighbours
Instance Method Summary collapse
- #character ⇒ Object
-
#generate_neighbours(current_space) ⇒ Object
Generate all possible Neighbouring Nodes.
Methods inherited from Piece
Constructor Details
This class inherits a constructor from ChessVwong::Piece
Instance Method Details
#character ⇒ Object
4 5 6 |
# File 'lib/chess_vwong/rook.rb', line 4 def character color == "w" ? "\u{265C}" : "\u{2656}" end |
#generate_neighbours(current_space) ⇒ Object
Generate all possible Neighbouring Nodes
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/chess_vwong/rook.rb', line 9 def generate_neighbours(current_space) moves = [] (1..8).each {|i| moves << [i, 0]} (1..8).each {|i| moves << [0, i]} (1..8).each {|i| moves << [-i, 0]} (1..8).each {|i| moves << [0, -i]} moves.each do |move| neigbour_helper(current_space, move[0], move[1]) end end |