-
Notifications
You must be signed in to change notification settings - Fork 0
/
simplemove.cpp
executable file
·69 lines (64 loc) · 1.33 KB
/
simplemove.cpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "header.h"
void simplemove(struct ball A, vector< vector<int> > &list,struct board **B){
int x1,y1;
vector<int> temp;
struct board **T = new struct board*[8];
for(int j = 0 ; j < 8 ; j++){
T[j] = new struct board[8];
}
for(int j = 0 ; j < 8 ; j++){
for(int k = 0 ; k < 8 ; k++){
T[j][k] = B[j][k];
}
}
if(A.king == 1){
x1 = A.x - 1;
y1 = A.y - 1;
if(x1 >=0 && y1 <= 7 && x1 <= 7 && y1 >= 0){
if(B[y1][x1].c == 'n'){
temp.push_back(A.y);
temp.push_back(A.x);
temp.push_back(y1);
temp.push_back(x1);
list.push_back(temp);
temp.clear();
}
}
x1 = A.x + 1;
y1 = A.y - 1;
if(x1 >=0 && y1 <= 7 && x1 <= 7 && y1 >= 0){
if(B[y1][x1].c == 'n'){
temp.push_back(A.y);
temp.push_back(A.x);
temp.push_back(y1);
temp.push_back(x1);
list.push_back(temp);
temp.clear();
}
}
}
x1 = A.x - 1;
y1 = A.y + 1;
if(x1 >=0 && y1 <= 7 && x1 <= 7 && y1 >= 0){
if(B[y1][x1].c == 'n'){
temp.push_back(A.y);
temp.push_back(A.x);
temp.push_back(y1);
temp.push_back(x1);
list.push_back(temp);
temp.clear();
}
}
x1 = A.x + 1;
y1 = A.y + 1;
if(x1 >=0 && y1 <= 7 && x1 <= 7 && y1 >= 0){
if(B[y1][x1].c == 'n'){
temp.push_back(A.y);
temp.push_back(A.x);
temp.push_back(y1);
temp.push_back(x1);
list.push_back(temp);
temp.clear();
}
}
}