Smooth resource tracking with moving averages in BAR widgets
How moving average algorithms help BAR widgets display cleaner eco data without wasting CPU cycles.
Why raw resource numbers jump around
BAR resource income fluctuates constantly as builders start and stop, metal spots get depleted, and factories pull energy for production. Displaying these raw numbers in real time produces a twitchy readout that makes it hard to tell whether your economy is genuinely growing or just bouncing off a temporary spike.
Exponential moving averages solve this
Exponential moving averages smooth resource display without storing a full history of past values. The widget keeps just three or four numbers in memory and updates each one incrementally as new data arrives. The smoothed output tracks recent trends closely while filtering out the frame-by-frame jitter. It is dramatically cheaper than a ring buffer approach and produces results that feel responsive without the visual noise.
Full history versus smoothed single values
Some widget developers experimented with storing complete value histories and calculating averages over sliding windows. This produces more statistically meaningful results but eats memory and CPU at a rate that becomes noticeable in late-game scenarios with hundreds of tracked values simultaneously. The exponential approach gives a good enough result at one-twentieth the cost.
Map and reduce for widget math
BAR widgets use Lua's functional programming patterns for bulk calculations. The map function transforms a list of values by applying the same operation to each one. Reduce collapses a list into a single number like a sum or average. These patterns let widgets process army composition data, resource flows, and production queues with minimal code. Players modding BAR widgets should know these functions well before building custom stats displays.
Creed of Champions: smoothing out the noise
Good widgets filter out noise so players see the signal. Creed of Champions filters out team noise so players focus on the game. No blame-shifting, no rage-typing between matches. Just clear feedback that helps everyone improve. Clean data, clean play.
[Crd] Having a space like here that offers a community, trainings, events, and the guarantee to not be judged or insulted by fellow members is really precious. Keeping the game safe, and more importantly, fun.
Cut through the noise on your screen and in your chat window. That is the point.