Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct { int id, myUnits, enemyUnits; } copy_of_copy[90];
- for (int j = 0; j < planetsN; j++) {
- copy_of_copy[j].id = j;
- copy_of_copy[j].myUnits = copy_p[j].myUnits;
- copy_of_copy[j].enemyUnits = copy_p[j].enemyUnits;
- }
- for (int i = 0; i < planetsN; i++) {
- if (copy_of_copy[i].myUnits > 0 || copy_of_copy[i].enemyUnits > 0) {
- int myChildren = 0;
- int enemyChildren = 0;
- for (int j = 0; j < copy_p[i].childrenN; j++) {
- int index = copy_p[i].children[j];
- if (copy_of_copy[index].myUnits > copy_of_copy[index].enemyUnits) {
- myChildren++;
- }
- else if (copy_of_copy[index].myUnits < copy_of_copy[index].enemyUnits) {
- enemyChildren++;
- }
- }
- if (myChildren > enemyChildren) copy_p[i].enemyUnits -= copy_p[i].enemyUnits > 0 ? 1 : 0;
- else if (myChildren < enemyChildren) copy_p[i].myUnits -= copy_p[i].myUnits > 0 ? 1 : 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement