Skip to content

Instantly share code, notes, and snippets.

@mattheweves
Created October 13, 2015 03:05
Show Gist options
  • Save mattheweves/bb6993eacb16afa18b7b to your computer and use it in GitHub Desktop.
Save mattheweves/bb6993eacb16afa18b7b to your computer and use it in GitHub Desktop.
class Knight < Piece
def valid_move?(x, y)
# Knight has no concern for obstruction, only check required is valid move of spaces.
return true if (self.x_position - x).abs == 2 && (self.y_position - y).abs == 1
return true if (self.x_position - x).abs == 1 && (self.y_position - y).abs == 2
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment