Class: ChessEngine::Knight
Instance Attribute Summary
Attributes inherited from Piece
Instance Method Summary collapse
-
#initialize(color) ⇒ Knight
constructor
A new instance of Knight.
- #moves ⇒ Object
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
#moves ⇒ Object
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 |