In this lesson, you will learn how to normalize raw environmental data and apply specific weights to ensure your AI makes tactical decisions based on a unified scoring system.
When using the Environmental Query System (EQS), your AI often gathers multiple, disparate metrics—such as the distance to a player, the amount of cover provided by an object, and the health of the AI itself. Because "distance" might be measured in thousands of unreal units while "cover rating" might be a simple 0 to 1 value, you cannot compare these numbers directly.
Normalizing Data
Normalization is the process of mapping raw data into a consistent range, typically [0, 1]. In Unreal’s EQS, this is handled via Normalization Functions. By converting all criteria into this common scale, you ensure that a very large distance value doesn't artificially outweigh a critical tactical value.
Applying Weighting
Once data is normalized, you apply Weighting to prioritize what matters most in a specific state. For example, if your AI is low on health, you might assign a high weight to "Distance from Player" but a low weight to "Distance to Ammo."
In your EQS Query, you define this in the Tests section. By adjusting the Weight multiplier for each test, you dictate the influence of that factor on the final score:
// Conceptual Logic for Scoring
float FinalScore = (NormalizedDistance * WeightDistance) +
(NormalizedCover * WeightCover) +
(NormalizedHealth * WeightHealth);
If you set the Weight for Cover to 2.0 and Distance to 0.5, the AI will prioritize finding a safe hiding spot over getting closer to the enemy, even if the enemy is nearby.
By balancing these weights, you can fine-tune your AI’s "personality." An aggressive AI will have high weights for distance-to-target tests, while a defensive AI will prioritize high-score normalization for cover-based tests. Always test your weights by visualizing the EQS results in the editor to ensure the "winning" location aligns with your intended tactical goal.
Key Takeaway: Normalization brings raw metrics into a common [0, 1] scale so that weighting can effectively prioritize which tactical factors drive the AI's final decision.