GitLab Commit is coming up on August 3-4. Learn how to innovate together using GitLab, the DevOps platform. Register for free: gitlabcommitvirtual2021.com

Commit a3281a8c authored by Rob Van Keilegom's avatar Rob Van Keilegom
Browse files

v3.0

parent 414031c1
......@@ -21,40 +21,107 @@ int main()
cin >> x >> y; cin.ignore();
int dataCount;
cin >> dataCount; cin.ignore();
int quadrantsData [4] = {0, 0, 0, 0};
for (int i = 0; i < dataCount; i++) {
int dataId;
int dataX;
int dataY;
cin >> dataId >> dataX >> dataY; cin.ignore();
if (dataX < 8000) {
if (dataY < 4500) {
quadrantsData[0] += 1;
} else {
quadrantsData[2] += 1;
}
} else {
if (dataY < 4500) {
quadrantsData[1] += 1;
} else {
quadrantsData[3] += 1;
}
}
}
int enemyCount;
int nearestId = -1;
int nearestDistance = 0;
cin >> enemyCount; cin.ignore();
int enemies[enemyCount][4];
for (int i = 0; i < enemyCount; i++) {
cin >> enemies[i][0] >> enemies[i][1] >> enemies[i][2] >> enemies[i][3]; cin.ignore();
}
int quadrantsEnemies [4] = {-1, -1, -1, -1};
for (int i = 0; i < enemyCount; i++) {
int enemyId = enemies[i][0];
int enemyX = enemies[i][1];
int enemyY = enemies[i][2];
int quadrant = -1;
if (enemyX < 8000) {
if (enemyY < 4500) {
quadrant = 0;
} else {
quadrant = 2;
}
} else {
if (enemyY < 4500) {
quadrant = 1;
} else {
quadrant = 3;
}
}
if (quadrantsEnemies[quadrant] == -1) {
quadrantsEnemies[quadrant] = enemyId;
} else {
quadrantsEnemies[quadrant] = enemyCount;
}
}
int shootEnemy = -1;
for (int i = 0; i < 4; i++) {
if (quadrantsEnemies[i] >= 0 && quadrantsEnemies[i] < enemyCount && quadrantsData[i] > 2) {
shootEnemy = quadrantsEnemies[i];
cerr << i << endl;
break;
}
}
int nearestId = -1;
int nearestDistance = 0;
bool move = false;
bool movecloser = false;
int wolffX;
int wolffY;
for (int i = 0; i < enemyCount; i++) {
int enemyId;
int enemyX;
int enemyY;
int enemyLife;
cin >> enemyId >> enemyX >> enemyY >> enemyLife; cin.ignore();
int enemyId = enemies[i][0];
int enemyX = enemies[i][1];
int enemyY = enemies[i][2];
int enemyLife = enemies[i][3];
if (enemyX < 8000) {
if (enemyX < 4500) {
quadrantsEnemies[0] += 1;
} else {
quadrantsEnemies[2] += 1;
}
} else {
if (enemyX < 4500) {
quadrantsEnemies[1] += 1;
} else {
quadrantsEnemies[3] += 1;
}
}
int distance;
distance = sqrt(pow((enemyX - x), 2) + pow((enemyY - y), 2)) ;
//cerr << "enemyId = " << enemyId << endl;
//cerr << "enemyLife = " << enemyLife << endl;
//cerr << "enemyX = " << enemyX << endl;
//cerr << "enemyY = " << enemyY << endl;
//cerr << " x = " << x << endl;
//cerr << " y = " << y << endl;
//cerr << "distance =" << distance << endl;
/*
cerr << "enemyId = " << enemyId << endl;
cerr << "enemyLife = " << enemyLife << endl;
cerr << "enemyX = " << enemyX << endl;
cerr << "enemyY = " << enemyY << endl;
cerr << " x = " << x << endl;
cerr << " y = " << y << endl;
cerr << "distance =" << distance << endl;
*/
// check if save
if ((distance < 2501)) {
......@@ -95,8 +162,12 @@ int main()
}
if ((distance < 4001 || enemies[shootEnemy][3] > 10)) {
shootEnemy = -1;
}
// get nearest enemy to shoot if save
if (!move) {
if (!move && shootEnemy == -1) {
if (distance < nearestDistance || nearestId == -1) {
nearestId = enemyId;
nearestDistance = distance;
......@@ -114,8 +185,10 @@ int main()
wolffY = enemyY + 1000;
}
}
} else if (!move && shootEnemy != -1) {
nearestId = shootEnemy;
}
}
}
if (move || movecloser) {
cout << "MOVE " << wolffX << " " << wolffY << endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment