forked from AnkushNaskar/Game-of-Cops-and-Robbers-on-Graphs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcylinder.cpp
48 lines (43 loc) · 1.33 KB
/
cylinder.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
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
void chaseInd(vector<pair<int, int>>& c, pair<int, int> r, int i);
void orient(vector<pair<int, int>>& c, pair<int, int> r, int copCnt, int m, int n, bool copEst[]);
void grid(vector<pair<int, int>>& c, pair <int, int> r, int copCnt);
bool copEstCyl[2] = { false };
void cylinder(vector<pair<int, int>>& c, pair<int, int> r, int copCnt, int m, int n){
for (int i = 0; i < 2; i++) {
if (c[i].second == r.second) {
copEstCyl[i] = 1;
}
}
if (copEstCyl[0] == 1 && copEstCyl[1] == 1) {
if (c[0].first < r.first && c[1].first < r.first) {
if (c[0].first < c[1].first) {
c[0].first += n;
}
else {
c[1].first += n;
}
}
else if (c[0].first > r.first && c[1].first > r.first) {
if (c[0].first < c[1].first) {
c[1].first -= n;
}
else {
c[0].first -= n;
}
}
grid(c, r, 2);
}
else {
for (int i = 0; i < 2; i++) {
if (copEstCyl[i] == 1) {
chaseInd(c, r, i);
}
}
orient(c, r, copCnt, m, n, copEstCyl);
}
}