Skip to content

Commit a19f226

Browse files
committed
Fix move selection being broken from out-of-bounds access.
1 parent f457ade commit a19f226

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

SerialPrograms/Source/PokemonLZA/Programs/PokemonLZA_TrainerBattle.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,17 @@ bool TrainerBattleState::attempt_one_attack(
9696

9797
int best_index = 4;
9898
for (int index = 0; index < 4; index++){
99+
// cout << "index: " << index << endl;
99100
if (move_watcher[index] == MoveEffectivenessSymbol::None){
101+
// cout << "skip due to none" << endl;
100102
continue;
101103
}
102104
if (m_settings.MODE == BattleAIMode::BlindMash){
103105
best_index = index;
104106
break;
105107
}
106-
if (move_watcher[best_index] < move_watcher[index]){
108+
if (best_index == 4 || move_watcher[best_index] < move_watcher[index]){
109+
// cout << "better move found: " << index << endl;
107110
best_index = index;
108111
}
109112
}

0 commit comments

Comments
 (0)