Class: ChessEngine::Knight

Inherits:
Piece
  • Object
show all
Defined in:
lib/chess_engine/piece.rb

Instance Attribute Summary

Attributes inherited from Piece

#color, #moves_count, #symbol

Instance Method Summary collapse

Methods inherited from Piece

#beats_diagonally?, #beats_straight?, #inspect

Constructor Details

#initialize(color) ⇒ Knight

Returns a new instance of Knight.



54
55
56
57
# File 'lib/chess_engine/piece.rb', line 54

def initialize(color)
  super
  @symbol = (@color == :black) ? "\u265E" : "\u2658"
end

Instance Method Details

#movesObject



59
60
61
62
# File 'lib/chess_engine/piece.rb', line 59

def moves
  [[1, 2], [2, 1], [1, -2], [-2, 1],
  [-1, 2], [2, -1], [-1, -2], [-2, -1]]
end