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
; <label>:140: ; preds = %181, %139 | |
%141 = load i32, i32* %19, align 4 | |
%142 = sext i32 %141 to i64 | |
%143 = icmp slt i64 %142, 20 | |
call void @_Z14IncrementCountm(i32 4) | |
br i1 %143, label %144, label %184 | |
; <label>:144: ; preds = %140 | |
%145 = getelementptr inbounds %"struct.player_state::State", | |
%"struct.player_state::State"* %2, i32 0, i32 1 |
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
; <label>:140: ; preds = %181, %139 | |
%141 = load i32, i32* %19, align 4 | |
%142 = sext i32 %141 to i64 | |
%143 = icmp slt i64 %142, 20 | |
br i1 %143, label %144, label %184 | |
; <label>:144: ; preds = %140 | |
%145 = getelementptr inbounds %"struct.player_state::State", | |
%"struct.player_state::State"* %2, i32 0, i32 1 | |
%146 = load i32, i32* %19, align 4 |
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
//-------------------------------- BB 1 ---------------------------------- | |
for (int i = NUM_SOLDIERS / 2; i < NUM_SOLDIERS; ++i) { | |
//-------------------------------- BB 2 ---------------------------------- | |
auto &soldier = state.soldiers[i]; | |
if (soldier.hp == 0) | |
//-------------------------------- BB 3 ---------------------------------- | |
continue; | |
//-------------------------------- BB 4 ---------------------------------- | |
for (auto enemy_soldier : state.enemy_soldiers) { | |
//-------------------------------- BB 5 ---------------------------------- |
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; |