-
Notifications
You must be signed in to change notification settings - Fork 0
/
Knight.cpp
21 lines (19 loc) · 670 Bytes
/
Knight.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Joshua Hahn jhahn19
// Kevin Kim kkim170
// Elissa Matlock ematloc1
#include "Knight.h"
namespace Chess {
bool Knight::legal_move_shape(std::pair<char, char> start, std::pair<char, char> end) const {
int horizontal_distance = end.first - start.first;
int vertical_distance = end.second - start.second;
//absolute value of distance
if (horizontal_distance < 0) horizontal_distance *= -1;
if (vertical_distance < 0) vertical_distance *= -1;
if (vertical_distance == 2 && horizontal_distance == 1) {
return true;
} else if (vertical_distance == 1 && horizontal_distance == 2) {
return true;
}
return false;
}
}