-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKnight.cpp
More file actions
53 lines (48 loc) · 1.21 KB
/
Copy pathKnight.cpp
File metadata and controls
53 lines (48 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//Courtney King and Elizabeth Mathew (cking61 and emathew4)
//Function file for Knight piece
#include "Knight.h"
bool Knight::legal_move_shape( std::pair< char , char > start , std::pair< char , char > end ) const {
char startLet = std::get<0>(start);
char startNum = std::get<1>(start);
char endLet = std::get<0>(end);
char endNum = std::get<1>(end);
if ((endLet == (startLet + 2))) {
//move right two paces
if ((startNum + 1 == endNum) || (startNum - 1 == endNum)) {
return true;
}
else {
return false;
}
}
else if (endLet == (startLet - 2)){
//left two spaces
if ((startNum + 1 == endNum) || (startNum - 1 == endNum)) {
return true;
}
else {
return false;
}
}
else if (endLet == (startLet + 1)) {
//right one space
if ((startNum + 2 == endNum) || (startNum - 2 == endNum)) {
return true;
}
else {
return false;
}
}
else if (endLet == (startLet - 1)) {
//moving left one space
if ((startNum + 2 == endNum) || (startNum - 2 == endNum)) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}