Skip to content

Instantly share code, notes, and snippets.

@JHurricane96
Last active February 9, 2018 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JHurricane96/8c9c3a45ec5e969de4d9fecb47ebef69 to your computer and use it in GitHub Desktop.
Save JHurricane96/8c9c3a45ec5e969de4d9fecb47ebef69 to your computer and use it in GitHub Desktop.
1st player code snippet
// 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