Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1.     struct { int id, myUnits, enemyUnits; } copy_of_copy[90];
  2.  
  3.             for (int j = 0; j < planetsN; j++) {
  4.                 copy_of_copy[j].id = j;
  5.                 copy_of_copy[j].myUnits = copy_p[j].myUnits;
  6.                 copy_of_copy[j].enemyUnits = copy_p[j].enemyUnits;
  7.             }
  8.             for (int i = 0; i < planetsN; i++) {
  9.                 if (copy_of_copy[i].myUnits > 0 || copy_of_copy[i].enemyUnits > 0) {
  10.                     int myChildren = 0;
  11.                     int enemyChildren = 0;
  12.                     for (int j = 0; j < copy_p[i].childrenN; j++) {
  13.                         int index = copy_p[i].children[j];
  14.                         if (copy_of_copy[index].myUnits > copy_of_copy[index].enemyUnits) {
  15.                             myChildren++;
  16.                         }
  17.                         else if (copy_of_copy[index].myUnits < copy_of_copy[index].enemyUnits) {
  18.                             enemyChildren++;
  19.                         }
  20.                     }
  21.  
  22.                     if (myChildren > enemyChildren) copy_p[i].enemyUnits -= copy_p[i].enemyUnits > 0 ? 1 : 0;
  23.                     else if (myChildren < enemyChildren) copy_p[i].myUnits -= copy_p[i].myUnits > 0 ? 1 : 0;
  24.                 }
  25.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement