Skip to content

Commit fc7bdd2

Browse files
committed
Refactoring
1 parent 6a71b49 commit fc7bdd2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Robocode/Channels.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@ void Channels::synthesize(const std::span<const std::complex<double>> dftanal,
2323
sum += channels[channel].synthesize(dftsynth, dftfreqs, pvcfreqs, gestalt);
2424
}
2525

26-
for (size_t i = 1; i < dftfreqs.size() - 1; ++i)
26+
if (sum > 0)
2727
{
28-
const double abs = std::abs(dftanal[i]);
28+
for (size_t i = 1; i < dftsynth.size() - 1; ++i)
29+
{
30+
const double abs = std::abs(dftanal[i]);
2931

30-
dftsynth[i] = (sum > 0) ? (abs / sum) * dftsynth[i] : 0;
32+
dftsynth[i] = (abs / sum) * dftsynth[i];
33+
}
34+
}
35+
else
36+
{
37+
std::fill(dftsynth.begin(), dftsynth.end(), std::complex<double>(0));
3138
}
3239
}
3340

0 commit comments

Comments
 (0)