Class: ChessVwong::Queen

Inherits:
Piece
  • Object
show all
Defined in:
lib/chess_vwong/queen.rb

Instance Attribute Summary

Attributes inherited from Piece

#color, #current_space, #ep_kill, #neighbours, #turns

Instance Method Summary collapse

Methods inherited from Piece

#initialize, #valid_space?

Constructor Details

This class inherits a constructor from ChessVwong::Piece

Instance Method Details

#characterObject



3
4
5
# File 'lib/chess_vwong/queen.rb', line 3

def character
  color == 'w' ? "\u{2655}" : "\u{265B}"
end

#generate_neighbours(current_space) ⇒ Object

Generate all possible Neighbouring Nodes



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/chess_vwong/queen.rb', line 8

def generate_neighbours(current_space)
  moves = []
  # Diaganol
  (1..8).each { |i| moves << [i, i] }
  (1..8).each { |i| moves << [i, -i] }
  (1..8).each { |i| moves << [-i, i] }
  (1..8).each { |i| moves << [-i, -i] }
  # Straight
  (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