Last active
February 9, 2018 21:50
-
-
Save JHurricane96/8c9c3a45ec5e969de4d9fecb47ebef69 to your computer and use it in GitHub Desktop.
1st player code snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make the soldiers who aren't patrolling attack the enemy | |
for (int i = NUM_SOLDIERS / 2; i < NUM_SOLDIERS; ++i) { | |
auto &soldier = state.soldiers[i]; | |
if (soldier.hp == 0) // If this soldier is dead, skip it | |
continue; | |
for (auto enemy_soldier : state.enemy_soldiers) { | |
if (enemy_soldier.hp != 0) { // Ensure your prospective target has | |
// not already been slain | |
soldier.soldier_target = enemy_soldier.id; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment