Optimization Tricks
Optimizing the decision-making process¶
Adjust the decision-making interval¶
In Utility Intelligence, decision-making is separated from decision-execution, allowing you to run decision-making at a different frequency than decision-execution by adjusting the Decision Making Interval in the Utility World Controller:
The default decision-making interval is 0.1s. You can inrease it to 0.2s, 0.3s, or 0.5s depending on your game needs. It will help reduce computational burden on the CPU.
Distribute the decision-making task across multiple frames¶
Starting from v2.1.0, we can distribute the decision-making task across multiple frames to balance the workload by checking Enable Decision Making Batch Processing in the Utility World Controller.
After Enable Decision Making Batch Processing is checked, you can set the Decision Making Batch Size to limit the number of agents that can make decisions per frame. The default batch size is 40.
For example, if you have 500 agents, and you set the Decision Making Batch Size to 20, it will take 25 frames to complete the decision-making process.
This feature will help you handle significantly more agents than before. Previously, the decision-making for all agents in a utility world was processed within a single frame, which could cause spikes in the profiler if you had a high number of agents. Now you can limit the number of agents to 20 per frame, or even to 10 per frame. This will greatly reduce the computational burden per frame on the CPU, and help avoid performance spikes.
Here’s my test with 300 agents: the decision-making process runs every 0.25s and processes 10 agents per frame.
Create separate worlds for different purposes¶
If your agents have different sets of behaviors for different purposes, you should create a separate utility world for each purpose to reduce the cost of decision-making.
For more information, please read: Why you should create separate worlds for different purposes.
Optimizing the score-calculation process¶
Understanding how the process works¶
Before starting optimization, you need to understand how the score-calculation process works first. In Utility Intelligence, the score-calculation process is executed sequentially from top to bottom, and the lower ones are discarded if they cannot possibly beat the higher one.
For example:
In this case, firstly, Decision 1 is scored, and its final score is 0.61
. This score will be passed into the score-calculation process of Decision 2 as minToBeat
.
When calculating the score of Decision 2, since its first consideration is scored as 0.54
and the decision weight is 1
, the maximum score of Decision 2 is 0.54
. Since it is lower than minToBeat
, Decision 2 realizes that it cannot beat Decision 1. Consequently, all lower considerations are discarded and the final score of Decision 2 is 0.00
.
For decision makers, they are similar to decisions, if the lower ones realize that they cannot possibly beat the higher one, then they will be discarded, and their final score will be 0.00
.
How to optimize the process¶
Now that you understand how the score-calculation process works, and to optimize this process, follow these guidelines:
Reordering decision makers, decisions, and considerations¶
- Considerations
- Put considerations that have a high probability of returning a low score at the top.
- This ensures that lower considerations will be discarded because it’s very difficult for lower decisions to beat the higher ones if their first consideration returns a low score.
- A good question we should ask ourselves when doing this is: Does this consideration return a low score most of the time? For example:
IsTargetInAttackRange
(it usually returns0.0
because most of the time the target is not in the attack range).
- Put considerations that are expensive at the bottom. For example:
- Considerations using raycasts.
- Put considerations that have a high probability of returning a low score at the top.
- Decisions
- Put decisions that have a high probability of returning a high score at the top.
- This ensures that lower decisions will be discarded because it’s very difficult for them to beat the higher ones with a high score.
- A good question we should ask ourselves when doing this is: Does this decision return a high score most of the time? For example:
FindPlayer
(it usually returns high score because most of the monsters are constantly finding the player).- Decisions with high weights.
- Put decisions that have a high probability of returning a high score at the top.
- Decision Makers
- Similar to decisions.
To reorder decision makers, decisions, and considerations, you need to enable the Reorderable option in the Editor. This option adds drag handles before every item, allowing you to change the order of each item by dragging it.
Note
- Considerations that are green have been executed.
- Considerations that are orange have been discarded.
- For more information about the statuses of considerations, check Consideration Statuses
Caching calculated results¶
Did you know that calculated results from inputs, input normalizations, considerations and decisions can be cached and reused across parent components, thereby eliminating unnecessary recalculations.
Considerations
To enable caching the calculated score of a consideration:
- If the consideration has no target, check the HasNoTarget toggle:
- If the consideration has targets, uncheck the HasNoTarget toggle and check the EnableCachePerTarget toggle:
Note
- Enable Cache Per Target
- Managing scores for individual targets incurs a cost. Therefore, caching is only effective if the cost of caching is lower than the cost of recalculating the score.
- You should enable caching per target only if the consideration contains heavy inputs, input normalizations and is used by multiple decisions.
- Has No Target
- The consideration is treated as having no target. In this case, the consideration score is cached directly within the consideration, eliminating the need to manage scores for individual targets. This results in a very low caching cost.
- You should enable this option for every consideration that does not access the decision’s target.
Inputs, Input Normalizations and Decisions
- Similar to considerations.
If you like Utility Intelligence, please consider supporting it by leaving a 5-star review on the Asset Store.
Your positive feedback motivates me to keep improving and delivering more updates for this framework.
Thank you so much for your support. I love you all! 🥰

Created : September 1, 2024